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")) {
|
||||
object @ Some(_) => {object},
|
||||
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)?,
|
||||
};
|
||||
|
||||
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! {
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
|
@ -675,6 +691,8 @@ pub mod rust {
|
|||
|
||||
#impls
|
||||
|
||||
#methods
|
||||
|
||||
#field_trait
|
||||
};
|
||||
todo!()
|
||||
|
|
Loading…
Reference in a new issue