1 /************************************************************************
2 *
3 * Copyright 2010 Jakob Leben (jakob.leben@gmail.com)
4 *
5 * This file is part of SuperCollider Qt GUI.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 ************************************************************************/
21
22 #include "Common.h"
23 #include "metatype.hpp"
24
25 #include <PyrKernel.h>
26 #include <VMGlobals.h>
27 #include <PyrLexer.h>
28
29 // WARNING: QtCollider::lockLang() must be called before
runLang(PyrObjectHdr * receiver,PyrSymbol * method,const QList<QVariant> & args,PyrSlot * result)30 void QtCollider::runLang(PyrObjectHdr* receiver, PyrSymbol* method, const QList<QVariant>& args, PyrSlot* result) {
31 VMGlobals* g = gMainVMGlobals;
32 g->canCallOS = true;
33 ++g->sp;
34 SetObject(g->sp, receiver);
35 Q_FOREACH (QVariant var, args) {
36 ++g->sp;
37 if (!QtCollider::set(g->sp, var)) {
38 qcErrorMsg("Failed to write a slot when trying to run interpreter!");
39 SetNil(g->sp);
40 }
41 }
42 runInterpreter(g, method, args.size() + 1);
43 g->canCallOS = false;
44 if (result)
45 slotCopy(result, &g->result);
46 }
47
wrongThreadError()48 int QtCollider::wrongThreadError() {
49 qcErrorMsg("You can not use this Qt functionality in the current thread. "
50 "Try scheduling on AppClock instead.");
51 return errFailed;
52 }
53