Skip to content

Commit

Permalink
Use explicit global namespaces in codegen (openethereum#1928)
Browse files Browse the repository at this point in the history
* ipc as a deault feature

* first part of purge

* second part of ns purge
  • Loading branch information
NikVolf authored and gavofyork committed Aug 17, 2016
1 parent e01ba60 commit 46f029e
Show file tree
Hide file tree
Showing 31 changed files with 16 additions and 94 deletions.
3 changes: 0 additions & 3 deletions db/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

//! Ethcore database trait
use std::mem;
use ipc::binary::BinaryConvertError;
use std::collections::VecDeque;
use std::cell::RefCell;

pub type IteratorHandle = u32;
Expand Down
4 changes: 1 addition & 3 deletions ethcore/src/client/chain_notify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use std::collections::VecDeque;
use std::mem;
use ipc::{IpcConfig, BinaryConvertError};
use ipc::IpcConfig;
use util::H256;

/// Represents what has to be handled by actor listening to chain events
Expand Down
4 changes: 1 addition & 3 deletions ethcore/src/client/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ use executive::Executed;
use env_info::LastHashes;
use types::call_analytics::CallAnalytics;
use block_import_error::BlockImportError;
use std::mem;
use std::collections::VecDeque;
use ipc::{IpcConfig, BinaryConvertError};
use ipc::IpcConfig;
use types::blockchain_info::BlockChainInfo;
use types::block_status::BlockStatus;

Expand Down
6 changes: 3 additions & 3 deletions ethcore/src/types/account_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
//! Diff between two accounts.
use std::cmp::*;
use std::{fmt, mem};
use std::collections::{VecDeque, BTreeMap};
use std::fmt;
use std::collections::BTreeMap;
use util::{U256, H256, Uint, Bytes};
use ipc::binary::{BinaryConvertError, BinaryConvertable};
use ipc::binary::BinaryConvertable;

#[derive(Debug, PartialEq, Eq, Clone, Binary)]
/// Diff type for specifying a change (or not).
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/types/block_import_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

//! Block import error related types
use std::mem;
use ipc::binary::BinaryConvertError;
use std::collections::VecDeque;
use error::{ImportError, BlockError, Error};
use std::convert::From;

Expand Down
4 changes: 0 additions & 4 deletions ethcore/src/types/block_queue_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

//! Block queue info types
use std::mem;
use ipc::binary::BinaryConvertError;
use std::collections::VecDeque;

/// Block queue status
#[derive(Debug, Binary)]
pub struct BlockQueueInfo {
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/types/block_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

//! Block status description module
use ipc::binary::BinaryConvertError;
use std::collections::VecDeque;

/// General block status
#[derive(Debug, Eq, PartialEq, Binary)]
pub enum BlockStatus {
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/types/blockchain_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

//! Blockhain info type definition
use std::mem;
use std::collections::VecDeque;
use util::{U256, H256};
use ipc::binary::BinaryConvertError;
use header::BlockNumber;

/// Information about the blockchain gathered together.
Expand Down
4 changes: 0 additions & 4 deletions ethcore/src/types/call_analytics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

//! Call analytics related types
use std::mem;
use ipc::binary::{BinaryConvertError};
use std::collections::VecDeque;

/// Options concerning what analytics we run on the call.
#[derive(Eq, PartialEq, Default, Clone, Copy, Debug, Binary)]
pub struct CallAnalytics {
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/types/executed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ use util::rlp::*;
use trace::{VMTrace, FlatTrace};
use types::log_entry::LogEntry;
use types::state_diff::StateDiff;
use ipc::binary::BinaryConvertError;
use std::fmt;
use std::mem;
use std::collections::VecDeque;

/// The type of the call-like instruction.
#[derive(Debug, PartialEq, Clone, Binary)]
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/types/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@

//! Blockchain filter
use std::mem;
use std::collections::VecDeque;
use util::{Address, H256, Hashable, H2048};
use util::bloom::Bloomable;
use client::BlockID;
use log_entry::LogEntry;
use ipc::binary::BinaryConvertError;

/// Blockchain Filter.
#[derive(Binary)]
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/types/ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
use util::hash::H256;
use header::BlockNumber;
use ipc::binary::BinaryConvertError;
use std::mem;
use std::collections::VecDeque;

/// Uniquely identifies block.
#[derive(Debug, PartialEq, Copy, Clone, Hash, Eq, Binary)]
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/types/log_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@

//! Log entry type definition.
use std::mem;
use std::ops::Deref;
use std::collections::VecDeque;
use util::{H256, Address, Bytes, HeapSizeOf, Hashable};
use util::rlp::*;
use util::bloom::Bloomable;
use ipc::binary::BinaryConvertError;
use basic_types::LogBloom;
use header::BlockNumber;
use ethjson;
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/types/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@

//! Receipt
use std::mem;
use std::collections::VecDeque;
use util::{H256, U256, Address};
use util::rlp::*;
use util::HeapSizeOf;
use basic_types::LogBloom;
use header::BlockNumber;
use log_entry::{LogEntry, LocalizedLogEntry};
use ipc::binary::BinaryConvertError;

/// Information describing execution of a transaction.
#[derive(Default, Debug, Clone, Binary)]
Expand Down
5 changes: 2 additions & 3 deletions ethcore/src/types/state_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@

//! State diff module.
use std::{mem, fmt};
use std::fmt;
use std::ops::*;
use std::collections::{VecDeque, BTreeMap};
use std::collections::BTreeMap;
use util::Address;
use account_diff::*;
use ipc::binary::BinaryConvertError;

#[derive(Debug, PartialEq, Eq, Clone, Binary)]
/// Expression for the delta between two system states. Encoded the
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/types/trace_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

//! Trace filter related types
use std::mem;
use ipc::binary::{BinaryConvertError};
use std::collections::VecDeque;
use std::ops::Range;
use util::{Address};
use types::ids::BlockID;
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/types/trace_types/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@
//! Trace filters type definitions
use std::ops::Range;
use std::mem;
use std::collections::VecDeque;
use bloomchain::{Filter as BloomFilter, Bloom, Number};
use util::Address;
use util::sha3::Hashable;
use util::bloom::Bloomable;
use basic_types::LogBloom;
use trace::flat::FlatTrace;
use types::trace_types::trace::{Action, Res};
use ipc::binary::BinaryConvertError;

/// Addresses filter.
///
Expand Down
2 changes: 0 additions & 2 deletions ethcore/src/types/trace_types/flat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
//! Flat trace module
use std::collections::VecDeque;
use std::mem;
use ipc::binary::BinaryConvertError;
use util::rlp::*;
use util::HeapSizeOf;
use basic_types::LogBloom;
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/types/trace_types/localized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
use util::H256;
use super::trace::{Action, Res};
use header::BlockNumber;
use ipc::binary::BinaryConvertError;
use std::mem;
use std::collections::VecDeque;

/// Localized trace.
#[derive(Debug, PartialEq, Binary)]
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/types/trace_types/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ use util::bloom::Bloomable;
use action_params::ActionParams;
use basic_types::LogBloom;
use types::executed::CallType;
use ipc::binary::BinaryConvertError;
use std::mem;
use std::collections::VecDeque;

/// `Call` result.
#[derive(Debug, Clone, PartialEq, Default, Binary)]
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

//! Transaction data structure.
use std::mem;
use std::collections::VecDeque;
use util::{H256, Address, U256, H520};
use std::ops::Deref;
use util::rlp::*;
Expand All @@ -29,7 +27,6 @@ use error::*;
use evm::Schedule;
use header::BlockNumber;
use ethjson;
use ipc::binary::BinaryConvertError;
use ethstore::ethkey::Signature as EthkeySignature;

#[derive(Debug, Clone, PartialEq, Eq, Binary)]
Expand Down
2 changes: 0 additions & 2 deletions ethcore/src/types/transaction_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
//! Transaction import result related types
use ipc::binary::{BinaryConvertError, BinaryConvertable};
use std::collections::VecDeque;
use error::{TransactionError, Error};
use std::mem;
use util::Populatable;

#[derive(Debug, Clone, PartialEq)]
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/types/tree_route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

//! Tree route info type definition
use std::collections::VecDeque;
use std::mem;
use ipc::BinaryConvertError;
use util::H256;

/// Represents a tree route between `from` block and `to` block:
Expand Down
14 changes: 7 additions & 7 deletions ipc/codegen/src/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ fn serialize_item(
$size_expr
}

fn to_bytes(&self, buffer: &mut [u8], length_stack: &mut VecDeque<usize>) -> Result<(), BinaryConvertError> {
fn to_bytes(&self, buffer: &mut [u8], length_stack: &mut ::std::collections::VecDeque<usize>) -> Result<(), ::ipc::BinaryConvertError> {
$write_expr
}

fn from_bytes(buffer: &[u8], length_stack: &mut VecDeque<usize>) -> Result<Self, BinaryConvertError> {
fn from_bytes(buffer: &[u8], length_stack: &mut ::std::collections::VecDeque<usize>) -> Result<Self, ::ipc::BinaryConvertError> {
$read_expr
}

Expand Down Expand Up @@ -210,13 +210,13 @@ fn binary_expr_struct(
let field_id = builder.id(field.ident.unwrap());
Some(quote_expr!(cx,
match $field_type_ident_qualified::len_params() {
0 => mem::size_of::<$field_type_ident>(),
0 => ::std::mem::size_of::<$field_type_ident>(),
_ => $x. $field_id .size(),
}))
})
.unwrap_or_else(|| {
quote_expr!(cx, match $field_type_ident_qualified::len_params() {
0 => mem::size_of::<$field_type_ident>(),
0 => ::std::mem::size_of::<$field_type_ident>(),
_ => $index_ident .size(),
})
})
Expand Down Expand Up @@ -279,7 +279,7 @@ fn binary_expr_struct(
}
_ => {
write_stmts.push(quote_stmt!(cx, let next_line = offset + match $field_type_ident_qualified::len_params() {
0 => mem::size_of::<$field_type_ident>(),
0 => ::std::mem::size_of::<$field_type_ident>(),
_ => { let size = $member_expr .size(); length_stack.push_back(size); size },
}).unwrap());
write_stmts.push(quote_stmt!(cx, let $range_ident = offset..next_line; ).unwrap());
Expand Down Expand Up @@ -309,7 +309,7 @@ fn binary_expr_struct(
},
_ => {
map_stmts.push(quote_stmt!(cx, let size = match $field_type_ident_qualified::len_params() {
0 => mem::size_of::<$field_type_ident>(),
0 => ::std::mem::size_of::<$field_type_ident>(),
_ => length_stack.pop_front().unwrap(),
}).unwrap());
map_stmts.push(quote_stmt!(cx, total += size;).unwrap());
Expand Down Expand Up @@ -412,7 +412,7 @@ fn binary_expr_enum(
arms.iter().map(|x| x.write.clone()).collect::<Vec<ast::Arm>>(),
arms.iter().map(|x| x.read.clone()).collect::<Vec<ast::Arm>>());

read_arms.push(quote_arm!(cx, _ => { Err(BinaryConvertError::variant(buffer[0])) } ));
read_arms.push(quote_arm!(cx, _ => { Err(::ipc::BinaryConvertError::variant(buffer[0])) } ));

Ok(BinaryExpressions {
size: quote_expr!(cx, 1usize + match *self { $size_arms }),
Expand Down
3 changes: 0 additions & 3 deletions ipc/hypervisor/src/service.rs.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
use std::sync::{RwLock,Arc};
use ipc::IpcConfig;
use std::collections::HashMap;
use std::mem;
use ipc::binary::BinaryConvertError;
use std::collections::VecDeque;

pub type IpcModuleId = u64;

Expand Down
4 changes: 2 additions & 2 deletions ipc/rpc/src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ pub fn serialize<T: BinaryConvertable>(t: &T) -> Result<Vec<u8>, BinaryError> {
macro_rules! binary_fixed_size {
($target_ty: ty) => {
impl BinaryConvertable for $target_ty {
fn from_bytes(bytes: &[u8], _length_stack: &mut VecDeque<usize>) -> Result<Self, BinaryConvertError> {
fn from_bytes(bytes: &[u8], _length_stack: &mut ::std::collections::VecDeque<usize>) -> Result<Self, BinaryConvertError> {
match bytes.len().cmp(&::std::mem::size_of::<$target_ty>()) {
::std::cmp::Ordering::Equal => (),
_ => return Err(BinaryConvertError::size(::std::mem::size_of::<$target_ty>(), bytes.len())),
Expand All @@ -717,7 +717,7 @@ macro_rules! binary_fixed_size {
Ok(res)
}

fn to_bytes(&self, buffer: &mut [u8], _length_stack: &mut VecDeque<usize>) -> Result<(), BinaryConvertError> {
fn to_bytes(&self, buffer: &mut [u8], _length_stack: &mut ::std::collections::VecDeque<usize>) -> Result<(), BinaryConvertError> {
let sz = ::std::mem::size_of::<$target_ty>();
let ip: *const $target_ty = self;
let ptr: *const u8 = ip as *const _;
Expand Down
2 changes: 0 additions & 2 deletions ipc/tests/binary.rs.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@


use ipc::*;
use std::mem;
use std::collections::VecDeque;
use util::Bytes;

#[derive(Binary)]
Expand Down
3 changes: 0 additions & 3 deletions ipc/tests/nested.rs.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

use std::sync::RwLock;
use ipc::IpcConfig;
use std::mem;
use ipc::binary::BinaryConvertError;
use std::collections::VecDeque;

pub struct DB<L: Sized> {
pub writes: RwLock<u64>,
Expand Down
3 changes: 0 additions & 3 deletions ipc/tests/service.rs.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

use std::sync::RwLock;
use ipc::IpcConfig;
use std::mem;
use ipc::binary::BinaryConvertError;
use std::collections::VecDeque;

pub struct Service {
pub commits: RwLock<usize>,
Expand Down
3 changes: 0 additions & 3 deletions ipc/tests/with_attrs.rs.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use ipc::IpcConfig;
use std::mem;
use ipc::binary::BinaryConvertError;
use std::collections::VecDeque;

pub struct BadlyNamedService;

Expand Down
Loading

0 comments on commit 46f029e

Please sign in to comment.