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

Miscellaneous improvements to archetype reflection #8432

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
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
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
Loading