Skip to content

Commit

Permalink
codegen: Stop renaming ffi crate
Browse files Browse the repository at this point in the history
As we would like to define those crates in the main workspace file
to simplify the release process
  • Loading branch information
bilelmoussaoui committed Jun 1, 2024
1 parent 8956bb1 commit 3b19fa4
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/analysis/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub fn new(env: &Env, obj: &GObject, imports: &mut Imports) -> Option<Info> {
if obj.status.need_generate() {
// Mark the type as available within the enum namespace:
imports.add_defined(&format!("crate::{name}"));
imports.add("crate::ffi");

let imports = &mut imports.with_defaults(enumeration.version, &None);
imports.add("glib::translate::*");
Expand Down
1 change: 1 addition & 0 deletions src/analysis/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub fn new(env: &Env, obj: &GObject, imports: &mut Imports) -> Option<Info> {
if obj.status.need_generate() {
// Mark the type as available within the bitfield namespace:
imports.add_defined(&format!("crate::{name}"));
imports.add("crate::ffi");

let imports = &mut imports.with_defaults(flags.version, &None);
imports.add("glib::translate::*");
Expand Down
3 changes: 0 additions & 3 deletions src/analysis/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ impl Imports {
/// It also extends the checks in case you are implementing "X". For
/// example, you don't want to import "X" or "crate::X" in this case.
fn common_checks(&self, name: &str) -> bool {
// The ffi namespace is used directly, including it is a programmer error.
assert_ne!(name, "crate::ffi");

if (!name.contains("::") && name != "xlib") || self.defined.contains(name) {
false
} else if let Some(name) = name.strip_prefix("crate::") {
Expand Down
1 change: 1 addition & 0 deletions src/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ fn analyze_global_functions(env: &mut Env) {

let mut imports = imports::Imports::new(&env.library);
imports.add("glib::translate::*");
imports.add("crate:ffi");

let functions = functions::analyze(
env,
Expand Down
2 changes: 2 additions & 0 deletions src/analysis/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ pub fn class(env: &Env, obj: &GObject, deps: &[library::TypeId]) -> Option<Info>
&& !is_fundamental
&& (has_signals || has_methods || !properties.is_empty() || !child_properties.is_empty());

imports.add("crate::ffi");
if is_fundamental {
imports.add("glib::translate::*");
imports.add("glib::prelude::*");
Expand Down Expand Up @@ -375,6 +376,7 @@ pub fn interface(env: &Env, obj: &GObject, deps: &[library::TypeId]) -> Option<I

let mut imports = Imports::with_defined(&env.library, &name);
imports.add("glib::prelude::*");
imports.add("crate::ffi");

let supertypes = supertypes::analyze(env, iface_tid, version, &mut imports, false);
let supertypes_properties = supertypes
Expand Down
1 change: 1 addition & 0 deletions src/analysis/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub fn new(env: &Env, obj: &GObject) -> Option<Info> {
let boxed_inline = obj.boxed_inline;

let mut imports = Imports::with_defined(&env.library, &name);
imports.add("crate:ffi");

let mut functions = functions::analyze(
env,
Expand Down
1 change: 1 addition & 0 deletions src/codegen/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn generate(env: &Env, root_path: &Path, mod_rs: &mut Vec<String>) {

let sys_crate_name = env.main_sys_crate_name();
imports.add("glib::GStr");
imports.add("crate::ffi");

file_saver::save_to_file(path, env.config.make_backup, |w| {
general::start_comments(w, &env.config)?;
Expand Down

0 comments on commit 3b19fa4

Please sign in to comment.