From ec9c70e9b295488f124009b6103e5d714018f314 Mon Sep 17 00:00:00 2001 From: Elie Michel Date: Thu, 28 Nov 2024 09:23:58 +0100 Subject: [PATCH] Fix inconsistent management of ExtSuffix in INIT macros --- gen/cheader.tmpl | 2 +- gen/gen.go | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gen/cheader.tmpl b/gen/cheader.tmpl index 898dacb..28db446 100644 --- a/gen/cheader.tmpl +++ b/gen/cheader.tmpl @@ -306,7 +306,7 @@ typedef struct WGPU{{.Name | PascalCase}}CallbackInfo{{$.ExtSuffix}} { /** * Initializer for @ref WGPU{{.Name | PascalCase}}CallbackInfo{{$.ExtSuffix}}. */ -#define WGPU_{{.Name | ConstantCase}}_CALLBACK_INFO{{$.ExtSuffix}}_INIT _wgpu_MAKE_INIT_STRUCT(WGPU{{.Name | PascalCase}}CallbackInfo{{$.ExtSuffix}}, { \ +#define WGPU_{{.Name | ConstantCase}}_CALLBACK_INFO{{if $.ExtSuffix}}_{{$.ExtSuffix}}{{end}}_INIT _wgpu_MAKE_INIT_STRUCT(WGPU{{.Name | PascalCase}}CallbackInfo{{$.ExtSuffix}}, { \ /*.nextInChain=*/NULL _wgpu_COMMA \ {{- if eq .Style "callback_mode" }} /*.mode=*/WGPUCallbackMode_WaitAnyOnly _wgpu_COMMA \ diff --git a/gen/gen.go b/gen/gen.go index 1ce0c62..33d01a9 100644 --- a/gen/gen.go +++ b/gen/gen.go @@ -569,11 +569,11 @@ func (g *Generator) DefaultValue(member ParameterType, isDocString bool) string return literal("NULL") } else { typ := strings.TrimPrefix(member.Type, "struct.") - return ref("WGPU_" + ConstantCase(typ) + "_INIT") + return ref("WGPU_" + ConstantCase(typ) + g.ConstantExtSuffix() + "_INIT") } case strings.HasPrefix(member.Type, "callback."): typ := strings.TrimPrefix(member.Type, "callback.") - return ref("WGPU_" + ConstantCase(typ) + "_CALLBACK_INFO_INIT") + return ref("WGPU_" + ConstantCase(typ) + "_CALLBACK_INFO" + g.ConstantExtSuffix() + "_INIT") case strings.HasPrefix(member.Type, "object."): return literal("NULL") case strings.HasPrefix(member.Type, "array<"): @@ -586,3 +586,11 @@ func (g *Generator) DefaultValue(member ParameterType, isDocString bool) string panic("invalid prefix: " + member.Type + " in member " + member.Name) } } + +func (g *Generator) ConstantExtSuffix() string { + if g.ExtSuffix != "" { + return "_" + ConstantCase(g.ExtSuffix) + } else { + return "" + } +}