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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<!--
Sample API v0.1.5 that generates code with all supported features.
-->
<!-- <config />: Include an optional config file with type and name redefinitions.
You can include as many configs as you want.
* Required attributes:
- file - Path to config file.
* Optional attributes: none
* Valid children: none
-->
<!-- Include config file for Rust -->
<!-- <var />: Generate a single variable. If nested by <func> tags, the variable
becomes the function's input parameter.
* Required attributes:
- type - Type of the variable. Tag will be ignored in generated code if
'type' is overriden to "" in language config (see ellipsis example).
- name - Variable name. Requried for standalone variables, optional for function parameters.
* Optional attributes:
- value - Initialization value for the variable or a default value for function parameter.
- qualifier - Variable's qualifier (extern, static, etc.)
* Valid children:
- <fptr /> - If <var /> is a function parameter, it can nest a <fptr /> which will
then be interpreted as the actual parameter. In this case, <var /> requires
no atributes.
-->
<!-- variable: extern void* void_ptr; -->
<!-- variable: int some_number = 1; -->
<!-- ignored variable - no type specified -->
<!-- <enum></enum>: Generate an enumerator.
* Required attributes:
- name - Enum name.
* Optional attributes:
- attribute - Adds an attribute/decorator to the enum. Ignored by C++.
* Valid children:
- <attribute /> - Adds an attribute/decorator to the enum. Use it if you want to
define multiple attributes.
- <var /> - Enumerator field. All fields except 'name' are optional.
If 'type' is specified, it will be ignored by C++ and interpreted
by Rust as a typecast.
-->
<!-- enum: (attribute and var types will be used only by Rust)
enum GenericEnum {
EnumVal1,
EnumVal2,
Count = 2,
};
-->
<!-- <bitflags></bitflags>: Generate a bitflag enumerator. This is a type
native to Rust language, when C++ is generated, it will create a standard enum.
* Required attributes:
- name - Bitflags name.
- type - Underlying data type.
* Optional attributes:
- attribute - Adds an attribute/decorator to bitflags.
* Valid children:
- <attribute /> - Adds an attribute/decorator to bitflags. Use it if you want to
define multiple attributes.
- <var /> - Bitflag numerator field. All fields except 'name' and 'value' are optional.
If 'type' is specified, it will be ignored by C++ and interpreted
by Rust as a typecast.
-->
<!-- bitflags:
//generated C++ code
enum SampleBitflags {
Field1 = 1,
Field2 = 2,
};
//generated Rust code
bitflags! {
#[repr(C)]
#[derive(Debug)]
flags SampleBitflags: c_int {
const FIELD1 = 1 as c_int,
const FIELD2 = 2 as c_int,
}
}
-->
<!-- alternative bitflags example -->
<!-- <func></func>: Generate a function.
* Required attributes:
- type - Function's return type.
- name - Name of the function.
* Optional attributes:
- qualifier - Function's qualifier (extern, static, etc.).
* Valid children:
- <var /> - Function patameter. Name is optional in this case. Function will take no
parameters if no <var />'s are defined.
- <fptr /> - Function parameter expressed as a function pointer.
-->
<!-- function: int get_ascii(char& letter, bool (*callback)(int code)); -->
<!-- function: int get_ascii_alt(char& letter, bool (*callback)(int code)); -->
<!-- Alternative way of defining a <fptr /> as a function parameter -->
<!-- function: static void process_func(); -->
<!-- function: void func_ellipsis(const char* str, ...); -->
<!-- no type specified - variable will be ignored -->
<!-- <fptr></fptr>: Generate a function pointer.
* Required attributes:
- type - Function pointer's return type.
- name - Name of the function pointer.
* Optional attributes:
- qualifier - Function pointer's qualifier (extern, static, etc.).
* Valid children:
- <var /> - Function patameter. Name is optional in this case. Fptr will take no
parameters if no <var />'s are defined.
- <fptr /> - Function parameter expressed as a function pointer.
-->
<!-- function pointer: int (*func_ptr)(); -->
<!-- function pointer: void (*f_ptr)(const int* fmt, void (*fptr_arg)(char&)); -->
<!-- <struct></struct>: Generate a structure.
* Required attributes:
name - Struct name.
* Optional attributes:
attribute - Adds an attribute/decorator to the struct. Ignored by C++.
* Valid children:
- <attribute /> (see enum for description)
- <var />
- <func />
- <fptr />
- <enum />
- <struct />
-->
<!-- Generate a structure with nested elements -->
<!-- unsupported items will be ignored -->