Skip to content

Commit

Permalink
analysis: Add XML parsing support for external types
Browse files Browse the repository at this point in the history
These are types either from C itself, or from another Vulkan library,
which are referenced in this XML file.
  • Loading branch information
Friz64 committed Apr 20, 2023
1 parent 7dddad9 commit d0dea6f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions analysis/src/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ fn api_matches(node: &Node, expected: &str) -> bool {
/// Raw representation of Vulkan XML files (`vk.xml`, `video.xml`).
#[derive(Debug, Default)]
pub struct Registry {
pub externals: Vec<External>,
pub basetypes: Vec<BaseType>,
pub bitmask_types: Vec<BitMaskType>,
pub bitmask_aliases: Vec<Alias>,
Expand Down Expand Up @@ -127,6 +128,9 @@ impl Registry {
Some("union") => {
registry.unions.push(Structure::from_node(type_node, api));
}
None => {
registry.externals.push(External::from_node(type_node));
}
_ => (),
}
}
Expand Down Expand Up @@ -213,6 +217,21 @@ impl Alias {
}
}

#[derive(Debug)]
pub struct External {
pub name: XmlStr,
pub requires: Option<XmlStr>,
}

impl External {
fn from_node(node: Node) -> External {
External {
name: attribute(node, "name").unwrap(),
requires: attribute(node, "requires"),
}
}
}

#[derive(Debug)]
pub struct BaseType {
pub name: XmlStr,
Expand Down

0 comments on commit d0dea6f

Please sign in to comment.