| 1 | module main |
| 2 | |
| 3 | #include "@VMODROOT/array.c" |
| 4 | |
| 5 | enum Flag_bits { |
| 6 | aaa = 0 |
| 7 | bbb = 1 |
| 8 | ccc = 2 |
| 9 | } |
| 10 | |
| 11 | pub type Array_t = C.array_t |
| 12 | |
| 13 | @[typedef] |
| 14 | struct C.array_t { |
| 15 | pub mut: |
| 16 | array_ptr &&char |
| 17 | array_len int |
| 18 | string_len int |
| 19 | } |
| 20 | |
| 21 | pub type Struct_array = C.struct_array |
| 22 | |
| 23 | @[typedef] |
| 24 | struct C.struct_array { |
| 25 | pub mut: |
| 26 | arr [4]Array_t |
| 27 | enu [2]Flag_bits |
| 28 | } |
| 29 | |
| 30 | fn C.get_string_array() &&char |
| 31 | @[inline] |
| 32 | pub fn get_string_array() &&char { |
| 33 | return C.get_string_array() |
| 34 | } |
| 35 | |
| 36 | fn C.get_struct_array() Struct_array |
| 37 | @[inline] |
| 38 | pub fn get_struct_array() Struct_array { |
| 39 | return C.get_struct_array() |
| 40 | } |
| 41 | |
| 42 | fn C.array_string_free(&Array_t) |
| 43 | |
| 44 | @[keep_args_alive] |
| 45 | fn C.set_struct_array(&Struct_array) |
| 46 | @[inline] |
| 47 | pub fn set_struct_array(param &Struct_array) { |
| 48 | C.set_struct_array(param) |
| 49 | } |
| 50 | |
| 51 | fn test_main() { |
| 52 | struct_array := get_struct_array() |
| 53 | |
| 54 | set_struct_array(&Struct_array{}) |
| 55 | set_struct_array(&struct_array) |
| 56 | |
| 57 | C.array_string_free(&struct_array.arr[0]) |
| 58 | } |
| 59 | |