diff options
author | Ayke van Laethem <[email protected]> | 2019-05-16 22:16:58 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2019-05-17 19:37:20 +0200 |
commit | dfa713040a7b3be012dc229996440005734aa9b4 (patch) | |
tree | b9e6085df2788c1c10e792739ea6d79b7adf2aa8 /testdata/cgo/main.go | |
parent | 82dc14b74174bc5114271773d6eb7d3858ad862d (diff) | |
download | tinygo-dfa713040a7b3be012dc229996440005734aa9b4.tar.gz tinygo-dfa713040a7b3be012dc229996440005734aa9b4.zip |
cgo: add support for enum types
Enum types are implemented as named types (with possible accompanying
typedefs as type aliases). The constants inside the enums are treated as
Go constants like in the Go toolchain.
Diffstat (limited to 'testdata/cgo/main.go')
-rw-r--r-- | testdata/cgo/main.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/testdata/cgo/main.go b/testdata/cgo/main.go index e1e757004..7837a7790 100644 --- a/testdata/cgo/main.go +++ b/testdata/cgo/main.go @@ -75,6 +75,24 @@ func main() { println("n in chain:", list.n) list = (*C.list_t)(list.next) } + + // named enum + var _ C.enum_option = C.optionA + var _ C.option_t = C.optionA + println("option:", C.globalOption) + println("option A:", C.optionA) + println("option B:", C.optionB) + println("option C:", C.optionC) + println("option D:", C.optionD) + println("option E:", C.optionE) + println("option F:", C.optionF) + println("option G:", C.optionG) + + // anonymous enum + var _ C.option2_t = C.option2A + var _ C.option3_t = C.option3A + println("option 2A:", C.option2A) + println("option 3A:", C.option3A) } func printUnion(union C.joined_t) C.joined_t { |