-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpythonbridge.h
More file actions
48 lines (43 loc) · 1.13 KB
/
pythonbridge.h
File metadata and controls
48 lines (43 loc) · 1.13 KB
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
#ifndef PYTHONBRIDGE_H
#define PYTHONBRIDGE_H
#include "bridgeplugin.h"
#include <QObject>
#include <QFile>
#include <QTextStream>
#include <QMutex>
#undef slots
#ifdef _DEBUG
#define _DEBUG_WAS_DEFINED
#undef _DEBUG
#endif
#include <Python.h>
#ifdef _DEBUG_WAS_DEFINED
#define _DEBUG
#undef _DEBUG_WAS_DEFINED
#endif
#define slots Q_SLOTS
class PythonBridge : public BridgePlugin
{
Q_OBJECT
public:
explicit PythonBridge(const QVariantMap &cfg, QObject *parent = nullptr);
~PythonBridge();
void registerPythonCallback(PyObject *cb, QString name);
size_t sendToStdout(char *msg);
void stdoutFlush();
size_t sendToStderr(char *msg);
void stderrFlush();
virtual void start();
protected:
virtual void callbackRequest(QString name, const QVariantList &args, QVariant &vres);
virtual void fastCallbackRequest(BridgeCallableObject cobj, const QVariantList &args, QVariant &vres);
private:
bool isReady;
QByteArray pycode;
PyObject *moduleObject;
QMap<QString, PyObject *> registeredCallbacks;
QString stdoutBuffer;
QString stderrBuffer;
QString modObjName;
};
#endif // PYTHONBRIDGE_H