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/native_driver.cpp
2021-05-20 18:27:45 +08:00

32 lines
951 B
C++

#include <functional>
#include "native_driver.h"
#include "async/async_call.h"
#include "utils/constant.h"
void NativeDriver::invokeContextEntityMethod(QString contextId, QString method, QVariantList args)
{
args.insert(0, QVariant(contextId));
args.insert(1, QVariant(method));
invokeDoricMethod(Constant::DORIC_CONTEXT_INVOKE, args);
}
void NativeDriver::invokeDoricMethod(QString method, QVariantList args)
{
return AsyncCall::ensureRunInThreadPool(&jsEngine.mJSThreadPool, [this, method, args]{
qDebug() << "invokeDoricMethod: " << this->jsEngine.invokeDoricMethod(method, args).toString();
});
}
void NativeDriver::createContext(QString contextId, QString script, QString source)
{
AsyncCall::ensureRunInThreadPool(&jsEngine.mJSThreadPool, [this, contextId, script, source]{
this->jsEngine.prepareContext(contextId, script, source);
});
}
void NativeDriver::destroyContext(QString contextId)
{
}