wasm_webidl_bindings_text_parser/
actions.rs

1pub trait Actions {
2    type WebidlBindingsSection;
3    fn webidl_bindings_section(
4        &mut self,
5        types: Self::WebidlTypeSubsection,
6        bindings: Self::WebidlFunctionBindingsSubsection,
7    ) -> Self::WebidlBindingsSection;
8
9    type WebidlTypeSubsection;
10    fn webidl_type_subsection(
11        &mut self,
12        types: Vec<Self::WebidlType>,
13    ) -> Self::WebidlTypeSubsection;
14
15    type WebidlType;
16    fn webidl_type(&mut self, name: Option<&str>, ty: Self::WebidlCompoundType)
17        -> Self::WebidlType;
18
19    type WebidlCompoundType: From<Self::WebidlFunction>
20        + From<Self::WebidlDictionary>
21        + From<Self::WebidlEnumeration>
22        + From<Self::WebidlUnion>;
23
24    type WebidlFunction;
25    fn webidl_function(
26        &mut self,
27        kind: Option<Self::WebidlFunctionKind>,
28        params: Option<Self::WebidlFunctionParams>,
29        result: Option<Self::WebidlFunctionResult>,
30    ) -> Self::WebidlFunction;
31
32    type WebidlFunctionKind: From<Self::WebidlFunctionKindMethod>
33        + From<Self::WebidlFunctionKindConstructor>;
34
35    type WebidlFunctionKindMethod;
36    fn webidl_function_kind_method(
37        &mut self,
38        ty: Self::WebidlTypeRef,
39    ) -> Self::WebidlFunctionKindMethod;
40
41    type WebidlFunctionKindConstructor;
42    fn webidl_function_kind_constructor_default_new_target(
43        &mut self,
44    ) -> Self::WebidlFunctionKindConstructor;
45
46    type WebidlFunctionParams;
47    fn webidl_function_params(
48        &mut self,
49        tys: Vec<Self::WebidlTypeRef>,
50    ) -> Self::WebidlFunctionParams;
51
52    type WebidlFunctionResult;
53    fn webidl_function_result(&mut self, ty: Self::WebidlTypeRef) -> Self::WebidlFunctionResult;
54
55    type WebidlDictionary;
56    fn webidl_dictionary(
57        &mut self,
58        fields: Vec<Self::WebidlDictionaryField>,
59    ) -> Self::WebidlDictionary;
60
61    type WebidlDictionaryField;
62    fn webidl_dictionary_field(
63        &mut self,
64        name: Self::WebidlDictionaryFieldName,
65        ty: Self::WebidlTypeRef,
66    ) -> Self::WebidlDictionaryField;
67
68    type WebidlDictionaryFieldName;
69    fn webidl_dictionary_field_name(&mut self, name: &str) -> Self::WebidlDictionaryFieldName;
70
71    type WebidlEnumeration;
72    fn webidl_enumeration(
73        &mut self,
74        values: Vec<Self::WebidlEnumerationValue>,
75    ) -> Self::WebidlEnumeration;
76
77    type WebidlEnumerationValue;
78    fn webidl_enumeration_value(&mut self, value: &str) -> Self::WebidlEnumerationValue;
79
80    type WebidlUnion;
81    fn webidl_union(&mut self, members: Vec<Self::WebidlTypeRef>) -> Self::WebidlUnion;
82
83    type WebidlFunctionBindingsSubsection;
84    fn webidl_function_bindings_subsection(
85        &mut self,
86        bindings: Vec<Self::FunctionBinding>,
87        binds: Vec<Self::Bind>,
88    ) -> Self::WebidlFunctionBindingsSubsection;
89
90    type FunctionBinding: From<Self::ImportBinding> + From<Self::ExportBinding>;
91
92    type ImportBinding;
93    fn import_binding(
94        &mut self,
95        name: Option<&str>,
96        wasm_ty: Self::WasmFuncTypeRef,
97        webidl_ty: Self::WebidlTypeRef,
98        params: Option<Self::OutgoingBindingMap>,
99        result: Option<Self::IncomingBindingMap>,
100    ) -> Self::ImportBinding;
101
102    type ExportBinding;
103    fn export_binding(
104        &mut self,
105        name: Option<&str>,
106        wasm_ty: Self::WasmFuncTypeRef,
107        webidl_ty: Self::WebidlTypeRef,
108        params: Option<Self::IncomingBindingMap>,
109        result: Option<Self::OutgoingBindingMap>,
110    ) -> Self::ExportBinding;
111
112    type Bind;
113    fn bind(&mut self, func: Self::WasmFuncRef, binding: Self::BindingRef) -> Self::Bind;
114
115    type OutgoingBindingMap;
116    fn outgoing_binding_map(
117        &mut self,
118        bindings: Vec<Self::OutgoingBindingExpression>,
119    ) -> Self::OutgoingBindingMap;
120
121    type IncomingBindingMap;
122    fn incoming_binding_map(
123        &mut self,
124        bindings: Vec<Self::IncomingBindingExpression>,
125    ) -> Self::IncomingBindingMap;
126
127    type OutgoingBindingExpression: From<Self::OutgoingBindingExpressionAs>
128        + From<Self::OutgoingBindingExpressionUtf8Str>
129        + From<Self::OutgoingBindingExpressionUtf8CStr>
130        + From<Self::OutgoingBindingExpressionI32ToEnum>
131        + From<Self::OutgoingBindingExpressionView>
132        + From<Self::OutgoingBindingExpressionCopy>
133        + From<Self::OutgoingBindingExpressionDict>
134        + From<Self::OutgoingBindingExpressionBindExport>;
135
136    type OutgoingBindingExpressionAs;
137    fn outgoing_binding_expression_as(
138        &mut self,
139        ty: Self::WebidlTypeRef,
140        idx: u32,
141    ) -> Self::OutgoingBindingExpressionAs;
142
143    type OutgoingBindingExpressionUtf8Str;
144    fn outgoing_binding_expression_utf8_str(
145        &mut self,
146        ty: Self::WebidlTypeRef,
147        offset: u32,
148        length: u32,
149    ) -> Self::OutgoingBindingExpressionUtf8Str;
150
151    type OutgoingBindingExpressionUtf8CStr;
152    fn outgoing_binding_expression_utf8_c_str(
153        &mut self,
154        ty: Self::WebidlTypeRef,
155        offset: u32,
156    ) -> Self::OutgoingBindingExpressionUtf8CStr;
157
158    type OutgoingBindingExpressionI32ToEnum;
159    fn outgoing_binding_expression_i32_to_enum(
160        &mut self,
161        ty: Self::WebidlTypeRef,
162        idx: u32,
163    ) -> Self::OutgoingBindingExpressionI32ToEnum;
164
165    type OutgoingBindingExpressionView;
166    fn outgoing_binding_expression_view(
167        &mut self,
168        ty: Self::WebidlTypeRef,
169        offset: u32,
170        length: u32,
171    ) -> Self::OutgoingBindingExpressionView;
172
173    type OutgoingBindingExpressionCopy;
174    fn outgoing_binding_expression_copy(
175        &mut self,
176        ty: Self::WebidlTypeRef,
177        offset: u32,
178        length: u32,
179    ) -> Self::OutgoingBindingExpressionCopy;
180
181    type OutgoingBindingExpressionDict;
182    fn outgoing_binding_expression_dict(
183        &mut self,
184        ty: Self::WebidlTypeRef,
185        fields: Vec<Self::OutgoingBindingExpression>,
186    ) -> Self::OutgoingBindingExpressionDict;
187
188    type OutgoingBindingExpressionBindExport;
189    fn outgoing_binding_expression_bind_export(
190        &mut self,
191        ty: Self::WebidlTypeRef,
192        binding: Self::BindingRef,
193        idx: u32,
194    ) -> Self::OutgoingBindingExpressionBindExport;
195
196    type IncomingBindingExpression: From<Self::IncomingBindingExpressionGet>
197        + From<Self::IncomingBindingExpressionAs>
198        + From<Self::IncomingBindingExpressionAllocUtf8Str>
199        + From<Self::IncomingBindingExpressionAllocCopy>
200        + From<Self::IncomingBindingExpressionEnumToI32>
201        + From<Self::IncomingBindingExpressionField>
202        + From<Self::IncomingBindingExpressionBindImport>;
203
204    type IncomingBindingExpressionGet;
205    fn incoming_binding_expression_get(&mut self, idx: u32) -> Self::IncomingBindingExpressionGet;
206
207    type IncomingBindingExpressionAs;
208    fn incoming_binding_expression_as(
209        &mut self,
210        ty: Self::WasmValType,
211        expr: Self::IncomingBindingExpression,
212    ) -> Self::IncomingBindingExpressionAs;
213
214    type IncomingBindingExpressionAllocUtf8Str;
215    fn incoming_binding_expression_alloc_utf8_str(
216        &mut self,
217        alloc_func_name: &str,
218        expr: Self::IncomingBindingExpression,
219    ) -> Self::IncomingBindingExpressionAllocUtf8Str;
220
221    type IncomingBindingExpressionAllocCopy;
222    fn incoming_binding_expression_alloc_copy(
223        &mut self,
224        alloc_func_name: &str,
225        expr: Self::IncomingBindingExpression,
226    ) -> Self::IncomingBindingExpressionAllocCopy;
227
228    type IncomingBindingExpressionEnumToI32;
229    fn incoming_binding_expression_enum_to_i32(
230        &mut self,
231        ty: Self::WebidlTypeRef,
232        expr: Self::IncomingBindingExpression,
233    ) -> Self::IncomingBindingExpressionEnumToI32;
234
235    type IncomingBindingExpressionField;
236    fn incoming_binding_expression_field(
237        &mut self,
238        idx: u32,
239        expr: Self::IncomingBindingExpression,
240    ) -> Self::IncomingBindingExpressionField;
241
242    type IncomingBindingExpressionBindImport;
243    fn incoming_binding_expression_bind_import(
244        &mut self,
245        ty: Self::WasmFuncTypeRef,
246        binding: Self::BindingRef,
247        expr: Self::IncomingBindingExpression,
248    ) -> Self::IncomingBindingExpressionBindImport;
249
250    type WebidlTypeRef: From<Self::WebidlTypeRefNamed>
251        + From<Self::WebidlTypeRefIndexed>
252        + From<Self::WebidlScalarType>;
253
254    type WebidlTypeRefNamed;
255    fn webidl_type_ref_named(&mut self, name: &str) -> Option<Self::WebidlTypeRefNamed>;
256
257    type WebidlTypeRefIndexed;
258    fn webidl_type_ref_indexed(&mut self, idx: u32) -> Option<Self::WebidlTypeRefIndexed>;
259
260    type WebidlScalarType;
261    fn webidl_scalar_type_any(&mut self) -> Self::WebidlScalarType;
262    fn webidl_scalar_type_boolean(&mut self) -> Self::WebidlScalarType;
263    fn webidl_scalar_type_byte(&mut self) -> Self::WebidlScalarType;
264    fn webidl_scalar_type_octet(&mut self) -> Self::WebidlScalarType;
265    fn webidl_scalar_type_long(&mut self) -> Self::WebidlScalarType;
266    fn webidl_scalar_type_unsigned_long(&mut self) -> Self::WebidlScalarType;
267    fn webidl_scalar_type_short(&mut self) -> Self::WebidlScalarType;
268    fn webidl_scalar_type_unsigned_short(&mut self) -> Self::WebidlScalarType;
269    fn webidl_scalar_type_long_long(&mut self) -> Self::WebidlScalarType;
270    fn webidl_scalar_type_unsigned_long_long(&mut self) -> Self::WebidlScalarType;
271    fn webidl_scalar_type_float(&mut self) -> Self::WebidlScalarType;
272    fn webidl_scalar_type_unrestricted_float(&mut self) -> Self::WebidlScalarType;
273    fn webidl_scalar_type_double(&mut self) -> Self::WebidlScalarType;
274    fn webidl_scalar_type_unrestricted_double(&mut self) -> Self::WebidlScalarType;
275    fn webidl_scalar_type_dom_string(&mut self) -> Self::WebidlScalarType;
276    fn webidl_scalar_type_byte_string(&mut self) -> Self::WebidlScalarType;
277    fn webidl_scalar_type_usv_string(&mut self) -> Self::WebidlScalarType;
278    fn webidl_scalar_type_object(&mut self) -> Self::WebidlScalarType;
279    fn webidl_scalar_type_symbol(&mut self) -> Self::WebidlScalarType;
280    fn webidl_scalar_type_array_buffer(&mut self) -> Self::WebidlScalarType;
281    fn webidl_scalar_type_data_view(&mut self) -> Self::WebidlScalarType;
282    fn webidl_scalar_type_int8_array(&mut self) -> Self::WebidlScalarType;
283    fn webidl_scalar_type_int16_array(&mut self) -> Self::WebidlScalarType;
284    fn webidl_scalar_type_int32_array(&mut self) -> Self::WebidlScalarType;
285    fn webidl_scalar_type_uint8_array(&mut self) -> Self::WebidlScalarType;
286    fn webidl_scalar_type_uint16_array(&mut self) -> Self::WebidlScalarType;
287    fn webidl_scalar_type_uint32_array(&mut self) -> Self::WebidlScalarType;
288    fn webidl_scalar_type_uint8_clamped_array(&mut self) -> Self::WebidlScalarType;
289    fn webidl_scalar_type_float32_array(&mut self) -> Self::WebidlScalarType;
290    fn webidl_scalar_type_float64_array(&mut self) -> Self::WebidlScalarType;
291
292    type WasmValType;
293    fn wasm_val_type_i32(&mut self) -> Self::WasmValType;
294    fn wasm_val_type_i64(&mut self) -> Self::WasmValType;
295    fn wasm_val_type_f32(&mut self) -> Self::WasmValType;
296    fn wasm_val_type_f64(&mut self) -> Self::WasmValType;
297    fn wasm_val_type_v128(&mut self) -> Self::WasmValType;
298    fn wasm_val_type_anyref(&mut self) -> Self::WasmValType;
299
300    type WasmFuncTypeRef: From<Self::WasmFuncTypeRefNamed> + From<Self::WasmFuncTypeRefIndexed>;
301
302    type WasmFuncTypeRefNamed;
303    fn wasm_func_type_ref_named(&mut self, name: &str) -> Option<Self::WasmFuncTypeRefNamed>;
304
305    type WasmFuncTypeRefIndexed;
306    fn wasm_func_type_ref_indexed(&mut self, idx: u32) -> Option<Self::WasmFuncTypeRefIndexed>;
307
308    type WasmFuncRef: From<Self::WasmFuncRefNamed> + From<Self::WasmFuncRefIndexed>;
309
310    type WasmFuncRefNamed;
311    fn wasm_func_ref_named(&mut self, name: &str) -> Option<Self::WasmFuncRefNamed>;
312
313    type WasmFuncRefIndexed;
314    fn wasm_func_ref_indexed(&mut self, idx: u32) -> Option<Self::WasmFuncRefIndexed>;
315
316    type BindingRef: From<Self::BindingRefNamed> + From<Self::BindingRefIndexed>;
317
318    type BindingRefNamed;
319    fn binding_ref_named(&mut self, name: &str) -> Option<Self::BindingRefNamed>;
320
321    type BindingRefIndexed;
322    fn binding_ref_indexed(&mut self, idx: u32) -> Option<Self::BindingRefIndexed>;
323}