Skip to content

Commit

Permalink
reject unexpected elements
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscorn committed Jan 3, 2024
1 parent 0715f7e commit 1eaa5f8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 12 additions & 1 deletion nusamai-citygml/macros/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn generate_citygml_impl_for_struct(
let struct_ident = &derive_input.ident;
let mut typename = String::from(stringify!(derive_input.ident));
let mut ty = StereoType::Feature;
let mut allow_extra = true; // FIXME
let mut allow_extra = false;

for attr in &derive_input.attrs {
if !attr.path().is_ident(CITYGML_ATTR_IDENT) {
Expand Down Expand Up @@ -202,6 +202,17 @@ fn generate_citygml_impl_for_struct(
Some(self.#field_ident)
};

Ok(())
} else if meta.path.is_ident("generics") {
chlid_arms.push(quote! {
b"gen:dateAttribute" => st.skip_current_element(),
b"gen:doubleAttribute" => st.skip_current_element(),
b"gen:genericAttributeSet" => st.skip_current_element(),
b"gen:intAttribute" => st.skip_current_element(),
b"gen:measureAttribute" => st.skip_current_element(),
b"gen:stringAttribute" => st.skip_current_element(),
b"gen:uriAttribute" => st.skip_current_element(),
});
Ok(())
} else {
Err(meta.error("unrecognized argument"))

Check warning on line 218 in nusamai-citygml/macros/src/derive.rs

View check run for this annotation

Codecov / codecov/patch

nusamai-citygml/macros/src/derive.rs#L218

Added line #L218 was not covered by tests
Expand Down
8 changes: 8 additions & 0 deletions nusamai-citygml/macros/src/type_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ fn modify(ty: &StereoType, args: &FeatureArgs, input: &mut DeriveInput) -> Resul
pub valid_to: Option<nusamai_citygml::Date> // TODO: DateTime (CityGML 3.0)
},
);
// TODO: not implemented yet
add_named_field(
fields,
quote! {
#[citygml(generics)]
pub generic_attribute: Option<i32> // FIXME:
},
);
}
}
}
Expand Down

0 comments on commit 1eaa5f8

Please sign in to comment.