This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-Qt/doric/engine/js_engine.h

29 lines
656 B
C
Raw Normal View History

2021-01-28 17:06:40 +08:00
#ifndef JSENGINE_H
#define JSENGINE_H
2019-12-04 15:51:46 +08:00
2021-01-28 17:06:40 +08:00
#include <QJSValue>
#include <QThreadPool>
2019-12-04 15:51:46 +08:00
2021-01-28 17:06:40 +08:00
#include "interface_jse.h"
2019-12-04 15:51:46 +08:00
2021-01-28 17:06:40 +08:00
class JSEngine : public QObject
{
Q_OBJECT
2019-12-04 15:51:46 +08:00
private:
2021-01-28 17:06:40 +08:00
QThreadPool mJSThreadPool;
InterfaceJSE *mJSE;
2019-12-04 16:44:30 +08:00
2021-01-28 17:06:40 +08:00
void loadBuiltinJS(QString assetName);
void prepareContext(QString contextId, QString script, QString source);
QString packageContextScript(QString contextId, QString content);
QString packageModuleScript(QString moduleName, QString content);
public:
explicit JSEngine(QObject *parent = nullptr);
2019-12-04 15:51:46 +08:00
2021-01-28 17:06:40 +08:00
QJSValue invokeDoricMethod(QString method, QJSValueList arguments);
2019-12-04 16:44:30 +08:00
2021-01-28 17:06:40 +08:00
~JSEngine();
2019-12-04 15:51:46 +08:00
};
2021-01-28 17:06:40 +08:00
#endif // JSENGINE_H