1#![allow(unused_imports, dead_code, missing_debug_implementations)]
2
3use crate::actions::Actions;
4use crate::lexer;
5
6include!(concat!(env!("OUT_DIR"), "/grammar.rs"));
7
8pub fn parse_with_actions<A>(
14 actions: &mut A,
15 input: &str,
16) -> anyhow::Result<A::WebidlBindingsSection>
17where
18 A: Actions,
19{
20 let lexer_builder = lexer::LexerBuilder::new();
21 let lexer = lexer_builder.lexer(input);
22
23 let ast = WebidlBindingsSectionParser::new()
24 .parse(input, actions, lexer)
25 .map_err(|e| anyhow::anyhow!("{}", e))?;
26 Ok(ast)
27}
28
29#[cfg(test)]
30mod tests {
31 use super::*;
32
33 macro_rules! t {
34 ( $( $x:expr )* ) => {
35 ParseTree::List(vec![ $( $x.into() ),* ])
36 };
37 }
38
39 #[derive(Clone, Debug, PartialEq, Eq)]
40 enum ParseTree {
41 List(Vec<ParseTree>),
42 Atom(String),
43 }
44
45 impl From<&'_ str> for ParseTree {
46 fn from(s: &str) -> ParseTree {
47 s.to_string().into()
48 }
49 }
50
51 impl From<String> for ParseTree {
52 fn from(s: String) -> ParseTree {
53 ParseTree::Atom(s)
54 }
55 }
56
57 impl From<u32> for ParseTree {
58 fn from(x: u32) -> ParseTree {
59 ParseTree::Atom(x.to_string())
60 }
61 }
62
63 impl From<Vec<ParseTree>> for ParseTree {
64 fn from(v: Vec<ParseTree>) -> ParseTree {
65 ParseTree::List(v)
66 }
67 }
68
69 impl<T: Into<ParseTree>> From<Option<T>> for ParseTree {
70 fn from(t: Option<T>) -> ParseTree {
71 if let Some(t) = t {
72 t!("Some" t)
73 } else {
74 t!("None")
75 }
76 }
77 }
78
79 struct BuildParseTree;
80
81 impl crate::actions::Actions for BuildParseTree {
82 type WebidlBindingsSection = ParseTree;
83 fn webidl_bindings_section(
84 &mut self,
85 types: Self::WebidlTypeSubsection,
86 bindings: Self::WebidlFunctionBindingsSubsection,
87 ) -> Self::WebidlBindingsSection {
88 t!("WebidlBindingsSection" types bindings)
89 }
90
91 type WebidlTypeSubsection = ParseTree;
92 fn webidl_type_subsection(
93 &mut self,
94 types: Vec<Self::WebidlType>,
95 ) -> Self::WebidlTypeSubsection {
96 t!("WebidlTypeSubsection" types)
97 }
98
99 type WebidlType = ParseTree;
100 fn webidl_type(
101 &mut self,
102 name: Option<&str>,
103 ty: Self::WebidlCompoundType,
104 ) -> Self::WebidlType {
105 t!("WebidlType" name ty)
106 }
107
108 type WebidlCompoundType = ParseTree;
109
110 type WebidlFunction = ParseTree;
111 fn webidl_function(
112 &mut self,
113 kind: Option<Self::WebidlFunctionKind>,
114 params: Option<Self::WebidlFunctionParams>,
115 result: Option<Self::WebidlFunctionResult>,
116 ) -> Self::WebidlFunction {
117 t!("WebidlFunction" kind params result)
118 }
119
120 type WebidlFunctionKind = ParseTree;
121
122 type WebidlFunctionKindMethod = ParseTree;
123 fn webidl_function_kind_method(
124 &mut self,
125 ty: Self::WebidlTypeRef,
126 ) -> Self::WebidlFunctionKindMethod {
127 t!("WebidlFunctionKindMethod" ty)
128 }
129
130 type WebidlFunctionKindConstructor = ParseTree;
131 fn webidl_function_kind_constructor_default_new_target(
132 &mut self,
133 ) -> Self::WebidlFunctionKindConstructor {
134 t!("WebidlFunctionKindConstructor")
135 }
136
137 type WebidlFunctionParams = ParseTree;
138 fn webidl_function_params(
139 &mut self,
140 tys: Vec<Self::WebidlTypeRef>,
141 ) -> Self::WebidlFunctionParams {
142 t!("WebidlFunctionParams" tys)
143 }
144
145 type WebidlFunctionResult = ParseTree;
146 fn webidl_function_result(
147 &mut self,
148 ty: Self::WebidlTypeRef,
149 ) -> Self::WebidlFunctionResult {
150 t!("WebidlFunctionResult" ty)
151 }
152
153 type WebidlDictionary = ParseTree;
154 fn webidl_dictionary(
155 &mut self,
156 fields: Vec<Self::WebidlDictionaryField>,
157 ) -> Self::WebidlDictionary {
158 t!("WebidlDictionary" fields)
159 }
160
161 type WebidlDictionaryField = ParseTree;
162 fn webidl_dictionary_field(
163 &mut self,
164 name: Self::WebidlDictionaryFieldName,
165 ty: Self::WebidlTypeRef,
166 ) -> Self::WebidlDictionaryField {
167 t!("WebidlDictionaryField" name ty)
168 }
169
170 type WebidlDictionaryFieldName = ParseTree;
171 fn webidl_dictionary_field_name(&mut self, name: &str) -> Self::WebidlDictionaryFieldName {
172 t!("WebidlDictionaryFieldName" name)
173 }
174
175 type WebidlEnumeration = ParseTree;
176 fn webidl_enumeration(
177 &mut self,
178 values: Vec<Self::WebidlEnumerationValue>,
179 ) -> Self::WebidlEnumeration {
180 t!("WebidlEnumeration" values)
181 }
182
183 type WebidlEnumerationValue = ParseTree;
184 fn webidl_enumeration_value(&mut self, value: &str) -> Self::WebidlEnumerationValue {
185 t!("WebidlEnumerationValue" value)
186 }
187
188 type WebidlUnion = ParseTree;
189 fn webidl_union(&mut self, members: Vec<Self::WebidlTypeRef>) -> Self::WebidlUnion {
190 t!("WebidlUnion" members)
191 }
192
193 type WebidlFunctionBindingsSubsection = ParseTree;
194 fn webidl_function_bindings_subsection(
195 &mut self,
196 bindings: Vec<Self::FunctionBinding>,
197 binds: Vec<Self::Bind>,
198 ) -> Self::WebidlFunctionBindingsSubsection {
199 t!("WebidlFunctionBindingsSubsection" bindings binds)
200 }
201
202 type FunctionBinding = ParseTree;
203
204 type ImportBinding = ParseTree;
205 fn import_binding(
206 &mut self,
207 name: Option<&str>,
208 wasm_ty: Self::WasmFuncTypeRef,
209 webidl_ty: Self::WebidlTypeRef,
210 params: Option<Self::OutgoingBindingMap>,
211 result: Option<Self::IncomingBindingMap>,
212 ) -> Self::ImportBinding {
213 t!("ImportBinding" name wasm_ty webidl_ty params result)
214 }
215
216 type ExportBinding = ParseTree;
217 fn export_binding(
218 &mut self,
219 name: Option<&str>,
220 wasm_ty: Self::WasmFuncTypeRef,
221 webidl_ty: Self::WebidlTypeRef,
222 params: Option<Self::IncomingBindingMap>,
223 result: Option<Self::OutgoingBindingMap>,
224 ) -> Self::ExportBinding {
225 t!("ExportBinding" name wasm_ty webidl_ty params result)
226 }
227
228 type Bind = ParseTree;
229 fn bind(&mut self, func: Self::WasmFuncRef, binding: Self::BindingRef) -> Self::Bind {
230 t!("Bind" func binding)
231 }
232
233 type OutgoingBindingMap = ParseTree;
234 fn outgoing_binding_map(
235 &mut self,
236 bindings: Vec<Self::OutgoingBindingExpression>,
237 ) -> Self::OutgoingBindingMap {
238 t!("OutgoingBindingMap" bindings)
239 }
240
241 type IncomingBindingMap = ParseTree;
242 fn incoming_binding_map(
243 &mut self,
244 bindings: Vec<Self::IncomingBindingExpression>,
245 ) -> Self::IncomingBindingMap {
246 t!("IncomingBindingMap" bindings)
247 }
248
249 type OutgoingBindingExpression = ParseTree;
250
251 type OutgoingBindingExpressionAs = ParseTree;
252 fn outgoing_binding_expression_as(
253 &mut self,
254 ty: Self::WebidlTypeRef,
255 idx: u32,
256 ) -> Self::OutgoingBindingExpressionAs {
257 t!("OutgoingBindingExpressionAs" ty idx)
258 }
259
260 type OutgoingBindingExpressionUtf8Str = ParseTree;
261 fn outgoing_binding_expression_utf8_str(
262 &mut self,
263 ty: Self::WebidlTypeRef,
264 offset: u32,
265 length: u32,
266 ) -> Self::OutgoingBindingExpressionUtf8Str {
267 t!("OutgoingBindingExpressionUtf8Str" ty offset length)
268 }
269
270 type OutgoingBindingExpressionUtf8CStr = ParseTree;
271 fn outgoing_binding_expression_utf8_c_str(
272 &mut self,
273 ty: Self::WebidlTypeRef,
274 offset: u32,
275 ) -> Self::OutgoingBindingExpressionUtf8CStr {
276 t!("OutgoingBindingExpressionUtf8CStr" ty offset)
277 }
278
279 type OutgoingBindingExpressionI32ToEnum = ParseTree;
280 fn outgoing_binding_expression_i32_to_enum(
281 &mut self,
282 ty: Self::WebidlTypeRef,
283 idx: u32,
284 ) -> Self::OutgoingBindingExpressionI32ToEnum {
285 t!("OutgoingBindingExpressionI32ToEnum" ty idx)
286 }
287
288 type OutgoingBindingExpressionView = ParseTree;
289 fn outgoing_binding_expression_view(
290 &mut self,
291 ty: Self::WebidlTypeRef,
292 offset: u32,
293 length: u32,
294 ) -> Self::OutgoingBindingExpressionView {
295 t!("OutgoingBindingExpressionView" ty offset length)
296 }
297
298 type OutgoingBindingExpressionCopy = ParseTree;
299 fn outgoing_binding_expression_copy(
300 &mut self,
301 ty: Self::WebidlTypeRef,
302 offset: u32,
303 length: u32,
304 ) -> Self::OutgoingBindingExpressionCopy {
305 t!("OutgoingBindingExpressionCopy" ty offset length)
306 }
307
308 type OutgoingBindingExpressionDict = ParseTree;
309 fn outgoing_binding_expression_dict(
310 &mut self,
311 ty: Self::WebidlTypeRef,
312 fields: Vec<Self::OutgoingBindingExpression>,
313 ) -> Self::OutgoingBindingExpressionDict {
314 t!("OutgoingBindingExpressionDict" ty fields)
315 }
316
317 type OutgoingBindingExpressionBindExport = ParseTree;
318 fn outgoing_binding_expression_bind_export(
319 &mut self,
320 ty: Self::WebidlTypeRef,
321 binding: Self::BindingRef,
322 idx: u32,
323 ) -> Self::OutgoingBindingExpressionBindExport {
324 t!("OutgoingBindingExpressionBindExport" ty binding idx)
325 }
326
327 type IncomingBindingExpression = ParseTree;
328
329 type IncomingBindingExpressionGet = ParseTree;
330 fn incoming_binding_expression_get(
331 &mut self,
332 idx: u32,
333 ) -> Self::IncomingBindingExpressionGet {
334 t!("IncomingBindingExpressionGet" idx)
335 }
336
337 type IncomingBindingExpressionAs = ParseTree;
338 fn incoming_binding_expression_as(
339 &mut self,
340 ty: Self::WasmValType,
341 expr: Self::IncomingBindingExpression,
342 ) -> Self::IncomingBindingExpressionAs {
343 t!("IncomingBindingExpressionAs" ty expr)
344 }
345
346 type IncomingBindingExpressionAllocUtf8Str = ParseTree;
347 fn incoming_binding_expression_alloc_utf8_str(
348 &mut self,
349 alloc_func_name: &str,
350 expr: Self::IncomingBindingExpression,
351 ) -> Self::IncomingBindingExpressionAllocUtf8Str {
352 t!("IncomingBindingExpressionAllocUtf8Str" alloc_func_name expr)
353 }
354
355 type IncomingBindingExpressionAllocCopy = ParseTree;
356 fn incoming_binding_expression_alloc_copy(
357 &mut self,
358 alloc_func_name: &str,
359 expr: Self::IncomingBindingExpression,
360 ) -> Self::IncomingBindingExpressionAllocCopy {
361 t!("IncomingBindingExpressionAllocCopy" alloc_func_name expr)
362 }
363
364 type IncomingBindingExpressionEnumToI32 = ParseTree;
365 fn incoming_binding_expression_enum_to_i32(
366 &mut self,
367 ty: Self::WebidlTypeRef,
368 expr: Self::IncomingBindingExpression,
369 ) -> Self::IncomingBindingExpressionEnumToI32 {
370 t!("IncomingBindingExpressionEnumToI32" ty expr)
371 }
372
373 type IncomingBindingExpressionField = ParseTree;
374 fn incoming_binding_expression_field(
375 &mut self,
376 idx: u32,
377 expr: Self::IncomingBindingExpression,
378 ) -> Self::IncomingBindingExpressionField {
379 t!("IncomingBindingExpressionField" idx expr)
380 }
381
382 type IncomingBindingExpressionBindImport = ParseTree;
383 fn incoming_binding_expression_bind_import(
384 &mut self,
385 ty: Self::WasmFuncTypeRef,
386 binding: Self::BindingRef,
387 expr: Self::IncomingBindingExpression,
388 ) -> Self::IncomingBindingExpressionBindImport {
389 t!("IncomingBindingExpressionBindImport" ty binding expr)
390 }
391
392 type WebidlTypeRef = ParseTree;
393
394 type WebidlTypeRefNamed = ParseTree;
395 fn webidl_type_ref_named(&mut self, name: &str) -> Option<Self::WebidlTypeRefNamed> {
396 Some(t!("WebidlTypeRefNamed" name))
397 }
398
399 type WebidlTypeRefIndexed = ParseTree;
400 fn webidl_type_ref_indexed(&mut self, idx: u32) -> Option<Self::WebidlTypeRefIndexed> {
401 Some(t!("WebidlTypeRefIndexed" idx))
402 }
403
404 type WebidlScalarType = ParseTree;
405 fn webidl_scalar_type_any(&mut self) -> Self::WebidlScalarType {
406 t!("WebidlScalarType" "any")
407 }
408 fn webidl_scalar_type_boolean(&mut self) -> Self::WebidlScalarType {
409 t!("WebidlScalarType" "boolean")
410 }
411 fn webidl_scalar_type_byte(&mut self) -> Self::WebidlScalarType {
412 t!("WebidlScalarType" "byte")
413 }
414 fn webidl_scalar_type_octet(&mut self) -> Self::WebidlScalarType {
415 t!("WebidlScalarType" "octet")
416 }
417 fn webidl_scalar_type_long(&mut self) -> Self::WebidlScalarType {
418 t!("WebidlScalarType" "long")
419 }
420 fn webidl_scalar_type_unsigned_long(&mut self) -> Self::WebidlScalarType {
421 t!("WebidlScalarType" "unsigned long")
422 }
423 fn webidl_scalar_type_short(&mut self) -> Self::WebidlScalarType {
424 t!("WebidlScalarType" "short")
425 }
426 fn webidl_scalar_type_unsigned_short(&mut self) -> Self::WebidlScalarType {
427 t!("WebidlScalarType" "unsigned short")
428 }
429 fn webidl_scalar_type_long_long(&mut self) -> Self::WebidlScalarType {
430 t!("WebidlScalarType" "long long")
431 }
432 fn webidl_scalar_type_unsigned_long_long(&mut self) -> Self::WebidlScalarType {
433 t!("WebidlScalarType" "unsigned long long")
434 }
435 fn webidl_scalar_type_float(&mut self) -> Self::WebidlScalarType {
436 t!("WebidlScalarType" "float")
437 }
438 fn webidl_scalar_type_unrestricted_float(&mut self) -> Self::WebidlScalarType {
439 t!("WebidlScalarType" "unrestricted float")
440 }
441 fn webidl_scalar_type_double(&mut self) -> Self::WebidlScalarType {
442 t!("WebidlScalarType" "double")
443 }
444 fn webidl_scalar_type_unrestricted_double(&mut self) -> Self::WebidlScalarType {
445 t!("WebidlScalarType" "unrestricted double")
446 }
447 fn webidl_scalar_type_dom_string(&mut self) -> Self::WebidlScalarType {
448 t!("WebidlScalarType" "DOMString")
449 }
450 fn webidl_scalar_type_byte_string(&mut self) -> Self::WebidlScalarType {
451 t!("WebidlScalarType" "ByteString")
452 }
453 fn webidl_scalar_type_usv_string(&mut self) -> Self::WebidlScalarType {
454 t!("WebidlScalarType" "USVString")
455 }
456 fn webidl_scalar_type_object(&mut self) -> Self::WebidlScalarType {
457 t!("WebidlScalarType" "object")
458 }
459 fn webidl_scalar_type_symbol(&mut self) -> Self::WebidlScalarType {
460 t!("WebidlScalarType" "symbol")
461 }
462 fn webidl_scalar_type_array_buffer(&mut self) -> Self::WebidlScalarType {
463 t!("WebidlScalarType" "ArrayBuffer")
464 }
465 fn webidl_scalar_type_data_view(&mut self) -> Self::WebidlScalarType {
466 t!("WebidlScalarType" "DataView")
467 }
468 fn webidl_scalar_type_int8_array(&mut self) -> Self::WebidlScalarType {
469 t!("WebidlScalarType" "Int8Array")
470 }
471 fn webidl_scalar_type_int16_array(&mut self) -> Self::WebidlScalarType {
472 t!("WebidlScalarType" "Int16Array")
473 }
474 fn webidl_scalar_type_int32_array(&mut self) -> Self::WebidlScalarType {
475 t!("WebidlScalarType" "Int32Array")
476 }
477 fn webidl_scalar_type_uint8_array(&mut self) -> Self::WebidlScalarType {
478 t!("WebidlScalarType" "Uint8Array")
479 }
480 fn webidl_scalar_type_uint16_array(&mut self) -> Self::WebidlScalarType {
481 t!("WebidlScalarType" "Uint16Array")
482 }
483 fn webidl_scalar_type_uint32_array(&mut self) -> Self::WebidlScalarType {
484 t!("WebidlScalarType" "Uint32Array")
485 }
486 fn webidl_scalar_type_uint8_clamped_array(&mut self) -> Self::WebidlScalarType {
487 t!("WebidlScalarType" "Uint8ClampedArray")
488 }
489 fn webidl_scalar_type_float32_array(&mut self) -> Self::WebidlScalarType {
490 t!("WebidlScalarType" "Float32Array")
491 }
492 fn webidl_scalar_type_float64_array(&mut self) -> Self::WebidlScalarType {
493 t!("WebidlScalarType" "Float64Array")
494 }
495
496 type WasmValType = ParseTree;
497 fn wasm_val_type_i32(&mut self) -> Self::WasmValType {
498 t!("WasmValType" "i32")
499 }
500 fn wasm_val_type_i64(&mut self) -> Self::WasmValType {
501 t!("WasmValType" "i64")
502 }
503 fn wasm_val_type_f32(&mut self) -> Self::WasmValType {
504 t!("WasmValType" "f32")
505 }
506 fn wasm_val_type_f64(&mut self) -> Self::WasmValType {
507 t!("WasmValType" "f64")
508 }
509 fn wasm_val_type_v128(&mut self) -> Self::WasmValType {
510 t!("WasmValType" "v128")
511 }
512 fn wasm_val_type_anyref(&mut self) -> Self::WasmValType {
513 t!("WasmValType" "anyref")
514 }
515
516 type WasmFuncTypeRef = ParseTree;
517
518 type WasmFuncTypeRefNamed = ParseTree;
519 fn wasm_func_type_ref_named(&mut self, name: &str) -> Option<Self::WasmFuncTypeRefNamed> {
520 Some(t!("WasmFuncTypeRefNamed" name))
521 }
522
523 type WasmFuncTypeRefIndexed = ParseTree;
524 fn wasm_func_type_ref_indexed(&mut self, idx: u32) -> Option<Self::WasmFuncTypeRefIndexed> {
525 Some(t!("WasmFuncTypeRefIndexed" idx))
526 }
527
528 type WasmFuncRef = ParseTree;
529
530 type WasmFuncRefNamed = ParseTree;
531 fn wasm_func_ref_named(&mut self, name: &str) -> Option<Self::WasmFuncRefNamed> {
532 Some(t!("WasmFuncRefNamed" name))
533 }
534
535 type WasmFuncRefIndexed = ParseTree;
536 fn wasm_func_ref_indexed(&mut self, idx: u32) -> Option<Self::WasmFuncRefIndexed> {
537 Some(t!("WasmFuncRefIndexed" idx))
538 }
539
540 type BindingRef = ParseTree;
541
542 type BindingRefNamed = ParseTree;
543 fn binding_ref_named(&mut self, name: &str) -> Option<Self::BindingRefNamed> {
544 Some(t!("BindingRefNamed" name))
545 }
546
547 type BindingRefIndexed = ParseTree;
548 fn binding_ref_indexed(&mut self, idx: u32) -> Option<Self::BindingRefIndexed> {
549 Some(t!("BindingRefIndexed" idx))
550 }
551 }
552
553 macro_rules! ok {
554 ($name: ident, $parser: ident, $input: expr, $output: expr) => {
555 #[test]
556 fn $name() {
557 let actions = &mut BuildParseTree;
558 let lexer_builder = crate::lexer::LexerBuilder::new();
559 let lexer = lexer_builder.lexer($input);
560
561 let actual = $parser::new().parse($input, actions, lexer).unwrap();
562 let expected = $output;
563 println!("actual = {:#?}", actual);
564 println!("expected = {:#?}", expected);
565 assert_eq!(actual, expected);
566 }
567 };
568 }
569
570 macro_rules! err {
571 ($name: ident, $parser: ident, $input: expr) => {
572 #[test]
573 fn $name() {
574 let actions = &mut BuildParseTree;
575 let lexer_builder = crate::lexer::LexerBuilder::new();
576 let lexer = lexer_builder.lexer($input);
577
578 assert!($parser::new().parse($input, actions, lexer).is_err());
579 }
580 };
581 }
582
583 ok!(
584 explainer_example,
585 WebidlBindingsSectionParser,
586 r#"
596 ;; Define the signature of `encodeInto`.
597 type $TextEncoderEncodeIntoResult
598 (; a dictionary with 2 fields: `read` and `written`. ; dict
599 (field "read" unsigned long long)
600 (field "written" unsigned long long))
601
602 type $EncodeIntoFuncWebIDL
603 (func (method any)
604 (param USVString Uint8Array)
605 (result $TextEncoderEncodeIntoResult))
606
607 ;; Apply the binding.
608 func-binding $encodeIntoBinding import $EncodeIntoFuncWasm $EncodeIntoFuncWebIDL
609 (param
610 (as any 0)
611 (as type=any idx=1)
612 (view Uint8Array 2 3))
613 (result
614 (as i64 (field 0 (get 0)))
615 (as i64 (field 1 (get idx=0))))
616
617 bind $encodeInto $encodeIntoBinding
618 "#,
619 t!("WebidlBindingsSection"
620 t!("WebidlTypeSubsection"
621 t!(t!("WebidlType"
622 t!("Some" "$TextEncoderEncodeIntoResult")
623 t!("WebidlDictionary"
624 t!(t!("WebidlDictionaryField"
625 t!("WebidlDictionaryFieldName" "read")
626 t!("WebidlScalarType" "unsigned long long"))
627 t!("WebidlDictionaryField"
628 t!("WebidlDictionaryFieldName" "written")
629 t!("WebidlScalarType" "unsigned long long")))))
630 t!("WebidlType"
631 t!("Some" "$EncodeIntoFuncWebIDL")
632 t!("WebidlFunction"
633 t!("Some" t!("WebidlFunctionKindMethod" t!("WebidlScalarType" "any")))
634 t!("Some" t!("WebidlFunctionParams"
635 t!(t!("WebidlScalarType" "USVString")
636 t!("WebidlScalarType" "Uint8Array"))))
637 t!("Some" t!("WebidlFunctionResult"
638 t!("WebidlTypeRefNamed" "$TextEncoderEncodeIntoResult")))))))
639 t!("WebidlFunctionBindingsSubsection"
640 t!(t!("ImportBinding"
641 t!("Some" "$encodeIntoBinding")
642 t!("WasmFuncTypeRefNamed" "$EncodeIntoFuncWasm")
643 t!("WebidlTypeRefNamed" "$EncodeIntoFuncWebIDL")
644 t!("Some" t!("OutgoingBindingMap"
645 t!(t!("OutgoingBindingExpressionAs"
646 t!("WebidlScalarType" "any")
647 0)
648 t!("OutgoingBindingExpressionAs"
649 t!("WebidlScalarType" "any")
650 1)
651 t!("OutgoingBindingExpressionView"
652 t!("WebidlScalarType" "Uint8Array")
653 2
654 3))))
655 t!("Some" t!("IncomingBindingMap"
656 t!(t!("IncomingBindingExpressionAs"
657 t!("WasmValType" "i64")
658 t!("IncomingBindingExpressionField"
659 0
660 t!("IncomingBindingExpressionGet" 0)))
661 t!("IncomingBindingExpressionAs"
662 t!("WasmValType" "i64")
663 t!("IncomingBindingExpressionField"
664 1
665 t!("IncomingBindingExpressionGet" 0))))))))
666 t!(t!("Bind"
667 t!("WasmFuncRefNamed" "$encodeInto")
668 t!("BindingRefNamed" "$encodeIntoBinding")))))
669 );
670
671 ok!(
672 webidl_type_func_ok_1,
673 WebidlTypeParser,
674 "type $AddContactFuncWebIDL (func (method any) (param $Contact DOMString) (result boolean))",
675 t!("WebidlType"
676 t!("Some" "$AddContactFuncWebIDL")
677 t!("WebidlFunction"
678 t!("Some" t!("WebidlFunctionKindMethod"
679 t!("WebidlScalarType" "any")))
680 t!("Some" t!("WebidlFunctionParams"
681 t!(t!("WebidlTypeRefNamed" "$Contact")
682 t!("WebidlScalarType" "DOMString"))))
683 t!("Some" t!("WebidlFunctionResult" t!("WebidlScalarType" "boolean")))))
684 );
685 ok!(
686 webidl_type_func_ok_2,
687 WebidlTypeParser,
688 "type $AddContactFuncWebIDL (func (method any) (param $Contact DOMString))",
689 t!("WebidlType"
690 t!("Some" "$AddContactFuncWebIDL")
691 t!("WebidlFunction"
692 t!("Some" t!("WebidlFunctionKindMethod"
693 t!("WebidlScalarType" "any")))
694 t!("Some" t!("WebidlFunctionParams"
695 t!(t!("WebidlTypeRefNamed" "$Contact")
696 t!("WebidlScalarType" "DOMString"))))
697 t!("None")))
698 );
699 ok!(
700 webidl_type_func_ok_3,
701 WebidlTypeParser,
702 "type $AddContactFuncWebIDL (func (param DOMString))",
703 t!("WebidlType"
704 t!("Some" "$AddContactFuncWebIDL")
705 t!("WebidlFunction"
706 t!("None")
707 t!("Some" t!("WebidlFunctionParams" t!(t!("WebidlScalarType" "DOMString"))))
708 t!("None")))
709 );
710 ok!(
711 webidl_type_func_ok_4,
712 WebidlTypeParser,
713 "type $AddContactFuncWebIDL (func (param))",
714 t!("WebidlType"
715 t!("Some" "$AddContactFuncWebIDL")
716 t!("WebidlFunction"
717 t!("None")
718 t!("Some" t!("WebidlFunctionParams" t!()))
719 t!("None")))
720 );
721 ok!(
722 webidl_type_func_ok_5,
723 WebidlTypeParser,
724 "type $AddContactFuncWebIDL (func)",
725 t!("WebidlType"
726 t!("Some" "$AddContactFuncWebIDL")
727 t!("WebidlFunction"
728 t!("None")
729 t!("None")
730 t!("None")))
731 );
732 ok!(
733 webidl_type_func_ok_6,
734 WebidlTypeParser,
735 "type (func)",
736 t!("WebidlType"
737 t!("None")
738 t!("WebidlFunction"
739 t!("None")
740 t!("None")
741 t!("None")))
742 );
743 ok!(
744 webidl_type_func_ok_7,
745 WebidlTypeParser,
746 "type MyCtor (func (constructor default-new-target) (result any))",
747 t!("WebidlType"
748 t!("Some" "MyCtor")
749 t!("WebidlFunction"
750 t!("Some" t!("WebidlFunctionKindConstructor"))
751 t!("None")
752 t!("Some" t!("WebidlFunctionResult" t!("WebidlScalarType" "any")))))
753 );
754 err!(
755 webidl_type_func_err_1,
756 WebidlTypeParser,
757 "type blahBlahBlah"
758 );
759 err!(
760 webidl_type_func_err_2,
761 WebidlTypeParser,
762 "type blahBlahBlah (func (result any) (result any))"
763 );
764 err!(
765 webidl_type_func_err_3,
766 WebidlTypeParser,
767 "type blahBlahBlah (func (method any) (method any))"
768 );
769
770 ok!(
771 webidl_type_dict_ok_1,
772 WebidlTypeParser,
773 r#"type $Contact (dict (field "name" DOMString) (field "age" long))"#,
774 t!("WebidlType"
775 t!("Some" "$Contact")
776 t!("WebidlDictionary"
777 t!(t!("WebidlDictionaryField"
778 t!("WebidlDictionaryFieldName" "name")
779 t!("WebidlScalarType" "DOMString"))
780 t!("WebidlDictionaryField"
781 t!("WebidlDictionaryFieldName" "age")
782 t!("WebidlScalarType" "long")))))
783 );
784 ok!(
785 webidl_type_dict_ok_2,
786 WebidlTypeParser,
787 r#"type $Contact (dict)"#,
788 t!("WebidlType"
789 t!("Some" "$Contact")
790 t!("WebidlDictionary" t!()))
791 );
792 err!(
793 webidl_type_dict_err_1,
794 WebidlTypeParser,
795 r#"type $Contact (dict (field "name"))"#
796 );
797 err!(
798 webidl_type_dict_err_2,
799 WebidlTypeParser,
800 r#"type $Contact (dict (field DOMString))"#
801 );
802
803 ok!(
804 webidl_type_enum_ok_1,
805 WebidlTypeParser,
806 r#"type Blah (enum "uno" "dos" "tres")"#,
807 t!("WebidlType"
808 t!("Some" "Blah")
809 t!("WebidlEnumeration"
810 t!(
811 t!("WebidlEnumerationValue" "uno")
812 t!("WebidlEnumerationValue" "dos")
813 t!("WebidlEnumerationValue" "tres")
814 )
815 )
816 )
817 );
818 ok!(
819 webidl_type_enum_ok_2,
820 WebidlTypeParser,
821 r#"type (enum)"#,
822 t!("WebidlType"
823 t!("None")
824 t!("WebidlEnumeration" t!())
825 )
826 );
827 err!(
828 webidl_type_enum_err_1,
829 WebidlTypeParser,
830 r#"type (enum 1 2 3)"#
831 );
832
833 ok!(
834 webidl_type_union_ok_1,
835 WebidlTypeParser,
836 "type MyUnion (union long boolean)",
837 t!("WebidlType"
838 t!("Some" "MyUnion")
839 t!("WebidlUnion"
840 t!(
841 t!("WebidlScalarType" "long")
842 t!("WebidlScalarType" "boolean")
843 )
844 )
845 )
846 );
847 ok!(
848 webidl_type_union_ok_2,
849 WebidlTypeParser,
850 "type (union)",
851 t!("WebidlType"
852 t!("None")
853 t!("WebidlUnion" t!())
854 )
855 );
856 err!(
857 webidl_type_union_err_1,
858 WebidlTypeParser,
859 r#"type (union "hello")"#
860 );
861
862 ok!(
863 import_binding_ok_1,
864 ImportBindingParser,
865 "func-binding Yoyo import MyWasmFunc MyWebidlFunc (param (as any 0)) (result (as i32 (get 0)))",
866 t!("ImportBinding"
867 t!("Some" "Yoyo")
868 t!("WasmFuncTypeRefNamed" "MyWasmFunc")
869 t!("WebidlTypeRefNamed" "MyWebidlFunc")
870 t!("Some" t!("OutgoingBindingMap"
871 t!(
872 t!("OutgoingBindingExpressionAs"
873 t!("WebidlScalarType" "any")
874 0
875 )
876 )
877 ))
878 t!("Some" t!("IncomingBindingMap"
879 t!(
880 t!("IncomingBindingExpressionAs"
881 t!("WasmValType" "i32")
882 t!("IncomingBindingExpressionGet" 0)
883 )
884 )
885 ))
886 )
887 );
888 ok!(
889 import_binding_ok_2,
890 ImportBindingParser,
891 "func-binding import MyWasmFunc MyWebidlFunc (param) (result)",
892 t!("ImportBinding"
893 t!("None")
894 t!("WasmFuncTypeRefNamed" "MyWasmFunc")
895 t!("WebidlTypeRefNamed" "MyWebidlFunc")
896 t!("Some" t!("OutgoingBindingMap" t!()))
897 t!("Some" t!("IncomingBindingMap" t!()))
898 )
899 );
900 ok!(
901 import_binding_ok_3,
902 ImportBindingParser,
903 "func-binding import MyWasmFunc MyWebidlFunc (param)",
904 t!("ImportBinding"
905 t!("None")
906 t!("WasmFuncTypeRefNamed" "MyWasmFunc")
907 t!("WebidlTypeRefNamed" "MyWebidlFunc")
908 t!("Some" t!("OutgoingBindingMap" t!()))
909 t!("None")
910 )
911 );
912 ok!(
913 import_binding_ok_4,
914 ImportBindingParser,
915 "func-binding import MyWasmFunc MyWebidlFunc (result)",
916 t!("ImportBinding"
917 t!("None")
918 t!("WasmFuncTypeRefNamed" "MyWasmFunc")
919 t!("WebidlTypeRefNamed" "MyWebidlFunc")
920 t!("None")
921 t!("Some" t!("IncomingBindingMap" t!()))
922 )
923 );
924 err!(
925 import_binding_err_3,
926 ImportBindingParser,
927 "func-binding import MyWasmFunc (param) (result)"
928 );
929 err!(
930 import_binding_err_4,
931 ImportBindingParser,
932 "func-binding import MyWebidlFunc (param) (result)"
933 );
934 err!(
935 import_binding_err_5,
936 ImportBindingParser,
937 "func-binding MyWasmFunc MyWebidlFunc (param) (result)"
938 );
939 err!(
940 import_binding_err_6,
941 ImportBindingParser,
942 "import MyWasmFunc MyWebidlFunc (param) (result)"
943 );
944
945 ok!(
946 export_binding_ok_1,
947 ExportBindingParser,
948 "func-binding $Yoyo export MyWasmFunc MyWebidlFunc (param (as i32 (get 0))) (result (as any 0))",
949 t!("ExportBinding"
950 t!("Some" "$Yoyo")
951 t!("WasmFuncTypeRefNamed" "MyWasmFunc")
952 t!("WebidlTypeRefNamed" "MyWebidlFunc")
953 t!("Some" t!("IncomingBindingMap"
954 t!(
955 t!("IncomingBindingExpressionAs"
956 t!("WasmValType" "i32")
957 t!("IncomingBindingExpressionGet" 0)
958 )
959 )
960 ))
961 t!("Some" t!("OutgoingBindingMap"
962 t!(
963 t!("OutgoingBindingExpressionAs"
964 t!("WebidlScalarType" "any")
965 0
966 )
967 )
968 ))
969 )
970 );
971 ok!(
972 export_binding_ok_2,
973 ExportBindingParser,
974 "func-binding export $MyWasmFunc $MyWebidlFunc (param) (result)",
975 t!("ExportBinding"
976 t!("None")
977 t!("WasmFuncTypeRefNamed" "$MyWasmFunc")
978 t!("WebidlTypeRefNamed" "$MyWebidlFunc")
979 t!("Some" t!("IncomingBindingMap" t!()))
980 t!("Some" t!("OutgoingBindingMap" t!()))
981 )
982 );
983 ok!(
984 export_binding_ok_3,
985 ExportBindingParser,
986 "func-binding export $MyWasmFunc $MyWebidlFunc (param)",
987 t!("ExportBinding"
988 t!("None")
989 t!("WasmFuncTypeRefNamed" "$MyWasmFunc")
990 t!("WebidlTypeRefNamed" "$MyWebidlFunc")
991 t!("Some" t!("IncomingBindingMap" t!()))
992 t!("None")
993 )
994 );
995 ok!(
996 export_binding_ok_4,
997 ExportBindingParser,
998 "func-binding export $MyWasmFunc $MyWebidlFunc (result)",
999 t!("ExportBinding"
1000 t!("None")
1001 t!("WasmFuncTypeRefNamed" "$MyWasmFunc")
1002 t!("WebidlTypeRefNamed" "$MyWebidlFunc")
1003 t!("None")
1004 t!("Some" t!("OutgoingBindingMap" t!()))
1005 )
1006 );
1007 err!(
1008 export_binding_err_3,
1009 ExportBindingParser,
1010 "func-binding export MyWasmFunc (param) (result)"
1011 );
1012 err!(
1013 export_binding_err_4,
1014 ExportBindingParser,
1015 "func-binding export MyWebidlFunc (param) (result)"
1016 );
1017 err!(
1018 export_binding_err_5,
1019 ExportBindingParser,
1020 "func-binding MyWasmFunc MyWebidlFunc (param) (result)"
1021 );
1022 err!(
1023 export_binding_err_6,
1024 ExportBindingParser,
1025 "export MyWasmFunc MyWebidlFunc (param) (result)"
1026 );
1027
1028 ok!(
1029 webidl_type_ref_ok_1,
1030 WebidlTypeRefParser,
1031 "$Contact",
1032 t!("WebidlTypeRefNamed" "$Contact")
1033 );
1034 ok!(
1035 webidl_type_ref_ok_2,
1036 WebidlTypeRefParser,
1037 "type=$Contact",
1038 t!("WebidlTypeRefNamed" "$Contact")
1039 );
1040 ok!(
1041 webidl_type_ref_ok_3,
1042 WebidlTypeRefParser,
1043 "42",
1044 t!("WebidlTypeRefIndexed" 42)
1045 );
1046 ok!(
1047 webidl_type_ref_ok_4,
1048 WebidlTypeRefParser,
1049 "type=42",
1050 t!("WebidlTypeRefIndexed" 42)
1051 );
1052 err!(webidl_type_ref_err, WebidlTypeRefParser, "1abc");
1053
1054 ok!(
1055 wasm_type_ref_ok_1,
1056 WasmValTypeParser,
1057 "i32",
1058 t!("WasmValType" "i32")
1059 );
1060 ok!(
1061 wasm_type_ref_ok_2,
1062 WasmValTypeParser,
1063 "i64",
1064 t!("WasmValType" "i64")
1065 );
1066 ok!(
1067 wasm_type_ref_ok_3,
1068 WasmValTypeParser,
1069 "f32",
1070 t!("WasmValType" "f32")
1071 );
1072 ok!(
1073 wasm_type_ref_ok_4,
1074 WasmValTypeParser,
1075 "f64",
1076 t!("WasmValType" "f64")
1077 );
1078 ok!(
1079 wasm_type_ref_ok_5,
1080 WasmValTypeParser,
1081 "v128",
1082 t!("WasmValType" "v128")
1083 );
1084 ok!(
1085 wasm_type_ref_ok_6,
1086 WasmValTypeParser,
1087 "anyref",
1088 t!("WasmValType" "anyref")
1089 );
1090 err!(wasm_type_ref_err, WasmValTypeParser, "a32");
1091
1092 ok!(
1093 export_binding_ref_ok_1,
1094 BindingRefParser,
1095 "$Contact",
1096 t!("BindingRefNamed" "$Contact")
1097 );
1098 ok!(
1099 export_binding_ref_ok_2,
1100 BindingRefParser,
1101 "42",
1102 t!("BindingRefIndexed" 42)
1103 );
1104 err!(export_binding_ref_err, BindingRefParser, "1abc");
1105
1106 ok!(
1107 wasm_func_ref_ok_1,
1108 WasmFuncRefParser,
1109 "$my_func",
1110 t!("WasmFuncRefNamed" "$my_func")
1111 );
1112 ok!(
1113 wasm_func_ref_ok_2,
1114 WasmFuncRefParser,
1115 "42",
1116 t!("WasmFuncRefIndexed" 42)
1117 );
1118 err!(wasm_func_ref_err, WasmFuncRefParser, "1abc");
1119
1120 ok!(
1121 outgoing_binding_expression_as_ok_1,
1122 OutgoingBindingExpressionParser,
1123 "(as long 2)",
1124 t!("OutgoingBindingExpressionAs"
1125 t!("WebidlScalarType" "long")
1126 2
1127 )
1128 );
1129 ok!(
1130 outgoing_binding_expression_as_ok_2,
1131 OutgoingBindingExpressionParser,
1132 "(as 1 2)",
1133 t!("OutgoingBindingExpressionAs"
1134 t!("WebidlTypeRefIndexed" 1)
1135 2
1136 )
1137 );
1138 err!(
1139 outgoing_binding_expression_as_err_1,
1140 OutgoingBindingExpressionParser,
1141 "(as long)"
1142 );
1143 err!(
1144 outgoing_binding_expression_as_err_2,
1145 OutgoingBindingExpressionParser,
1146 "(as 2)"
1147 );
1148
1149 ok!(
1150 outgoing_binding_expression_utf8_str_ok,
1151 OutgoingBindingExpressionParser,
1152 "(utf8-str DOMString 123 456)",
1153 t!("OutgoingBindingExpressionUtf8Str"
1154 t!("WebidlScalarType" "DOMString")
1155 123
1156 456
1157 )
1158 );
1159 err!(
1160 outgoing_binding_expression_utf8_str_err_1,
1161 OutgoingBindingExpressionParser,
1162 "(utf8-str DOMString 123)"
1163 );
1164 err!(
1165 outgoing_binding_expression_utf8_str_err_2,
1166 OutgoingBindingExpressionParser,
1167 "(utf8-str 123 456)"
1168 );
1169
1170 ok!(
1171 outgoing_binding_expression_utf8_c_str_ok,
1172 OutgoingBindingExpressionParser,
1173 "(utf8-cstr DOMString 123)",
1174 t!("OutgoingBindingExpressionUtf8CStr"
1175 t!("WebidlScalarType" "DOMString")
1176 123
1177 )
1178 );
1179 err!(
1180 outgoing_binding_expression_utf8_c_str_err_1,
1181 OutgoingBindingExpressionParser,
1182 "(utf8-cstr DOMString)"
1183 );
1184 err!(
1185 outgoing_binding_expression_utf8_c_str_err_2,
1186 OutgoingBindingExpressionParser,
1187 "(utf8-cstr 123)"
1188 );
1189
1190 ok!(
1191 outgoing_binding_expression_i32_to_enum_ok,
1192 OutgoingBindingExpressionParser,
1193 "(i32-to-enum Blah 22)",
1194 t!("OutgoingBindingExpressionI32ToEnum"
1195 t!("WebidlTypeRefNamed" "Blah")
1196 22
1197 )
1198 );
1199 err!(
1200 outgoing_binding_expression_i32_to_enum_err_1,
1201 OutgoingBindingExpressionParser,
1202 "(i32-to-enum Blah)"
1203 );
1204 err!(
1205 outgoing_binding_expression_i32_to_enum_err_2,
1206 OutgoingBindingExpressionParser,
1207 "(i32-to-enum 22)"
1208 );
1209
1210 ok!(
1211 outgoing_binding_expression_view_ok,
1212 OutgoingBindingExpressionParser,
1213 "(view Uint8Array 123 456)",
1214 t!("OutgoingBindingExpressionView"
1215 t!("WebidlScalarType" "Uint8Array")
1216 123
1217 456
1218 )
1219 );
1220 err!(
1221 outgoing_binding_expression_view_err_1,
1222 OutgoingBindingExpressionParser,
1223 "(view Uint8Array 123)"
1224 );
1225 err!(
1226 outgoing_binding_expression_view_err_2,
1227 OutgoingBindingExpressionParser,
1228 "(view 123 456)"
1229 );
1230
1231 ok!(
1232 outgoing_binding_expression_copy_ok,
1233 OutgoingBindingExpressionParser,
1234 "(copy Uint8Array 123 456)",
1235 t!("OutgoingBindingExpressionCopy"
1236 t!("WebidlScalarType" "Uint8Array")
1237 123
1238 456
1239 )
1240 );
1241 err!(
1242 outgoing_binding_expression_copy_err_1,
1243 OutgoingBindingExpressionParser,
1244 "(copy Uint8Array 123)"
1245 );
1246 err!(
1247 outgoing_binding_expression_copy_err_2,
1248 OutgoingBindingExpressionParser,
1249 "(copy 123 456)"
1250 );
1251
1252 ok!(
1253 outgoing_binding_expression_dict_ok_1,
1254 OutgoingBindingExpressionParser,
1255 "(dict $Contact (utf8-str DOMString 0 1) (as long 2))",
1256 t!("OutgoingBindingExpressionDict"
1257 t!("WebidlTypeRefNamed" "$Contact")
1258 t!(
1259 t!("OutgoingBindingExpressionUtf8Str"
1260 t!("WebidlScalarType" "DOMString")
1261 0
1262 1)
1263 t!("OutgoingBindingExpressionAs"
1264 t!("WebidlScalarType" "long")
1265 2)
1266 )
1267 )
1268 );
1269 ok!(
1270 outgoing_binding_expression_dict_ok_2,
1271 OutgoingBindingExpressionParser,
1272 "(dict $Contact)",
1273 t!("OutgoingBindingExpressionDict"
1274 t!("WebidlTypeRefNamed" "$Contact")
1275 t!()
1276 )
1277 );
1278 err!(
1279 outgoing_binding_expression_dict_err_1,
1280 OutgoingBindingExpressionParser,
1281 "(dict (as long 1))"
1282 );
1283
1284 ok!(
1285 outgoing_binding_expression_bind_export_ok_1,
1286 OutgoingBindingExpressionParser,
1287 "(bind-export $SomeCallback $SomeBinding 2)",
1288 t!("OutgoingBindingExpressionBindExport"
1289 t!("WebidlTypeRefNamed" "$SomeCallback")
1290 t!("BindingRefNamed" "$SomeBinding")
1291 2
1292 )
1293 );
1294 err!(
1295 outgoing_binding_expression_bind_export_err_1,
1296 OutgoingBindingExpressionParser,
1297 "(bind-export SomeBinding 2)"
1298 );
1299 err!(
1300 outgoing_binding_expression_bind_export_err_2,
1301 OutgoingBindingExpressionParser,
1302 "(bind-export SomeCallback 2)"
1303 );
1304 err!(
1305 outgoing_binding_expression_bind_export_err_3,
1306 OutgoingBindingExpressionParser,
1307 "(bind-export SomeCallback SomeBinding)"
1308 );
1309
1310 ok!(
1311 incoming_binding_expression_get_ok_1,
1312 IncomingBindingExpressionParser,
1313 "(get 9)",
1314 t!("IncomingBindingExpressionGet" 9)
1315 );
1316 err!(
1317 incoming_binding_expression_get_err_1,
1318 IncomingBindingExpressionParser,
1319 "(get)"
1320 );
1321 err!(
1322 incoming_binding_expression_get_err_2,
1323 IncomingBindingExpressionParser,
1324 "(get 1 2)"
1325 );
1326
1327 ok!(
1328 incoming_binding_expression_as_ok_1,
1329 IncomingBindingExpressionParser,
1330 "(as i32 (get 0))",
1331 t!("IncomingBindingExpressionAs"
1332 t!("WasmValType" "i32")
1333 t!("IncomingBindingExpressionGet" 0)
1334 )
1335 );
1336 err!(
1337 incoming_binding_expression_as_err_1,
1338 IncomingBindingExpressionParser,
1339 "(as i32)"
1340 );
1341 err!(
1342 incoming_binding_expression_as_err_2,
1343 IncomingBindingExpressionParser,
1344 "(as (get 1))"
1345 );
1346
1347 ok!(
1348 incoming_binding_expression_alloc_utf8_str_ok_1,
1349 IncomingBindingExpressionParser,
1350 "(alloc-utf8-str malloc (get 0))",
1351 t!("IncomingBindingExpressionAllocUtf8Str"
1352 "malloc"
1353 t!("IncomingBindingExpressionGet" 0)
1354 )
1355 );
1356 err!(
1357 incoming_binding_expression_alloc_utf8_str_err_1,
1358 IncomingBindingExpressionParser,
1359 "(alloc-utf8-str (get 0))"
1360 );
1361 err!(
1362 incoming_binding_expression_alloc_utf8_str_err_2,
1363 IncomingBindingExpressionParser,
1364 "(alloc-utf8-str malloc)"
1365 );
1366
1367 ok!(
1368 incoming_binding_expression_alloc_copy_ok_1,
1369 IncomingBindingExpressionParser,
1370 "(alloc-copy malloc (get 0))",
1371 t!("IncomingBindingExpressionAllocCopy"
1372 "malloc"
1373 t!("IncomingBindingExpressionGet" 0)
1374 )
1375 );
1376 err!(
1377 incoming_binding_expression_alloc_copy_err_1,
1378 IncomingBindingExpressionParser,
1379 "(alloc-copy (get 0))"
1380 );
1381 err!(
1382 incoming_binding_expression_alloc_copy_err_2,
1383 IncomingBindingExpressionParser,
1384 "(alloc-copy malloc)"
1385 );
1386
1387 ok!(
1388 incoming_binding_expression_enum_to_i32_ok_1,
1389 IncomingBindingExpressionParser,
1390 "(enum-to-i32 Blah (get 0))",
1391 t!("IncomingBindingExpressionEnumToI32"
1392 t!("WebidlTypeRefNamed" "Blah")
1393 t!("IncomingBindingExpressionGet" 0)
1394 )
1395 );
1396 err!(
1397 incoming_binding_expression_enum_to_i32_err_1,
1398 IncomingBindingExpressionParser,
1399 "(enum-to-i32 (get 0))"
1400 );
1401 err!(
1402 incoming_binding_expression_enum_to_i32_err_2,
1403 IncomingBindingExpressionParser,
1404 "(enum-to-i32 Blah)"
1405 );
1406
1407 ok!(
1408 incoming_binding_expression_field_ok_1,
1409 IncomingBindingExpressionParser,
1410 "(field 0 (get 1))",
1411 t!("IncomingBindingExpressionField"
1412 0
1413 t!("IncomingBindingExpressionGet" 1)
1414 )
1415 );
1416 err!(
1417 incoming_binding_expression_field_err_1,
1418 IncomingBindingExpressionParser,
1419 "(field (get 1))"
1420 );
1421 err!(
1422 incoming_binding_expression_field_err_2,
1423 IncomingBindingExpressionParser,
1424 "(field 0)"
1425 );
1426
1427 ok!(
1428 incoming_binding_expression_bind_import_ok_1,
1429 IncomingBindingExpressionParser,
1430 "(bind-import hi hello (get 1))",
1431 t!("IncomingBindingExpressionBindImport"
1432 t!("WasmFuncTypeRefNamed" "hi")
1433 t!("BindingRefNamed" "hello")
1434 t!("IncomingBindingExpressionGet" 1)
1435 )
1436 );
1437 err!(
1438 incoming_binding_expression_bind_import_err_1,
1439 IncomingBindingExpressionParser,
1440 "(bind-import hi hello)"
1441 );
1442 err!(
1443 incoming_binding_expression_bind_import_err_2,
1444 IncomingBindingExpressionParser,
1445 "(bind-import hi (get 1))"
1446 );
1447 err!(
1448 incoming_binding_expression_bind_import_err_3,
1449 IncomingBindingExpressionParser,
1450 "(bind-import hello (get 1))"
1451 );
1452
1453 ok!(webidl_index_ok_1, WebidlIndexParser, "42", 42);
1454 ok!(webidl_index_ok_2, WebidlIndexParser, "idx=42", 42);
1455 err!(webidl_index_err_1, WebidlIndexParser, "idx=");
1456}