mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 11:07:46 +00:00
cgo: include all enums in the CGo Go AST
Not all enums may be used as a type anywhere, which was previously the only way to include an enum in the AST. This commit makes sure all enums are included.
This commit is contained in:
committed by
Ron Evans
parent
d31deda1b5
commit
76c9f13e13
@@ -255,6 +255,11 @@ func tinygo_clang_globals_visitor(c, parent C.GoCXCursor, client_data C.CXClient
|
||||
// Parsing was successful.
|
||||
p.constants[name] = constantInfo{expr, pos}
|
||||
}
|
||||
case C.CXCursor_EnumDecl:
|
||||
// Visit all enums, because the fields may be used even when the enum
|
||||
// type itself is not.
|
||||
typ := C.tinygo_clang_getCursorType(c)
|
||||
p.makeASTType(typ, pos)
|
||||
}
|
||||
return C.CXChildVisit_Continue
|
||||
}
|
||||
|
||||
Vendored
+3
@@ -38,6 +38,9 @@ typedef enum option {
|
||||
optionF,
|
||||
optionG,
|
||||
} option_t;
|
||||
enum unused {
|
||||
unused1 = 5,
|
||||
};
|
||||
|
||||
// Anonymous enum.
|
||||
typedef enum {
|
||||
|
||||
Vendored
+2
@@ -12,6 +12,7 @@ const C.optionD = -4
|
||||
const C.optionE = 10
|
||||
const C.optionF = 11
|
||||
const C.optionG = 12
|
||||
const C.unused1 = 5
|
||||
|
||||
type C.int16_t = int16
|
||||
type C.int32_t = int32
|
||||
@@ -81,3 +82,4 @@ type C.struct_type1 struct {
|
||||
}
|
||||
type C.struct_type2 struct{ _type C.int }
|
||||
type C.enum_option C.int
|
||||
type C.enum_unused C.uint
|
||||
|
||||
Reference in New Issue
Block a user