diff --git a/doric-Qt/example/doric/DoricContext.cpp b/doric-Qt/example/doric/DoricContext.cpp index 454f8914..15caec45 100644 --- a/doric-Qt/example/doric/DoricContext.cpp +++ b/doric-Qt/example/doric/DoricContext.cpp @@ -54,7 +54,8 @@ void DoricContext::build(int width, int height) { callEntity(DoricConstant::DORIC_ENTITY_BUILD, args); } -void DoricContext::callEntity(QString methodName, QVariantList args) { +std::shared_ptr DoricContext::callEntity(QString methodName, + QVariantList args) { return getDriver()->invokeContextEntityMethod(this->mContextId, methodName, args); } diff --git a/doric-Qt/example/doric/DoricContext.h b/doric-Qt/example/doric/DoricContext.h index b8581d53..d9bd9422 100644 --- a/doric-Qt/example/doric/DoricContext.h +++ b/doric-Qt/example/doric/DoricContext.h @@ -34,7 +34,8 @@ public: void build(int width, int height); - void callEntity(QString methodName, QVariantList args); + std::shared_ptr callEntity(QString methodName, + QVariantList args); DoricInterfaceDriver *getDriver(); diff --git a/doric-Qt/example/doric/DoricInterfaceDriver.h b/doric-Qt/example/doric/DoricInterfaceDriver.h index 113ce957..3d304f82 100644 --- a/doric-Qt/example/doric/DoricInterfaceDriver.h +++ b/doric-Qt/example/doric/DoricInterfaceDriver.h @@ -11,18 +11,21 @@ class DoricInterfaceDriver { public: - virtual void invokeContextEntityMethod(QString contextId, QString method, - QVariantList args) = 0; + virtual std::shared_ptr + invokeContextEntityMethod(QString contextId, QString method, + QVariantList args) = 0; - virtual void invokeDoricMethod(QString method, QVariantList args) = 0; + virtual std::shared_ptr + invokeDoricMethod(QString method, QVariantList args) = 0; - virtual DoricAsyncResult *asyncCall(std::function lambda, - DoricThreadMode mode) = 0; + virtual std::shared_ptr + asyncCall(std::function lambda, DoricThreadMode mode) = 0; - virtual void createContext(QString contextId, QString script, - QString source) = 0; + virtual std::shared_ptr + createContext(QString contextId, QString script, QString source) = 0; - virtual void destroyContext(QString contextId) = 0; + virtual std::shared_ptr + destroyContext(QString contextId) = 0; virtual DoricRegistry *getRegistry() = 0; }; diff --git a/doric-Qt/example/doric/DoricNativeDriver.cpp b/doric-Qt/example/doric/DoricNativeDriver.cpp index 84a5b024..a231660a 100644 --- a/doric-Qt/example/doric/DoricNativeDriver.cpp +++ b/doric-Qt/example/doric/DoricNativeDriver.cpp @@ -4,22 +4,26 @@ #include "async/DoricAsyncCall.h" #include "utils/DoricConstant.h" -void DoricNativeDriver::invokeContextEntityMethod(QString contextId, - QString method, - QVariantList args) { +std::shared_ptr +DoricNativeDriver::invokeContextEntityMethod(QString contextId, QString method, + QVariantList args) { args.insert(0, QVariant(contextId)); args.insert(1, QVariant(method)); - invokeDoricMethod(DoricConstant::DORIC_CONTEXT_INVOKE, args); + return invokeDoricMethod(DoricConstant::DORIC_CONTEXT_INVOKE, args); } -void DoricNativeDriver::invokeDoricMethod(QString method, QVariantList args) { - return DoricAsyncCall::ensureRunInThreadPool( +std::shared_ptr +DoricNativeDriver::invokeDoricMethod(QString method, QVariantList args) { + DoricAsyncCall::ensureRunInThreadPool( &jsEngine.mJSThreadPool, [this, method, args] { this->jsEngine.invokeDoricMethod(method, args); }); + + return std::make_shared(); } -DoricAsyncResult *DoricNativeDriver::asyncCall(std::function lambda, - DoricThreadMode mode) { +std::shared_ptr +DoricNativeDriver::asyncCall(std::function lambda, + DoricThreadMode mode) { switch (mode) { case UI: DoricAsyncCall::ensureRunInMain(lambda); @@ -31,18 +35,24 @@ DoricAsyncResult *DoricNativeDriver::asyncCall(std::function lambda, return NULL; } -void DoricNativeDriver::createContext(QString contextId, QString script, - QString source) { +std::shared_ptr +DoricNativeDriver::createContext(QString contextId, QString script, + QString source) { DoricAsyncCall::ensureRunInThreadPool( &jsEngine.mJSThreadPool, [this, contextId, script, source] { this->jsEngine.prepareContext(contextId, script, source); }); + + return std::make_shared(); } -void DoricNativeDriver::destroyContext(QString contextId) { +std::shared_ptr +DoricNativeDriver::destroyContext(QString contextId) { DoricAsyncCall::ensureRunInThreadPool( &jsEngine.mJSThreadPool, [this, contextId] { this->jsEngine.destroyContext(contextId); }); + + return std::make_shared(); } DoricRegistry *DoricNativeDriver::getRegistry() { diff --git a/doric-Qt/example/doric/DoricNativeDriver.h b/doric-Qt/example/doric/DoricNativeDriver.h index 78ee25b0..183a429f 100644 --- a/doric-Qt/example/doric/DoricNativeDriver.h +++ b/doric-Qt/example/doric/DoricNativeDriver.h @@ -21,18 +21,20 @@ public: return &instance; } - void invokeContextEntityMethod(QString contextId, QString method, - QVariantList args) override; + std::shared_ptr + invokeContextEntityMethod(QString contextId, QString method, + QVariantList args) override; - void invokeDoricMethod(QString method, QVariantList args) override; + std::shared_ptr + invokeDoricMethod(QString method, QVariantList args) override; - DoricAsyncResult *asyncCall(std::function lambda, - DoricThreadMode mode) override; + std::shared_ptr asyncCall(std::function lambda, + DoricThreadMode mode) override; - void createContext(QString contextId, QString script, - QString source) override; + std::shared_ptr + createContext(QString contextId, QString script, QString source) override; - void destroyContext(QString contextId) override; + std::shared_ptr destroyContext(QString contextId) override; DoricRegistry *getRegistry() override; }; diff --git a/doric-Qt/example/doric/shader/DoricViewNode.cpp b/doric-Qt/example/doric/shader/DoricViewNode.cpp index 6671d637..0a1cafc8 100644 --- a/doric-Qt/example/doric/shader/DoricViewNode.cpp +++ b/doric-Qt/example/doric/shader/DoricViewNode.cpp @@ -208,7 +208,8 @@ QList DoricViewNode::getIdList() { void DoricViewNode::requestLayout() {} -void DoricViewNode::callJSResponse(QString funcId, QVariantList args) { +std::shared_ptr +DoricViewNode::callJSResponse(QString funcId, QVariantList args) { QVariantList nArgs; QList idList = getIdList(); nArgs.append(QVariant(idList)); @@ -219,7 +220,8 @@ void DoricViewNode::callJSResponse(QString funcId, QVariantList args) { return getContext()->callEntity(DoricConstant::DORIC_ENTITY_RESPONSE, nArgs); } -void DoricViewNode::pureCallJSResponse(QString funcId, QVariantList args) { +std::shared_ptr +DoricViewNode::pureCallJSResponse(QString funcId, QVariantList args) { QVariantList nArgs; nArgs.append(getContext()->getContextId()); nArgs.append(DoricConstant::DORIC_ENTITY_RESPONSE); diff --git a/doric-Qt/example/doric/shader/DoricViewNode.h b/doric-Qt/example/doric/shader/DoricViewNode.h index 76235e7d..80543b4b 100644 --- a/doric-Qt/example/doric/shader/DoricViewNode.h +++ b/doric-Qt/example/doric/shader/DoricViewNode.h @@ -77,8 +77,10 @@ public: void onClick(); - void callJSResponse(QString funcId, QVariantList args); + std::shared_ptr callJSResponse(QString funcId, + QVariantList args); - void pureCallJSResponse(QString funcId, QVariantList args); + std::shared_ptr pureCallJSResponse(QString funcId, + QVariantList args); }; #endif // DORICVIEWNODE_H