diff --git a/src/analysis/object.rs b/src/analysis/object.rs index 4e6e5143e..ce9cbde07 100644 --- a/src/analysis/object.rs +++ b/src/analysis/object.rs @@ -11,6 +11,7 @@ use super::info_base::InfoBase; use super::signatures::Signatures; use traits::*; use super::functions::Visibility; +use config::WorkMode; #[derive(Debug, Default)] pub struct Info { @@ -105,12 +106,17 @@ pub fn class(env: &Env, obj: &GObject, deps: &[library::TypeId]) -> Option let mut imports = Imports::with_defined(&env.library, &name); imports.add("glib::translate::*", None); - imports.add("ffi", None); imports.add("glib_ffi", None); imports.add("gobject_ffi", None); imports.add("std::mem", None); imports.add("std::ptr", None); + if env.config.work_mode != WorkMode::Subclass { + imports.add("ffi", None); + }else{ + imports.add(&format!("{}_ffi", env.config.library_name.to_lowercase()), None); + } + let supertypes = supertypes::analyze(env, class_tid, &mut imports); let mut generate_trait = obj.generate_trait; @@ -301,13 +307,19 @@ pub fn interface(env: &Env, obj: &GObject, deps: &[library::TypeId]) -> Option Result<()> { try!(writeln!(w)); for (name, &(ref version, ref constraints)) in imports.iter() { - // HACK: skip ffi in subclass mode. - if name == "ffi" && env.config.work_mode == WorkMode::Subclass{ - continue - } - if constraints.len() == 1 { try!(writeln!(w, "#[cfg(feature = \"{}\")]", constraints[0])); } else if !constraints.is_empty() {