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

30 lines
657 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
InterfaceJSE *mJSE;
2019-12-04 16:44:30 +08:00
2021-01-28 17:06:40 +08:00
void loadBuiltinJS(QString assetName);
QString packageContextScript(QString contextId, QString content);
QString packageModuleScript(QString moduleName, QString content);
public:
2021-01-28 18:08:13 +08:00
QThreadPool mJSThreadPool;
2021-01-28 17:06:40 +08:00
explicit JSEngine(QObject *parent = nullptr);
2019-12-04 15:51:46 +08:00
2021-01-28 17:06:40 +08:00
~JSEngine();
2021-01-28 19:44:06 +08:00
2021-02-02 20:42:37 +08:00
QJSValue invokeDoricMethod(QString method, QVariantList arguments);
2021-01-28 19:44:06 +08:00
void prepareContext(QString contextId, QString script, QString source);
2019-12-04 15:51:46 +08:00
};
2021-01-28 17:06:40 +08:00
#endif // JSENGINE_H