Global: code refactor

This commit is contained in:
李通洲
2023-08-31 13:54:46 +08:00
parent 76fce2c5a9
commit 639ad436a0
9 changed files with 16 additions and 16 deletions
+8
View File
@@ -23,3 +23,11 @@ yyjson_api_inline yyjson_mut_val* yyjson_mut_obj_add_obj(yyjson_mut_doc *doc,
yyjson_mut_obj_add_val(doc, obj, _key, newObj);
return newObj;
}
yyjson_api_inline yyjson_mut_val* yyjson_mut_obj_add_arr(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
const char *_key) {
yyjson_mut_val* newArr = yyjson_mut_arr(doc);
yyjson_mut_obj_add_val(doc, obj, _key, newArr);
return newArr;
}
+1 -2
View File
@@ -187,8 +187,7 @@ void ffGenerateBatteryJson(FFBatteryOptions* options, yyjson_mut_doc* doc, yyjso
return;
}
yyjson_mut_val* arr = yyjson_mut_arr(doc);
yyjson_mut_obj_add_val(doc, module, "result", arr);
yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result");
FF_LIST_FOR_EACH(FFBatteryResult, battery, results)
{
+1 -2
View File
@@ -113,8 +113,7 @@ void ffGenerateBiosJson(FF_MAYBE_UNUSED FFBiosOptions* options, yyjson_mut_doc*
goto exit;
}
yyjson_mut_val* obj = yyjson_mut_obj(doc);
yyjson_mut_obj_add_val(doc, module, "result", obj);
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
yyjson_mut_obj_add_strbuf(doc, obj, "date", &bios.date);
yyjson_mut_obj_add_strbuf(doc, obj, "release", &bios.release);
yyjson_mut_obj_add_strbuf(doc, obj, "vendor", &bios.vendor);
+1 -2
View File
@@ -136,8 +136,7 @@ void ffGenerateBluetoothJson(FF_MAYBE_UNUSED FFBluetoothOptions* options, yyjson
}
else
{
yyjson_mut_val* arr = yyjson_mut_arr(doc);
yyjson_mut_obj_add_val(doc, module, "result", arr);
yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result");
FF_LIST_FOR_EACH(FFBluetoothResult, item, results)
{
+1 -2
View File
@@ -108,8 +108,7 @@ void ffGenerateBoardJson(FF_MAYBE_UNUSED FFBoardOptions* options, yyjson_mut_doc
goto exit;
}
yyjson_mut_val* obj = yyjson_mut_obj(doc);
yyjson_mut_obj_add_val(doc, module, "result", obj);
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
yyjson_mut_obj_add_strbuf(doc, obj, "name", &board.name);
yyjson_mut_obj_add_strbuf(doc, obj, "vendor", &board.vendor);
yyjson_mut_obj_add_strbuf(doc, obj, "version", &board.version);
+1 -2
View File
@@ -109,8 +109,7 @@ void ffGenerateChassisJson(FF_MAYBE_UNUSED FFChassisOptions* options, yyjson_mut
goto exit;
}
yyjson_mut_val* obj = yyjson_mut_obj(doc);
yyjson_mut_obj_add_val(doc, module, "result", obj);
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
yyjson_mut_obj_add_strbuf(doc, obj, "type", &result.type);
yyjson_mut_obj_add_strbuf(doc, obj, "vendor", &result.vendor);
yyjson_mut_obj_add_strbuf(doc, obj, "version", &result.version);
+1 -2
View File
@@ -149,8 +149,7 @@ void ffGenerateCPUJson(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_mut_va
}
else
{
yyjson_mut_val* obj = yyjson_mut_obj(doc);
yyjson_mut_obj_add_val(doc, module, "result", obj);
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
yyjson_mut_obj_add_strbuf(doc, obj, "cpu", &cpu.name);
yyjson_mut_obj_add_strbuf(doc, obj, "vendor", &cpu.vendor);
yyjson_mut_obj_add_uint(doc, obj, "coresPhysical", cpu.coresPhysical);
+1 -2
View File
@@ -103,8 +103,7 @@ void ffGenerateCursorJson(FF_MAYBE_UNUSED FFCursorOptions* options, yyjson_mut_d
return;
}
yyjson_mut_val* obj = yyjson_mut_obj(doc);
yyjson_mut_obj_add_val(doc, module, "result", obj);
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
yyjson_mut_obj_add_strbuf(doc, obj, "theme", &result.theme);
yyjson_mut_obj_add_strbuf(doc, obj, "size", &result.size);
}
+1 -2
View File
@@ -91,8 +91,7 @@ void ffGenerateDateTimeJson(FF_MAYBE_UNUSED FFDateTimeOptions* options, yyjson_m
{
const FFDateTimeResult* result = ffDetectDateTime();
yyjson_mut_val* obj = yyjson_mut_obj(doc);
yyjson_mut_obj_add_val(doc, module, "result", obj);
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
yyjson_mut_obj_add_uint(doc, obj, "year", result->year);
yyjson_mut_obj_add_uint(doc, obj, "yearShort", result->yearShort);
yyjson_mut_obj_add_uint(doc, obj, "month", result->month);