aboutsummaryrefslogtreecommitdiffhomepage
path: root/cgo/libclang.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2019-11-07 20:25:51 +0100
committerRon Evans <[email protected]>2019-11-08 08:38:50 +0100
commitb153bd63f2f32a1593c01d5c7ce9d0e595197c46 (patch)
tree681756022b850e8a839b3dd4450744ff65c98375 /cgo/libclang.go
parent6108ee6859ff6fa2154ee588709e1e0b68f6b2b5 (diff)
downloadtinygo-b153bd63f2f32a1593c01d5c7ce9d0e595197c46.tar.gz
tinygo-b153bd63f2f32a1593c01d5c7ce9d0e595197c46.zip
cgo: add support for nested structs and unions
Diffstat (limited to 'cgo/libclang.go')
-rw-r--r--cgo/libclang.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/cgo/libclang.go b/cgo/libclang.go
index d495384e7..46eff01c0 100644
--- a/cgo/libclang.go
+++ b/cgo/libclang.go
@@ -667,7 +667,13 @@ func tinygo_clang_struct_visitor(c, parent C.GoCXCursor, client_data C.CXClientD
bitfieldNum := passed.bitfieldNum
bitfieldList := passed.bitfieldList
pos := p.getCursorPosition(c)
- if cursorKind := C.tinygo_clang_getCursorKind(c); cursorKind != C.CXCursor_FieldDecl {
+ switch cursorKind := C.tinygo_clang_getCursorKind(c); cursorKind {
+ case C.CXCursor_FieldDecl:
+ // Expected. This is a regular field.
+ case C.CXCursor_StructDecl, C.CXCursor_UnionDecl:
+ // Ignore. The next field will be the struct/union itself.
+ return C.CXChildVisit_Continue
+ default:
cursorKindSpelling := getString(C.clang_getCursorKindSpelling(cursorKind))
p.addError(pos, fmt.Sprintf("expected FieldDecl in struct or union, not %s", cursorKindSpelling))
return C.CXChildVisit_Continue