aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata/cgo/main.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2019-05-29 23:26:57 +0200
committerRon Evans <[email protected]>2019-06-03 16:13:19 +0200
commit1d7cc2c2427c473b5ad07ab4e1ce144114e73988 (patch)
tree91227c51fe4aaa33b565e49106145b1605795e7f /testdata/cgo/main.go
parent23c8d158470e8df944a93b45fb204b06ee5685b8 (diff)
downloadtinygo-1d7cc2c2427c473b5ad07ab4e1ce144114e73988.tar.gz
tinygo-1d7cc2c2427c473b5ad07ab4e1ce144114e73988.zip
cgo: add support for bitfields using generated getters and setters
Diffstat (limited to 'testdata/cgo/main.go')
-rw-r--r--testdata/cgo/main.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/testdata/cgo/main.go b/testdata/cgo/main.go
index 7837a7790..1668b51a9 100644
--- a/testdata/cgo/main.go
+++ b/testdata/cgo/main.go
@@ -64,6 +64,11 @@ func main() {
println("union global data:", C.globalUnion.data[0], C.globalUnion.data[1], C.globalUnion.data[2])
println("union field:", printUnion(C.globalUnion).f)
var _ C.union_joined = C.globalUnion
+ printBitfield(&C.globalBitfield)
+ C.globalBitfield.set_bitfield_a(7)
+ C.globalBitfield.set_bitfield_b(0)
+ C.globalBitfield.set_bitfield_c(0xff)
+ printBitfield(&C.globalBitfield)
// elaborated type
p := C.struct_point{x: 3, y: 5}
@@ -108,3 +113,11 @@ func printUnion(union C.joined_t) C.joined_t {
func mul(a, b C.int) C.int {
return a * b
}
+
+func printBitfield(bitfield *C.bitfield_t) {
+ println("bitfield a:", bitfield.bitfield_a())
+ println("bitfield b:", bitfield.bitfield_b())
+ println("bitfield c:", bitfield.bitfield_c())
+ println("bitfield d:", bitfield.d)
+ println("bitfield e:", bitfield.e)
+}