Skip to content

Commit

Permalink
Merge pull request #29 from mappu/miqt-next
Browse files Browse the repository at this point in the history
Refactor, CABI improvement, and QSet<> support
  • Loading branch information
mappu authored Sep 18, 2024
2 parents 88d7251 + 3f1c8cb commit 8145c1e
Show file tree
Hide file tree
Showing 884 changed files with 17,926 additions and 25,395 deletions.
22 changes: 17 additions & 5 deletions cmd/genbindings/clang2il.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,12 @@ func parseHeader(topLevel []interface{}, addNamePrefix string) (*CppParsedHeader
if err != nil {
panic(fmt.Errorf("processEnum: %w", err)) // A real problem
}
if len(en.Entries) > 0 { // e.g. qmetatype's version of QCborSimpleType (the real one is in qcborcommon)
ret.Enums = append(ret.Enums, en)
}

// n.b. In some cases we may produce multiple "copies" of an enum
// (e.g. qcborcommon and qmetatype both define QCborSimpleType)
// Allow, but use a transform pass to avoid multiple definitions of
// it
ret.Enums = append(ret.Enums, en)

case "VarDecl":
// TODO e.g. qmath.h
Expand Down Expand Up @@ -480,8 +483,16 @@ var (

func processEnum(node map[string]interface{}, addNamePrefix string) (CppEnum, error) {
var ret CppEnum
ret.UnderlyingType = "int" // FIXME

// Underlying type
ret.UnderlyingType = parseSingleTypeString("int")
if nodefut, ok := node["fixedUnderlyingType"].(map[string]interface{}); ok {
if nodequal, ok := nodefut["qualType"].(string); ok {
ret.UnderlyingType = parseSingleTypeString(nodequal)
}
}

// Name
nodename, ok := node["name"].(string)
if !ok {
// An unnamed enum is possible (e.g. qcalendar.h)
Expand All @@ -492,6 +503,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
Expand Down Expand Up @@ -565,7 +577,7 @@ func processEnum(node map[string]interface{}, addNamePrefix string) (CppEnum, er

var err error
if cee.EntryValue == "true" || cee.EntryValue == "false" {
ret.UnderlyingType = "bool"
ret.UnderlyingType = parseSingleTypeString("bool")

} else {
lastImplicitValue, err = strconv.ParseInt(cee.EntryValue, 10, 64)
Expand Down
Loading

0 comments on commit 8145c1e

Please sign in to comment.