add asset js loader & export doric classes
This commit is contained in:
parent
928a4ab038
commit
0b4b9c2ed6
@ -1,9 +1,11 @@
|
|||||||
#ifndef DORIC_H
|
#ifndef DORIC_H
|
||||||
#define DORIC_H
|
#define DORIC_H
|
||||||
|
|
||||||
|
#include "DoricExport.h"
|
||||||
|
|
||||||
#include "DoricLibrary.h"
|
#include "DoricLibrary.h"
|
||||||
|
|
||||||
class Doric {
|
class DORIC_EXPORT Doric {
|
||||||
public:
|
public:
|
||||||
static void registerLibrary(DoricLibrary *doricLibrary) {
|
static void registerLibrary(DoricLibrary *doricLibrary) {
|
||||||
DoricRegistry::getInstance()->registerLibrary(doricLibrary);
|
DoricRegistry::getInstance()->registerLibrary(doricLibrary);
|
||||||
|
@ -5,11 +5,13 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
|
#include "DoricExport.h"
|
||||||
|
|
||||||
#include "DoricRegistry.h"
|
#include "DoricRegistry.h"
|
||||||
#include "async/DoricAsyncResult.h"
|
#include "async/DoricAsyncResult.h"
|
||||||
#include "utils/DoricThreadMode.h"
|
#include "utils/DoricThreadMode.h"
|
||||||
|
|
||||||
class DoricInterfaceDriver {
|
class DORIC_EXPORT DoricInterfaceDriver {
|
||||||
public:
|
public:
|
||||||
virtual std::shared_ptr<DoricAsyncResult>
|
virtual std::shared_ptr<DoricAsyncResult>
|
||||||
invokeContextEntityMethod(QString contextId, QString method,
|
invokeContextEntityMethod(QString contextId, QString method,
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
#ifndef DORICLIBRARY_H
|
#ifndef DORICLIBRARY_H
|
||||||
#define DORICLIBRARY_H
|
#define DORICLIBRARY_H
|
||||||
|
|
||||||
|
#include "DoricExport.h"
|
||||||
|
|
||||||
#include "DoricRegistry.h"
|
#include "DoricRegistry.h"
|
||||||
|
|
||||||
class DoricLibrary {
|
class DORIC_EXPORT DoricLibrary {
|
||||||
public:
|
public:
|
||||||
virtual void load(DoricRegistry *registry) = 0;
|
virtual void load(DoricRegistry *registry) = 0;
|
||||||
};
|
};
|
||||||
|
@ -5,9 +5,11 @@
|
|||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
|
||||||
|
#include "DoricExport.h"
|
||||||
|
|
||||||
#include "DoricAsyncResult.h"
|
#include "DoricAsyncResult.h"
|
||||||
|
|
||||||
class DoricAsyncCall {
|
class DORIC_EXPORT DoricAsyncCall {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template <typename Function>
|
template <typename Function>
|
||||||
|
@ -36,6 +36,7 @@ SOURCES += \
|
|||||||
engine/native/NativeExecutor.cpp \
|
engine/native/NativeExecutor.cpp \
|
||||||
engine/v8/JSValueHelper.cpp \
|
engine/v8/JSValueHelper.cpp \
|
||||||
engine/v8/V8Executor.cpp \
|
engine/v8/V8Executor.cpp \
|
||||||
|
loader/DoricAssetJSLoader.cpp \
|
||||||
loader/DoricJSLoaderManager.cpp \
|
loader/DoricJSLoaderManager.cpp \
|
||||||
plugin/DoricModalPlugin.cpp \
|
plugin/DoricModalPlugin.cpp \
|
||||||
plugin/DoricNavigatorPlugin.cpp \
|
plugin/DoricNavigatorPlugin.cpp \
|
||||||
@ -125,6 +126,7 @@ HEADERS += \
|
|||||||
engine/native/NativeExecutor.h \
|
engine/native/NativeExecutor.h \
|
||||||
engine/v8/JSValueHelper.h \
|
engine/v8/JSValueHelper.h \
|
||||||
engine/v8/V8Executor.h \
|
engine/v8/V8Executor.h \
|
||||||
|
loader/DoricAssetJSLoader.h \
|
||||||
loader/DoricInterfaceLoader.h \
|
loader/DoricInterfaceLoader.h \
|
||||||
loader/DoricJSLoaderManager.h \
|
loader/DoricJSLoaderManager.h \
|
||||||
plugin/DoricModalPlugin.h \
|
plugin/DoricModalPlugin.h \
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
class DoricInterfaceJSE {
|
#include "DoricExport.h"
|
||||||
|
|
||||||
|
class DORIC_EXPORT DoricInterfaceJSE {
|
||||||
public:
|
public:
|
||||||
virtual QString loadJS(QString script, QString source) = 0;
|
virtual QString loadJS(QString script, QString source) = 0;
|
||||||
|
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
#include "DoricContext.h"
|
#include "DoricContext.h"
|
||||||
#include "utils/DoricConstant.h"
|
#include "utils/DoricConstant.h"
|
||||||
|
|
||||||
class DoricPromise {
|
#include "DoricExport.h"
|
||||||
|
|
||||||
|
class DORIC_EXPORT DoricPromise {
|
||||||
public:
|
public:
|
||||||
static void resolve(DoricContext *context, QString callbackId,
|
static void resolve(DoricContext *context, QString callbackId,
|
||||||
QVariantList args) {
|
QVariantList args) {
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
|
|
||||||
#include <QJSEngine>
|
#include <QJSEngine>
|
||||||
|
|
||||||
class NativeExecutor {
|
#include "DoricExport.h"
|
||||||
|
|
||||||
|
class DORIC_EXPORT NativeExecutor {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QJSEngine *mJSEngine;
|
QJSEngine *mJSEngine;
|
||||||
|
@ -8,10 +8,12 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
#include "DoricExport.h"
|
||||||
|
|
||||||
static QMap<QString, QPair<QObject *, QString>> *map =
|
static QMap<QString, QPair<QObject *, QString>> *map =
|
||||||
new QMap<QString, QPair<QObject *, QString>>();
|
new QMap<QString, QPair<QObject *, QString>>();
|
||||||
|
|
||||||
class V8Executor {
|
class DORIC_EXPORT V8Executor {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<v8::Platform> platform;
|
std::unique_ptr<v8::Platform> platform;
|
||||||
|
19
doric-Qt/example/doric/loader/DoricAssetJSLoader.cpp
Normal file
19
doric-Qt/example/doric/loader/DoricAssetJSLoader.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "DoricAssetJSLoader.h"
|
||||||
|
|
||||||
|
#include "utils/DoricUtils.h"
|
||||||
|
|
||||||
|
DoricAssetJSLoader::DoricAssetJSLoader() {}
|
||||||
|
|
||||||
|
bool DoricAssetJSLoader::filter(QString source) {
|
||||||
|
return source.startsWith("assets");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<DoricAsyncResult> DoricAssetJSLoader::request(QString source) {
|
||||||
|
QString protocol = "assets://";
|
||||||
|
QString assetPath = source.mid(protocol.length());
|
||||||
|
|
||||||
|
std::shared_ptr<DoricAsyncResult> asyncResult =
|
||||||
|
std::make_shared<DoricAsyncResult>();
|
||||||
|
|
||||||
|
return asyncResult;
|
||||||
|
}
|
17
doric-Qt/example/doric/loader/DoricAssetJSLoader.h
Normal file
17
doric-Qt/example/doric/loader/DoricAssetJSLoader.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef DORICASSETJSLOADER_H
|
||||||
|
#define DORICASSETJSLOADER_H
|
||||||
|
|
||||||
|
#include "DoricExport.h"
|
||||||
|
|
||||||
|
#include "DoricInterfaceLoader.h"
|
||||||
|
|
||||||
|
class DORIC_EXPORT DoricAssetJSLoader : public DoricInterfaceLoader {
|
||||||
|
public:
|
||||||
|
DoricAssetJSLoader();
|
||||||
|
|
||||||
|
virtual bool filter(QString source) override;
|
||||||
|
|
||||||
|
virtual std::shared_ptr<DoricAsyncResult> request(QString source) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DORICASSETJSLOADER_H
|
@ -1,11 +1,13 @@
|
|||||||
#ifndef DORICINTERFACELOADER_H
|
#ifndef DORICINTERFACELOADER_H
|
||||||
#define DORICINTERFACELOADER_H
|
#define DORICINTERFACELOADER_H
|
||||||
|
|
||||||
#include "async/DoricAsyncResult.h"
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class DoricInterfaceLoader {
|
#include "DoricExport.h"
|
||||||
|
|
||||||
|
#include "async/DoricAsyncResult.h"
|
||||||
|
|
||||||
|
class DORIC_EXPORT DoricInterfaceLoader {
|
||||||
public:
|
public:
|
||||||
virtual bool filter(QString source) = 0;
|
virtual bool filter(QString source) = 0;
|
||||||
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#include "DoricJSLoaderManager.h"
|
#include "DoricJSLoaderManager.h"
|
||||||
|
#include "DoricAssetJSLoader.h"
|
||||||
|
|
||||||
DoricJSLoaderManager::DoricJSLoaderManager() {
|
DoricJSLoaderManager::DoricJSLoaderManager() {
|
||||||
qDebug() << "DoricJSLoaderManager constructor";
|
qDebug() << "DoricJSLoaderManager constructor";
|
||||||
|
|
||||||
|
addJSLoader(new DoricAssetJSLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoricJSLoaderManager::addJSLoader(DoricInterfaceLoader *jsLoader) {
|
void DoricJSLoaderManager::addJSLoader(DoricInterfaceLoader *jsLoader) {
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "DoricExport.h"
|
||||||
|
|
||||||
#include "DoricInterfaceLoader.h"
|
#include "DoricInterfaceLoader.h"
|
||||||
|
|
||||||
class DoricJSLoaderManager {
|
class DORIC_EXPORT DoricJSLoaderManager {
|
||||||
private:
|
private:
|
||||||
static DoricJSLoaderManager *local_instance;
|
static DoricJSLoaderManager *local_instance;
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
#ifndef DORICNATIVEPLUGIN_H
|
#ifndef DORICNATIVEPLUGIN_H
|
||||||
#define DORICNATIVEPLUGIN_H
|
#define DORICNATIVEPLUGIN_H
|
||||||
|
|
||||||
|
#include "DoricExport.h"
|
||||||
|
|
||||||
#include "../utils/DoricContextHolder.h"
|
#include "../utils/DoricContextHolder.h"
|
||||||
|
|
||||||
class DoricNativePlugin : public DoricContextHolder {
|
class DORIC_EXPORT DoricNativePlugin : public DoricContextHolder {
|
||||||
public:
|
public:
|
||||||
using DoricContextHolder::DoricContextHolder;
|
using DoricContextHolder::DoricContextHolder;
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
class DoricSingleton {
|
#include "DoricExport.h"
|
||||||
|
|
||||||
|
class DORIC_EXPORT DoricSingleton {
|
||||||
private:
|
private:
|
||||||
static DoricSingleton *local_instance;
|
static DoricSingleton *local_instance;
|
||||||
DoricSingleton() { qDebug() << "constructor"; }
|
DoricSingleton() { qDebug() << "constructor"; }
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
class DoricGlobalBroadcast {
|
#include "DoricExport.h"
|
||||||
|
|
||||||
|
class DORIC_EXPORT DoricGlobalBroadcast {
|
||||||
private:
|
private:
|
||||||
static DoricGlobalBroadcast *local_instance;
|
static DoricGlobalBroadcast *local_instance;
|
||||||
DoricGlobalBroadcast() { qDebug() << "DoricGlobalBroadcast constructor"; }
|
DoricGlobalBroadcast() { qDebug() << "DoricGlobalBroadcast constructor"; }
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
class InnerTask : public QObject {
|
#include "DoricExport.h"
|
||||||
|
|
||||||
|
class DORIC_EXPORT InnerTask : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QNetworkRequest httpRequest;
|
QNetworkRequest httpRequest;
|
||||||
@ -63,7 +65,7 @@ signals:
|
|||||||
void response(int code, QList<QByteArray> headers, QByteArray data);
|
void response(int code, QList<QByteArray> headers, QByteArray data);
|
||||||
};
|
};
|
||||||
|
|
||||||
class DoricNetworkService : public QObject {
|
class DORIC_EXPORT DoricNetworkService : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QThread thread;
|
QThread thread;
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
|
|
||||||
class DoricObjectFactory {
|
#include "DoricExport.h"
|
||||||
|
|
||||||
|
class DORIC_EXPORT DoricObjectFactory {
|
||||||
public:
|
public:
|
||||||
template <typename T> static void registerClass(QString name) {
|
template <typename T> static void registerClass(QString name) {
|
||||||
constructors().insert(name, &constructorHelper<T>);
|
constructors().insert(name, &constructorHelper<T>);
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
class DoricUtils {
|
#include "DoricExport.h"
|
||||||
|
|
||||||
|
class DORIC_EXPORT DoricUtils {
|
||||||
public:
|
public:
|
||||||
static QString readAssetFile(QString preffix, QString assetName) {
|
static QString readAssetFile(QString preffix, QString assetName) {
|
||||||
QResource resource(":" + preffix + "/" + assetName);
|
QResource resource(":" + preffix + "/" + assetName);
|
||||||
|
Reference in New Issue
Block a user