zig-webgpu-gen

git clone git://git.electrosoup.com/zig-webgpu-gen
Log | Files | Refs

commit 6d0d2f300c1b2b88ddadcb2aa263ad0dd1c219b6
parent 94b6fa19cb2e5490134bf22ea5281143030de536
Author: Christian Ermann <christianermann@gmail.com>
Date:   Sat, 28 Feb 2026 08:04:49 -0800

Remove 'WebGPU' prefix from types

Diffstat:
Msrc/main.zig | 69+++++++++++++++++++++++++++++++--------------------------------------
1 file changed, 31 insertions(+), 38 deletions(-)

diff --git a/src/main.zig b/src/main.zig @@ -2,22 +2,22 @@ const std = @import("std"); const lib = @import("wgpu_gen_zig_lib"); -const WebGPUJson = struct { +const Api = struct { copyright: []const u8, name: []const u8, enum_prefix: i64, doc: []const u8, - typedefs: []WebGPUTypeDef, - constants: []WebGPUConstant, - enums: []WebGPUEnum, - bitflags: []WebGPUBitFlag, - structs: []WebGPUStruct, - callbacks: []WebGPUCallback, - functions: []WebGPUFunction, - objects: []WebGPUObject, + typedefs: []TypeDef, + constants: []Constant, + enums: []Enum, + bitflags: []BitFlag, + structs: []Struct, + callbacks: []Callback, + functions: []Function, + objects: []Object, }; -const WebGPUValue64 = union(enum) { +const Value64 = union(enum) { int: u64, float: f64, @@ -25,7 +25,7 @@ const WebGPUValue64 = union(enum) { allocator: std.mem.Allocator, source: anytype, options: std.json.ParseOptions, - ) !WebGPUValue64 { + ) !Value64 { _ = allocator; _ = options; const token = try source.next(); @@ -54,17 +54,10 @@ const WebGPUValue64 = union(enum) { else => error.UnexpectedToken, }; } - - pub fn deinit(self: WebGPUValue64, allocator: std.mem.Allocator) void { - switch (self) { - .string => |s| allocator.free(s), - .int => {}, - } - } }; -const WebGPUParameterType = struct { +const ParameterType = struct { name: []const u8, doc: []const u8, type: []const u8, @@ -74,62 +67,62 @@ const WebGPUParameterType = struct { // TODO: default: ... , }; -const WebGPUTypeDef = struct { +const TypeDef = struct { name: []const u8, namespace: ?[]const u8 = null, doc: []const u8, type: []const u8, }; -const WebGPUConstant = struct { +const Constant = struct { name: []const u8, namespace: ?[]const u8 = null, - value: WebGPUValue64, + value: Value64, doc: []const u8, }; -const WebGPUEnum = struct { +const Enum = struct { name: []const u8, namespace: ?[]const u8 = null, doc: []const u8, extended: ?bool = null, - entries: []const ?WebGPUEnumEntry, + entries: []const ?EnumEntry, }; -const WebGPUEnumEntry = struct { +const EnumEntry = struct { name: []const u8, namespace: ?[] const u8 = null, doc: []const u8, value: ?u16 = null, }; -const WebGPUBitFlag = struct { +const BitFlag = struct { name: []const u8, namespace: ?[]const u8 = null, doc: []const u8, extended: ?bool = null, - entries: []const ?WebGPUBitFlagEntry, + entries: []const ?BitFlagEntry, }; -const WebGPUBitFlagEntry = struct { +const BitFlagEntry = struct { name: []const u8, namespace: ?[]const u8 = null, doc: []const u8, - value: ?WebGPUValue64 = null, + value: ?Value64 = null, value_combination: ?[][]const u8 = null }; -const WebGPUStruct = struct { +const Struct = struct { name: []const u8, namespace: ?[]const u8 = null, doc: []const u8, type: []const u8, extends: ?[][]const u8 = null, free_members: ?bool = null, - members: ?[]WebGPUParameterType = null, + members: ?[]ParameterType = null, }; -const WebGPUCallback = struct { +const Callback = struct { name: []const u8, namespace: ?[]const u8 = null, doc: []const u8, @@ -137,7 +130,7 @@ const WebGPUCallback = struct { // TODO: args: ... , }; -const WebGPUReturnType = struct { +const ReturnType = struct { doc: []const u8, type: []const u8, optional: ?bool = null, @@ -145,21 +138,21 @@ const WebGPUReturnType = struct { pointer: ?[]const u8 = null, }; -const WebGPUFunction = struct { +const Function = struct { name: []const u8, namespace: ?[]const u8 = null, doc: []const u8, - returns: ?WebGPUReturnType = null, + returns: ?ReturnType = null, callback: ?[]const u8 = null, // TODO: args ... , }; -const WebGPUObject = struct { +const Object = struct { name: []const u8, namespace: ?[]const u8 = null, doc: []const u8, extended: ?bool = null, - methods: []WebGPUFunction, + methods: []Function, }; pub fn main() !void { @@ -173,7 +166,7 @@ pub fn main() !void { defer allocator.free(json); const parsed = try std.json.parseFromSlice( - WebGPUJson, + Api, allocator, json, .{