This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-Qt/doric/engine/bridge_extension.cpp

31 lines
1.0 KiB
C++
Raw Normal View History

2021-01-28 17:06:40 +08:00
#include <QDebug>
2021-02-04 14:55:36 +08:00
#include <QMetaObject>
2021-01-28 17:06:40 +08:00
#include "bridge_extension.h"
2021-02-04 14:55:36 +08:00
#include "../context_manager.h"
2021-01-28 17:06:40 +08:00
BridgeExtension::BridgeExtension(QObject *parent) : QObject(parent)
{
}
void BridgeExtension::callNative(QString contextId, QString module, QString methodName, QString callbackId, QJSValue jsValue)
{
2021-02-04 14:55:36 +08:00
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;
}
2021-01-28 17:06:40 +08:00
qDebug() << "contextId: " + contextId;
qDebug() << "module: " + module;
qDebug() << "methodName: " + methodName;
qDebug() << "callbackId: " + callbackId;
qDebug() << "jsValue: " + jsValue.toString();
}