add shader plugin reg
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#include <QDebug>
|
||||
#include <QMetaObject>
|
||||
|
||||
#include "bridge_extension.h"
|
||||
#include "../context_manager.h"
|
||||
|
||||
BridgeExtension::BridgeExtension(QObject *parent) : QObject(parent)
|
||||
{
|
||||
@@ -8,6 +11,17 @@ BridgeExtension::BridgeExtension(QObject *parent) : QObject(parent)
|
||||
|
||||
void BridgeExtension::callNative(QString contextId, QString module, QString methodName, QString callbackId, QJSValue jsValue)
|
||||
{
|
||||
Context *context = ContextManager::getInstance()->getContext(contextId);
|
||||
bool classRegistered = context->getDriver()->getRegistry()->acquirePluginInfo(module);
|
||||
if (classRegistered) {
|
||||
QObject *plugin = context->obtainPlugin(module);
|
||||
QMetaObject::invokeMethod(
|
||||
plugin,
|
||||
methodName.toStdString().c_str(),
|
||||
Qt::DirectConnection, QGenericReturnArgument(),
|
||||
Q_ARG(QJSValue, jsValue), Q_ARG(QString, callbackId));
|
||||
qDebug() << plugin;
|
||||
}
|
||||
qDebug() << "contextId: " + contextId;
|
||||
qDebug() << "module: " + module;
|
||||
qDebug() << "methodName: " + methodName;
|
||||
|
@@ -79,6 +79,11 @@ JSEngine::JSEngine(QObject *parent) : QObject(parent)
|
||||
});
|
||||
}
|
||||
|
||||
void JSEngine::prepareContext(QString contextId, QString script, QString source)
|
||||
{
|
||||
mJSE->loadJS(packageContextScript(contextId, script), "Context://" + source);
|
||||
}
|
||||
|
||||
QJSValue JSEngine::invokeDoricMethod(QString method, QVariantList arguments)
|
||||
{
|
||||
return mJSE->invokeObject(Constant::GLOBAL_DORIC, method, arguments);
|
||||
@@ -90,11 +95,6 @@ void JSEngine::loadBuiltinJS(QString assetName)
|
||||
QString result = mJSE->loadJS(script, "Assets://" + assetName);
|
||||
}
|
||||
|
||||
void JSEngine::prepareContext(QString contextId, QString script, QString source)
|
||||
{
|
||||
mJSE->loadJS(packageContextScript(contextId, script), "Context://" + source);
|
||||
}
|
||||
|
||||
QString JSEngine::packageContextScript(QString contextId, QString content)
|
||||
{
|
||||
return QString(Constant::TEMPLATE_CONTEXT_CREATE).replace("%s1", content).replace("%s2", contextId).replace("%s3", contextId);
|
||||
@@ -105,6 +105,11 @@ QString JSEngine::packageModuleScript(QString moduleName, QString content)
|
||||
return QString(Constant::TEMPLATE_MODULE).replace("%s1", moduleName).replace("%s2", content);
|
||||
}
|
||||
|
||||
Registry *JSEngine::getRegistry()
|
||||
{
|
||||
return this->mRegistry;
|
||||
}
|
||||
|
||||
JSEngine::~JSEngine()
|
||||
{
|
||||
|
||||
|
@@ -5,12 +5,14 @@
|
||||
#include <QThreadPool>
|
||||
|
||||
#include "interface_jse.h"
|
||||
#include "../registry.h"
|
||||
|
||||
class JSEngine : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
InterfaceJSE *mJSE;
|
||||
Registry *mRegistry = new Registry();
|
||||
|
||||
void loadBuiltinJS(QString assetName);
|
||||
QString packageContextScript(QString contextId, QString content);
|
||||
@@ -22,8 +24,9 @@ public:
|
||||
|
||||
~JSEngine();
|
||||
|
||||
QJSValue invokeDoricMethod(QString method, QVariantList arguments);
|
||||
void prepareContext(QString contextId, QString script, QString source);
|
||||
QJSValue invokeDoricMethod(QString method, QVariantList arguments);
|
||||
Registry *getRegistry();
|
||||
};
|
||||
|
||||
#endif // JSENGINE_H
|
||||
|
Reference in New Issue
Block a user