Skip to content

Commit

Permalink
always import ffi library in subclass mode
Browse files Browse the repository at this point in the history
  • Loading branch information
vhdirk committed Jul 6, 2018
1 parent 59d17d4 commit a1f2b15
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
16 changes: 14 additions & 2 deletions src/analysis/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -105,12 +106,17 @@ pub fn class(env: &Env, obj: &GObject, deps: &[library::TypeId]) -> Option<Info>

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;
Expand Down Expand Up @@ -301,13 +307,19 @@ pub fn interface(env: &Env, obj: &GObject, deps: &[library::TypeId]) -> Option<I

let mut imports = Imports::with_defined(&env.library, &name);
imports.add("glib::translate::*", None);
imports.add("ffi", None);
imports.add("glib::object::IsA", 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("glib", None);
imports.add(&format!("{}_ffi", env.config.library_name.to_lowercase()), None);
}else{
imports.add("ffi", None);
}

let supertypes = supertypes::analyze(env, iface_tid, &mut imports);

let trait_name = obj.trait_name
Expand Down
6 changes: 0 additions & 6 deletions src/codegen/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use config::Config;
use config::derives::Derive;
use env::Env;
use gir_version::VERSION;
use config::WorkMode;
use version::Version;
use writer::primitives::tabs;

Expand Down Expand Up @@ -48,11 +47,6 @@ pub fn uses(w: &mut Write, env: &Env, imports: &Imports) -> 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() {
Expand Down

0 comments on commit a1f2b15

Please sign in to comment.