@@ -519,6 +519,8 @@ impl ToTokens for ast::ImportType {
519
519
None => "" ,
520
520
Some ( comment) => comment,
521
521
} ;
522
+ let const_name = format ! ( "__wbg_generated_const_{}" , name) ;
523
+ let const_name = Ident :: new ( & const_name, Span :: call_site ( ) ) ;
522
524
( quote ! {
523
525
#[ allow( bad_style) ]
524
526
#( #attrs) *
@@ -527,84 +529,85 @@ impl ToTokens for ast::ImportType {
527
529
obj: :: wasm_bindgen:: JsValue ,
528
530
}
529
531
530
- impl :: wasm_bindgen:: describe:: WasmDescribe for #name {
531
- fn describe( ) {
532
- :: wasm_bindgen:: JsValue :: describe( ) ;
532
+ #[ allow( bad_style) ]
533
+ const #const_name: ( ) = {
534
+ use wasm_bindgen:: convert:: { IntoWasmAbi , FromWasmAbi , Stack } ;
535
+ use wasm_bindgen:: convert:: { OptionIntoWasmAbi , OptionFromWasmAbi } ;
536
+ use wasm_bindgen:: convert:: RefFromWasmAbi ;
537
+ use wasm_bindgen:: describe:: WasmDescribe ;
538
+ use wasm_bindgen:: { JsValue , JsCast } ;
539
+ use wasm_bindgen:: __rt:: core:: mem:: ManuallyDrop ;
540
+
541
+ impl WasmDescribe for #name {
542
+ fn describe( ) {
543
+ JsValue :: describe( ) ;
544
+ }
533
545
}
534
- }
535
546
536
- impl :: wasm_bindgen:: convert:: IntoWasmAbi for #name {
537
- type Abi = <:: wasm_bindgen:: JsValue as
538
- :: wasm_bindgen:: convert:: IntoWasmAbi >:: Abi ;
547
+ impl IntoWasmAbi for #name {
548
+ type Abi = <JsValue as IntoWasmAbi >:: Abi ;
539
549
540
- fn into_abi( self , extra: & mut :: wasm_bindgen:: convert:: Stack ) -> Self :: Abi {
541
- self . obj. into_abi( extra)
550
+ fn into_abi( self , extra: & mut Stack ) -> Self :: Abi {
551
+ self . obj. into_abi( extra)
552
+ }
542
553
}
543
- }
544
554
545
- impl :: wasm_bindgen :: convert :: OptionIntoWasmAbi for #name {
546
- fn none( ) -> Self :: Abi { 0 }
547
- }
555
+ impl OptionIntoWasmAbi for #name {
556
+ fn none( ) -> Self :: Abi { 0 }
557
+ }
548
558
549
- impl <' a> :: wasm_bindgen :: convert :: OptionIntoWasmAbi for & ' a #name {
550
- fn none( ) -> Self :: Abi { 0 }
551
- }
559
+ impl <' a> OptionIntoWasmAbi for & ' a #name {
560
+ fn none( ) -> Self :: Abi { 0 }
561
+ }
552
562
553
- impl :: wasm_bindgen:: convert:: FromWasmAbi for #name {
554
- type Abi = <:: wasm_bindgen:: JsValue as
555
- :: wasm_bindgen:: convert:: FromWasmAbi >:: Abi ;
563
+ impl FromWasmAbi for #name {
564
+ type Abi = <JsValue as FromWasmAbi >:: Abi ;
556
565
557
- unsafe fn from_abi(
558
- js: Self :: Abi ,
559
- extra: & mut :: wasm_bindgen:: convert:: Stack ,
560
- ) -> Self {
561
- #name {
562
- obj: :: wasm_bindgen:: JsValue :: from_abi( js, extra) ,
566
+ unsafe fn from_abi( js: Self :: Abi , extra: & mut Stack ) -> Self {
567
+ #name {
568
+ obj: JsValue :: from_abi( js, extra) ,
569
+ }
563
570
}
564
571
}
565
- }
566
572
567
- impl :: wasm_bindgen :: convert :: OptionFromWasmAbi for #name {
568
- fn is_none( abi: & Self :: Abi ) -> bool { * abi == 0 }
569
- }
573
+ impl OptionFromWasmAbi for #name {
574
+ fn is_none( abi: & Self :: Abi ) -> bool { * abi == 0 }
575
+ }
570
576
571
- impl <' a> :: wasm_bindgen:: convert:: IntoWasmAbi for & ' a #name {
572
- type Abi = <& ' a :: wasm_bindgen:: JsValue as
573
- :: wasm_bindgen:: convert:: IntoWasmAbi >:: Abi ;
577
+ impl <' a> IntoWasmAbi for & ' a #name {
578
+ type Abi = <& ' a JsValue as IntoWasmAbi >:: Abi ;
574
579
575
- fn into_abi( self , extra: & mut :: wasm_bindgen:: convert:: Stack ) -> Self :: Abi {
576
- ( & self . obj) . into_abi( extra)
580
+ fn into_abi( self , extra: & mut Stack ) -> Self :: Abi {
581
+ ( & self . obj) . into_abi( extra)
582
+ }
577
583
}
578
- }
579
584
580
- impl :: wasm_bindgen:: convert:: RefFromWasmAbi for #name {
581
- type Abi = <:: wasm_bindgen:: JsValue as
582
- :: wasm_bindgen:: convert:: RefFromWasmAbi >:: Abi ;
583
- type Anchor = :: wasm_bindgen:: __rt:: core:: mem:: ManuallyDrop <#name>;
585
+ impl RefFromWasmAbi for #name {
586
+ type Abi = <JsValue as RefFromWasmAbi >:: Abi ;
587
+ type Anchor = ManuallyDrop <#name>;
584
588
585
- unsafe fn ref_from_abi(
586
- js: Self :: Abi ,
587
- extra: & mut :: wasm_bindgen:: convert:: Stack ,
588
- ) -> Self :: Anchor {
589
- let tmp = <:: wasm_bindgen:: JsValue as :: wasm_bindgen:: convert:: RefFromWasmAbi >
590
- :: ref_from_abi( js, extra) ;
591
- :: wasm_bindgen:: __rt:: core:: mem:: ManuallyDrop :: new( #name {
592
- obj: :: wasm_bindgen:: __rt:: core:: mem:: ManuallyDrop :: into_inner( tmp) ,
593
- } )
589
+ unsafe fn ref_from_abi( js: Self :: Abi , extra: & mut Stack ) -> Self :: Anchor {
590
+ let tmp = <JsValue as RefFromWasmAbi >:: ref_from_abi( js, extra) ;
591
+ ManuallyDrop :: new( #name {
592
+ obj: ManuallyDrop :: into_inner( tmp) ,
593
+ } )
594
+ }
594
595
}
595
- }
596
596
597
- impl From <:: wasm_bindgen:: JsValue > for #name {
598
- fn from( obj: :: wasm_bindgen:: JsValue ) -> #name {
599
- #name { obj }
597
+ impl From <JsValue > for #name {
598
+ fn from( obj: JsValue ) -> #name {
599
+ #name { obj }
600
+ }
600
601
}
601
- }
602
602
603
- impl From <#name> for :: wasm_bindgen:: JsValue {
604
- fn from( obj: #name) -> :: wasm_bindgen:: JsValue {
605
- obj. obj
603
+ impl From <#name> for JsValue {
604
+ fn from( obj: #name) -> JsValue {
605
+ obj. obj
606
+ }
606
607
}
607
- }
608
+
609
+ ( )
610
+ } ;
608
611
} ) . to_tokens ( tokens) ;
609
612
}
610
613
}
0 commit comments