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 void invokeDoricMethod(QString method, QVariantList args) = 0;
|
||||||
|
|
||||||
virtual DoricAsyncResult *asyncCall(QRunnable *runnable,
|
virtual DoricAsyncResult *asyncCall(std::function<void()> lambda,
|
||||||
DoricThreadMode mode) = 0;
|
DoricThreadMode mode) = 0;
|
||||||
|
|
||||||
virtual void createContext(QString contextId, QString script,
|
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) {
|
DoricThreadMode mode) {
|
||||||
|
switch (mode) {
|
||||||
|
case UI:
|
||||||
|
break;
|
||||||
|
case JS:
|
||||||
|
DoricAsyncCall::ensureRunInThreadPool(&jsEngine.mJSThreadPool, lambda);
|
||||||
|
break;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ public:
|
|||||||
|
|
||||||
void invokeDoricMethod(QString method, QVariantList args) override;
|
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,
|
void createContext(QString contextId, QString script,
|
||||||
QString source) override;
|
QString source) override;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef ASYNC_CALL_H
|
#ifndef ASYNC_CALL_H
|
||||||
#define ASYNC_CALL_H
|
#define ASYNC_CALL_H
|
||||||
|
|
||||||
|
#include <QFuture>
|
||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
|
||||||
@ -9,6 +10,7 @@ class DoricAsyncCall {
|
|||||||
public:
|
public:
|
||||||
static void ensureRunInThreadPool(QThreadPool *threadPool,
|
static void ensureRunInThreadPool(QThreadPool *threadPool,
|
||||||
std::function<void()> lambda) {
|
std::function<void()> lambda) {
|
||||||
|
QFuture<std::function<void()>::result_type> future =
|
||||||
QtConcurrent::run(threadPool, lambda);
|
QtConcurrent::run(threadPool, lambda);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -9,7 +9,7 @@ DoricDemoBridge::DoricDemoBridge(QObject *parent) : QObject(parent) {}
|
|||||||
void DoricDemoBridge::navigate(QVariant route) {
|
void DoricDemoBridge::navigate(QVariant route) {
|
||||||
switch (route.toInt()) {
|
switch (route.toInt()) {
|
||||||
case 0:
|
case 0:
|
||||||
QString name = "Snake.es5.js";
|
QString name = "Snake.js";
|
||||||
QString script = DoricUtils::readAssetFile("/doric/bundles", name);
|
QString script = DoricUtils::readAssetFile("/doric/bundles", name);
|
||||||
|
|
||||||
DoricPanel panel;
|
DoricPanel panel;
|
||||||
|
@ -32,6 +32,7 @@ SOURCES += \
|
|||||||
main.cpp \
|
main.cpp \
|
||||||
plugin/DoricShaderPlugin.cpp \
|
plugin/DoricShaderPlugin.cpp \
|
||||||
shader/DoricRootNode.cpp \
|
shader/DoricRootNode.cpp \
|
||||||
|
shader/DoricViewNode.cpp \
|
||||||
utils/DoricConstant.cpp \
|
utils/DoricConstant.cpp \
|
||||||
utils/DoricContextHolder.cpp
|
utils/DoricContextHolder.cpp
|
||||||
|
|
||||||
@ -71,6 +72,7 @@ HEADERS += \
|
|||||||
plugin/DoricNativePlugin.h \
|
plugin/DoricNativePlugin.h \
|
||||||
plugin/DoricShaderPlugin.h \
|
plugin/DoricShaderPlugin.h \
|
||||||
shader/DoricRootNode.h \
|
shader/DoricRootNode.h \
|
||||||
|
shader/DoricViewNode.h \
|
||||||
template/DoricSingleton.h \
|
template/DoricSingleton.h \
|
||||||
utils/DoricConstant.h \
|
utils/DoricConstant.h \
|
||||||
utils/DoricContextHolder.h \
|
utils/DoricContextHolder.h \
|
||||||
|
@ -57,9 +57,15 @@ QJSValue DoricNativeJSE::invokeObject(QString objectName, QString functionName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
QJSValue result = function.call(args);
|
QJSValue result = function.call(args);
|
||||||
if (result.isError())
|
if (result.isError()) {
|
||||||
qDebug() << "Uncaught exception at line"
|
qDebug() << "Uncaught exception at line"
|
||||||
<< result.property("lineNumber").toInt() << ":"
|
<< result.property("lineNumber").toInt() << ":"
|
||||||
<< result.toString();
|
<< result.toString();
|
||||||
|
QStringList stacktraces = result.property("stack").toString().split("\n");
|
||||||
|
qDebug() << "++++++++++++++++++++++++";
|
||||||
|
foreach (QString stacktrace, stacktraces) { qDebug() << stacktrace; }
|
||||||
|
qDebug() << "------------------------";
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
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"
|
#include "DoricConstant.h"
|
||||||
|
|
||||||
const QString DoricConstant::DORIC_BUNDLE_SANDBOX = "doric-sandbox.es5.js";
|
const QString DoricConstant::DORIC_BUNDLE_SANDBOX = "doric-sandbox.js";
|
||||||
const QString DoricConstant::DORIC_BUNDLE_LIB = "doric-lib.es5.js";
|
const QString DoricConstant::DORIC_BUNDLE_LIB = "doric-lib.js";
|
||||||
const QString DoricConstant::DORIC_MODULE_LIB = "doric";
|
const QString DoricConstant::DORIC_MODULE_LIB = "doric";
|
||||||
|
|
||||||
const QString DoricConstant::INJECT_ENVIRONMENT = "Environment";
|
const QString DoricConstant::INJECT_ENVIRONMENT = "Environment";
|
||||||
|
Reference in New Issue
Block a user