genbindings/enums: more accurate underlying type definitions

This commit is contained in:
mappu 2024-09-16 19:03:02 +12:00
parent 88d7251b69
commit 7fdccff799
1 changed files with 10 additions and 1 deletions

View File

@ -480,8 +480,16 @@ var (
func processEnum(node map[string]interface{}, addNamePrefix string) (CppEnum, error) {
var ret CppEnum
ret.UnderlyingType = "int" // FIXME
// Underlying type
ret.UnderlyingType = "int"
if nodefut, ok := node["fixedUnderlyingType"].(map[string]interface{}); ok {
if nodequal, ok := nodefut["qualType"].(string); ok {
ret.UnderlyingType = nodequal
}
}
// Name
nodename, ok := node["name"].(string)
if !ok {
// An unnamed enum is possible (e.g. qcalendar.h)
@ -492,6 +500,7 @@ func processEnum(node map[string]interface{}, addNamePrefix string) (CppEnum, er
ret.EnumName = addNamePrefix + nodename
}
// Entries
inner, ok := node["inner"].([]interface{})
if !ok {
// An enum with no entries? We're done