Skip to content

Commit

Permalink
improved reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Dec 12, 2024
1 parent e1aea95 commit b334cf5
Show file tree
Hide file tree
Showing 3 changed files with 755 additions and 661 deletions.
12 changes: 11 additions & 1 deletion crates/build/re_types_builder/src/codegen/rust/reflection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ fn generate_archetype_reflection(reporter: &Reporter, objects: &Objects) -> Toke
let Some(component_name) = field.typ.fqname() else {
panic!("archetype field must be an object/union or an array/vector of such")
};
let name = &field.name;
let display_name = re_case::to_human_case(&field.name);
let docstring_md = doc_as_lines(
reporter,
Expand All @@ -193,8 +194,9 @@ fn generate_archetype_reflection(reporter: &Reporter, objects: &Objects) -> Toke

quote! {
ArchetypeFieldReflection {
component_name: #component_name.into(),
name: #name,
display_name: #display_name,
component_name: #component_name.into(),
docstring_md: #docstring_md,
is_required: #required,
}
Expand All @@ -220,6 +222,12 @@ fn generate_archetype_reflection(reporter: &Reporter, objects: &Objects) -> Toke
.join("\n");
}

let scope = if let Some(scope) = obj.scope() {
quote!(Some(#scope))
} else {
quote!(None)
};

let quoted_view_types = obj
.archetype_view_types()
.unwrap_or_default()
Expand All @@ -234,6 +242,8 @@ fn generate_archetype_reflection(reporter: &Reporter, objects: &Objects) -> Toke
ArchetypeReflection {
display_name: #display_name,

scope: #scope,

view_types: &[
#(#quoted_view_types,)*
],
Expand Down
Loading

0 comments on commit b334cf5

Please sign in to comment.