Add pretty-printed JSON output using Zig's std.json formatter
- Parse generated JSON with std.json.parseFromSlice - Re-format with 2-space indentation using std.json.fmt - Produces readable, properly formatted JSON output - All JSON files now have consistent formatting
This commit is contained in:
parent
818375b78e
commit
f910526948
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,239 @@
|
|||
{
|
||||
"header": "SDL_init.h",
|
||||
"opaque_types": [],
|
||||
"typedefs": [],
|
||||
"function_pointers": [
|
||||
{
|
||||
"name": "SDL_AppInit_func",
|
||||
"return_type": "SDL_AppResult",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "appstate",
|
||||
"type": "void **"
|
||||
},
|
||||
{
|
||||
"name": "argc",
|
||||
"type": "int"
|
||||
},
|
||||
{
|
||||
"name": "argv[]",
|
||||
"type": "char *"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SDL_AppIterate_func",
|
||||
"return_type": "SDL_AppResult",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "appstate",
|
||||
"type": "void *"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SDL_AppEvent_func",
|
||||
"return_type": "SDL_AppResult",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "appstate",
|
||||
"type": "void *"
|
||||
},
|
||||
{
|
||||
"name": "event",
|
||||
"type": "SDL_Event *"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SDL_AppQuit_func",
|
||||
"return_type": "void",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "appstate",
|
||||
"type": "void *"
|
||||
},
|
||||
{
|
||||
"name": "result",
|
||||
"type": "SDL_AppResult"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SDL_MainThreadCallback",
|
||||
"return_type": "void",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "userdata",
|
||||
"type": "void *"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"enums": [
|
||||
{
|
||||
"name": "SDL_AppResult",
|
||||
"values": []
|
||||
}
|
||||
],
|
||||
"structs": [],
|
||||
"unions": [],
|
||||
"flags": [
|
||||
{
|
||||
"name": "SDL_InitFlags",
|
||||
"underlying_type": "Uint32",
|
||||
"values": [
|
||||
{
|
||||
"name": "SDL_INIT_AUDIO",
|
||||
"value": "0x00000010u",
|
||||
"comment": "`SDL_INIT_AUDIO` implies `SDL_INIT_EVENTS`"
|
||||
},
|
||||
{
|
||||
"name": "SDL_INIT_VIDEO",
|
||||
"value": "0x00000020u",
|
||||
"comment": "`SDL_INIT_VIDEO` implies `SDL_INIT_EVENTS`, should be initialized on the main thread"
|
||||
},
|
||||
{
|
||||
"name": "SDL_INIT_JOYSTICK",
|
||||
"value": "0x00000200u",
|
||||
"comment": "`SDL_INIT_JOYSTICK` implies `SDL_INIT_EVENTS`, should be initialized on the same thread as SDL_INIT_VIDEO on Windows if you don't set SDL_HINT_JOYSTICK_THREAD"
|
||||
},
|
||||
{
|
||||
"name": "SDL_INIT_HAPTIC",
|
||||
"value": "0x00001000u"
|
||||
},
|
||||
{
|
||||
"name": "SDL_INIT_GAMEPAD",
|
||||
"value": "0x00002000u",
|
||||
"comment": "`SDL_INIT_GAMEPAD` implies `SDL_INIT_JOYSTICK`"
|
||||
},
|
||||
{
|
||||
"name": "SDL_INIT_EVENTS",
|
||||
"value": "0x00004000u"
|
||||
},
|
||||
{
|
||||
"name": "SDL_INIT_SENSOR",
|
||||
"value": "0x00008000u",
|
||||
"comment": "`SDL_INIT_SENSOR` implies `SDL_INIT_EVENTS`"
|
||||
},
|
||||
{
|
||||
"name": "SDL_INIT_CAMERA",
|
||||
"value": "0x00010000u",
|
||||
"comment": "`SDL_INIT_CAMERA` implies `SDL_INIT_EVENTS`"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"name": "SDL_Init",
|
||||
"return_type": "bool",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "flags",
|
||||
"type": "SDL_InitFlags"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SDL_InitSubSystem",
|
||||
"return_type": "bool",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "flags",
|
||||
"type": "SDL_InitFlags"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SDL_QuitSubSystem",
|
||||
"return_type": "void",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "flags",
|
||||
"type": "SDL_InitFlags"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SDL_WasInit",
|
||||
"return_type": "SDL_InitFlags",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "flags",
|
||||
"type": "SDL_InitFlags"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SDL_Quit",
|
||||
"return_type": "void",
|
||||
"parameters": []
|
||||
},
|
||||
{
|
||||
"name": "SDL_IsMainThread",
|
||||
"return_type": "bool",
|
||||
"parameters": []
|
||||
},
|
||||
{
|
||||
"name": "SDL_RunOnMainThread",
|
||||
"return_type": "bool",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "callback",
|
||||
"type": "SDL_MainThreadCallback"
|
||||
},
|
||||
{
|
||||
"name": "userdata",
|
||||
"type": "void *"
|
||||
},
|
||||
{
|
||||
"name": "wait_complete",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SDL_SetAppMetadata",
|
||||
"return_type": "bool",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "appname",
|
||||
"type": "const char *"
|
||||
},
|
||||
{
|
||||
"name": "appversion",
|
||||
"type": "const char *"
|
||||
},
|
||||
{
|
||||
"name": "appidentifier",
|
||||
"type": "const char *"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SDL_SetAppMetadataProperty",
|
||||
"return_type": "bool",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "const char *"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "const char *"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SDL_GetAppMetadataProperty",
|
||||
"return_type": "const char *",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "const char *"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -181,11 +181,21 @@ pub fn main() !void {
|
|||
|
||||
try serializer.addDeclarations(decls);
|
||||
const json_output = try serializer.finalize();
|
||||
// json_output is owned by serializer, so we need to write it before deinit
|
||||
// json_output is owned by serializer
|
||||
|
||||
// Parse and re-format JSON with proper indentation
|
||||
const parsed = try std.json.parseFromSlice(std.json.Value, allocator, json_output, .{});
|
||||
defer parsed.deinit();
|
||||
|
||||
var formatted_output = std.ArrayList(u8){};
|
||||
defer formatted_output.deinit(allocator);
|
||||
|
||||
const formatter = std.json.fmt(parsed.value, .{ .whitespace = .indent_2 });
|
||||
try std.fmt.format(formatted_output.writer(allocator), "{f}", .{formatter});
|
||||
|
||||
try std.fs.cwd().writeFile(.{
|
||||
.sub_path = json_path,
|
||||
.data = json_output,
|
||||
.data = formatted_output.items,
|
||||
});
|
||||
serializer.deinit();
|
||||
std.debug.print("Generated JSON: {s}\n", .{json_path});
|
||||
|
|
|
|||
Loading…
Reference in New Issue