More traits for dispatchable handles
This commit is contained in:
parent
f13e01d026
commit
aa171d405a
3291
ash/src/vk.rs
3291
ash/src/vk.rs
File diff suppressed because it is too large
Load diff
|
@ -90,7 +90,7 @@ pub fn define_handle_macro() -> Tokens {
|
||||||
macro_rules! define_handle{
|
macro_rules! define_handle{
|
||||||
($name: ident, $ty: ident) => {
|
($name: ident, $ty: ident) => {
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash)]
|
||||||
pub struct $name(*mut u8);
|
pub struct $name(*mut u8);
|
||||||
impl Default for $name {
|
impl Default for $name {
|
||||||
fn default() -> $name {
|
fn default() -> $name {
|
||||||
|
@ -112,6 +112,18 @@ pub fn define_handle_macro() -> Tokens {
|
||||||
$name(::std::ptr::null_mut())
|
$name(::std::ptr::null_mut())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Pointer for $name {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
fmt::Pointer::fmt(&self.0, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for $name {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
fmt::Debug::fmt(&self.0, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,14 +148,15 @@ pub fn handle_nondispatchable_macro() -> Tokens {
|
||||||
$name(0)
|
$name(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl ::std::fmt::Pointer for $name {
|
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::result::Result<(), ::std::fmt::Error> {
|
impl fmt::Pointer for $name {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "0x{:x}", self.0)
|
write!(f, "0x{:x}", self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::fmt::Debug for $name {
|
impl fmt::Debug for $name {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::result::Result<(), ::std::fmt::Error> {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "0x{:x}", self.0)
|
write!(f, "0x{:x}", self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,8 +205,8 @@ pub fn vk_bitflags_wrapped_macro() -> Tokens {
|
||||||
$name(0)
|
$name(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl ::std::fmt::Debug for $name {
|
impl fmt::Debug for $name {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::result::Result<(), ::std::fmt::Error> {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "{}({:b})", stringify!($name), self.0)
|
write!(f, "{}({:b})", stringify!($name), self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1268,8 +1281,8 @@ pub fn derive_debug(_struct: &vkxml::Struct, union_types: &HashSet<&str>) -> Opt
|
||||||
});
|
});
|
||||||
let name_str = name.as_ref();
|
let name_str = name.as_ref();
|
||||||
let q = quote!{
|
let q = quote!{
|
||||||
impl ::std::fmt::Debug for #name {
|
impl fmt::Debug for #name {
|
||||||
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::result::Result<(), ::std::fmt::Error> {
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
fmt.debug_struct(#name_str)
|
fmt.debug_struct(#name_str)
|
||||||
#(#debug_fields)*
|
#(#debug_fields)*
|
||||||
.finish()
|
.finish()
|
||||||
|
|
Loading…
Reference in a new issue