genbindings/enum: skip over deprecated enum values

This commit is contained in:
mappu 2024-10-08 17:36:02 +13:00
parent 8585fc05f4
commit c0ff37a9c6
1 changed files with 12 additions and 1 deletions

View File

@ -512,6 +512,7 @@ func processEnum(node map[string]interface{}, addNamePrefix string) (CppEnum, er
var lastImplicitValue int64 = -1 var lastImplicitValue int64 = -1
nextEnumEntry:
for _, entry := range inner { for _, entry := range inner {
entry, ok := entry.(map[string]interface{}) entry, ok := entry.(map[string]interface{})
if !ok { if !ok {
@ -519,7 +520,12 @@ func processEnum(node map[string]interface{}, addNamePrefix string) (CppEnum, er
} }
kind, ok := entry["kind"].(string) kind, ok := entry["kind"].(string)
if !ok || kind != "EnumConstantDecl" { if kind == "DeprecatedAttr" {
continue nextEnumEntry // skip
} else if kind == "EnumConstantDecl" {
// allow
} else {
// unknown kind, or maybe !ok
return ret, fmt.Errorf("unexpected kind %q", kind) return ret, fmt.Errorf("unexpected kind %q", kind)
} }
@ -575,6 +581,11 @@ func processEnum(node map[string]interface{}, addNamePrefix string) (CppEnum, er
} }
} }
if ei1Kind, ok := ei1_0["kind"].(string); ok && ei1Kind == "DeprecatedAttr" {
log.Printf("Enum entry %q is deprecated, skipping", ret.EnumName+"::"+entryname)
continue nextEnumEntry
}
} }
// If we made it here, we did not hit any of the `goto afterParse` cases // If we made it here, we did not hit any of the `goto afterParse` cases