1
+ #![ allow( non_snake_case) ]
2
+
1
3
use std:: borrow:: Cow ;
2
4
use std:: ops:: Deref ;
3
5
@@ -16,7 +18,6 @@ use crate::utils::crate_imports::CrateImports;
16
18
fn define_alias_exports < ' a , TIter : Iterator < Item =& ' a FnExportData > > (
17
19
imports : & CrateImports ,
18
20
iter : TIter ,
19
- orig_name : Cow < str > ,
20
21
export_name : & Ident ,
21
22
) -> Vec < TokenStream > {
22
23
let CrateImports { ResultWithError, Environment, FunctionParameters, FunctionReturnValue, .. } = imports;
@@ -98,7 +99,7 @@ fn define_export_for_constructor(
98
99
const THIS_PARAM_NAME : & ' static str = #concat_str!( "this parameter of " , FUNC_NAME ) ;
99
100
let mut drain = params. drain( ..) ;
100
101
let this_val = drain. next( ) . unwrap( ) ;
101
- #( #params_decl_list) * ;
102
+ #( #params_decl_list) *
102
103
let this_obj = #expect_object_fn(
103
104
& this_val,
104
105
|| #Descriptor :: Name ( THIS_PARAM_NAME . into( ) )
@@ -140,7 +141,6 @@ fn define_export_for_member_function(
140
141
let mut iter = fn_dat. exports . iter ( ) ;
141
142
let main_export = iter. next ( ) . expect ( "Expected an export" ) ;
142
143
let orig_name = & fn_dat. signature . ident ;
143
- let orig_name_str = orig_name. to_string ( ) ;
144
144
let export_name = & main_export. export_ident ;
145
145
let first_arg = fn_dat. signature . inputs . first ( ) . expect ( "Expected at-least one argument" ) ;
146
146
let FnArg :: Receiver ( self_param) = first_arg else {
@@ -160,7 +160,6 @@ fn define_export_for_member_function(
160
160
let rest_exports = define_alias_exports (
161
161
& imports,
162
162
iter,
163
- orig_name_str. into ( ) ,
164
163
& export_name,
165
164
) ;
166
165
let res = quote_spanned ! { main_export. attribute. get_span( ) =>
@@ -181,7 +180,7 @@ fn define_export_for_member_function(
181
180
// }
182
181
let mut drain = params. drain( ..) ;
183
182
let this_val = drain. next( ) . unwrap( ) ;
184
- #( #params_decl_list) * ;
183
+ #( #params_decl_list) *
185
184
let this_val_ref = & this_val;
186
185
let result = #native_unwrap_exec_fn:: <#ExpT , _, _, _>(
187
186
& this_val,
@@ -202,7 +201,6 @@ fn define_export_for_member_function(
202
201
fn define_export_for_static_function (
203
202
imports : & CrateImports ,
204
203
ExpT : & TokenStream ,
205
- NATIVE_BOX_WRAP_NAME : & TokenStream ,
206
204
fn_dat : & FunctionData ,
207
205
) -> TokenStream {
208
206
if fn_dat. exports . len ( ) == 0 {
@@ -221,7 +219,6 @@ fn define_export_for_static_function(
221
219
let mut iter = fn_dat. exports . iter ( ) ;
222
220
let main_export = iter. next ( ) . expect ( "Expected an export" ) ;
223
221
let orig_name = & fn_dat. signature . ident ;
224
- let orig_name_str = orig_name. to_string ( ) ;
225
222
let export_name = & main_export. export_ident ;
226
223
let ( params_decl_list, param_names_list) = for_params (
227
224
fn_dat. signature . inputs . iter ( ) . skip ( 1 /*skip ctx*/ ) ,
@@ -232,14 +229,13 @@ fn define_export_for_static_function(
232
229
let rest_exports = define_alias_exports (
233
230
& imports,
234
231
iter,
235
- orig_name_str. into ( ) ,
236
232
& export_name,
237
233
) ;
238
234
let res = quote_spanned ! { main_export. attribute. get_span( ) =>
239
235
pub fn #export_name( env: & mut #Environment , mut params: #FunctionParameters ) ->
240
236
#ResultWithError <#FunctionReturnValue > {
241
237
let mut drain = params. drain( ..) ;
242
- #( #params_decl_list) * ;
238
+ #( #params_decl_list) *
243
239
let result = #ExpT :: #orig_name(
244
240
#NativeClassStaticFunctionContext :: new( env) ,
245
241
#( #param_names_list) , *
@@ -254,7 +250,6 @@ fn define_export_for_static_function(
254
250
fn define_export_for_raw_native_function (
255
251
imports : & CrateImports ,
256
252
ExpT : & TokenStream ,
257
- NATIVE_BOX_WRAP_NAME : & TokenStream ,
258
253
fn_dat : & FunctionData ,
259
254
) -> TokenStream {
260
255
if fn_dat. exports . len ( ) == 0 {
@@ -270,12 +265,10 @@ fn define_export_for_raw_native_function(
270
265
let mut iter = fn_dat. exports . iter ( ) ;
271
266
let main_export = iter. next ( ) . expect ( "Expected an export" ) ;
272
267
let orig_name = & fn_dat. signature . ident ;
273
- let orig_name_str = orig_name. to_string ( ) ;
274
268
let export_name = & main_export. export_ident ;
275
269
let rest_exports = define_alias_exports (
276
270
& imports,
277
271
iter,
278
- orig_name_str. into ( ) ,
279
272
& export_name,
280
273
) ;
281
274
let res = quote_spanned ! { main_export. attribute. get_span( ) =>
@@ -291,8 +284,8 @@ fn define_export_for_raw_native_function(
291
284
292
285
#[ derive( FromMeta , Debug , Default ) ]
293
286
pub ( crate ) struct RootAttributes {
294
- #[ darling( default ) ]
295
- name : Option < String > ,
287
+ // #[darling(default)]
288
+ // name: Option<String>,
296
289
#[ darling( default ) ]
297
290
evilang_lib_crate : Option < Path > ,
298
291
}
@@ -319,7 +312,7 @@ impl TryParseAttribute for ExportAttribute {
319
312
Self {
320
313
export_as : Some ( expr_as_string ( expr) ) ,
321
314
attribute : None ,
322
- raw : false
315
+ raw : false ,
323
316
}
324
317
}
325
318
@@ -390,7 +383,7 @@ impl RootData {
390
383
items : implementation. items . into_iter ( ) . map ( |impl_item| match impl_item {
391
384
ImplItem :: Fn ( f) => {
392
385
// dbg!(&f.attrs);
393
- let ( mut exports_iter, attrs_iter) =
386
+ let ( exports_iter, attrs_iter) =
394
387
f. attrs
395
388
. into_iter ( )
396
389
. map ( ExportAttribute :: try_parse_attribute)
@@ -418,14 +411,13 @@ impl RootData {
418
411
} , implementation)
419
412
}
420
413
421
- #[ allow( non_snake_case) ]
422
- pub fn generate_implementation ( mut self ) -> TokenStream {
414
+ pub fn generate_implementation ( self ) -> TokenStream {
423
415
let module = self . attributes . evilang_lib_crate
424
416
. as_ref ( )
425
417
. map ( Path :: to_token_stream)
426
418
. unwrap_or_else ( || quote ! { :: #MODULE_NAME } ) ;
427
419
let imports = CrateImports :: new ( module) ;
428
- let CrateImports { ResultWithError, Descriptor , ErrorT , EvilangError , RuntimeError , Environment, GcPtrToObject, PrimitiveValue, expect_object_fn , FunctionReturnValue , FunctionParameters , concat_str, INativeClass, INativeClass_BuildClass, from_option_of_primitive_value , NativeClassMemberFunctionContext , native_wrap , native_unwrap_exec_fn , Some_ , None_ , Err_ , Ok_, gc_ptr_cell_from, RuntimeObject, VariablesMap, HashMap, INativeClass_IsStructWrapper, .. } = & imports;
420
+ let CrateImports { ResultWithError, Environment, GcPtrToObject, PrimitiveValue, concat_str, INativeClass, INativeClass_BuildClass, Ok_, gc_ptr_cell_from, RuntimeObject, VariablesMap, HashMap, INativeClass_IsStructWrapper, .. } = & imports;
429
421
let SelfT = & self . self_ty ;
430
422
let ExpT = quote ! { super :: #SelfT } ;
431
423
let Self_exports = str_concat_token_stream (
@@ -490,14 +482,12 @@ impl RootData {
490
482
return define_export_for_raw_native_function (
491
483
& imports,
492
484
& ExpT ,
493
- & NATIVE_BOX_WRAP_NAME ,
494
485
func,
495
486
) ;
496
487
}
497
488
return define_export_for_static_function (
498
489
& imports,
499
490
& ExpT ,
500
- & NATIVE_BOX_WRAP_NAME ,
501
491
func,
502
492
) ;
503
493
} ;
@@ -513,9 +503,9 @@ impl RootData {
513
503
}
514
504
impl #INativeClass_BuildClass for #SelfT {
515
505
fn build_class( env: & mut #Environment ) -> #ResultWithError <#GcPtrToObject > {
516
- #Ok_ ( #RuntimeObject :: new_gc( #VariablesMap :: new_direct( #HashMap :: from( [
506
+ return #Ok_ ( #RuntimeObject :: new_gc( #VariablesMap :: new_direct( #HashMap :: from( [
517
507
#( #export_tuples_for_functions) , *
518
- ] ) ) , <#SelfT as #INativeClass >:: get_parent_class( env) ?, <#SelfT as #INativeClass >:: NAME . into( ) ) )
508
+ ] ) ) , <#SelfT as #INativeClass >:: get_parent_class( env) ?, <#SelfT as #INativeClass >:: NAME . into( ) ) ) ;
519
509
}
520
510
}
521
511
#[ allow( non_snake_case) ]
0 commit comments