Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistent management of ExtSuffix in INIT macros #453

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gen/cheader.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,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 \
Expand Down
12 changes: 10 additions & 2 deletions gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,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<"):
Expand All @@ -607,3 +607,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 ""
}
}
Loading