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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/// Emulates C++ parenting, with a constraint that a child may only has ONE parent.
/// # Behavior
/// * Each struct declared within `makestruct` macro will have C-like layout.
/// * For each struct declared within `makestruct` macro with specified parent there will be generated:
/// * Additional first field of parent type and name of `parent`
/// * Deref<Target = Parent> implementation
/// ```
/// memflex::makestruct! {
/// // Attributes works as expected
/// #[derive(Default)]
/// struct Parent {
/// // on fields as well
/// // #[serde(skip)]
/// first: f32
/// }
///
/// // `pub` means that `parent` field will be `pub`
/// // but Deref<Target = Parent> implementation will be generated regardless.
/// struct Child : pub Parent {
/// second: i32
/// }
///
/// // Implements `Foo` interface on `Nested`
/// struct Nested impl Foo : Child {
/// third: bool
/// }
///
/// struct ParentWithVmt impl ParentVmt {
/// vmt: usize,
/// t1: f32,
/// t2: bool
/// }
///
/// // By using `dyn ParentWithVmt`, child offsets all of their vfunc indices by the number of functions in `ParentWithVmt`,
/// // should work with nested inheritance but hasn't been tested!
/// struct ChildInheritsParentVmt impl ChildVmt(dyn ParentWithVmt) : pub ParentWithVmt {
/// t3: u64,
/// t4: i8
/// }
/// }
///
/// memflex::interface! {
/// trait Foo {
/// extern fn foo() = #0;
/// }
///
/// trait ParentVmt {
/// fn f1() -> i32 = #0;
/// fn f2() -> i32 = #1;
/// }
///
/// trait ChildVmt {
/// fn f3(a: i32) = #0;
/// fn f4(a: i32) = #1;
/// }
/// }
/// ```
)*
} =>
$?
$?
)*
};
}