@@ -6,6 +6,7 @@ import scala.scalanative.native._
66@ native.link(" bindgentests" )
77@ native.extern
88object Union {
9+ type struct_s = native.CStruct1 [native.CInt ]
910 type union_values = native.CArray [Byte , native.Nat ._8]
1011 type enum_union_op = native.CUnsignedInt
1112 def union_get_sizeof (): native.CInt = native.extern
@@ -14,6 +15,7 @@ object Union {
1415 def union_test_long_long (v : native.Ptr [union_values], op : enum_union_op, value : native.CLongLong ): native.CInt = native.extern
1516 def union_test_double (v : native.Ptr [union_values], op : enum_union_op, value : native.CDouble ): native.CInt = native.extern
1617 def union_test_string (v : native.Ptr [union_values], op : enum_union_op, value : native.CString ): native.CInt = native.extern
18+ def union_test_struct (v : native.Ptr [union_values], op : enum_union_op, value : native.Ptr [struct_s]): native.CInt = native.extern
1719}
1820
1921import Union ._
@@ -25,6 +27,13 @@ object UnionEnums {
2527
2628object UnionHelpers {
2729
30+ implicit class struct_s_ops (val p : native.Ptr [struct_s]) extends AnyVal {
31+ def a : native.CInt = ! p._1
32+ def a_= (value : native.CInt ): Unit = ! p._1 = value
33+ }
34+
35+ def struct_s ()(implicit z : native.Zone ): native.Ptr [struct_s] = native.alloc[struct_s]
36+
2837 implicit class union_values_pos (val p : native.Ptr [union_values]) extends AnyVal {
2938 def l : native.Ptr [native.CLong ] = p.cast[native.Ptr [native.CLong ]]
3039 def l_= (value : native.CLong ): Unit = ! p.cast[native.Ptr [native.CLong ]] = value
@@ -36,5 +45,7 @@ object UnionHelpers {
3645 def d_= (value : native.CDouble ): Unit = ! p.cast[native.Ptr [native.CDouble ]] = value
3746 def s : native.Ptr [native.CString ] = p.cast[native.Ptr [native.CString ]]
3847 def s_= (value : native.CString ): Unit = ! p.cast[native.Ptr [native.CString ]] = value
48+ def structInUnion : native.Ptr [struct_s] = p.cast[native.Ptr [struct_s]]
49+ def structInUnion_= (value : native.Ptr [struct_s]): Unit = ! p.cast[native.Ptr [struct_s]] = ! value
3950 }
4051}
0 commit comments