From 0165ee349fc92b11e8f09b5f29fa3cc10cf25195 Mon Sep 17 00:00:00 2001 From: Luke Jones Date: Fri, 7 Jul 2017 08:51:59 +1200 Subject: [PATCH] Allow special cases for bitflags in structs (and proper truncation if bitflags) --- src/codegen/sys/lib_.rs | 44 ++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/codegen/sys/lib_.rs b/src/codegen/sys/lib_.rs index 87c05ef35..65d0d5bdd 100644 --- a/src/codegen/sys/lib_.rs +++ b/src/codegen/sys/lib_.rs @@ -312,6 +312,7 @@ fn generate_enums(w: &mut Write, env: &Env, items: &[&Enumeration]) -> Result<() } fn generate_unions(w: &mut Write, env: &Env, items: &[&Union]) -> Result<()> { + if !items.is_empty() { try!(writeln!(w, "// Unions")); } @@ -363,8 +364,11 @@ fn generate_unions(w: &mut Write, env: &Env, items: &[&Union]) -> Result<()> { } } } - if !items.is_empty() { - try!(writeln!(w, "")); + #[cfg(not(feature = "use_unions"))] + { + if !items.is_empty() { + try!(writeln!(w, "")); + } } Ok(()) @@ -530,7 +534,7 @@ fn generate_fields(env: &Env, struct_name: &str, fields: &[Field]) -> (Vec (Vec