fn generate_napi_code(&self, args: &FunctionArgMetadata) -> TokenStream {


        let input_fn = &self.fn_item;
        let ident_n_api_fn = self.napi_fn_id();

        let mut ctx = FunctionContext {
            is_async: self.is_async(),
            is_multi_threaded: args.is_multi_threaded(),
            name: self.name().to_string(),
            ..Default::default()
        };

        let rust_invocation = self.generate_rust_invocation(args,&mut ctx);
        let rust_args_struct= &ctx.cb_args;

        if args.is_method() {

            // if function is method, we can't put rust function inside our napi because we need to preserver self
            // in the rust method.
            let napi_fn = raw_napi_function_template(
                self.napi_fn_id(), 
                quote! {}, 
                rust_args_struct,
                rust_invocation);

            quote! {
                #input_fn

                #napi_fn
            }
        } else {
           
            // otherwise we can put rust function inside to make it tidy
            raw_napi_function_template(
                ident_n_api_fn, 
                quote! { #input_fn }, 
                rust_args_struct,
                rust_invocation)
        }
    }
/// generate native code to be invoked by napi
generate native code to be invoked by napi
generate native code to be invoked by napi
fn generate_napi_code(&self, args: &FunctionArgMetadata) -> TokenStream {
        let input_fn = &self.fn_item;
        let ident_n_api_fn = self.napi_fn_id();
        let mut ctx = FunctionContext {
            is_async: self.is_async(),
            is_multi_threaded: args.is_multi_threaded(),
            name: self.name().to_string(),
            ..Default::default()
        };
        let rust_invocation = self.generate_rust_invocation(args,&mut ctx);
        let rust_args_struct= &ctx.cb_args;
        if args.is_method() {
            // if function is method, we can't put rust function inside our napi because we need to preserver self
            // in the rust method.
            let napi_fn = raw_napi_function_template(
                self.napi_fn_id(), 
                quote! {}, 
                rust_args_struct,
                rust_invocation);
            quote! {
                #input_fn
                #napi_fn
            }
        } else {
            // otherwise we can put rust function inside to make it tidy
            raw_napi_function_template(
                ident_n_api_fn, 
                quote! { #input_fn }, 
                rust_args_struct,
                rust_invocation)
        }
    }
fn generate_napi_code ( & self , args : & FunctionArgMetadata ) -> TokenStream { let input_fn = & self . fn_item ; let ident_n_api_fn = self . napi_fn_id ( ) ; let mut ctx = FunctionContext { is_async : self . is_async ( ) , is_multi_threaded : args . is_multi_threaded ( ) , name : self . name ( ) . to_string ( ) , .. Default :: default ( ) } ; let rust_invocation = self . generate_rust_invocation ( args , & mut ctx ) ; let rust_args_struct = & ctx . cb_args ; if args . is_method ( ) { // if function is method, we can't put rust function inside our napi because we need to preserver self // in the rust method. let napi_fn = raw_napi_function_template ( self . napi_fn_id ( ) , quote ! { } , rust_args_struct , rust_invocation ) ; quote ! { input_fn napi_fn } } else { // otherwise we can put rust function inside to make it tidy raw_napi_function_template ( ident_n_api_fn , quote ! { input_fn } , rust_args_struct , rust_invocation ) } }
generate native code to be invoked by napi
generate native code to be invoked by napi
&self
args
&FunctionArgMetadata