writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
pub const MAGIC_NUMBER: u32 = #magic_number;
pub const MAJOR_VERSION: u32 = #major_version;
pub const MINOR_VERSION: u32 = #minor_version;
new_combined_id(&[kind.as_ref(), &enumerant.enumerant], CamelCase);
let enumerant_parse_operation;
if enumerant.parameters.is_empty() {
- enumerant_items.push(quote!{
+ enumerant_items.push(quote! {
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash)]
pub struct #type_name;
});
- enumerant_parse_operation = quote!{(Some(#type_name), words)};
- enumerant_display_mask_operations.push(quote!{
+ enumerant_parse_operation = quote! {(Some(#type_name), words)};
+ enumerant_display_mask_operations.push(quote! {
if self.#member_name.is_some() {
if any_members {
write!(f, "|{}", #enumerant_name)?;
}
}
});
- enumerant_display_operations.push(quote!{});
+ enumerant_display_operations.push(quote! {});
} else {
let mut enumerant_parameter_declarations = Vec::new();
let mut enumerant_parameter_names = Vec::new();
for (index, parameter) in enumerant.parameters.iter().enumerate() {
let name = new_id(format!("parameter_{}", index), SnakeCase);
let kind = new_id(¶meter.kind, CamelCase);
- enumerant_parameter_declarations.push(quote!{
+ enumerant_parameter_declarations.push(quote! {
pub #kind,
});
- enumerant_parameter_names.push(quote!{
+ enumerant_parameter_names.push(quote! {
#name,
});
- parse_enumerant_members.push(quote!{
+ parse_enumerant_members.push(quote! {
let (#name, words) = #kind::spirv_parse(words, parse_state)?;
});
- display_enumerant_members.push(quote!{
+ display_enumerant_members.push(quote! {
#name.spirv_display(f)?;
});
}
- enumerant_items.push(quote!{
+ enumerant_items.push(quote! {
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash)]
pub struct #type_name(#(#enumerant_parameter_declarations)*);
});
let enumerant_parameter_names = &enumerant_parameter_names;
- enumerant_parse_operation = quote!{
+ enumerant_parse_operation = quote! {
#(#parse_enumerant_members)*
(Some(#type_name(#(#enumerant_parameter_names)*)), words)
};
- enumerant_display_mask_operations.push(quote!{
+ enumerant_display_mask_operations.push(quote! {
if self.#member_name.is_some() {
if any_members {
write!(f, "|{}", #enumerant_name)?;
}
});
};
- enumerant_members.push(quote!{
+ enumerant_members.push(quote! {
pub #member_name: Option<#type_name>
});
let enumerant_value = enumerant.value;
- enumerant_parse_operations.push(quote!{
+ enumerant_parse_operations.push(quote! {
let (#member_name, words) = if (mask & #enumerant_value) != 0 {
mask &= !#enumerant_value;
#enumerant_parse_operation
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash)]
pub struct #kind_id {
#(#enumerant_members),*
#(#enumerant_items)*
}
)?;
- let parse_body = quote!{
+ let parse_body = quote! {
let (mut mask, words) = u32::spirv_parse(words, parse_state)?;
#(#enumerant_parse_operations)*
if mask != 0 {
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
impl SPIRVParse for #kind_id {
fn spirv_parse<'a>(
words: &'a [u32],
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
impl SPIRVDisplay for #kind_id {
fn spirv_display(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut any_members = false;
let enumerant_value = enumerant.value;
let display_name = &enumerant.enumerant;
if enumerant.parameters.is_empty() {
- generated_enumerants.push(quote!{#name});
- enumerant_parse_cases.push(quote!{
+ generated_enumerants.push(quote! {#name});
+ enumerant_parse_cases.push(quote! {
#enumerant_value => Ok((#kind_id::#name, words)),
});
- enumerant_display_cases.push(quote!{
+ enumerant_display_cases.push(quote! {
#kind_id::#name => write!(f, " {}", #display_name),
});
} else {
for parameter in enumerant.parameters.iter() {
let name = new_id(parameter.name.as_ref().unwrap(), SnakeCase);
let kind = new_id(¶meter.kind, CamelCase);
- enumerant_member_declarations.push(quote!{
+ enumerant_member_declarations.push(quote! {
#name: #kind,
});
- enumerant_member_names.push(quote!{
+ enumerant_member_names.push(quote! {
#name,
});
- parse_enumerant_members.push(quote!{
+ parse_enumerant_members.push(quote! {
let (#name, words) = #kind::spirv_parse(words, parse_state)?;
});
- display_enumerant_members.push(quote!{
+ display_enumerant_members.push(quote! {
#name.spirv_display(f)?;
});
}
- generated_enumerants.push(quote!{
+ generated_enumerants.push(quote! {
#name {
#(#enumerant_member_declarations)*
}
});
let enumerant_member_names = &enumerant_member_names;
- enumerant_parse_cases.push(quote!{
+ enumerant_parse_cases.push(quote! {
#enumerant_value => {
#(#parse_enumerant_members)*
Ok((#kind_id::#name {
}, words))
},
});
- enumerant_display_cases.push(quote!{
+ enumerant_display_cases.push(quote! {
#kind_id::#name {
#(#enumerant_member_names)*
} => {
}
}
let mut derives = vec![
- quote!{Clone},
- quote!{Debug},
- quote!{Eq},
- quote!{PartialEq},
- quote!{Hash},
+ quote! {Clone},
+ quote! {Debug},
+ quote! {Eq},
+ quote! {PartialEq},
+ quote! {Hash},
];
if !has_any_parameters {
- derives.push(quote!{Copy});
+ derives.push(quote! {Copy});
}
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
#[derive(#(#derives),*)]
pub enum #kind_id {
#(#generated_enumerants,)*
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
impl SPIRVParse for #kind_id {
fn spirv_parse<'a>(
words: &'a [u32],
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
impl SPIRVDisplay for #kind_id {
fn spirv_display(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
}
ast::OperandKind::Id { kind, .. } => {
let base = if *kind == ast::Kind::IdRef {
- quote!{u32}
+ quote! {u32}
} else {
- quote!{IdRef}
+ quote! {IdRef}
};
let kind_id = new_id(kind, CamelCase);
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug, Default)]
#[repr(transparent)]
pub struct #kind_id(pub #base);
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
impl SPIRVParse for #kind_id {
fn spirv_parse<'a>(
words: &'a [u32],
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
impl fmt::Display for #kind_id {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
impl SPIRVDisplay for #kind_id {
fn spirv_display(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.0.spirv_display(f)
| ast::LiteralKind::LiteralContextDependentNumber => unreachable!(),
ast::LiteralKind::LiteralInteger32
| ast::LiteralKind::LiteralContextDependentNumber32 => {
- quote!{pub type #kind_id = u32;}
+ quote! {pub type #kind_id = u32;}
}
ast::LiteralKind::LiteralInteger64
| ast::LiteralKind::LiteralContextDependentNumber64 => {
- quote!{pub type #kind_id = u64;}
+ quote! {pub type #kind_id = u64;}
}
- ast::LiteralKind::LiteralString => quote!{pub type #kind_id = String;},
+ ast::LiteralKind::LiteralString => quote! {pub type #kind_id = String;},
ast::LiteralKind::LiteralExtInstInteger => {
- quote!{pub type #kind_id = u32;}
+ quote! {pub type #kind_id = u32;}
}
ast::LiteralKind::LiteralSpecConstantOpInteger => continue,
}
ast::OperandKind::Composite { kind, bases } => {
let kind = new_id(kind, CamelCase);
let bases = bases.iter().map(|base| new_id(base, CamelCase));
- writeln!(&mut out, "{}", quote!{pub type #kind = (#(#bases),*);})?;
+ writeln!(&mut out, "{}", quote! {pub type #kind = (#(#bases),*);})?;
}
}
}
let kind = new_id(&operand.kind, CamelCase);
let name = new_id(operand.name.as_ref().unwrap(), SnakeCase);
let kind = match &operand.quantifier {
- None => quote!{#kind},
- Some(ast::Quantifier::Optional) => quote!{Option<#kind>},
- Some(ast::Quantifier::Variadic) => quote!{Vec<#kind>},
+ None => quote! {#kind},
+ Some(ast::Quantifier::Optional) => quote! {Option<#kind>},
+ Some(ast::Quantifier::Variadic) => quote! {Vec<#kind>},
};
- fields.push(quote!{#name: #kind});
+ fields.push(quote! {#name: #kind});
}
- let instruction_extension_enumerant = quote!{
+ let instruction_extension_enumerant = quote! {
#instruction_enumerant_name {
id_result_type: IdResultType,
id_result: IdResult,
let kind = new_id(&operand.kind, CamelCase);
let name = new_id(operand.name.as_ref().unwrap(), SnakeCase);
let kind = match operand.quantifier {
- None => quote!{#kind},
- Some(ast::Quantifier::Optional) => quote!{Option::<#kind>},
- Some(ast::Quantifier::Variadic) => quote!{Vec::<#kind>},
+ None => quote! {#kind},
+ Some(ast::Quantifier::Optional) => quote! {Option::<#kind>},
+ Some(ast::Quantifier::Variadic) => quote! {Vec::<#kind>},
};
- parse_operations.push(quote!{
+ parse_operations.push(quote! {
let (#name, words) = #kind::spirv_parse(words, parse_state)?;
});
- display_operations.push(quote!{
+ display_operations.push(quote! {
#name.spirv_display(f)?;
});
operand_names.push(name);
}
let operand_names = &operand_names;
- let body = quote!{
+ let body = quote! {
#(#parse_operations)*
if words.is_empty() {
Ok(Instruction::#instruction_enumerant_name {
Err(Error::InstructionTooLong)
}
};
- let instruction_extension_parse_case = quote!{
+ let instruction_extension_parse_case = quote! {
(ExtensionInstructionSet::#extension_instruction_set, #opcode) => {
#body
}
};
instruction_extension_parse_cases.push(instruction_extension_parse_case);
let display_opname = &instruction.opname;
- let instruction_extension_display_case = quote!{
+ let instruction_extension_display_case = quote! {
Instruction::#instruction_enumerant_name {
id_result_type,
id_result,
let instruction_display_case;
match &instruction.opname {
ast::InstructionName::OpExtInstImport => {
- let body = quote!{
+ let body = quote! {
parse_state.define_id(
id_result,
IdState::ExtensionInstructionSet(ExtensionInstructionSet::from(&*name)),
Err(Error::InstructionTooLong)
}
};
- instruction_parse_case = quote!{#opcode => {
+ instruction_parse_case = quote! {#opcode => {
let (id_result, words) = IdResult::spirv_parse(words, parse_state)?;
let (name, words) = LiteralString::spirv_parse(words, parse_state)?;
#body
}};
- instruction_display_case = quote!{
+ instruction_display_case = quote! {
Instruction::ExtInstImport { id_result, name } => {
writeln!(f, "{}{} {:?}", InstructionIndentAndResult(Some(*id_result)), #display_opname, name)
}
};
}
ast::InstructionName::OpExtInst => {
- let body = quote!{
+ let body = quote! {
let extension_instruction_set;
match parse_state.id_states[set.0 as usize].clone() {
IdState::ExtensionInstructionSet(ExtensionInstructionSet::Other(_)) => {
(extension_instruction_set, instruction) => Err(Error::UnknownExtensionOpcode(extension_instruction_set, instruction)),
}
};
- instruction_parse_case = quote!{
+ instruction_parse_case = quote! {
#opcode => {
let (id_result_type, words) = IdResultType::spirv_parse(words, parse_state)?;
let (id_result, words) = IdResult::spirv_parse(words, parse_state)?;
#body
}
};
- instruction_display_case = quote!{
+ instruction_display_case = quote! {
Instruction::ExtInst {
id_result_type,
id_result,
};
}
ast::InstructionName::OpTypeInt => {
- let body = quote!{
+ let body = quote! {
let (signedness, words) = LiteralInteger32::spirv_parse(words, parse_state)?;
let id_state = match width {
8 | 16 | 32 => IdState::Type(IdStateType(BitWidth::Width32OrLess)),
Err(Error::InstructionTooLong)
}
};
- instruction_parse_case = quote!{
+ instruction_parse_case = quote! {
#opcode => {
let (id_result, words) = IdResult::spirv_parse(words, parse_state)?;
let (width, words) = LiteralInteger32::spirv_parse(words, parse_state)?;
#body
}
};
- instruction_display_case = quote!{
+ instruction_display_case = quote! {
Instruction::TypeInt {
id_result,
width,
};
}
ast::InstructionName::OpTypeFloat => {
- instruction_parse_case = quote!{
+ instruction_parse_case = quote! {
#opcode => {
let (id_result, words) = IdResult::spirv_parse(words, parse_state)?;
let (width, words) = LiteralInteger32::spirv_parse(words, parse_state)?;
}
}
};
- instruction_display_case = quote!{
+ instruction_display_case = quote! {
Instruction::TypeFloat { id_result, width } => {
write!(
f,
};
}
ast::InstructionName::OpSwitch32 => {
- let body32 = quote!{
+ let body32 = quote! {
IdState::Value(IdStateValue(BitWidth::Width32OrLess)) => {
let (target, words) = Vec::<PairLiteralInteger32IdRef>::spirv_parse(words, parse_state)?;
if words.is_empty() {
}
}
};
- let body64 = quote!{
+ let body64 = quote! {
IdState::Value(IdStateValue(BitWidth::Width64)) => {
let (target, words) = Vec::<PairLiteralInteger64IdRef>::spirv_parse(words, parse_state)?;
if words.is_empty() {
}
}
};
- instruction_parse_case = quote!{
+ instruction_parse_case = quote! {
#opcode => {
let (selector, words) = IdRef::spirv_parse(words, parse_state)?;
let (default, words) = IdRef::spirv_parse(words, parse_state)?;
}
}
};
- instruction_display_case = quote!{
+ instruction_display_case = quote! {
Instruction::Switch32 {
selector,
default,
};
}
ast::InstructionName::OpSwitch64 => {
- instruction_parse_case = quote!{};
- instruction_display_case = quote!{};
+ instruction_parse_case = quote! {};
+ instruction_display_case = quote! {};
}
ast::InstructionName::OpConstant32 => {
- let body32 = quote!{
+ let body32 = quote! {
IdStateType(BitWidth::Width32OrLess) => {
let (value, words) = LiteralContextDependentNumber32::spirv_parse(words, parse_state)?;
if words.is_empty() {
}
}
};
- let body64 = quote!{
+ let body64 = quote! {
IdStateType(BitWidth::Width64) => {
let (value, words) = LiteralContextDependentNumber64::spirv_parse(words, parse_state)?;
if words.is_empty() {
}
}
};
- instruction_parse_case = quote!{
+ instruction_parse_case = quote! {
#opcode => {
let (id_result_type, words) = IdResultType::spirv_parse(words, parse_state)?;
let (id_result, words) = IdResult::spirv_parse(words, parse_state)?;
}
}
};
- instruction_display_case = quote!{
+ instruction_display_case = quote! {
Instruction::Constant32 {
id_result_type,
id_result,
};
}
ast::InstructionName::OpConstant64 => {
- instruction_parse_case = quote!{};
- instruction_display_case = quote!{};
+ instruction_parse_case = quote! {};
+ instruction_display_case = quote! {};
}
ast::InstructionName::OpSpecConstant32 => {
- let body32 = quote!{
+ let body32 = quote! {
IdStateType(BitWidth::Width32OrLess) => {
let (value, words) = LiteralContextDependentNumber32::spirv_parse(words, parse_state)?;
if words.is_empty() {
}
}
};
- let body64 = quote!{
+ let body64 = quote! {
IdStateType(BitWidth::Width64) => {
let (value, words) = LiteralContextDependentNumber64::spirv_parse(words, parse_state)?;
if words.is_empty() {
}
}
};
- instruction_parse_case = quote!{
+ instruction_parse_case = quote! {
#opcode => {
let (id_result_type, words) = IdResultType::spirv_parse(words, parse_state)?;
let (id_result, words) = IdResult::spirv_parse(words, parse_state)?;
}
}
};
- instruction_display_case = quote!{
+ instruction_display_case = quote! {
Instruction::SpecConstant32 {
id_result_type,
id_result,
};
}
ast::InstructionName::OpSpecConstant64 => {
- instruction_parse_case = quote!{};
- instruction_display_case = quote!{};
+ instruction_parse_case = quote! {};
+ instruction_display_case = quote! {};
}
ast::InstructionName::OpSpecConstantOp => {
- instruction_parse_case = quote!{#opcode => {
+ instruction_parse_case = quote! {#opcode => {
let (operation, words) = OpSpecConstantOp::spirv_parse(words, parse_state)?;
if words.is_empty() {
Ok(Instruction::#opname { operation })
Err(Error::InstructionTooLong)
}
}};
- instruction_display_case = quote!{
+ instruction_display_case = quote! {
Instruction::#opname { operation } => fmt::Display::fmt(operation, f),
};
}
let kind = new_id(&operand.kind, CamelCase);
let name = new_id(operand.name.as_ref().unwrap(), SnakeCase);
let kind = match operand.quantifier {
- None => quote!{#kind},
- Some(ast::Quantifier::Optional) => quote!{Option::<#kind>},
- Some(ast::Quantifier::Variadic) => quote!{Vec::<#kind>},
+ None => quote! {#kind},
+ Some(ast::Quantifier::Optional) => quote! {Option::<#kind>},
+ Some(ast::Quantifier::Variadic) => quote! {Vec::<#kind>},
};
- parse_operations.push(quote!{
+ parse_operations.push(quote! {
let (#name, words) = #kind::spirv_parse(words, parse_state)?;
});
operand_names.push(name.clone());
assert_eq!(result_name, None);
result_name = Some(name);
} else {
- display_operations.push(quote!{
+ display_operations.push(quote! {
#name.spirv_display(f)?;
});
}
{
let operand1_name = new_id(operand1.name.as_ref().unwrap(), SnakeCase);
let operand2_name = new_id(operand2.name.as_ref().unwrap(), SnakeCase);
- parse_operations.push(quote!{
+ parse_operations.push(quote! {
parse_state.define_value(#operand1_name, #operand2_name)?;
});
}
}
let operand_names = &operand_names;
- instruction_parse_case = quote!{#opcode => {
+ instruction_parse_case = quote! {#opcode => {
#(#parse_operations)*
if words.is_empty() {
Ok(Instruction::#opname {
}
}};
let result_value = match result_name {
- None => quote!{None},
- Some(result_name) => quote!{Some(*#result_name)},
+ None => quote! {None},
+ Some(result_name) => quote! {Some(*#result_name)},
};
- instruction_display_case = quote!{
+ instruction_display_case = quote! {
Instruction::#opname { #(#operand_names,)* } => {
write!(f, "{}{}", InstructionIndentAndResult(#result_value), #display_opname)?;
#(#display_operations)*
instruction_display_cases.push(instruction_display_case);
let instruction_enumerant =
if instruction.opname == ast::InstructionName::OpSpecConstantOp {
- quote!{
+ quote! {
#opname {
operation: OpSpecConstantOp,
}
}
} else if instruction.operands.is_empty() {
- quote!{#opname}
+ quote! {#opname}
} else {
let mut fields = Vec::new();
for operand in instruction.operands.iter() {
let kind = new_id(&operand.kind, CamelCase);
let name = new_id(operand.name.as_ref().unwrap(), SnakeCase);
let kind = match &operand.quantifier {
- None => quote!{#kind},
- Some(ast::Quantifier::Optional) => quote!{Option<#kind>},
- Some(ast::Quantifier::Variadic) => quote!{Vec<#kind>},
+ None => quote! {#kind},
+ Some(ast::Quantifier::Optional) => quote! {Option<#kind>},
+ Some(ast::Quantifier::Variadic) => quote! {Vec<#kind>},
};
- fields.push(quote!{#name: #kind});
+ fields.push(quote! {#name: #kind});
}
- quote!{
+ quote! {
#opname {
#(#fields,)*
}
let kind = new_id(&operand.kind, CamelCase);
let name = new_id(operand.name.as_ref().unwrap(), SnakeCase);
let kind = match operand.quantifier {
- None => quote!{#kind},
- Some(ast::Quantifier::Optional) => quote!{Option::<#kind>},
- Some(ast::Quantifier::Variadic) => quote!{Vec::<#kind>},
+ None => quote! {#kind},
+ Some(ast::Quantifier::Optional) => quote! {Option::<#kind>},
+ Some(ast::Quantifier::Variadic) => quote! {Vec::<#kind>},
};
- parse_operations.push(quote!{
+ parse_operations.push(quote! {
let (#name, words) = #kind::spirv_parse(words, parse_state)?;
});
- display_operations.push(quote!{
+ display_operations.push(quote! {
#name.spirv_display(f)?;
});
operand_names.push(name);
assert_eq!(operand2.kind, ast::Kind::IdResult);
let operand1_name = new_id(operand1.name.as_ref().unwrap(), SnakeCase);
let operand2_name = new_id(operand2.name.as_ref().unwrap(), SnakeCase);
- parse_operations.push(quote!{
+ parse_operations.push(quote! {
parse_state.define_value(#operand1_name, #operand2_name)?;
});
} else {
);
}
let operand_names = &operand_names;
- instruction_spec_constant_parse_cases.push(quote!{#opcode => {
+ instruction_spec_constant_parse_cases.push(quote! {#opcode => {
#(#parse_operations)*
if words.is_empty() {
Ok((OpSpecConstantOp::#opname {
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
#[derive(Clone, Debug)]
pub enum OpSpecConstantOp {
#(#spec_constant_op_instruction_enumerants,)*
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
impl fmt::Display for OpSpecConstantOp {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
#[derive(Clone, Debug)]
pub enum Instruction {
#(#instruction_enumerants,)*
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
fn parse_instruction(opcode: u16, words: &[u32], parse_state: &mut ParseState) -> Result<Instruction> {
match opcode {
#(#instruction_parse_cases)*
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
impl fmt::Display for Instruction {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
}
}
)?;
- let body = quote!{
+ let body = quote! {
let (id_result_type, words) = IdResultType::spirv_parse(words, parse_state)?;
let (id_result, words) = IdResult::spirv_parse(words, parse_state)?;
let (opcode, words) = u32::spirv_parse(words, parse_state)?;
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
impl SPIRVParse for OpSpecConstantOp {
fn spirv_parse<'a>(
words: &'a [u32],
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
pub const #version_name: u32 = #version;
pub const #revision_name: u32 = #revision;
}
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub enum ExtensionInstructionSet {
#(#extension_instruction_set_enumerants,)*
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
impl<'a> From<Cow<'a, str>> for ExtensionInstructionSet {
fn from(s: Cow<'a, str>) -> ExtensionInstructionSet {
match s.as_ref() {
writeln!(
&mut out,
"{}",
- quote!{
+ quote! {
impl Deref for ExtensionInstructionSet {
type Target = str;
fn deref(&self) -> &str {
}
pub fn get_recursively_required_extensions(self) -> Extensions {
let mut retval = self.get_required_extensions();
- let mut worklist: EnumMap<Extension, Extension> = enum_map!{_ => self};
+ let mut worklist: EnumMap<Extension, Extension> = enum_map! {_ => self};
let worklist = worklist.as_mut_slice();
let mut worklist_size = 1;
while worklist_size > 0 {
impl Extensions {
pub fn create_empty() -> Self {
- Extensions(enum_map!{_ => false})
+ Extensions(enum_map! {_ => false})
}
pub fn is_empty(&self) -> bool {
self.iter().all(|(_, &v)| !v)
physical_device: SharedHandle<api::VkPhysicalDevice>,
create_info: *const api::VkDeviceCreateInfo,
) -> Result<OwnedHandle<api::VkDevice>, api::VkResult> {
- parse_next_chain_const!{
+ parse_next_chain_const! {
create_info,
root = api::VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
device_group_device_create_info: api::VkDeviceGroupDeviceCreateInfo = api::VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO,
let mut total_queue_count = 0;
let mut queue_counts: Vec<_> = Vec::new();
for queue_create_info in queue_create_infos {
- parse_next_chain_const!{
+ parse_next_chain_const! {
queue_create_info,
root = api::VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
}
pub unsafe fn new(
create_info: *const api::VkInstanceCreateInfo,
) -> Result<api::VkInstance, api::VkResult> {
- parse_next_chain_const!{
+ parse_next_chain_const! {
create_info,
root = api::VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
}
queue_family_properties: &mut api::VkQueueFamilyProperties2,
queue_count: u32,
) {
- parse_next_chain_mut!{
+ parse_next_chain_mut! {
queue_family_properties,
root = api::VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2,
}
_allocator: *const api::VkAllocationCallbacks,
memory: *mut api::VkDeviceMemory,
) -> api::VkResult {
- parse_next_chain_const!{
+ parse_next_chain_const! {
allocate_info,
root = api::VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
export_memory_allocate_info: api::VkExportMemoryAllocateInfo = api::VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO,
_allocator: *const api::VkAllocationCallbacks,
buffer: *mut api::VkBuffer,
) -> api::VkResult {
- parse_next_chain_const!{
+ parse_next_chain_const! {
create_info,
root = api::VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
external_memory_buffer: api::VkExternalMemoryBufferCreateInfo = api::VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO,
_allocator: *const api::VkAllocationCallbacks,
image: *mut api::VkImage,
) -> api::VkResult {
- parse_next_chain_const!{
+ parse_next_chain_const! {
create_info,
root = api::VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
external_memory_image_create_info: api::VkExternalMemoryImageCreateInfo = api::VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO,
_allocator: *const api::VkAllocationCallbacks,
view: *mut api::VkImageView,
) -> api::VkResult {
- parse_next_chain_const!{
+ parse_next_chain_const! {
create_info,
root = api::VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
}
_allocator: *const api::VkAllocationCallbacks,
shader_module: *mut api::VkShaderModule,
) -> api::VkResult {
- parse_next_chain_const!{
+ parse_next_chain_const! {
create_info,
root = api::VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
}
_allocator: *const api::VkAllocationCallbacks,
pipeline_layout: *mut api::VkPipelineLayout,
) -> api::VkResult {
- parse_next_chain_const!{
+ parse_next_chain_const! {
create_info,
root = api::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
}
_allocator: *const api::VkAllocationCallbacks,
sampler: *mut api::VkSampler,
) -> api::VkResult {
- parse_next_chain_const!{
+ parse_next_chain_const! {
create_info,
root = api::VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
}
_allocator: *const api::VkAllocationCallbacks,
set_layout: *mut api::VkDescriptorSetLayout,
) -> api::VkResult {
- parse_next_chain_const!{
+ parse_next_chain_const! {
create_info,
root = api::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
}
_allocator: *const api::VkAllocationCallbacks,
descriptor_pool: *mut api::VkDescriptorPool,
) -> api::VkResult {
- parse_next_chain_const!{
+ parse_next_chain_const! {
create_info,
root = api::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
}
allocate_info: *const api::VkDescriptorSetAllocateInfo,
descriptor_sets: *mut api::VkDescriptorSet,
) -> api::VkResult {
- parse_next_chain_const!{
+ parse_next_chain_const! {
allocate_info,
root = api::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
}
let descriptor_writes = util::to_slice(descriptor_writes, descriptor_write_count as usize);
let descriptor_copies = util::to_slice(descriptor_copies, descriptor_copy_count as usize);
for descriptor_write in descriptor_writes {
- parse_next_chain_const!{
+ parse_next_chain_const! {
descriptor_write,
root = api::VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
}
}
}
for descriptor_copy in descriptor_copies {
- parse_next_chain_const!{
+ parse_next_chain_const! {
descriptor_copy,
root = api::VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET,
}
_allocator: *const api::VkAllocationCallbacks,
render_pass: *mut api::VkRenderPass,
) -> api::VkResult {
- parse_next_chain_const!{
+ parse_next_chain_const! {
create_info,
root = api::VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
}
assert_ne!(bind_info_count, 0);
let bind_infos = util::to_slice(bind_infos, bind_info_count as usize);
for bind_info in bind_infos {
- parse_next_chain_const!{
+ parse_next_chain_const! {
bind_info,
root = api::VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO,
device_group_info: api::VkBindBufferMemoryDeviceGroupInfo = api::VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO,
assert_ne!(bind_info_count, 0);
let bind_infos = util::to_slice(bind_infos, bind_info_count as usize);
for bind_info in bind_infos {
- parse_next_chain_const!{
+ parse_next_chain_const! {
bind_info,
root = api::VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO,
device_group_info: api::VkBindImageMemoryDeviceGroupInfo = api::VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO,
physical_device_group_properties,
iter::once(()),
|physical_device_group_properties, _| {
- parse_next_chain_mut!{
+ parse_next_chain_mut! {
physical_device_group_properties,
root = api::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES,
}
memory_requirements: *mut api::VkMemoryRequirements2,
) {
#![cfg_attr(feature = "cargo-clippy", allow(clippy::needless_update))]
- parse_next_chain_const!{
+ parse_next_chain_const! {
info,
root = api::VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2,
image_plane_memory_requirements_info: api::VkImagePlaneMemoryRequirementsInfo = api::VK_STRUCTURE_TYPE_IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO,
}
- parse_next_chain_mut!{
+ parse_next_chain_mut! {
memory_requirements,
root = api::VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2,
dedicated_requirements: api::VkMemoryDedicatedRequirements = api::VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS,
memory_requirements: *mut api::VkMemoryRequirements2,
) {
#![cfg_attr(feature = "cargo-clippy", allow(clippy::needless_update))]
- parse_next_chain_const!{
+ parse_next_chain_const! {
info,
root = api::VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2,
}
- parse_next_chain_mut!{
+ parse_next_chain_mut! {
memory_requirements,
root = api::VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2,
dedicated_requirements: api::VkMemoryDedicatedRequirements = api::VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS,
physical_device: api::VkPhysicalDevice,
features: *mut api::VkPhysicalDeviceFeatures2,
) {
- parse_next_chain_mut!{
+ parse_next_chain_mut! {
features,
root = api::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
sampler_ycbcr_conversion_features: api::VkPhysicalDeviceSamplerYcbcrConversionFeatures = api::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES,
physical_device: api::VkPhysicalDevice,
properties: *mut api::VkPhysicalDeviceProperties2,
) {
- parse_next_chain_mut!{
+ parse_next_chain_mut! {
properties,
root = api::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
point_clipping_properties: api::VkPhysicalDevicePointClippingProperties = api::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES,
format: api::VkFormat,
format_properties: *mut api::VkFormatProperties2,
) {
- parse_next_chain_mut!{
+ parse_next_chain_mut! {
format_properties,
root = api::VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2,
}
) {
#![cfg_attr(feature = "cargo-clippy", allow(clippy::needless_update))]
let physical_device = SharedHandle::from(physical_device).unwrap();
- parse_next_chain_mut!{
+ parse_next_chain_mut! {
memory_properties,
root = api::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2,
}
queue_info: *const api::VkDeviceQueueInfo2,
queue: *mut api::VkQueue,
) {
- parse_next_chain_const!{
+ parse_next_chain_const! {
queue_info,
root = api::VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2,
}
_allocator: *const api::VkAllocationCallbacks,
swapchain: *mut api::VkSwapchainKHR,
) -> api::VkResult {
- parse_next_chain_const!{
+ parse_next_chain_const! {
create_info,
root = api::VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
device_group_swapchain_create_info: api::VkDeviceGroupSwapchainCreateInfoKHR = api::VK_STRUCTURE_TYPE_DEVICE_GROUP_SWAPCHAIN_CREATE_INFO_KHR,
surface_info: *const api::VkPhysicalDeviceSurfaceInfo2KHR,
surface_capabilities: *mut api::VkSurfaceCapabilities2KHR,
) -> api::VkResult {
- parse_next_chain_const!{
+ parse_next_chain_const! {
surface_info,
root = api::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR,
}
let surface_info = &*surface_info;
- parse_next_chain_mut!{
+ parse_next_chain_mut! {
surface_capabilities,
root = api::VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR,
}
_allocator: *const api::VkAllocationCallbacks,
surface: *mut api::VkSurfaceKHR,
) -> api::VkResult {
- parse_next_chain_const!{
+ parse_next_chain_const! {
create_info,
root = api::VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR,
}