fix(napi-derive-backend): missing crate prefix
This commit is contained in:
parent
3ae12f7c36
commit
cd7c7a342f
5 changed files with 24 additions and 4 deletions
|
@ -120,9 +120,9 @@ impl NapiStruct {
|
|||
let ty = &field.ty;
|
||||
match &field.name {
|
||||
syn::Member::Named(ident) => fields
|
||||
.push(quote! { #ident: <#ty as FromNapiValue>::from_napi_value(env, cb.get_arg(#i))? }),
|
||||
.push(quote! { #ident: <#ty as napi::bindgen_prelude::FromNapiValue>::from_napi_value(env, cb.get_arg(#i))? }),
|
||||
syn::Member::Unnamed(_) => {
|
||||
fields.push(quote! { <#ty as FromNapiValue>::from_napi_value(env, cb.get_arg(#i))? });
|
||||
fields.push(quote! { <#ty as napi::bindgen_prelude::FromNapiValue>::from_napi_value(env, cb.get_arg(#i))? });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -171,11 +171,15 @@ impl NapiStruct {
|
|||
match &field.name {
|
||||
syn::Member::Named(ident) => {
|
||||
field_destructions.push(quote! { #ident });
|
||||
field_conversions.push(quote! { <#ty as ToNapiValue>::to_napi_value(env, #ident)? });
|
||||
field_conversions.push(
|
||||
quote! { <#ty as napi::bindgen_prelude::ToNapiValue>::to_napi_value(env, #ident)? },
|
||||
);
|
||||
}
|
||||
syn::Member::Unnamed(i) => {
|
||||
field_destructions.push(quote! { arg #i });
|
||||
field_conversions.push(quote! { <#ty as ToNapiValue>::to_napi_value(env, arg #i)? });
|
||||
field_conversions.push(
|
||||
quote! { <#ty as napi::bindgen_prelude::ToNapiValue>::to_napi_value(env, arg #i)? },
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,6 +147,11 @@ Generated by [AVA](https://avajs.dev).
|
|||
static withData(data: string): Context␊
|
||||
method(): string␊
|
||||
}␊
|
||||
export class AnimalWithDefaultConstructor {␊
|
||||
name: string␊
|
||||
kind: number␊
|
||||
constructor(name: string, kind: number)␊
|
||||
}␊
|
||||
export class ClassWithFactory {␊
|
||||
name: string␊
|
||||
static withName(name: string): ClassWithFactory␊
|
||||
|
|
Binary file not shown.
5
examples/napi/index.d.ts
vendored
5
examples/napi/index.d.ts
vendored
|
@ -137,6 +137,11 @@ export class Context {
|
|||
static withData(data: string): Context
|
||||
method(): string
|
||||
}
|
||||
export class AnimalWithDefaultConstructor {
|
||||
name: string
|
||||
kind: number
|
||||
constructor(name: string, kind: number)
|
||||
}
|
||||
export class ClassWithFactory {
|
||||
name: string
|
||||
static withName(name: string): ClassWithFactory
|
||||
|
|
|
@ -114,3 +114,9 @@ impl Context {
|
|||
self.data.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[napi(constructor)]
|
||||
pub struct AnimalWithDefaultConstructor {
|
||||
pub name: String,
|
||||
pub kind: u32,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue