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() {
quote! { #native_call }
} else {
quote! {
CallbackInfo::<#args_len>::new(env, cb, None).and_then(|mut cb| {
#(#arg_conversions)*
#native_call
})
}
};
let function_call =
if args_len == 0 && self.fn_self.is_none() && self.kind != FnKind::Constructor {
quote! { #native_call }
} else {
quote! {
CallbackInfo::<#args_len>::new(env, cb, None).and_then(|mut cb| {
#(#arg_conversions)*
#native_call
})
}
};
(quote! {
#(#attrs)*