Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inherit struct visibility on Unity class derive #82

Merged
merged 1 commit into from
Dec 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions asr-derive/src/unity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use syn::{Data, DeriveInput, Expr, ExprLit, Ident, Lit, Meta};
pub fn process(input: TokenStream, mono_module: impl ToTokens) -> TokenStream {
let ast: DeriveInput = syn::parse(input).unwrap();

let vis = ast.vis;

let struct_data = match ast.data {
Data::Struct(s) => s,
_ => panic!("Only structs are supported"),
Expand Down Expand Up @@ -90,14 +92,14 @@ pub fn process(input: TokenStream, mono_module: impl ToTokens) -> TokenStream {
};

quote! {
struct #binding_name {
#vis struct #binding_name {
class: #mono_module::Class,
#static_table_field
#(#field_names: u32,)*
}

impl #struct_name {
async fn bind(
#vis async fn bind(
process: &asr::Process,
module: &#mono_module::Module,
image: &#mono_module::Image,
Expand All @@ -117,11 +119,11 @@ pub fn process(input: TokenStream, mono_module: impl ToTokens) -> TokenStream {
}

impl #binding_name {
fn class(&self) -> &#mono_module::Class {
#vis fn class(&self) -> &#mono_module::Class {
&self.class
}

fn read(&self, process: &asr::Process #maybe_instance_param) -> Result<#struct_name, ()> {
#vis fn read(&self, process: &asr::Process #maybe_instance_param) -> Result<#struct_name, ()> {
Ok(#struct_name {#(
#field_names: #field_reads,
)*})
Expand Down
Loading