@@ -64,12 +64,6 @@ impl TryToTokens for ast::Program {
64
64
for e in self . enums . iter ( ) {
65
65
e. to_tokens ( tokens) ;
66
66
}
67
- for c in self . consts . iter ( ) {
68
- c. to_tokens ( tokens) ;
69
- }
70
- for d in self . dictionaries . iter ( ) {
71
- d. to_tokens ( tokens) ;
72
- }
73
67
74
68
Diagnostic :: from_vec ( errors) ?;
75
69
@@ -1211,157 +1205,6 @@ impl ToTokens for ast::ImportStatic {
1211
1205
}
1212
1206
}
1213
1207
1214
- impl ToTokens for ast:: ConstValue {
1215
- fn to_tokens ( & self , tokens : & mut TokenStream ) {
1216
- use crate :: ast:: ConstValue :: * ;
1217
-
1218
- match self {
1219
- BooleanLiteral ( false ) => quote ! ( false ) ,
1220
- BooleanLiteral ( true ) => quote ! ( true ) ,
1221
- // the actual type is unknown because of typedefs
1222
- // so we cannot use std::fxx::INFINITY
1223
- // but we can use type inference
1224
- FloatLiteral ( f) if f. is_infinite ( ) && f. is_sign_positive ( ) => quote ! ( 1.0 / 0.0 ) ,
1225
- FloatLiteral ( f) if f. is_infinite ( ) && f. is_sign_negative ( ) => quote ! ( -1.0 / 0.0 ) ,
1226
- FloatLiteral ( f) if f. is_nan ( ) => quote ! ( 0.0 / 0.0 ) ,
1227
- // again no suffix
1228
- // panics on +-inf, nan
1229
- FloatLiteral ( f) => {
1230
- let f = Literal :: f64_suffixed ( * f) ;
1231
- quote ! ( #f)
1232
- }
1233
- SignedIntegerLiteral ( i) => {
1234
- let i = Literal :: i64_suffixed ( * i) ;
1235
- quote ! ( #i)
1236
- }
1237
- UnsignedIntegerLiteral ( i) => {
1238
- let i = Literal :: u64_suffixed ( * i) ;
1239
- quote ! ( #i)
1240
- }
1241
- Null => unimplemented ! ( ) ,
1242
- } . to_tokens ( tokens)
1243
- }
1244
- }
1245
-
1246
- impl ToTokens for ast:: Const {
1247
- fn to_tokens ( & self , tokens : & mut TokenStream ) {
1248
- let vis = & self . vis ;
1249
- let name = & self . name ;
1250
- let ty = & self . ty ;
1251
- let value = & self . value ;
1252
-
1253
- let declaration = quote ! ( #vis const #name: #ty = #value as #ty; ) ;
1254
-
1255
- if let Some ( class) = & self . class {
1256
- ( quote ! {
1257
- impl #class {
1258
- #declaration
1259
- }
1260
- } )
1261
- . to_tokens ( tokens) ;
1262
- } else {
1263
- declaration. to_tokens ( tokens) ;
1264
- }
1265
- }
1266
- }
1267
-
1268
- impl ToTokens for ast:: Dictionary {
1269
- fn to_tokens ( & self , tokens : & mut TokenStream ) {
1270
- let name = & self . name ;
1271
- let vis = & self . vis ;
1272
- let mut methods = TokenStream :: new ( ) ;
1273
- for field in self . fields . iter ( ) {
1274
- field. to_tokens ( & mut methods) ;
1275
- }
1276
- let required_names = & self
1277
- . fields
1278
- . iter ( )
1279
- . filter ( |f| f. required )
1280
- . map ( |f| & f. rust_name )
1281
- . collect :: < Vec < _ > > ( ) ;
1282
- let required_types = & self
1283
- . fields
1284
- . iter ( )
1285
- . filter ( |f| f. required )
1286
- . map ( |f| & f. ty )
1287
- . collect :: < Vec < _ > > ( ) ;
1288
- let required_names2 = required_names;
1289
- let required_names3 = required_names;
1290
- let doc_comment = match & self . doc_comment {
1291
- None => "" ,
1292
- Some ( doc_string) => doc_string,
1293
- } ;
1294
-
1295
- let ctor = match & self . constructor {
1296
- Some ( ctor) => {
1297
- let attrs = & ctor. rust_attrs ;
1298
-
1299
- let doc_comment = match & ctor. doc_comment {
1300
- None => "" ,
1301
- Some ( doc_string) => doc_string,
1302
- } ;
1303
-
1304
- quote ! {
1305
- #( #attrs) *
1306
- #[ doc = #doc_comment]
1307
- pub fn new( #( #required_names: #required_types) , * ) -> #name {
1308
- let mut ret: #name = :: js_sys:: Object :: new( ) . into( ) ;
1309
- #( ret. #required_names2( #required_names3) ; ) *
1310
- ret
1311
- }
1312
- }
1313
- } ,
1314
- None => quote ! { } ,
1315
- } ;
1316
-
1317
- ( quote ! {
1318
- #[ wasm_bindgen]
1319
- extern "C" {
1320
- #[ wasm_bindgen( extends = :: js_sys:: Object ) ]
1321
- #[ doc = #doc_comment]
1322
- #[ derive( Clone , Debug ) ]
1323
- #vis type #name;
1324
- }
1325
-
1326
- #[ allow( clippy:: all) ]
1327
- impl #name {
1328
- #ctor
1329
- #methods
1330
- }
1331
- } )
1332
- . to_tokens ( tokens) ;
1333
- }
1334
- }
1335
-
1336
- impl ToTokens for ast:: DictionaryField {
1337
- fn to_tokens ( & self , tokens : & mut TokenStream ) {
1338
- let attrs = & self . rust_attrs ;
1339
- let rust_name = & self . rust_name ;
1340
- let js_name = & self . js_name ;
1341
- let ty = & self . ty ;
1342
- let doc_comment = match & self . doc_comment {
1343
- None => "" ,
1344
- Some ( doc_string) => doc_string,
1345
- } ;
1346
- ( quote ! {
1347
- #( #attrs) *
1348
- #[ allow( clippy:: all) ]
1349
- #[ doc = #doc_comment]
1350
- pub fn #rust_name( & mut self , val: #ty) -> & mut Self {
1351
- use wasm_bindgen:: JsValue ;
1352
- let r = :: js_sys:: Reflect :: set(
1353
- self . as_ref( ) ,
1354
- & JsValue :: from( #js_name) ,
1355
- & JsValue :: from( val) ,
1356
- ) ;
1357
- debug_assert!( r. is_ok( ) , "setting properties should never fail on our dictionary objects" ) ;
1358
- let _ = r;
1359
- self
1360
- }
1361
- } ) . to_tokens ( tokens) ;
1362
- }
1363
- }
1364
-
1365
1208
/// Emits the necessary glue tokens for "descriptor", generating an appropriate
1366
1209
/// symbol name as well as attributes around the descriptor function itself.
1367
1210
struct Descriptor < ' a , T > {
0 commit comments