Skip to content

Commit

Permalink
Reenable special case for bit-field structs
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Jones committed Jul 6, 2017
1 parent a1b9d03 commit c39bdde
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/codegen/sys/lib_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::collections::HashMap;
use std::io::{Result, Write};
use case::CaseExt;

#[cfg(not(feature = "use_unions"))]
use analysis::c_type::rustify_pointers;

use codegen::general::{self, version_condition};
Expand Down Expand Up @@ -471,7 +470,6 @@ fn generate_records(w: &mut Write, env: &Env, records: &[&Record]) -> Result<()>
}

// TODO: GLib/GObject special cases unless nightly unions are enabled
#[cfg(not(feature = "use_unions"))]
fn is_union_special_case(c_type: &Option<String>) -> bool {
if let Some(c_type) = c_type.as_ref() {
c_type.as_str() == "GMutex"
Expand All @@ -483,7 +481,6 @@ fn is_union_special_case(c_type: &Option<String>) -> bool {
fn generate_fields(env: &Env, struct_name: &str, fields: &[Field]) -> (Vec<String>, bool) {
let mut lines = Vec::new();
let mut commented = false;
#[cfg(not(feature = "use_unions"))]
let mut truncated = false;

//TODO: remove after GObject-2.0.gir fixed
Expand All @@ -495,14 +492,11 @@ fn generate_fields(env: &Env, struct_name: &str, fields: &[Field]) -> (Vec<Strin
let is_gweakref = env.config.library_name == "GObject" && struct_name == "WeakRef";

'fields: for field in fields {
#[cfg(not(feature = "use_unions"))]
let is_union = env.library
.type_(field.typ)
.maybe_ref_as::<Union>()
.is_some();
#[cfg(not(feature = "use_unions"))]
let is_bits = field.bits.is_some();
#[cfg(not(feature = "use_unions"))]
let is_ptr = {
if let Some(ref c_type) = field.c_type {
!rustify_pointers(c_type).0.is_empty()
Expand Down Expand Up @@ -536,8 +530,7 @@ fn generate_fields(env: &Env, struct_name: &str, fields: &[Field]) -> (Vec<Strin
}
}

#[cfg(not(feature = "use_unions"))]
{
if !cfg!(feature = "use_unions") || is_bits {
if !is_gweakref && !truncated && !is_ptr &&
(is_union || is_bits) &&
!is_union_special_case(&field.c_type)
Expand Down

0 comments on commit c39bdde

Please sign in to comment.