#[macro_use]
extern crate serde_derive;
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Registry {
#[serde(rename = "$value")] pub elements: Vec<RegistryElement>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "lowercase")]
pub enum RegistryElement {
Notation(Notation),
VendorIds(VendorIds),
Tags(Tags),
Definitions(Definitions),
Constants(Constants),
Enums(Enums),
Commands(Commands),
Features(Features),
Extensions(Extensions),
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct VendorIds {
pub notation: Option<Notation>,
#[serde(rename = "vendorid")] pub elements: Vec<VendorId>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct VendorId {
pub name: String,
pub notation: Option<Notation>,
pub id: HexadecimalNumber,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Tags {
pub notation: Option<Notation>,
#[serde(rename = "tag")] pub elements: Vec<Tag>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Tag {
pub name: String,
pub notation: Option<Notation>,
pub author: String,
pub contact: String,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Definitions {
pub notation: Option<Notation>,
#[serde(rename = "$value")] pub elements: Vec<DefinitionsElement>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "lowercase")]
pub enum DefinitionsElement {
Notation(Notation),
Include(Include),
Typedef(Typedef),
Reference(Reference),
Bitmask(Bitmask),
Struct(Struct),
Union(Union),
Define(Define),
Handle(Handle),
Enumeration(EnumerationDeclaration),
FuncPtr(FunctionPointer),
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Include {
pub name: String,
pub notation: Option<Notation>,
pub style: IncludeStyle,
#[serde(default)]
pub need_ext: bool,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum IncludeStyle {
Quote,
Bracket,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Typedef {
pub name: Identifier,
pub notation: Option<Notation>,
pub basetype: Identifier,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Reference {
pub name: Identifier,
pub notation: Option<Notation>,
pub include: Option<String>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Bitmask {
pub name: Identifier,
pub notation: Option<Notation>,
pub basetype: Identifier,
pub enumref: Option<Identifier>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Define {
pub name: Identifier,
pub notation: Option<Notation>,
#[serde(default, rename = "disabled")]
pub is_disabled: bool,
pub comment: Option<String>,
#[serde(default)]
pub replace: bool,
#[serde(default)]
pub defref: Vec<Identifier>,
#[serde(default, rename = "param")]
pub parameters: Vec<Identifier>,
pub c_expression: Option<String>,
pub value: Option<String>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Handle {
pub name: Identifier,
pub notation: Option<Notation>,
pub parent: Option<CommaSeparatedIdentifiers>,
#[serde(rename = "type")] pub ty: HandleType,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "lowercase")]
pub enum HandleType {
Dispatch,
NoDispatch,
}
#[derive(Deserialize, Serialize, Debug)]
pub enum ReferenceType {
#[serde(rename = "pointer")]
Pointer,
#[serde(rename = "pointer-pointer")]
PointerToPointer,
#[serde(rename = "pointer-const-pointer")]
PointerToConstPointer,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "lowercase")]
pub enum ArrayType {
Dynamic,
Static,
}
pub type ArraySize = String;
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct EnumerationDeclaration {
pub name: Identifier,
pub notation: Option<Notation>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Struct {
pub name: Identifier,
pub notation: Option<Notation>,
#[serde(default)]
pub is_return: bool,
pub extends: Option<CommaSeparatedIdentifiers>,
#[serde(rename = "$value")] pub elements: Vec<StructElement>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum StructElement {
Notation(Notation),
Member(Field),
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Field {
pub name: Option<Identifier>,
pub notation: Option<Notation>,
pub basetype: Identifier,
#[serde(default, rename = "const")]
pub is_const: bool,
#[serde(default, rename = "struct")]
pub is_struct: bool,
pub reference: Option<ReferenceType>,
pub optional: Option<CommaSeparatedBooleans>,
#[serde(default = "bool_true")]
pub auto_validity: bool,
pub sync: Option<String>,
pub type_enums: Option<CommaSeparatedIdentifiers>,
pub array: Option<ArrayType>,
pub size: Option<ArraySize>,
pub size_enumref: Option<Identifier>,
pub c_size: Option<CExpression>,
#[serde(default)]
pub null_terminate: bool,
pub successcodes: Option<CommaSeparatedIdentifiers>,
pub errorcodes: Option<CommaSeparatedIdentifiers>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Union {
pub name: Identifier,
pub notation: Option<Notation>,
#[serde(rename = "member")] pub elements: Vec<Field>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct FunctionPointer {
pub name: Identifier,
pub notation: Option<Notation>,
pub return_type: Field,
#[serde(default)] pub param: Vec<Field>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Constants {
pub notation: Option<Notation>,
#[serde(rename = "constant")] pub elements: Vec<Constant>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Constant {
pub name: String,
pub notation: Option<Notation>,
pub number: Option<i32>,
pub hex: Option<String>,
pub bitpos: Option<u32>,
pub c_expression: Option<CExpression>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Enums {
pub notation: Option<Notation>,
#[serde(rename = "$value")] pub elements: Vec<EnumsElement>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum EnumsElement {
Notation(Notation),
Enumeration(Enumeration),
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Enumeration {
pub name: String,
pub notation: Option<Notation>,
pub purpose: Option<EnumerationPurpose>,
#[serde(default, rename = "$value")] pub elements: Vec<EnumerationElement>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum EnumerationPurpose {
Bitmask,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum EnumerationElement {
Notation(Notation),
Enum(Constant),
#[serde(rename = "unused-range")] UnusedRange(Range),
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Range {
pub range_start: i32,
pub range_end: Option<i32>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Commands {
pub notation: Option<Notation>,
#[serde(rename = "command")] pub elements: Vec<Command>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Command {
pub name: Identifier,
pub notation: Option<Notation>,
pub return_type: Field,
pub param: Vec<Field>,
pub external_sync: Option<ExternalSync>,
pub renderpass: Option<Renderpass>,
pub cmdbufferlevel: Option<CommaSeparatedIdentifiers>,
pub pipeline: Option<Pipeline>,
pub queues: Option<CommaSeparatedIdentifiers>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum Renderpass {
Inside,
Outside,
Both,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum Pipeline {
Graphics,
Compute,
Transfer,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct ExternalSync {
pub sync: String,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Features {
#[serde(rename = "feature")] pub elements: Vec<Feature>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Feature {
pub name: Identifier,
pub notation: Option<Notation>,
pub api: String,
pub version: f32,
pub define: Option<Identifier>,
#[serde(rename = "$value")] pub elements: Vec<FeatureElement>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum FeatureElement {
Notation(Notation),
Require(FeatureSpecification),
Remove(FeatureSpecification),
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct FeatureSpecification {
pub profile: Option<String>,
pub notation: Option<Notation>,
pub extension: Option<Identifier>,
#[serde(rename = "$value")] pub elements: Vec<FeatureReference>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum FeatureReference {
Notation(Notation),
#[serde(rename = "defref")]
DefinitionReference(NamedIdentifier),
#[serde(rename = "commandref")]
CommandReference(NamedIdentifier),
#[serde(rename = "enumref")]
EnumeratorReference(NamedIdentifier),
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Extensions {
pub notation: Option<Notation>,
#[serde(rename = "extension")] pub elements: Vec<Extension>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Extension {
pub name: Identifier,
pub notation: Option<Notation>,
pub number: i32,
#[serde(default)]
pub disabled: bool,
pub match_api: Option<String>,
#[serde(rename = "type")] pub ty: Option<ExtensionType>,
pub define: Option<Identifier>,
pub requires: Option<CommaSeparatedIdentifiers>,
pub author: Option<String>,
pub contact: Option<String>,
#[serde(rename = "$value")] pub elements: Vec<ExtensionElement>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum ExtensionElement {
Notation(Notation),
Require(ExtensionSpecification),
Remove(ExtensionSpecification),
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum ExtensionType {
Instance,
Device,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct ExtensionSpecification {
pub profile: Option<String>,
pub notation: Option<Notation>,
pub extension: Option<Identifier>,
pub api: Option<String>,
#[serde(rename = "$value")] pub elements: Vec<ExtensionSpecificationElement>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum ExtensionSpecificationElement {
Notation(Notation),
#[serde(rename = "defref")]
DefinitionReference(NamedIdentifier),
#[serde(rename = "commandref")]
CommandReference(NamedIdentifier),
#[serde(rename = "enumref")]
EnumeratorReference(NamedIdentifier),
Constant(ExtensionConstant),
Enum(ExtensionEnum),
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct ExtensionConstant {
pub name: Identifier,
pub notation: Option<Notation>,
#[serde(rename = "string")]
pub text: Option<String>,
pub enumref: Option<Identifier>,
pub number: Option<i32>,
pub hex: Option<String>,
pub bitpos: Option<u32>,
pub c_expression: Option<CExpression>,
}
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct ExtensionEnum {
pub name: Identifier,
pub notation: Option<Notation>,
pub offset: Option<usize>,
#[serde(default)]
pub negate: bool,
pub extends: Identifier,
pub number: Option<i32>,
pub hex: Option<String>,
pub bitpos: Option<u32>,
pub c_expression: Option<CExpression>,
}
pub type Identifier = String;
pub type CommaSeparatedIdentifiers = String;
pub type HexadecimalNumber = String;
pub type CommaSeparatedBooleans = String;
pub type CExpression = String;
pub type Notation = String;
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct NamedIdentifier {
pub name: Identifier,
pub notation: Option<Notation>,
}
fn bool_true() -> bool {
true
}