From 44f25c0ef375081c40446b919b8423c7224286af Mon Sep 17 00:00:00 2001 From: wingsummer <1326224942@qq.com> Date: Sun, 15 Jun 2025 22:39:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8F=92=E4=BB=B6=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestPlugin/testplugin.cpp | 6 +- WingPlugin | 2 +- lang/zh_CN/winghex_zh_CN.ts | 90 +++++++------- lang/zh_TW/winghex_zh_TW.ts | 90 +++++++------- src/class/pluginsystem.cpp | 9 +- src/class/pluginsystem.h | 2 +- src/class/wingangelapi.cpp | 237 +++++++++++++++++++----------------- 7 files changed, 228 insertions(+), 208 deletions(-) diff --git a/TestPlugin/testplugin.cpp b/TestPlugin/testplugin.cpp index e18a83c..5ac37a7 100644 --- a/TestPlugin/testplugin.cpp +++ b/TestPlugin/testplugin.cpp @@ -62,8 +62,8 @@ TestPlugin::TestPlugin() : WingHex::IWingPlugin() { std::bind(QOverload::of(&TestPlugin::test_c), this, std::placeholders::_1); info.ret = MetaType::Void; - info.params.append(qMakePair(MetaType(MetaType::Int | MetaType::Array), - QStringLiteral("c"))); + info.params.append( + qMakePair(MetaType::Int | MetaType::Array, QStringLiteral("c"))); _scriptInfo.insert(QStringLiteral("test_c"), info); } @@ -91,7 +91,7 @@ TestPlugin::TestPlugin() : WingHex::IWingPlugin() { info.fn = std::bind(QOverload::of(&TestPlugin::test_f), this, std::placeholders::_1); - info.ret = MetaType(MetaType::Byte | MetaType::Array); + info.ret = MetaType::Byte | MetaType::Array; _scriptInfo.insert(QStringLiteral("test_f"), info); } diff --git a/WingPlugin b/WingPlugin index 07d1b5a..8541087 160000 --- a/WingPlugin +++ b/WingPlugin @@ -1 +1 @@ -Subproject commit 07d1b5a19e7b3fca2444c02edbe1d28e13d34316 +Subproject commit 8541087abd410facd5559038f67949a58a39aa50 diff --git a/lang/zh_CN/winghex_zh_CN.ts b/lang/zh_CN/winghex_zh_CN.ts index 5bed38b..0c3cd55 100644 --- a/lang/zh_CN/winghex_zh_CN.ts +++ b/lang/zh_CN/winghex_zh_CN.ts @@ -2285,195 +2285,195 @@ PluginSystem - + LoadingPlugin 加载插件中: - + InvalidPluginBrokenInfo 加载插件失败:损坏的插件数据 - + AppClosingCanceled: 程序关闭被取消: - + - PluginID: - 插件 ID: - + FoundDrvPluginCount 总计发现设备拓展插件数目: - + RegisterScriptFnUnSupportedTypes: 因脚本函数含有未支持的类型而注册失败: - - + + RegisterScriptFnInvalidSig: 因脚本函数签名非法而注册失败: - - + + RegisterScriptFnConflitSig: 因脚本函数签名冲突而注册失败: - + InvalidEnumName: 非法枚举名: - + InvalidEnumValue: 非法枚举值: - + InvalidMarcosRegister: 非法宏注册: - + ErrLoadPluginSDKVersion 插件加载失败:非法插件 SDK 版本! - + ErrLoadPluginNoName 插件加载失败:非法插件名称! - + ErrLoadInitPlugin 插件加载失败:初始化插件失败! - + PluginName : 插件名: - + PluginAuthor : 插件作者: - + PluginWidgetRegister 注册插件对象中…… - + ErrLoadExtPluginSDKVersion 设备拓展插件加载失败:非法插件 SDK 版本! - + ExtPluginAuthor : 设备拓展插件作者: - + ExtPluginWidgetRegister 设备拓展注册插件对象中…… - + ErrLoadInitExtPlugin 设备拓展插件加载失败:初始化插件失败! - + ChooseFile 选择文件 - - + + Error 错误 - + FileNotExist 文件不存在! - + FilePermission 因文件权限无法继续! - + EmptyNameDockWidget: 空的贴边组件名: - + InvalidNameDockWidget: 无效贴边组件名: - + InvalidNullDockWidget: 无效空贴边组件: - + Not allowed operation in non-UI thread 该操作在非 UI 线程非法 - + UnsafePluginDir 不安全的插件目录,请将插件目录设置为仅管理员账户可写 - + InvalidPluginID 加载插件失败:非法插件标识符 - + InvalidDupPlugin 加载插件失败:重复的插件标识符 - + FoundPluginCount 总计发现插件数目: - + PluginLoadingFailedSummary 有依赖插件加载失败总结 - + - Dependencies: - 依赖: - + PUID: 插件唯一标志符: - + Version: 版本: - + PluginLoadingFinished 加载插件完毕! @@ -5247,18 +5247,18 @@ 为 AngelScript 脚本提供调用主机 API 能力的内部插件。 - + NotSupportedQMetaType: 不支持的 QT 数据元类型: - - + + Get Exception While ScriptCall: (%1) %2 脚本调用发生异常:(%1)%2 - + InvalidRetType: need 无效返回值:需要 diff --git a/lang/zh_TW/winghex_zh_TW.ts b/lang/zh_TW/winghex_zh_TW.ts index 2706988..425dd8e 100644 --- a/lang/zh_TW/winghex_zh_TW.ts +++ b/lang/zh_TW/winghex_zh_TW.ts @@ -2285,195 +2285,195 @@ PluginSystem - + LoadingPlugin 加載插件中: - + InvalidPluginBrokenInfo 加載插件失敗:損壞的插件數據 - + AppClosingCanceled: 程式關閉被取消: - + - PluginID: - 插件 ID: - + FoundDrvPluginCount 總計發現設備拓展插件數目: - + RegisterScriptFnUnSupportedTypes: 因腳本函數含有未支持的類型而註冊失敗: - - + + RegisterScriptFnInvalidSig: 因腳本函數簽名非法而註冊失敗: - - + + RegisterScriptFnConflitSig: 因腳本函數簽名衝突而註冊失敗: - + InvalidEnumName: 非法枚舉名: - + InvalidEnumValue: 非法枚舉值: - + InvalidMarcosRegister: 非法宏註冊: - + ErrLoadPluginSDKVersion 插件加載失敗:非法插件 SDK 版本! - + ErrLoadPluginNoName 插件加載失敗:非法插件名稱! - + ErrLoadInitPlugin 插件加載失敗:初始化插件失敗! - + PluginName : 插件名: - + PluginAuthor : 插件作者: - + PluginWidgetRegister 註冊插件對象中…… - + ErrLoadExtPluginSDKVersion 設備拓展插件加載失敗:非法插件 SDK 版本! - + ExtPluginAuthor : 設備拓展插件作者: - + ExtPluginWidgetRegister 設備拓展註冊插件對象中…… - + ErrLoadInitExtPlugin 設備拓展插件加載失敗:初始化插件失敗! - + ChooseFile 選擇檔 - - + + Error 錯誤 - + FileNotExist 檔不存在! - + FilePermission 因檔許可權無法繼續! - + EmptyNameDockWidget: 空的貼邊組件名: - + InvalidNameDockWidget: 無效貼邊組件名: - + InvalidNullDockWidget: 無效空貼邊組件: - + Not allowed operation in non-UI thread 該操作在非 UI 線程非法 - + UnsafePluginDir 不安全的插件目錄,請將插件目錄設置為僅管理員帳戶可寫 - + InvalidPluginID 加載插件失敗:非法插件識別字 - + InvalidDupPlugin 加載插件失敗:重複的插件識別字 - + FoundPluginCount 總計發現插件數目: - + PluginLoadingFailedSummary 有依賴插件加載失敗總結 - + - Dependencies: - 依賴: - + PUID: 插件唯一標誌符: - + Version: 版本: - + PluginLoadingFinished 加載插件完畢! @@ -5247,18 +5247,18 @@ 為 AngelScript 腳本提供調用主機 API 能力的內部插件。 - + NotSupportedQMetaType: 不支持的 QT 數據元類型: - - + + Get Exception While ScriptCall: (%1) %2 腳本調用發生異常:(%1)%2 - + InvalidRetType: need 無效返回值:需要 diff --git a/src/class/pluginsystem.cpp b/src/class/pluginsystem.cpp index eb78444..f8e0239 100644 --- a/src/class/pluginsystem.cpp +++ b/src/class/pluginsystem.cpp @@ -45,8 +45,6 @@ #include PluginSystem::PluginSystem(QObject *parent) : QObject(parent) { - qRegisterMetaType("MetaCallInfo"); - auto mobj = PluginSystem::metaObject(); auto total = mobj->methodCount(); for (int i = 0; i < total; ++i) { @@ -372,7 +370,7 @@ bool PluginSystem::existsServiceHost(const QObject *sender, } bool PluginSystem::invokeServiceImpl(const QObject *sender, const QString &puid, - const MetaCallInfo &infos) { + const WingHex::MetaCallInfo &infos) { auto p = checkPluginAndReport(sender, __func__); if (p == nullptr) { return false; @@ -396,6 +394,10 @@ bool PluginSystem::invokeServiceImpl(const QObject *sender, const QString &puid, const QtPrivate::QMetaTypeInterface *const *metaTypes; std::tie(method, c, paramCount, parameters, typeNames, metaTypes) = infos; + if (parameters == nullptr || typeNames == nullptr || metaTypes == nullptr) { + return false; + } + QMetaMethod m; // retrive method auto len = meta->methodCount(); @@ -417,6 +419,7 @@ bool PluginSystem::invokeServiceImpl(const QObject *sender, const QString &puid, continue; } m = met; + break; } } diff --git a/src/class/pluginsystem.h b/src/class/pluginsystem.h index c4395c5..34e22bc 100644 --- a/src/class/pluginsystem.h +++ b/src/class/pluginsystem.h @@ -422,7 +422,7 @@ public slots: WING_API bool existsServiceHost(const QObject *sender, const QString &puid); WING_API bool invokeServiceImpl(const QObject *sender, const QString &puid, - const MetaCallInfo &infos); + const WingHex::MetaCallInfo &infos); WING_API bool isCurrentDocEditing(const QObject *sender); diff --git a/src/class/wingangelapi.cpp b/src/class/wingangelapi.cpp index d912e25..87c69f5 100644 --- a/src/class/wingangelapi.cpp +++ b/src/class/wingangelapi.cpp @@ -258,25 +258,30 @@ void WingAngelAPI::installLogAPI(asIScriptEngine *engine) { Q_ASSERT(r >= 0); Q_UNUSED(r); - registerAPI(engine, - asMETHODPR(WingAngelAPI, logInfo, (const QString &), void), - "void info(const string &in message)"); + registerAPI( + engine, + asMETHODPR(WingAngelAPI, logInfo, (const QString &) const, void), + "void info(const string &in message)"); - registerAPI(engine, - asMETHODPR(WingAngelAPI, logTrace, (const QString &), void), - "void trace(const string &in message)"); + registerAPI( + engine, + asMETHODPR(WingAngelAPI, logTrace, (const QString &) const, void), + "void trace(const string &in message)"); - registerAPI(engine, - asMETHODPR(WingAngelAPI, logDebug, (const QString &), void), - "void debug(const string &in message)"); + registerAPI( + engine, + asMETHODPR(WingAngelAPI, logDebug, (const QString &) const, void), + "void debug(const string &in message)"); - registerAPI(engine, - asMETHODPR(WingAngelAPI, logWarn, (const QString &), void), - "void warn(const string &in message)"); + registerAPI( + engine, + asMETHODPR(WingAngelAPI, logWarn, (const QString &) const, void), + "void warn(const string &in message)"); - registerAPI(engine, - asMETHODPR(WingAngelAPI, logError, (const QString &), void), - "void error(const string &in message)"); + registerAPI( + engine, + asMETHODPR(WingAngelAPI, logError, (const QString &) const, void), + "void error(const string &in message)"); engine->SetDefaultNamespace(""); } @@ -544,65 +549,73 @@ void WingAngelAPI::installHexReaderAPI(asIScriptEngine *engine) { Q_ASSERT(r >= 0); Q_UNUSED(r); + registerAPI(engine, + asMETHODPR(WingHex::IWingPlugin, isCurrentDocEditing, + (void) const, bool), + "bool isCurrentDocEditing()"); + registerAPI(engine, + asMETHODPR(WingHex::IWingPlugin, currentDocFilename, + (void) const, QString), + "string currentDocFilename()"); registerAPI( engine, - asMETHODPR(WingHex::IWingPlugin, isCurrentDocEditing, (void), bool), - "bool isCurrentDocEditing()"); + asMETHODPR(WingHex::IWingPlugin, isInsertionMode, (void) const, bool), + "bool isInsertionMode()"); registerAPI( engine, - asMETHODPR(WingHex::IWingPlugin, currentDocFilename, (void), QString), - "string currentDocFilename()"); + asMETHODPR(WingHex::IWingPlugin, isReadOnly, (void) const, bool), + "bool isReadOnly()"); + registerAPI( + engine, + asMETHODPR(WingHex::IWingPlugin, isKeepSize, (void) const, bool), + "bool isKeepSize()"); registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, isInsertionMode, (void), bool), - "bool isInsertionMode()"); - registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, isReadOnly, (void), bool), - "bool isReadOnly()"); - registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, isKeepSize, (void), bool), - "bool isKeepSize()"); - registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, isLocked, (void), bool), + asMETHODPR(WingHex::IWingPlugin, isLocked, (void) const, bool), "bool isLocked()"); registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, currentPos, (void), + asMETHODPR(WingHex::IWingPlugin, currentPos, (void) const, WingHex::HexPosition), "HexPosition currentPos()"); - registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, stringVisible, (void), bool), - "bool stringVisible()"); - registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, addressVisible, (void), bool), - "bool addressVisible()"); - registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, headerVisible, (void), bool), - "bool headerVisible()"); - registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, isModified, (void), bool), - "bool isModified()"); registerAPI( engine, - asMETHODPR(WingHex::IWingPlugin, documentLines, (void), qsizetype), - QSIZETYPE_WRAP("documentLines()")); + asMETHODPR(WingHex::IWingPlugin, stringVisible, (void) const, bool), + "bool stringVisible()"); registerAPI( engine, - asMETHODPR(WingHex::IWingPlugin, documentBytes, (void), qsizetype), - QSIZETYPE_WRAP("documentBytes()")); + asMETHODPR(WingHex::IWingPlugin, addressVisible, (void) const, bool), + "bool addressVisible()"); + registerAPI( + engine, + asMETHODPR(WingHex::IWingPlugin, headerVisible, (void) const, bool), + "bool headerVisible()"); + registerAPI( + engine, + asMETHODPR(WingHex::IWingPlugin, isModified, (void) const, bool), + "bool isModified()"); registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, currentRow, (void), qsizetype), - QSIZETYPE_WRAP("currentRow()")); + asMETHODPR(WingHex::IWingPlugin, documentLines, (void) const, + qsizetype), + QSIZETYPE_WRAP("documentLines()")); + registerAPI(engine, + asMETHODPR(WingHex::IWingPlugin, documentBytes, (void) const, + qsizetype), + QSIZETYPE_WRAP("documentBytes()")); registerAPI( engine, - asMETHODPR(WingHex::IWingPlugin, currentColumn, (void), qsizetype), - QSIZETYPE_WRAP("currentColumn()")); - registerAPI( - engine, - asMETHODPR(WingHex::IWingPlugin, currentOffset, (void), qsizetype), - QSIZETYPE_WRAP("currentOffset()")); - registerAPI( - engine, - asMETHODPR(WingHex::IWingPlugin, selectedLength, (void), qsizetype), - QSIZETYPE_WRAP("selectedLength()")); + asMETHODPR(WingHex::IWingPlugin, currentRow, (void) const, qsizetype), + QSIZETYPE_WRAP("currentRow()")); + registerAPI(engine, + asMETHODPR(WingHex::IWingPlugin, currentColumn, (void) const, + qsizetype), + QSIZETYPE_WRAP("currentColumn()")); + registerAPI(engine, + asMETHODPR(WingHex::IWingPlugin, currentOffset, (void) const, + qsizetype), + QSIZETYPE_WRAP("currentOffset()")); + registerAPI(engine, + asMETHODPR(WingHex::IWingPlugin, selectedLength, (void) const, + qsizetype), + QSIZETYPE_WRAP("selectedLength()")); registerAPI(engine, asMETHODPR(WingAngelAPI, _HexReader_selectedBytes, (qsizetype), @@ -614,76 +627,80 @@ void WingAngelAPI::installHexReaderAPI(asIScriptEngine *engine) { "byte[][]@ selectionBytes()"); registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, selectionStart, (qsizetype), - WingHex::HexPosition), + asMETHODPR(WingHex::IWingPlugin, selectionStart, + (qsizetype) const, WingHex::HexPosition), "HexPosition selectionStart(" QSIZETYPE " index)"); registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, selectionEnd, (qsizetype), - WingHex::HexPosition), + asMETHODPR(WingHex::IWingPlugin, selectionEnd, + (qsizetype) const, WingHex::HexPosition), "HexPosition selectionEnd(" QSIZETYPE " index)"); registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, selectionLength, (qsizetype), - qsizetype), + asMETHODPR(WingHex::IWingPlugin, selectionLength, + (qsizetype) const, qsizetype), QSIZETYPE_WRAP("selectionLength(" QSIZETYPE " index)")); - registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, selectionCount, (), qsizetype), - QSIZETYPE_WRAP("selectionCount()")); + registerAPI( + engine, + asMETHODPR(WingHex::IWingPlugin, selectionCount, () const, qsizetype), + QSIZETYPE_WRAP("selectionCount()")); - registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, addressBase, (void), quintptr), - QPTR_WRAP("addressBase()")); + registerAPI( + engine, + asMETHODPR(WingHex::IWingPlugin, addressBase, (void) const, quintptr), + QPTR_WRAP("addressBase()")); registerAPI(engine, asMETHODPR(WingAngelAPI, _HexReader_readBytes, (qsizetype, qsizetype), CScriptArray *), "byte[]@ readBytes(" QSIZETYPE " offset," QSIZETYPE " len)"); - registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, readInt8, (qsizetype), qint8), - "int8 readInt8(" QSIZETYPE " offset)"); registerAPI( engine, - asMETHODPR(WingHex::IWingPlugin, readUInt8, (qsizetype), quint8), + asMETHODPR(WingHex::IWingPlugin, readInt8, (qsizetype) const, qint8), + "int8 readInt8(" QSIZETYPE " offset)"); + registerAPI( + engine, + asMETHODPR(WingHex::IWingPlugin, readUInt8, (qsizetype) const, quint8), "uint8 readUInt8(" QSIZETYPE " offset)"); registerAPI( engine, - asMETHODPR(WingHex::IWingPlugin, readInt16, (qsizetype), qint16), + asMETHODPR(WingHex::IWingPlugin, readInt16, (qsizetype) const, qint16), "int16 readInt16(" QSIZETYPE " offset)"); - registerAPI( - engine, - asMETHODPR(WingHex::IWingPlugin, readUInt16, (qsizetype), quint16), - "uint16 readUInt16(" QSIZETYPE " offset)"); - - registerAPI( - engine, - asMETHODPR(WingHex::IWingPlugin, readInt32, (qsizetype), qint32), - "int readInt32(" QSIZETYPE " offset)"); - registerAPI( - engine, - asMETHODPR(WingHex::IWingPlugin, readUInt32, (qsizetype), quint32), - "uint readUInt32(" QSIZETYPE " offset)"); - - registerAPI( - engine, - asMETHODPR(WingHex::IWingPlugin, readInt64, (qsizetype), qint64), - "int64 readInt64(" QSIZETYPE " offset)"); - registerAPI( - engine, - asMETHODPR(WingHex::IWingPlugin, readUInt64, (qsizetype), quint64), - "uint64 readUInt64(" QSIZETYPE " offset)"); - registerAPI(engine, - asMETHODPR(WingHex::IWingPlugin, readFloat, (qsizetype), float), - "float readFloat(" QSIZETYPE " offset)"); + asMETHODPR(WingHex::IWingPlugin, readUInt16, (qsizetype) const, + quint16), + "uint16 readUInt16(" QSIZETYPE " offset)"); + registerAPI( engine, - asMETHODPR(WingHex::IWingPlugin, readDouble, (qsizetype), double), + asMETHODPR(WingHex::IWingPlugin, readInt32, (qsizetype) const, qint32), + "int readInt32(" QSIZETYPE " offset)"); + registerAPI(engine, + asMETHODPR(WingHex::IWingPlugin, readUInt32, (qsizetype) const, + quint32), + "uint readUInt32(" QSIZETYPE " offset)"); + + registerAPI( + engine, + asMETHODPR(WingHex::IWingPlugin, readInt64, (qsizetype) const, qint64), + "int64 readInt64(" QSIZETYPE " offset)"); + registerAPI(engine, + asMETHODPR(WingHex::IWingPlugin, readUInt64, (qsizetype) const, + quint64), + "uint64 readUInt64(" QSIZETYPE " offset)"); + + registerAPI( + engine, + asMETHODPR(WingHex::IWingPlugin, readFloat, (qsizetype) const, float), + "float readFloat(" QSIZETYPE " offset)"); + registerAPI( + engine, + asMETHODPR(WingHex::IWingPlugin, readDouble, (qsizetype) const, double), "double readDouble(" QSIZETYPE " offset)"); registerAPI(engine, asMETHODPR(WingHex::IWingPlugin, readString, - (qsizetype, const QString &), QString), + (qsizetype, const QString &) const, QString), "string readString(" QSIZETYPE " offset, string &in encoding = \"\")"); @@ -697,15 +714,15 @@ void WingAngelAPI::installHexReaderAPI(asIScriptEngine *engine) { (qsizetype, const CScriptArray &), qsizetype), QSIZETYPE_WRAP("findPrevious(" QSIZETYPE " begin, byte[] &in ba)")); - registerAPI( - engine, - asMETHODPR(WingHex::IWingPlugin, bookMarkComment, (qsizetype), QString), - "string bookMarkComment(" QSIZETYPE " pos)"); + registerAPI(engine, + asMETHODPR(WingHex::IWingPlugin, bookMarkComment, + (qsizetype) const, QString), + "string bookMarkComment(" QSIZETYPE " pos)"); - registerAPI( - engine, - asMETHODPR(WingHex::IWingPlugin, existBookMark, (qsizetype), bool), - "bool existBookMark(" QSIZETYPE " pos)"); + registerAPI(engine, + asMETHODPR(WingHex::IWingPlugin, existBookMark, + (qsizetype) const, bool), + "bool existBookMark(" QSIZETYPE " pos)"); engine->SetDefaultNamespace(""); }