2021-02-02 20:42:37 +08:00
|
|
|
#include <functional>
|
|
|
|
|
2021-01-28 17:06:40 +08:00
|
|
|
#include "native_driver.h"
|
2021-01-28 18:08:13 +08:00
|
|
|
#include "async/async_call.h"
|
2021-02-02 20:42:37 +08:00
|
|
|
#include "utils/constant.h"
|
2021-01-28 17:06:40 +08:00
|
|
|
|
2021-02-02 20:42:37 +08:00
|
|
|
void NativeDriver::invokeContextEntityMethod(QString contextId, QString method, QVariantList args)
|
2021-01-28 17:06:40 +08:00
|
|
|
{
|
2021-02-02 20:42:37 +08:00
|
|
|
args.insert(0, QVariant(contextId));
|
|
|
|
args.insert(1, QVariant(method));
|
|
|
|
invokeDoricMethod(Constant::DORIC_CONTEXT_INVOKE, args);
|
2021-01-28 17:06:40 +08:00
|
|
|
}
|
|
|
|
|
2021-02-02 20:42:37 +08:00
|
|
|
void NativeDriver::invokeDoricMethod(QString method, QVariantList args)
|
2021-01-28 17:06:40 +08:00
|
|
|
{
|
2021-02-02 20:42:37 +08:00
|
|
|
return AsyncCall::ensureRunInThreadPool(&jsEngine.mJSThreadPool, [this, method, args]{
|
2021-02-03 10:50:32 +08:00
|
|
|
this->jsEngine.invokeDoricMethod(method, args).toString();
|
2021-02-02 20:42:37 +08:00
|
|
|
});
|
2021-01-28 17:06:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void NativeDriver::createContext(QString contextId, QString script, QString source)
|
|
|
|
{
|
2021-01-28 19:44:06 +08:00
|
|
|
AsyncCall::ensureRunInThreadPool(&jsEngine.mJSThreadPool, [this, contextId, script, source]{
|
|
|
|
this->jsEngine.prepareContext(contextId, script, source);
|
|
|
|
});
|
2021-01-28 17:06:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void NativeDriver::destroyContext(QString contextId)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2021-02-04 14:55:36 +08:00
|
|
|
|
|
|
|
Registry *NativeDriver::getRegistry()
|
|
|
|
{
|
|
|
|
return this->jsEngine.getRegistry();
|
|
|
|
}
|