-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathquikqtbridge.cpp
92 lines (78 loc) · 2.05 KB
/
quikqtbridge.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "quikcoast.h"
#include "quikqtbridge.h"
#include <QDebug>
QuikQtBridge *QuikQtBridge::global_bridge = nullptr;
QuikQtBridge *QuikQtBridge::initQuikQtBridge()
{
if(!global_bridge)
global_bridge = new QuikQtBridge();
return global_bridge;
}
void QuikQtBridge::deinitQuikQtBridge()
{
if(global_bridge)
{
QuikQtBridge *toDel = global_bridge;
delete toDel;
}
}
void QuikQtBridge::invokeMethod(QString method, const QVariantList &args, QVariantList &res, QuikCallbackHandler *errOut)
{
QString errMsg;
if(!invokeQuik(method, args, res, errMsg))
errOut->sendStderrLine(errMsg);
}
void QuikQtBridge::invokeObjectMethod(int objid, QString method, const QVariantList &args, QVariantList &res, QuikCallbackHandler *errOut)
{
QString errMsg;
if(!invokeQuikObject(objid, method, args, res, errMsg))
errOut->sendStderrLine(errMsg);
}
void QuikQtBridge::deleteObject(int objid)
{
deleteQuikObject(objid);
}
bool QuikQtBridge::registerCallback(QuikCallbackHandler *handler, QString name)
{
if(m_handlers.contains(name))
return false;
if(name!="OnStop" && name!="OnParam" && name!="OnQuote")
{
if(!registerNamedCallback(name))
return false;
}
m_handlers.insert(name, handler);
return true;
}
void QuikQtBridge::getVariable(QString varname, QVariant &res)
{
getQuikVariable(varname, res);
}
lua_State *QuikQtBridge::getRecentStackForThreadId(Qt::HANDLE ctid)
{
if(recentStackMap.contains(ctid))
return recentStackMap.value(ctid);
return nullptr;
}
void QuikQtBridge::setRecentStack(Qt::HANDLE ctid, lua_State *l)
{
recentStackMap.insert(ctid, l);
}
void QuikQtBridge::callbackRequest(QString name, const QVariantList &args, QVariant &vres)
{
#ifdef QT_DEBUG
qDebug() << "callbackRequest:" << name;
#endif
if(m_handlers.contains(name))
{
m_handlers.value(name)->callbackRequest(name, args, vres);
}
}
QuikQtBridge::QuikQtBridge()
: QObject()
{
}
QuikQtBridge::~QuikQtBridge()
{
unregisterAllNamedCallbacks();
}