1 use std::ptr::NonNull;
2 
3 /// This will have a destructor manually implemented via variant_body, and
4 /// similarly a Drop impl in Rust.
5 #[repr(C)]
6 pub struct OwnedSlice<T> {
7     len: usize,
8     ptr: NonNull<T>,
9 }
10 
11 #[repr(u8)]
12 pub enum FillRule { A, B }
13 
14 #[repr(C)]
15 pub struct Polygon<LengthPercentage> {
16     pub fill: FillRule,
17     pub coordinates: OwnedSlice<LengthPercentage>,
18 }
19 
20 #[repr(C, u8)]
21 pub enum Foo<T> {
22     Bar,
23     Polygon1(Polygon<T>),
24     Slice1(OwnedSlice<T>),
25     Slice2(OwnedSlice<i32>),
26     Slice3 {
27         fill: FillRule,
28         coords: OwnedSlice<T>,
29     },
30     Slice4 {
31         fill: FillRule,
32         coords: OwnedSlice<i32>,
33     },
34 }
35 
36 #[repr(u8)]
37 pub enum Baz<T> {
38     Bar2,
39     Polygon21(Polygon<T>),
40     Slice21(OwnedSlice<T>),
41     Slice22(OwnedSlice<i32>),
42     Slice23 {
43         fill: FillRule,
44         coords: OwnedSlice<T>,
45     },
46     Slice24 {
47         fill: FillRule,
48         coords: OwnedSlice<i32>,
49     },
50 }
51 
52 #[repr(u8)]
53 pub enum Taz {
54     Bar3,
55     Taz1(i32),
56     Taz3(OwnedSlice<i32>),
57 }
58 
59 /// cbindgen:derive-tagged-enum-destructor=false
60 /// cbindgen:derive-tagged-enum-copy-constructor=false
61 #[repr(u8)]
62 pub enum Tazz {
63     Bar4,
64     Taz2(i32),
65 }
66 
67 /// cbindgen:derive-tagged-enum-copy-assignment=false
68 #[repr(u8)]
69 pub enum Tazzz {
70     Bar5,
71     Taz5(i32),
72 }
73 
74 #[repr(u8)]
75 pub enum Tazzzz {
76     Taz6(i32),
77     Taz7(u32),
78 }
79 
80 /// cbindgen:derive-eq=true
81 /// cbindgen:derive-neq=true
82 /// cbindgen:neq-attributes=NODISCARD
83 /// cbindgen:eq-attributes=NODISCARD
84 /// cbindgen:destructor-attributes=NOINLINE
85 /// cbindgen:copy-constructor-attributes=NOINLINE
86 /// cbindgen:copy-assignment-attributes=NOINLINE
87 #[repr(u8)]
88 pub enum Qux {
89     /// cbindgen:derive-eq=true
90     Qux1(i32),
91     /// cbindgen:derive-eq=true
92     Qux2(u32),
93 }
94 
95 
96 #[no_mangle]
root(a: &Foo<u32>, b: &Baz<i32>, c: &Taz, d: Tazz, e: &Tazzz, f: &Tazzzz, g: &Qux)97 pub extern "C" fn root(a: &Foo<u32>, b: &Baz<i32>, c: &Taz, d: Tazz, e: &Tazzz, f: &Tazzzz, g: &Qux) {}
98