Move debug_flags definition out of the generator
This commit is contained in:
parent
0ae56a0961
commit
e34f755ece
|
@ -25,7 +25,9 @@
|
||||||
*
|
*
|
||||||
**********************************************************************************************************************/
|
**********************************************************************************************************************/
|
||||||
|
|
||||||
|
use crate::prelude::debug_flags;
|
||||||
use crate::vk::*;
|
use crate::vk::*;
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::os::raw::*;
|
use std::os::raw::*;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
use crate::vk;
|
use crate::vk;
|
||||||
pub type VkResult<T> = Result<T, vk::Result>;
|
pub type VkResult<T> = Result<T, vk::Result>;
|
||||||
|
@ -81,3 +82,30 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn debug_flags<Value: Into<u64> + Copy>(
|
||||||
|
f: &mut fmt::Formatter,
|
||||||
|
known: &[(Value, &'static str)],
|
||||||
|
value: Value,
|
||||||
|
) -> fmt::Result {
|
||||||
|
let mut first = true;
|
||||||
|
let mut accum = value.into();
|
||||||
|
for &(bit, name) in known {
|
||||||
|
let bit = bit.into();
|
||||||
|
if bit != 0 && accum & bit == bit {
|
||||||
|
if !first {
|
||||||
|
f.write_str(" | ")?;
|
||||||
|
}
|
||||||
|
f.write_str(name)?;
|
||||||
|
first = false;
|
||||||
|
accum &= !bit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if accum != 0 {
|
||||||
|
if !first {
|
||||||
|
f.write_str(" | ")?;
|
||||||
|
}
|
||||||
|
write!(f, "{:b}", accum)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ pub use aliases::*;
|
||||||
mod bitflags;
|
mod bitflags;
|
||||||
pub use bitflags::*;
|
pub use bitflags::*;
|
||||||
mod const_debugs;
|
mod const_debugs;
|
||||||
pub(crate) use const_debugs::*;
|
|
||||||
mod constants;
|
mod constants;
|
||||||
pub use constants::*;
|
pub use constants::*;
|
||||||
mod definitions;
|
mod definitions;
|
||||||
|
|
|
@ -1,33 +1,8 @@
|
||||||
|
use crate::prelude::debug_flags;
|
||||||
use crate::vk::bitflags::*;
|
use crate::vk::bitflags::*;
|
||||||
use crate::vk::definitions::*;
|
use crate::vk::definitions::*;
|
||||||
use crate::vk::enums::*;
|
use crate::vk::enums::*;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
pub(crate) fn debug_flags<Value: Into<u64> + Copy>(
|
|
||||||
f: &mut fmt::Formatter,
|
|
||||||
known: &[(Value, &'static str)],
|
|
||||||
value: Value,
|
|
||||||
) -> fmt::Result {
|
|
||||||
let mut first = true;
|
|
||||||
let mut accum = value.into();
|
|
||||||
for &(bit, name) in known {
|
|
||||||
let bit = bit.into();
|
|
||||||
if bit != 0 && accum & bit == bit {
|
|
||||||
if !first {
|
|
||||||
f.write_str(" | ")?;
|
|
||||||
}
|
|
||||||
f.write_str(name)?;
|
|
||||||
first = false;
|
|
||||||
accum &= !bit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if accum != 0 {
|
|
||||||
if !first {
|
|
||||||
f.write_str(" | ")?;
|
|
||||||
}
|
|
||||||
write!(f, "{:b}", accum)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
impl fmt::Debug for AccelerationStructureBuildTypeKHR {
|
impl fmt::Debug for AccelerationStructureBuildTypeKHR {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let name = match *self {
|
let name = match *self {
|
||||||
|
|
|
@ -2461,33 +2461,6 @@ pub fn generate_const_debugs(const_values: &BTreeMap<Ident, ConstantTypeInfo>) -
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
quote! {
|
quote! {
|
||||||
pub(crate) fn debug_flags<Value: Into<u64> + Copy>(
|
|
||||||
f: &mut fmt::Formatter,
|
|
||||||
known: &[(Value, &'static str)],
|
|
||||||
value: Value,
|
|
||||||
) -> fmt::Result {
|
|
||||||
let mut first = true;
|
|
||||||
let mut accum = value.into();
|
|
||||||
for &(bit, name) in known {
|
|
||||||
let bit = bit.into();
|
|
||||||
if bit != 0 && accum & bit == bit {
|
|
||||||
if !first {
|
|
||||||
f.write_str(" | ")?;
|
|
||||||
}
|
|
||||||
f.write_str(name)?;
|
|
||||||
first = false;
|
|
||||||
accum &= !bit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if accum != 0 {
|
|
||||||
if !first {
|
|
||||||
f.write_str(" | ")?;
|
|
||||||
}
|
|
||||||
write!(f, "{:b}", accum)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#(#impls)*
|
#(#impls)*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2823,6 +2796,7 @@ pub fn write_source_code<P: AsRef<Path>>(vk_headers_dir: &Path, src_dir: P) {
|
||||||
use crate::vk::bitflags::*;
|
use crate::vk::bitflags::*;
|
||||||
use crate::vk::definitions::*;
|
use crate::vk::definitions::*;
|
||||||
use crate::vk::enums::*;
|
use crate::vk::enums::*;
|
||||||
|
use crate::prelude::debug_flags;
|
||||||
#const_debugs
|
#const_debugs
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue