diff --git a/doric-Qt/doric/DoricInterfaceDriver.h b/doric-Qt/doric/DoricInterfaceDriver.h index 7e630667..113ce957 100644 --- a/doric-Qt/doric/DoricInterfaceDriver.h +++ b/doric-Qt/doric/DoricInterfaceDriver.h @@ -16,7 +16,7 @@ public: virtual void invokeDoricMethod(QString method, QVariantList args) = 0; - virtual DoricAsyncResult *asyncCall(QRunnable *runnable, + virtual DoricAsyncResult *asyncCall(std::function lambda, DoricThreadMode mode) = 0; virtual void createContext(QString contextId, QString script, diff --git a/doric-Qt/doric/DoricNativeDriver.cpp b/doric-Qt/doric/DoricNativeDriver.cpp index f35dc323..11d2f4cd 100644 --- a/doric-Qt/doric/DoricNativeDriver.cpp +++ b/doric-Qt/doric/DoricNativeDriver.cpp @@ -19,8 +19,15 @@ void DoricNativeDriver::invokeDoricMethod(QString method, QVariantList args) { }); } -DoricAsyncResult *DoricNativeDriver::asyncCall(QRunnable *runnable, +DoricAsyncResult *DoricNativeDriver::asyncCall(std::function lambda, DoricThreadMode mode) { + switch (mode) { + case UI: + break; + case JS: + DoricAsyncCall::ensureRunInThreadPool(&jsEngine.mJSThreadPool, lambda); + break; + } return NULL; } diff --git a/doric-Qt/doric/DoricNativeDriver.h b/doric-Qt/doric/DoricNativeDriver.h index 48f54494..78ee25b0 100644 --- a/doric-Qt/doric/DoricNativeDriver.h +++ b/doric-Qt/doric/DoricNativeDriver.h @@ -26,7 +26,8 @@ public: void invokeDoricMethod(QString method, QVariantList args) override; - DoricAsyncResult * asyncCall(QRunnable *runnable, DoricThreadMode mode) override; + DoricAsyncResult *asyncCall(std::function lambda, + DoricThreadMode mode) override; void createContext(QString contextId, QString script, QString source) override; diff --git a/doric-Qt/doric/async/DoricAsyncCall.h b/doric-Qt/doric/async/DoricAsyncCall.h index 047efca1..bc883ac0 100644 --- a/doric-Qt/doric/async/DoricAsyncCall.h +++ b/doric-Qt/doric/async/DoricAsyncCall.h @@ -1,6 +1,7 @@ #ifndef ASYNC_CALL_H #define ASYNC_CALL_H +#include #include #include @@ -9,7 +10,8 @@ class DoricAsyncCall { public: static void ensureRunInThreadPool(QThreadPool *threadPool, std::function lambda) { - QtConcurrent::run(threadPool, lambda); + QFuture::result_type> future = + QtConcurrent::run(threadPool, lambda); } }; diff --git a/doric-Qt/doric/demo/DoricDemoBridge.cpp b/doric-Qt/doric/demo/DoricDemoBridge.cpp index 09e24f80..3d56d32f 100644 --- a/doric-Qt/doric/demo/DoricDemoBridge.cpp +++ b/doric-Qt/doric/demo/DoricDemoBridge.cpp @@ -9,7 +9,7 @@ DoricDemoBridge::DoricDemoBridge(QObject *parent) : QObject(parent) {} void DoricDemoBridge::navigate(QVariant route) { switch (route.toInt()) { case 0: - QString name = "Snake.es5.js"; + QString name = "Snake.js"; QString script = DoricUtils::readAssetFile("/doric/bundles", name); DoricPanel panel; diff --git a/doric-Qt/doric/doric.pro b/doric-Qt/doric/doric.pro index 71a22e42..7b4b33c7 100644 --- a/doric-Qt/doric/doric.pro +++ b/doric-Qt/doric/doric.pro @@ -32,6 +32,7 @@ SOURCES += \ main.cpp \ plugin/DoricShaderPlugin.cpp \ shader/DoricRootNode.cpp \ + shader/DoricViewNode.cpp \ utils/DoricConstant.cpp \ utils/DoricContextHolder.cpp @@ -71,6 +72,7 @@ HEADERS += \ plugin/DoricNativePlugin.h \ plugin/DoricShaderPlugin.h \ shader/DoricRootNode.h \ + shader/DoricViewNode.h \ template/DoricSingleton.h \ utils/DoricConstant.h \ utils/DoricContextHolder.h \ diff --git a/doric-Qt/doric/engine/DoricNativeJSE.cpp b/doric-Qt/doric/engine/DoricNativeJSE.cpp index b019835b..0bb2bfc7 100644 --- a/doric-Qt/doric/engine/DoricNativeJSE.cpp +++ b/doric-Qt/doric/engine/DoricNativeJSE.cpp @@ -57,9 +57,15 @@ QJSValue DoricNativeJSE::invokeObject(QString objectName, QString functionName, } QJSValue result = function.call(args); - if (result.isError()) + if (result.isError()) { qDebug() << "Uncaught exception at line" << result.property("lineNumber").toInt() << ":" << result.toString(); + QStringList stacktraces = result.property("stack").toString().split("\n"); + qDebug() << "++++++++++++++++++++++++"; + foreach (QString stacktrace, stacktraces) { qDebug() << stacktrace; } + qDebug() << "------------------------"; + } + return result; } diff --git a/doric-Qt/doric/shader/DoricViewNode.cpp b/doric-Qt/doric/shader/DoricViewNode.cpp new file mode 100644 index 00000000..258c1382 --- /dev/null +++ b/doric-Qt/doric/shader/DoricViewNode.cpp @@ -0,0 +1 @@ +#include "DoricViewNode.h" diff --git a/doric-Qt/doric/shader/DoricViewNode.h b/doric-Qt/doric/shader/DoricViewNode.h new file mode 100644 index 00000000..b1ef2d7e --- /dev/null +++ b/doric-Qt/doric/shader/DoricViewNode.h @@ -0,0 +1,10 @@ +#ifndef DORICVIEWNODE_H +#define DORICVIEWNODE_H + +#include "../utils/DoricContextHolder.h" + +class DoricViewNode : public DoricContextHolder { +public: + using DoricContextHolder::DoricContextHolder; +}; +#endif // DORICVIEWNODE_H diff --git a/doric-Qt/doric/utils/DoricConstant.cpp b/doric-Qt/doric/utils/DoricConstant.cpp index 3128019f..aa615006 100644 --- a/doric-Qt/doric/utils/DoricConstant.cpp +++ b/doric-Qt/doric/utils/DoricConstant.cpp @@ -1,7 +1,7 @@ #include "DoricConstant.h" -const QString DoricConstant::DORIC_BUNDLE_SANDBOX = "doric-sandbox.es5.js"; -const QString DoricConstant::DORIC_BUNDLE_LIB = "doric-lib.es5.js"; +const QString DoricConstant::DORIC_BUNDLE_SANDBOX = "doric-sandbox.js"; +const QString DoricConstant::DORIC_BUNDLE_LIB = "doric-lib.js"; const QString DoricConstant::DORIC_MODULE_LIB = "doric"; const QString DoricConstant::INJECT_ENVIRONMENT = "Environment";