File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -405,9 +405,11 @@ impl Program {
405
405
} ;
406
406
let class_name = extract_path_ident ( class_name)
407
407
. expect ( "first argument of method must be a bare type" ) ;
408
+ let class_name = wasm. opts . js_class ( ) . map ( Into :: into)
409
+ . unwrap_or_else ( || class_name. to_string ( ) ) ;
408
410
409
411
ImportFunctionKind :: Method {
410
- class : class_name. to_string ( ) ,
412
+ class : class_name,
411
413
ty : class. clone ( ) ,
412
414
kind : MethodKind :: Normal ,
413
415
}
@@ -947,6 +949,16 @@ impl BindgenAttrs {
947
949
} )
948
950
. next ( )
949
951
}
952
+
953
+ fn js_class ( & self ) -> Option < & str > {
954
+ self . attrs
955
+ . iter ( )
956
+ . filter_map ( |a| match a {
957
+ BindgenAttr :: JsClass ( s) => Some ( & s[ ..] ) ,
958
+ _ => None ,
959
+ } )
960
+ . next ( )
961
+ }
950
962
}
951
963
952
964
impl syn:: synom:: Synom for BindgenAttrs {
@@ -977,6 +989,7 @@ pub enum BindgenAttr {
977
989
Structural ,
978
990
Readonly ,
979
991
JsName ( Ident ) ,
992
+ JsClass ( String ) ,
980
993
}
981
994
982
995
impl syn:: synom:: Synom for BindgenAttr {
@@ -1038,6 +1051,13 @@ impl syn::synom::Synom for BindgenAttr {
1038
1051
ns: call!( term2ident) >>
1039
1052
( ns)
1040
1053
) => { BindgenAttr :: JsName }
1054
+ |
1055
+ do_parse!(
1056
+ call!( term, "js_class" ) >>
1057
+ punct!( =) >>
1058
+ s: syn!( syn:: LitStr ) >>
1059
+ ( s. value( ) )
1060
+ ) => { BindgenAttr :: JsClass }
1041
1061
) ) ;
1042
1062
}
1043
1063
You can’t perform that action at this time.
0 commit comments