add view node
This commit is contained in:
parent
ceb08bfa1d
commit
ed7d186510
@ -16,7 +16,7 @@ public:
|
||||
|
||||
virtual void invokeDoricMethod(QString method, QVariantList args) = 0;
|
||||
|
||||
virtual DoricAsyncResult *asyncCall(QRunnable *runnable,
|
||||
virtual DoricAsyncResult *asyncCall(std::function<void()> lambda,
|
||||
DoricThreadMode mode) = 0;
|
||||
|
||||
virtual void createContext(QString contextId, QString script,
|
||||
|
@ -19,8 +19,15 @@ void DoricNativeDriver::invokeDoricMethod(QString method, QVariantList args) {
|
||||
});
|
||||
}
|
||||
|
||||
DoricAsyncResult *DoricNativeDriver::asyncCall(QRunnable *runnable,
|
||||
DoricAsyncResult *DoricNativeDriver::asyncCall(std::function<void()> lambda,
|
||||
DoricThreadMode mode) {
|
||||
switch (mode) {
|
||||
case UI:
|
||||
break;
|
||||
case JS:
|
||||
DoricAsyncCall::ensureRunInThreadPool(&jsEngine.mJSThreadPool, lambda);
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,8 @@ public:
|
||||
|
||||
void invokeDoricMethod(QString method, QVariantList args) override;
|
||||
|
||||
DoricAsyncResult * asyncCall(QRunnable *runnable, DoricThreadMode mode) override;
|
||||
DoricAsyncResult *asyncCall(std::function<void()> lambda,
|
||||
DoricThreadMode mode) override;
|
||||
|
||||
void createContext(QString contextId, QString script,
|
||||
QString source) override;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef ASYNC_CALL_H
|
||||
#define ASYNC_CALL_H
|
||||
|
||||
#include <QFuture>
|
||||
#include <QThreadPool>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
|
||||
@ -9,7 +10,8 @@ class DoricAsyncCall {
|
||||
public:
|
||||
static void ensureRunInThreadPool(QThreadPool *threadPool,
|
||||
std::function<void()> lambda) {
|
||||
QtConcurrent::run(threadPool, lambda);
|
||||
QFuture<std::function<void()>::result_type> future =
|
||||
QtConcurrent::run(threadPool, lambda);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 \
|
||||
|
@ -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;
|
||||
}
|
||||
|
1
doric-Qt/doric/shader/DoricViewNode.cpp
Normal file
1
doric-Qt/doric/shader/DoricViewNode.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "DoricViewNode.h"
|
10
doric-Qt/doric/shader/DoricViewNode.h
Normal file
10
doric-Qt/doric/shader/DoricViewNode.h
Normal file
@ -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
|
@ -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";
|
||||
|
Reference in New Issue
Block a user