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/engine/js_engine.h

36 lines
699 B
C
Raw Normal View History

2019-12-04 15:51:46 +08:00
#ifndef JS_ENGINE_H
#define JS_ENGINE_H
#include <QJSEngine>
2019-12-04 16:44:30 +08:00
#include "native/native_bridge.h"
2019-12-04 15:51:46 +08:00
#include "native/native_empty.h"
#include "native/native_log.h"
#include "native/native_timer.h"
2019-12-14 10:04:17 +08:00
class JSEngine {
2019-12-04 15:51:46 +08:00
public:
2019-12-04 16:44:30 +08:00
QJSEngine *engine = new QJSEngine();
2019-12-14 10:04:17 +08:00
JSEngine();
2019-12-04 15:51:46 +08:00
2019-12-14 10:04:17 +08:00
void prepareContext(int contextId, QString *script);
2019-12-04 15:51:46 +08:00
2019-12-14 10:04:17 +08:00
void destroyContext(int contextId);
2019-12-04 15:51:46 +08:00
private:
2019-12-13 17:48:37 +08:00
NativeLog *nativeLog = new NativeLog();
NativeTimer *nativeTimer = new NativeTimer(engine);
NativeEmpty *nativeEmpty = new NativeEmpty();
NativeBridge *nativeBridge = new NativeBridge();
2019-12-04 16:44:30 +08:00
2019-12-14 10:04:17 +08:00
void initJSEngine();
2019-12-04 15:51:46 +08:00
2019-12-14 10:04:17 +08:00
void injectGlobal();
2019-12-04 16:44:30 +08:00
2019-12-14 10:04:17 +08:00
void initDoricRuntime();
2019-12-04 15:51:46 +08:00
};
#endif // JS_ENGINE_H