mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
Global: code refactor
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user