From c1f5b3336836e15d193582e9b8f3e044f7d8bc1b Mon Sep 17 00:00:00 2001 From: saturneric Date: Thu, 29 Feb 2024 18:15:57 +0800 Subject: feat: add module controller and continue to work on module system 1. speed up building by reducing build info sheader including 2. add module controller 3. continue to work on module system --- src/module/sdk/Basic.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/module/sdk/Basic.cpp') diff --git a/src/module/sdk/Basic.cpp b/src/module/sdk/Basic.cpp index 35ce8054..ce222fbd 100644 --- a/src/module/sdk/Basic.cpp +++ b/src/module/sdk/Basic.cpp @@ -57,12 +57,16 @@ void ExecuteCommandSync(const char* cmd, int32_t argc, const char** argv, void ExecuteCommandBatchSync(int32_t context_size, const CommandExecuteContext* context) { QList contexts; + for (int i = 0; i < context_size; i++) { - auto exec_context = context[i]; + const auto& exec_context = context[i]; + QStringList args; - for (int i = 0; i < exec_context.argc; i++) { - args.append(QString::fromUtf8(exec_context.argv[i])); + const char** argv = exec_context.argv; + for (int j = 0; j < exec_context.argc; j++) { + args.append(QString::fromUtf8(argv[j])); } + contexts.append( {exec_context.cmd, args, [data = exec_context.data, cb = exec_context.cb]( @@ -72,4 +76,14 @@ void ExecuteCommandBatchSync(int32_t context_size, } GpgFrontend::GpgCommandExecutor::ExecuteConcurrentlySync(contexts); +} + +auto GPGFRONTEND_MODULE_SDK_EXPORT GFModuleStrDup(const char* src) -> char* { + auto len = strlen(src); + + char* dst = static_cast(AllocateMemory((len + 1) * sizeof(char))); + memcpy(dst, src, len); + dst[len] = '\0'; + + return dst; } \ No newline at end of file -- cgit v1.2.3