genbindings/cabi: zero values in CABI should use enum's underlying type

This commit is contained in:
mappu 2025-02-06 18:46:41 +13:00
parent f192a6a330
commit 78fae7cbcb

View File

@ -616,10 +616,13 @@ func getCabiZeroValue(p CppParameter) string {
if p.Pointer { if p.Pointer {
return getCppZeroValue(p) return getCppZeroValue(p)
} else if p.IsKnownEnum() { } else if ev, ok := KnownEnums[p.ParameterType]; ok {
return getCppZeroValue(p) // In CABI the zero value may be the underlying type of an enum instead
return "(" + ev.Enum.UnderlyingType.RenderTypeCabi() + ")(0)"
} else if p.IntType() { } else if p.IntType() {
return getCppZeroValue(p) return getCppZeroValue(p) // default
} else if p.ParameterType == "bool" { } else if p.ParameterType == "bool" {
return getCppZeroValue(p) return getCppZeroValue(p)
} else if p.ParameterType == "void" { } else if p.ParameterType == "void" {