generate method trait
This commit is contained in:
parent
b4492dbfd5
commit
9ebaf8cd5d
|
@ -644,7 +644,7 @@ pub mod rust {
|
||||||
match find_object(::obfstr::obfstr!("#name")) {
|
match find_object(::obfstr::obfstr!("#name")) {
|
||||||
object @ Some(_) => {object},
|
object @ Some(_) => {object},
|
||||||
None => {
|
None => {
|
||||||
::log::error!("{}", obfstr::obfstr!("static object {#name} not found!"));
|
::log::error!("{}", obfstr::obfstr!("static object #name not found!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -665,6 +665,22 @@ pub mod rust {
|
||||||
StructKind::Struct => self.generate_struct(class, name, ctor)?,
|
StructKind::Struct => self.generate_struct(class, name, ctor)?,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let (method_params, methods) = self.generate_struct_methods(class, &name)?;
|
||||||
|
|
||||||
|
let method_trait = format_ident!("{name}Methods");
|
||||||
|
|
||||||
|
let methods = quote! {
|
||||||
|
#(#method_params)*
|
||||||
|
|
||||||
|
pub trait #method_trait {
|
||||||
|
#(#methods)*
|
||||||
|
}
|
||||||
|
|
||||||
|
impl #method_trait for #name {}
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO: impl super-type fields and methods.
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -675,6 +691,8 @@ pub mod rust {
|
||||||
|
|
||||||
#impls
|
#impls
|
||||||
|
|
||||||
|
#methods
|
||||||
|
|
||||||
#field_trait
|
#field_trait
|
||||||
};
|
};
|
||||||
todo!()
|
todo!()
|
||||||
|
|
Loading…
Reference in a new issue