mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 17:08:38 +00:00
genbindings/clang: handle FullComment in enum declarations
This commit is contained in:
parent
b6aa72f62f
commit
6a01cc2d86
@ -525,7 +525,7 @@ nextEnumEntry:
|
|||||||
}
|
}
|
||||||
|
|
||||||
kind, ok := entry["kind"].(string)
|
kind, ok := entry["kind"].(string)
|
||||||
if kind == "DeprecatedAttr" {
|
if kind == "DeprecatedAttr" || kind == "FullComment" {
|
||||||
continue nextEnumEntry // skip
|
continue nextEnumEntry // skip
|
||||||
} else if kind == "EnumConstantDecl" {
|
} else if kind == "EnumConstantDecl" {
|
||||||
// allow
|
// allow
|
||||||
@ -545,56 +545,69 @@ nextEnumEntry:
|
|||||||
|
|
||||||
// Try to find the enum value
|
// Try to find the enum value
|
||||||
ei1, ok := entry["inner"].([]interface{})
|
ei1, ok := entry["inner"].([]interface{})
|
||||||
if !ok || len(ei1) == 0 {
|
if !ok {
|
||||||
// Enum case without definition e.g. QCalendar::Gregorian
|
// No inner value on the enum = autoincrement
|
||||||
// This means one more than the last value
|
// Fall through as if a blank ei1, this will be handled
|
||||||
cee.EntryValue = fmt.Sprintf("%d", lastImplicitValue+1)
|
}
|
||||||
|
|
||||||
} else if len(ei1) >= 1 {
|
// There may be more than one RHS `inner` expression if one of them
|
||||||
|
// is a comment
|
||||||
|
// Iterate through each of the ei1 entries and see if any of them
|
||||||
|
// work for the purposes of enum constant value parsing
|
||||||
|
foundValidInner := false
|
||||||
|
for _, ei1_0 := range ei1 {
|
||||||
|
|
||||||
// There may be more than one RHS `inner` expression if one of them
|
ei1_0 := ei1_0.(map[string]interface{})
|
||||||
// is a comment
|
ei1Kind, ok := ei1_0["kind"].(string)
|
||||||
// Iterate through each of the ei1 entries and see if any of them
|
if !ok {
|
||||||
// work for the purposes of enum constant value parsing
|
panic("inner with no kind (1)")
|
||||||
for _, ei1_0 := range ei1 {
|
}
|
||||||
|
|
||||||
ei1_0 := ei1_0.(map[string]interface{})
|
if ei1Kind == "FullComment" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
foundValidInner = true
|
||||||
|
|
||||||
// Best case: .inner -> kind=ConstantExpr value=xx
|
// Best case: .inner -> kind=ConstantExpr value=xx
|
||||||
// e.g. qabstractitemmodel
|
// e.g. qabstractitemmodel
|
||||||
if ei1Kind, ok := ei1_0["kind"].(string); ok && ei1Kind == "ConstantExpr" {
|
if ei1Kind == "ConstantExpr" {
|
||||||
log.Printf("Got ConstantExpr OK")
|
log.Printf("Got ConstantExpr OK")
|
||||||
if ei1Value, ok := ei1_0["value"].(string); ok {
|
if ei1Value, ok := ei1_0["value"].(string); ok {
|
||||||
cee.EntryValue = ei1Value
|
cee.EntryValue = ei1Value
|
||||||
goto afterParse
|
goto afterParse
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Best case: .inner -> kind=ImplicitCastExpr .inner -> kind=ConstantExpr value=xx
|
// Best case: .inner -> kind=ImplicitCastExpr .inner -> kind=ConstantExpr value=xx
|
||||||
// e.g. QCalendar (when there is a int typecast)
|
// e.g. QCalendar (when there is a int typecast)
|
||||||
if ei1Kind, ok := ei1_0["kind"].(string); ok && ei1Kind == "ImplicitCastExpr" {
|
if ei1Kind == "ImplicitCastExpr" {
|
||||||
log.Printf("Got ImplicitCastExpr OK")
|
log.Printf("Got ImplicitCastExpr OK")
|
||||||
if ei2, ok := ei1_0["inner"].([]interface{}); ok && len(ei2) > 0 {
|
if ei2, ok := ei1_0["inner"].([]interface{}); ok && len(ei2) > 0 {
|
||||||
ei2_0 := ei2[0].(map[string]interface{})
|
ei2_0 := ei2[0].(map[string]interface{})
|
||||||
if ei2Kind, ok := ei2_0["kind"].(string); ok && ei2Kind == "ConstantExpr" {
|
if ei2Kind, ok := ei2_0["kind"].(string); ok && ei2Kind == "ConstantExpr" {
|
||||||
log.Printf("Got ConstantExpr OK")
|
log.Printf("Got ConstantExpr OK")
|
||||||
if ei2Value, ok := ei2_0["value"].(string); ok {
|
if ei2Value, ok := ei2_0["value"].(string); ok {
|
||||||
cee.EntryValue = ei2Value
|
cee.EntryValue = ei2Value
|
||||||
goto afterParse
|
goto afterParse
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 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 !foundValidInner {
|
||||||
|
// Enum case without definition e.g. QCalendar::Gregorian
|
||||||
|
// This means one more than the last value
|
||||||
|
cee.EntryValue = fmt.Sprintf("%d", lastImplicitValue+1)
|
||||||
|
}
|
||||||
|
|
||||||
afterParse:
|
afterParse:
|
||||||
if cee.EntryValue == "" {
|
if cee.EntryValue == "" {
|
||||||
return ret, fmt.Errorf("Complex enum %q entry %q", ret.EnumName, entryname)
|
return ret, fmt.Errorf("Complex enum %q entry %q", ret.EnumName, entryname)
|
||||||
|
Loading…
Reference in New Issue
Block a user