mirror of
https://github.com/mappu/miqt.git
synced 2025-01-21 22:20:38 +00:00
genbindings/enums: handle enum values with comments
This commit is contained in:
parent
11d0eaf5f4
commit
8585fc05f4
@ -539,35 +539,44 @@ func processEnum(node map[string]interface{}, addNamePrefix string) (CppEnum, er
|
|||||||
// This means one more than the last value
|
// This means one more than the last value
|
||||||
cee.EntryValue = fmt.Sprintf("%d", lastImplicitValue+1)
|
cee.EntryValue = fmt.Sprintf("%d", lastImplicitValue+1)
|
||||||
|
|
||||||
} else if len(ei1) == 1 {
|
} else if len(ei1) >= 1 {
|
||||||
|
|
||||||
ei1_0 := ei1[0].(map[string]interface{})
|
// 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
|
||||||
|
for _, ei1_0 := range ei1 {
|
||||||
|
|
||||||
// Best case: .inner -> kind=ConstantExpr value=xx
|
ei1_0 := ei1_0.(map[string]interface{})
|
||||||
// e.g. qabstractitemmodel
|
|
||||||
if ei1Kind, ok := ei1_0["kind"].(string); ok && ei1Kind == "ConstantExpr" {
|
// Best case: .inner -> kind=ConstantExpr value=xx
|
||||||
log.Printf("Got ConstantExpr OK")
|
// e.g. qabstractitemmodel
|
||||||
if ei1Value, ok := ei1_0["value"].(string); ok {
|
if ei1Kind, ok := ei1_0["kind"].(string); ok && ei1Kind == "ConstantExpr" {
|
||||||
cee.EntryValue = ei1Value
|
log.Printf("Got ConstantExpr OK")
|
||||||
goto afterParse
|
if ei1Value, ok := ei1_0["value"].(string); ok {
|
||||||
|
cee.EntryValue = ei1Value
|
||||||
|
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, ok := ei1_0["kind"].(string); ok && 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 we made it here, we did not hit any of the `goto afterParse` cases
|
||||||
|
|
||||||
}
|
}
|
||||||
afterParse:
|
afterParse:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user