-
Notifications
You must be signed in to change notification settings - Fork 15
Closed
Description
Hi.
I was tinkering around with the new sub_elements_spec interface from DanielT/autosar-data-py#8 and noticed some unexpected results. It isn't related to the bindings though. I reproduced the issue with rust too.
So I'm trying to visit the ElementType for every ElementName (except adaptive) ... I noticed that at least one ElementName (maybe there is more) was never encountered. It's TARGET-REQUIRED-OPERATION-REF.
But it becomes even more strange ... If I remove the std_restriction condition (marked with THISONE) both types I'm checking for are not encountered.
Am I doing something wrong?
Example:
use autosar_data::*;
use autosar_data_specification::{ElementType, StdRestrict};
static PROVIDED: &str = "TARGET-PROVIDED-OPERATION-REF";
static REQUIRED: &str = "TARGET-REQUIRED-OPERATION-REF";
fn main() {
let mut seen: Vec<&str> = Vec::new();
let m = AutosarModel::new();
let _ = m.create_file("dummy", AutosarVersion::Autosar_00048);
let root = m.root_element();
let root_name = root.element_name();
let root_type = root.element_type();
visit(&mut seen, &root_name, &root_type);
println!("\n{}", seen.len());
if seen.contains(&PROVIDED) {
println!(" seen {}", PROVIDED); // only seen with std_restriction
}
if seen.contains(&REQUIRED) {
println!(" seen {}", REQUIRED); // never seen
}
}
fn visit(seen: &mut Vec<&str>, e: &ElementName, et: &ElementType) {
let name = e.to_str();
if seen.contains(&name) {
return;
}
seen.push(name);
for (n, t, _, _) in et.sub_element_spec_iter() {
if t.std_restriction() != StdRestrict::AdaptivePlatform { // THISONE
visit(seen, &n, &t);
}
}
}Metadata
Metadata
Assignees
Labels
No labels