Modules: major code refactor

Also fix some bugs found when refactoring
This commit is contained in:
李通洲
2023-08-17 10:56:54 +08:00
parent 75323d64f8
commit c888254f70
171 changed files with 778 additions and 963 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
typedef struct FFShellOptions
{
const char* moduleName;
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
bool version;
+4 -9
View File
@@ -45,7 +45,7 @@ void ffPrintShell(FFShellOptions* options)
void ffInitShellOptions(FFShellOptions* options)
{
options->moduleName = FF_SHELL_MODULE_NAME;
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_SHELL_MODULE_NAME, ffParseShellCommandOptions, ffParseShellJsonObject, ffPrintShell);
ffOptionInitModuleArg(&options->moduleArgs);
}
@@ -64,11 +64,8 @@ void ffDestroyShellOptions(FFShellOptions* options)
ffOptionDestroyModuleArg(&options->moduleArgs);
}
void ffParseShellJsonObject(yyjson_val* module)
void ffParseShellJsonObject(FFShellOptions* options, yyjson_val* module)
{
FFShellOptions __attribute__((__cleanup__(ffDestroyShellOptions))) options;
ffInitShellOptions(&options);
if (module)
{
yyjson_val *key_, *val;
@@ -79,12 +76,10 @@ void ffParseShellJsonObject(yyjson_val* module)
if(ffStrEqualsIgnCase(key, "type"))
continue;
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue;
ffPrintError(FF_SHELL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
ffPrintError(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
}
}
ffPrintShell(&options);
}
+1 -1
View File
@@ -8,4 +8,4 @@ void ffPrintShell(FFShellOptions* options);
void ffInitShellOptions(FFShellOptions* options);
bool ffParseShellCommandOptions(FFShellOptions* options, const char* key, const char* value);
void ffDestroyShellOptions(FFShellOptions* options);
void ffParseShellJsonObject(yyjson_val* module);
void ffParseShellJsonObject(FFShellOptions* options, yyjson_val* module);