Merge pull request #92 from Cyres/boolean-type

Change type of `TRUE` and `FALSE` to `Bool32`
This commit is contained in:
Maik Klein 2018-08-03 16:31:09 +02:00 committed by GitHub
commit a1f79e102d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View file

@ -13432,8 +13432,8 @@ pub const REMAINING_MIP_LEVELS: u32 = !0;
pub const REMAINING_ARRAY_LAYERS: u32 = !0; pub const REMAINING_ARRAY_LAYERS: u32 = !0;
pub const WHOLE_SIZE: u64 = !0; pub const WHOLE_SIZE: u64 = !0;
pub const ATTACHMENT_UNUSED: u32 = !0; pub const ATTACHMENT_UNUSED: u32 = !0;
pub const TRUE: usize = 1; pub const TRUE: Bool32 = 1;
pub const FALSE: usize = 0; pub const FALSE: Bool32 = 0;
pub const QUEUE_FAMILY_IGNORED: u32 = !0; pub const QUEUE_FAMILY_IGNORED: u32 = !0;
pub const QUEUE_FAMILY_EXTERNAL: u32 = !0 - 1; pub const QUEUE_FAMILY_EXTERNAL: u32 = !0 - 1;
pub const QUEUE_FAMILY_FOREIGN_EXT: u32 = !0 - 2; pub const QUEUE_FAMILY_FOREIGN_EXT: u32 = !0 - 2;

View file

@ -24,6 +24,7 @@ pub enum CType {
U32, U32,
U64, U64,
Float, Float,
Bool32,
} }
impl CType { impl CType {
@ -33,6 +34,7 @@ impl CType {
CType::U32 => Term::intern("u32"), CType::U32 => Term::intern("u32"),
CType::U64 => Term::intern("u64"), CType::U64 => Term::intern("u64"),
CType::Float => Term::intern("f32"), CType::Float => Term::intern("f32"),
CType::Bool32 => Term::intern("Bool32"),
}; };
quote!{#term} quote!{#term}
} }
@ -1399,7 +1401,12 @@ pub fn generate_constant<'a>(
let name = constant_name(&constant.name); let name = constant_name(&constant.name);
let ident = Ident::from(name.as_str()); let ident = Ident::from(name.as_str());
let value = c.to_tokens(); let value = c.to_tokens();
let ty = c.ty().to_tokens(); let ty = if name == "TRUE" || name == "FALSE" {
CType::Bool32
} else {
c.ty()
};
let ty = ty.to_tokens();
quote!{ quote!{
pub const #ident: #ty = #value; pub const #ident: #ty = #value;
} }