From df4cc0677ba626c8eaa79dfc85c3efa423f778a3 Mon Sep 17 00:00:00 2001 From: Janis Date: Sun, 25 Jun 2023 16:36:22 +0200 Subject: [PATCH] implement super-type fields and methods --- sdk-builder/src/main.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sdk-builder/src/main.rs b/sdk-builder/src/main.rs index 5dd63a9..a172c23 100644 --- a/sdk-builder/src/main.rs +++ b/sdk-builder/src/main.rs @@ -681,6 +681,29 @@ pub mod rust { // TODO: impl super-type fields and methods. + let mut sup = class.super_class; + let super_traits = core::iter::from_fn(|| { + if let Some(key) = sup { + let next = self.sdk.get_object(&key); + sup = next.and_then(|next| next.super_class()); + next + } else { + None + } + }) + .map(|ty| ty.unique_name()) + .map(|super_name| { + let fields = format_ident!("{super_name}Fields"); + let methods = format_ident!("{super_name}Methods"); + + // FIXME: full path here? meaning I need the package name aswell. + + quote! { + impl #fields for #name {} + impl #methods for #name {} + } + }); + quote! { #[repr(transparent)] #[derive(Debug)]