forked from mozilla/cbindgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdestructor-and-copy-ctor.rs
67 lines (59 loc) · 1.21 KB
/
destructor-and-copy-ctor.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use std::ptr::NonNull;
/// This will have a destructor manually implemented via variant_body, and
/// similarly a Drop impl in Rust.
#[repr(C)]
pub struct OwnedSlice<T> {
len: usize,
ptr: NonNull<T>,
}
#[repr(u8)]
pub enum FillRule { A, B }
#[repr(C)]
pub struct Polygon<LengthPercentage> {
pub fill: FillRule,
pub coordinates: OwnedSlice<LengthPercentage>,
}
#[repr(C, u8)]
pub enum Foo<T> {
Bar,
Polygon1(Polygon<T>),
Slice1(OwnedSlice<T>),
Slice2(OwnedSlice<i32>),
Slice3 {
fill: FillRule,
coords: OwnedSlice<T>,
},
Slice4 {
fill: FillRule,
coords: OwnedSlice<i32>,
},
}
#[repr(u8)]
pub enum Baz<T> {
Bar2,
Polygon21(Polygon<T>),
Slice21(OwnedSlice<T>),
Slice22(OwnedSlice<i32>),
Slice23 {
fill: FillRule,
coords: OwnedSlice<T>,
},
Slice24 {
fill: FillRule,
coords: OwnedSlice<i32>,
},
}
#[repr(u8)]
pub enum Taz {
Bar3,
Taz1(i32),
}
/// cbindgen:derive-tagged-enum-destructor=false
/// cbindgen:derive-tagged-enum-copy-constructor=false
#[repr(u8)]
pub enum Tazz {
Bar4,
Taz2(i32),
}
#[no_mangle]
pub extern "C" fn root(a: &Foo<u32>, b: &Baz<i32>, c: &Taz, d: Tazz) {}