fix(napi-derive-backend): always generate CallContext for constructor function

This commit is contained in:
LongYinan 2021-10-28 18:11:06 +08:00
parent d08f9b03e0
commit 813d671d76

View file

@ -39,16 +39,17 @@ impl TryToTokens for NapiFn {
} }
}; };
let function_call = if args_len == 0 && self.fn_self.is_none() { let function_call =
quote! { #native_call } if args_len == 0 && self.fn_self.is_none() && self.kind != FnKind::Constructor {
} else { quote! { #native_call }
quote! { } else {
CallbackInfo::<#args_len>::new(env, cb, None).and_then(|mut cb| { quote! {
#(#arg_conversions)* CallbackInfo::<#args_len>::new(env, cb, None).and_then(|mut cb| {
#native_call #(#arg_conversions)*
}) #native_call
} })
}; }
};
(quote! { (quote! {
#(#attrs)* #(#attrs)*