Skip to content

Commit

Permalink
Reorder imports into a single block
Browse files Browse the repository at this point in the history
  • Loading branch information
heftig committed May 12, 2019
1 parent ae40a58 commit 81953fb
Show file tree
Hide file tree
Showing 66 changed files with 120 additions and 188 deletions.
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{fs::File, io::Write};

#[path = "src/git.rs"]
mod git;

use std::{fs::File, io::Write};

fn main() {
let ver = git::repo_hash(".").unwrap_or_else(|_| "???".into());

Expand Down
3 changes: 1 addition & 2 deletions src/analysis/bounds.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::{collections::vec_deque::VecDeque, slice::Iter, vec::Vec};

use crate::{
analysis::{
function_parameters::{async_param_to_remove, CParameter},
Expand All @@ -15,6 +13,7 @@ use crate::{
},
traits::IntoString,
};
use std::{collections::vec_deque::VecDeque, slice::Iter};

#[derive(Clone, Eq, Debug, PartialEq)]
pub enum BoundType {
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/c_type.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use log::trace;

use crate::{env::Env, library::TypeId};
use log::trace;

pub fn rustify_pointers(c_type: &str) -> (String, String) {
let mut input = c_type.trim();
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/child_properties.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use log::error;

use crate::{
analysis::{bounds::Bounds, imports::Imports, ref_mode::RefMode, rust_type::*},
codegen::function,
Expand All @@ -8,6 +6,7 @@ use crate::{
library, nameutil,
traits::*,
};
use log::error;

#[derive(Clone, Debug)]
pub struct ChildProperty {
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/class_hierarchy.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::library::*;
use std::{
collections::{HashMap, HashSet},
iter::{self, Iterator},
iter,
};

#[derive(Debug)]
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/constants.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::borrow::Borrow;

use crate::{config, env::Env, library, nameutil, traits::*, version::Version};
use std::borrow::Borrow;

#[derive(Debug)]
pub struct Info {
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/ffi_type.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use log::{info, trace};

use crate::{
analysis::{
c_type::{implements_c_type, rustify_pointers},
Expand All @@ -9,6 +7,7 @@ use crate::{
library::*,
traits::*,
};
use log::{info, trace};

pub fn used_ffi_type(env: &Env, type_id: TypeId, c_type: &str) -> Option<String> {
let (_ptr, inner) = rustify_pointers(c_type);
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/function_parameters.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::collections::HashMap;

use super::{
conversion_type::ConversionType, out_parameters::can_as_return,
override_string_type::override_string_type_parameter, ref_mode::RefMode, rust_type::rust_type,
Expand All @@ -11,6 +9,7 @@ use crate::{
nameutil,
traits::IntoString,
};
use std::collections::HashMap;

//TODO: remove unused fields
#[derive(Clone, Debug)]
Expand Down
12 changes: 5 additions & 7 deletions src/analysis/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
* method has a different prefix.
*/

use log::warn;
use std::{
borrow::Borrow,
collections::{HashMap, HashSet},
vec::Vec,
};

use crate::{
analysis::{
bounds::{Bounds, CallbackInfo},
Expand All @@ -32,6 +25,11 @@ use crate::{
traits::*,
version::Version,
};
use log::warn;
use std::{
borrow::Borrow,
collections::{HashMap, HashSet},
};

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Visibility {
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/imports.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::btree_map::{BTreeMap, Iter};

use super::namespaces;
use crate::{library::Library, nameutil::crate_name, version::Version};
use std::collections::btree_map::{BTreeMap, Iter};

/// Provides assistance in generating use declarations.
///
Expand Down
5 changes: 2 additions & 3 deletions src/analysis/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use log::error;
use std::collections::BTreeMap;

use crate::{
env::Env,
library::{self, Type, TypeId},
};
use log::error;
use std::collections::BTreeMap;

pub mod bounds;
pub mod c_type;
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/namespaces.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::ops::Index;

use crate::{library, nameutil, version::Version};
use std::ops::Index;

pub type NsId = u16;
pub const MAIN: NsId = library::MAIN_NAMESPACE;
Expand Down
5 changes: 2 additions & 3 deletions src/analysis/object.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use log::info;
use std::ops::Deref;

use super::{
child_properties::ChildProperties, imports::Imports, info_base::InfoBase,
signatures::Signatures, *,
};
use crate::{config::gobjects::GObject, env::Env, library, nameutil::*, traits::*};
use log::info;
use std::ops::Deref;

#[derive(Debug, Default)]
pub struct Info {
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/out_parameters.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::{slice::Iter, vec::Vec};

use crate::{
analysis::{
conversion_type::ConversionType, function_parameters::CParameter,
Expand All @@ -12,6 +10,7 @@ use crate::{
nameutil,
version::Version,
};
use std::slice::Iter;

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Mode {
Expand Down
5 changes: 1 addition & 4 deletions src/analysis/override_string_type.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use log::error;

use crate::{config, env::Env, library::*};
use log::error;

pub fn override_string_type_parameter(
env: &Env,
Expand All @@ -27,7 +26,6 @@ pub fn override_string_type_return(
}

fn apply(env: &Env, type_id: TypeId, string_type: Option<config::StringType>) -> TypeId {
use crate::library::*;
let string_type = if let Some(string_type) = string_type {
string_type
} else {
Expand Down Expand Up @@ -60,7 +58,6 @@ fn apply(env: &Env, type_id: TypeId, string_type: Option<config::StringType>) ->
}

fn can_overriden_fundamental(env: &Env, type_id: TypeId) -> bool {
use crate::library::*;
match *env.library.type_(type_id) {
Type::Fundamental(Fundamental::Filename) => true,
Type::Fundamental(Fundamental::OsString) => true,
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/properties.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use log::warn;

use crate::{
analysis::{
imports::Imports,
Expand All @@ -15,6 +13,7 @@ use crate::{
traits::*,
version::Version,
};
use log::warn;

#[derive(Debug)]
pub struct Property {
Expand Down
5 changes: 2 additions & 3 deletions src/analysis/record.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
use log::info;
use std::ops::Deref;

use super::{imports::Imports, info_base::InfoBase, record_type::RecordType, *};
use crate::{
config::{
Expand All @@ -12,6 +9,8 @@ use crate::{
nameutil::*,
traits::*,
};
use log::info;
use std::ops::Deref;

#[derive(Debug, Default)]
pub struct Info {
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/return_value.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use log::error;

use crate::{
analysis::{
imports::Imports, namespaces, override_string_type::override_string_type_return,
Expand All @@ -9,6 +7,7 @@ use crate::{
env::Env,
library::{self, Nullable, TypeId},
};
use log::error;

#[derive(Clone, Debug, Default)]
pub struct Info {
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/rust_type.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use std::result;

use super::conversion_type::ConversionType;
use crate::{
analysis::ref_mode::RefMode,
env::Env,
library::{self, Nullable, ParameterScope},
traits::*,
};
use std::result;

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum TypeError {
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/signatures.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::HashMap;

use crate::{env::Env, library, version::Version};
use std::collections::HashMap;

#[derive(Debug)]
pub struct Signature(Vec<library::TypeId>, library::TypeId, Option<Version>);
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/special_functions.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::{collections::BTreeMap, str::FromStr};

use crate::analysis::{
functions::{Info as FuncInfo, Visibility},
imports::Imports,
};
use std::{collections::BTreeMap, str::FromStr};

#[derive(Clone, Copy, Eq, Debug, Ord, PartialEq, PartialOrd)]
pub enum Type {
Expand Down
2 changes: 0 additions & 2 deletions src/analysis/supertypes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::vec::Vec;

use super::{general::StatusedTypeId, imports::Imports};
use crate::{
analysis::{namespaces, rust_type::used_rust_type},
Expand Down
3 changes: 1 addition & 2 deletions src/analysis/trampoline_parameters.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use log::error;

use super::{conversion_type::ConversionType, ref_mode::RefMode};
use crate::{
analysis::rust_type::rust_type,
config::{self, parameter_matchable::ParameterMatchable},
env::Env,
library, nameutil,
};
use log::error;

pub use crate::config::signals::TransformationType;

Expand Down
3 changes: 1 addition & 2 deletions src/analysis/trampolines.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use log::error;

use super::{
bounds::{BoundType, Bounds},
conversion_type::ConversionType,
Expand All @@ -16,6 +14,7 @@ use crate::{
traits::IntoString,
version::Version,
};
use log::error;

#[derive(Debug, Clone)]
pub struct Trampoline {
Expand Down
2 changes: 0 additions & 2 deletions src/chunk/chunk.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::vec::Vec;

use super::{conversion_from_glib, parameter_ffi_call_out};
use crate::analysis::{function_parameters::TransformationType, return_value};

Expand Down
3 changes: 2 additions & 1 deletion src/chunk/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::env::Env;

#[allow(clippy::module_inception)]
mod chunk;
pub mod conversion_from_glib;
pub mod parameter_ffi_call_out;

pub use self::chunk::{chunks, Chunk, Param, TupleMode};
use crate::env::Env;

pub fn ffi_function_todo(env: &Env, name: &str) -> Chunk {
let sys_crate_name = env.main_sys_crate_name();
Expand Down
3 changes: 1 addition & 2 deletions src/codegen/child_properties.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::io::{Result, Write};

use super::{general::doc_hidden, property_body};
use crate::{
analysis::{
Expand All @@ -12,6 +10,7 @@ use crate::{
traits::IntoString,
writer::{primitives::tabs, ToCode},
};
use std::io::{Result, Write};

pub fn generate(
w: &mut dyn Write,
Expand Down
3 changes: 1 addition & 2 deletions src/codegen/doc/format.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::analysis::symbols;
use lazy_static::lazy_static;
use regex::{Captures, Regex};

use crate::analysis::symbols;

const LANGUAGE_SEP_BEGIN: &str = "<!-- language=\"";
const LANGUAGE_SEP_END: &str = "\" -->";
const LANGUAGE_BLOCK_BEGIN: &str = "|[";
Expand Down
17 changes: 8 additions & 9 deletions src/codegen/doc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
use lazy_static::lazy_static;
use log::{error, info};
use regex::{Captures, Regex};
use std::{
borrow::Cow,
io::{Result, Write},
};
use stripper_lib::{write_file_name, write_item_doc, Type as SType, TypeStruct};

use self::format::reformat_doc;
use crate::{
analysis::{self, namespaces::MAIN},
Expand All @@ -19,6 +10,14 @@ use crate::{
traits::*,
version::Version,
};
use lazy_static::lazy_static;
use log::{error, info};
use regex::{Captures, Regex};
use std::{
borrow::Cow,
io::{Result, Write},
};
use stripper_lib::{write_file_name, write_item_doc, Type as SType, TypeStruct};

mod format;

Expand Down
Loading

0 comments on commit 81953fb

Please sign in to comment.