From 2b147616fdf0b47136afe09ff836a26c86eeac48 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Tue, 4 Oct 2016 19:20:16 +0300 Subject: [PATCH 1/3] derive -> ipc --- Cargo.lock | 16 ---------------- Cargo.toml | 9 +-------- db/src/database.rs | 2 +- ethcore/src/client/chain_notify.rs | 2 +- ethcore/src/client/traits.rs | 1 - ethcore/src/snapshot/snapshot_service_trait.rs | 1 - ipc/codegen/src/codegen.rs | 4 ++-- ipc/codegen/src/lib.rs | 4 ++-- ipc/hypervisor/src/service.rs.in | 4 ++-- ipc/tests/nested.rs.in | 4 ++-- ipc/tests/service.rs.in | 2 +- ipc/tests/with_attrs.rs.in | 1 - stratum/src/traits.rs | 2 -- sync/Cargo.toml | 3 ++- sync/src/api.rs | 2 -- 15 files changed, 14 insertions(+), 43 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb91080c2..821933d2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -276,7 +276,6 @@ dependencies = [ "bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 1.4.0", @@ -290,7 +289,6 @@ dependencies = [ "ethjson 0.1.0", "ethkey 0.2.0", "ethstore 0.1.0", - "evmjit 1.4.0", "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.9.4 (git+https://github.com/ethcore/hyper)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -324,7 +322,6 @@ version = "0.1.0" name = "ethcore-dapps" version = "1.4.0" dependencies = [ - "clippy 0.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-devtools 1.4.0", "ethcore-rpc 1.4.0", @@ -466,7 +463,6 @@ dependencies = [ name = "ethcore-rpc" version = "1.4.0" dependencies = [ - "clippy 0.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 1.4.0", "ethcore 1.4.0", "ethcore-devtools 1.4.0", @@ -496,7 +492,6 @@ dependencies = [ name = "ethcore-signer" version = "1.4.0" dependencies = [ - "clippy 0.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-devtools 1.4.0", "ethcore-io 1.4.0", @@ -534,7 +529,6 @@ version = "1.4.0" dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "eth-secp256k1 0.5.4 (git+https://github.com/ethcore/rust-secp256k1)", @@ -588,7 +582,6 @@ dependencies = [ name = "ethkey" version = "0.2.0" dependencies = [ - "docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)", "eth-secp256k1 0.5.4 (git+https://github.com/ethcore/rust-secp256k1)", "ethcore-bigint 0.1.0", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -601,7 +594,6 @@ dependencies = [ name = "ethstore" version = "0.1.0" dependencies = [ - "docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)", "ethcrypto 0.1.0", "ethkey 0.2.0", "itertools 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -621,7 +613,6 @@ dependencies = [ name = "ethsync" version = "1.4.0" dependencies = [ - "clippy 0.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.4.0", "ethcore-io 1.4.0", @@ -639,13 +630,6 @@ dependencies = [ "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "evmjit" -version = "1.4.0" -dependencies = [ - "tiny-keccak 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "fdlimit" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 034b1383b..da7e252f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,14 +62,7 @@ default = ["ui", "use-precompiled-js", "ipc"] ui = ["dapps", "ethcore-signer/ui"] use-precompiled-js = ["ethcore-dapps/use-precompiled-js", "ethcore-signer/use-precompiled-js"] dapps = ["ethcore-dapps"] -ipc = ["ethcore/ipc"] -jit = ["ethcore/jit"] -dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev", "ethcore-rpc/dev", "ethcore-dapps/dev", "ethcore-signer/dev"] -json-tests = ["ethcore/json-tests"] -stratum = ["ipc"] -ethkey-cli = ["ethcore/ethkey-cli"] -ethstore-cli = ["ethcore/ethstore-cli"] -evm-debug = ["ethcore/evm-debug"] +ipc = ["ethcore/ipc", "ethsync/ipc"] evm-debug-tests = ["ethcore/evm-debug-tests"] slow-blocks = ["ethcore/slow-blocks"] diff --git a/db/src/database.rs b/db/src/database.rs index 9a52822f6..e1774159b 100644 --- a/db/src/database.rs +++ b/db/src/database.rs @@ -157,7 +157,7 @@ impl Drop for Database { } } -#[derive(Ipc)] +#[ipc] impl DatabaseService for Database { fn open(&self, config: DatabaseConfig, path: String) -> Result<(), Error> { let mut db = self.db.write(); diff --git a/ethcore/src/client/chain_notify.rs b/ethcore/src/client/chain_notify.rs index 0c34382a0..e0282d460 100644 --- a/ethcore/src/client/chain_notify.rs +++ b/ethcore/src/client/chain_notify.rs @@ -18,7 +18,7 @@ use ipc::IpcConfig; use util::H256; /// Represents what has to be handled by actor listening to chain events -#[derive(Ipc)] +#[ipc] pub trait ChainNotify : Send + Sync { /// fires when chain has new blocks. fn new_blocks(&self, diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index c2af744dd..5f7b62ee2 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -38,7 +38,6 @@ use ipc::IpcConfig; use types::blockchain_info::BlockChainInfo; use types::block_status::BlockStatus; -#[derive(Ipc)] #[ipc(client_ident="RemoteClient")] /// Blockchain database client. Owns and manages a blockchain and a block queue. pub trait BlockChainClient : Sync + Send { diff --git a/ethcore/src/snapshot/snapshot_service_trait.rs b/ethcore/src/snapshot/snapshot_service_trait.rs index 7df90c943..65448090f 100644 --- a/ethcore/src/snapshot/snapshot_service_trait.rs +++ b/ethcore/src/snapshot/snapshot_service_trait.rs @@ -22,7 +22,6 @@ use ipc::IpcConfig; /// This handles: /// - restoration of snapshots to temporary databases. /// - responding to queries for snapshot manifests and chunks -#[derive(Ipc)] #[ipc(client_ident="RemoteSnapshotService")] pub trait SnapshotService : Sync + Send { /// Query the most recent manifest data. diff --git a/ipc/codegen/src/codegen.rs b/ipc/codegen/src/codegen.rs index 89bd9548c..9c7b33be8 100644 --- a/ipc/codegen/src/codegen.rs +++ b/ipc/codegen/src/codegen.rs @@ -49,7 +49,7 @@ pub fn expand_ipc_implementation( let item = match *annotatable { Annotatable::Item(ref item) => item, _ => { - cx.span_err(meta_item.span, "`#[derive(Ipc)]` may only be applied to struct implementations"); + cx.span_err(meta_item.span, "`#[ipc]` may only be applied to struct implementations"); return; }, }; @@ -832,7 +832,7 @@ fn implement_interface( _ => { cx.span_err( item.span, - "`#[derive(Ipc)]` may only be applied to implementations and traits"); + "`#[ipc]` may only be applied to implementations and traits"); return Err(Error); }, }; diff --git a/ipc/codegen/src/lib.rs b/ipc/codegen/src/lib.rs index ce1ca8592..94959b058 100644 --- a/ipc/codegen/src/lib.rs +++ b/ipc/codegen/src/lib.rs @@ -83,7 +83,7 @@ pub fn register(reg: &mut syntex::Registry) { reg.add_attr("feature(custom_derive)"); reg.add_attr("feature(custom_attribute)"); - reg.add_decorator("derive_Ipc", codegen::expand_ipc_implementation); + reg.add_decorator("ipc", codegen::expand_ipc_implementation); reg.add_decorator("derive_Binary", serialization::expand_serialization_implementation); reg.add_post_expansion_pass(strip_attributes); @@ -92,7 +92,7 @@ pub fn register(reg: &mut syntex::Registry) { #[cfg(not(feature = "with-syntex"))] pub fn register(reg: &mut rustc_plugin::Registry) { reg.register_syntax_extension( - syntax::parse::token::intern("derive_Ipc"), + syntax::parse::token::intern("ipc"), syntax::ext::base::MultiDecorator( Box::new(codegen::expand_ipc_implementation))); reg.register_syntax_extension( diff --git a/ipc/hypervisor/src/service.rs.in b/ipc/hypervisor/src/service.rs.in index 74d289f50..6996765ec 100644 --- a/ipc/hypervisor/src/service.rs.in +++ b/ipc/hypervisor/src/service.rs.in @@ -40,12 +40,12 @@ pub struct ModuleState { } -#[derive(Ipc)] +#[ipc] pub trait ControlService { fn shutdown(&self) -> bool; } -#[derive(Ipc)] +#[ipc] impl HypervisorService { // return type for making method synchronous fn module_ready(&self, module_id: u64, control_url: String) -> bool { diff --git a/ipc/tests/nested.rs.in b/ipc/tests/nested.rs.in index 4f0ac4a8a..df0c9bde3 100644 --- a/ipc/tests/nested.rs.in +++ b/ipc/tests/nested.rs.in @@ -33,7 +33,7 @@ impl IpcConfig for DBWriter {} #[derive(Binary)] pub enum DBError { Write, Read } -#[derive(Ipc)] +#[ipc] impl DBWriter for DB { fn write(&self, data: Vec) -> Result<(), DBError> { let mut writes = self.writes.write().unwrap(); @@ -48,7 +48,7 @@ impl DBWriter for DB { } } -#[derive(Ipc)] +#[ipc] trait DBNotify { fn notify(&self, a: u64, b: u64) -> bool; } diff --git a/ipc/tests/service.rs.in b/ipc/tests/service.rs.in index 9c221d481..cd9a5a6b2 100644 --- a/ipc/tests/service.rs.in +++ b/ipc/tests/service.rs.in @@ -28,7 +28,7 @@ pub struct CustomData { pub b: u64, } -#[derive(Ipc)] +#[ipc] impl Service { fn commit(&self, f: u32) -> u32 { let mut lock = self.commits.write().unwrap(); diff --git a/ipc/tests/with_attrs.rs.in b/ipc/tests/with_attrs.rs.in index bbf5b894a..f65627fce 100644 --- a/ipc/tests/with_attrs.rs.in +++ b/ipc/tests/with_attrs.rs.in @@ -18,7 +18,6 @@ use ipc::IpcConfig; pub struct BadlyNamedService; -#[derive(Ipc)] #[ipc(client_ident="PrettyNamedClient")] impl BadlyNamedService { fn is_zero(&self, x: u64) -> bool { diff --git a/stratum/src/traits.rs b/stratum/src/traits.rs index 339f753b5..5e93a9484 100644 --- a/stratum/src/traits.rs +++ b/stratum/src/traits.rs @@ -32,7 +32,6 @@ impl From for Error { } } -#[derive(Ipc)] #[ipc(client_ident="RemoteJobDispatcher")] /// Interface that can provide pow/blockchain-specific responses for the clients pub trait JobDispatcher: Send + Sync { @@ -44,7 +43,6 @@ pub trait JobDispatcher: Send + Sync { fn job(&self, _worker_id: String) -> Option { None } } -#[derive(Ipc)] #[ipc(client_ident="RemoteWorkHandler")] /// Interface that can handle requests to push job for workers pub trait PushWorkHandler: Send + Sync { diff --git a/sync/Cargo.toml b/sync/Cargo.toml index 99c522075..3b5fc3c9c 100644 --- a/sync/Cargo.toml +++ b/sync/Cargo.toml @@ -29,5 +29,6 @@ ethcore-ipc-nano = { path = "../ipc/nano" } parking_lot = "0.2.6" [features] -default = [] +default = ["ipc"] dev = ["clippy", "ethcore/dev", "ethcore-util/dev"] +ipc = [] diff --git a/sync/src/api.rs b/sync/src/api.rs index 961a70cd3..c09157e3b 100644 --- a/sync/src/api.rs +++ b/sync/src/api.rs @@ -88,7 +88,6 @@ impl EthSync { } } -#[derive(Ipc)] #[ipc(client_ident="SyncClient")] impl SyncProvider for EthSync { /// Get sync status @@ -184,7 +183,6 @@ pub trait ManageNetwork : Send + Sync { } -#[derive(Ipc)] #[ipc(client_ident="NetworkManagerClient")] impl ManageNetwork for EthSync { fn accept_unreserved_peers(&self) { From 0002bfadabefe68eb3334a5b9b39014b8549001e Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Tue, 4 Oct 2016 19:22:26 +0300 Subject: [PATCH 2/3] accident repair --- Cargo.lock | 16 ++++++++++++++++ Cargo.toml | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 821933d2e..bb91080c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -276,6 +276,7 @@ dependencies = [ "bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 1.4.0", @@ -289,6 +290,7 @@ dependencies = [ "ethjson 0.1.0", "ethkey 0.2.0", "ethstore 0.1.0", + "evmjit 1.4.0", "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.9.4 (git+https://github.com/ethcore/hyper)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -322,6 +324,7 @@ version = "0.1.0" name = "ethcore-dapps" version = "1.4.0" dependencies = [ + "clippy 0.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-devtools 1.4.0", "ethcore-rpc 1.4.0", @@ -463,6 +466,7 @@ dependencies = [ name = "ethcore-rpc" version = "1.4.0" dependencies = [ + "clippy 0.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 1.4.0", "ethcore 1.4.0", "ethcore-devtools 1.4.0", @@ -492,6 +496,7 @@ dependencies = [ name = "ethcore-signer" version = "1.4.0" dependencies = [ + "clippy 0.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-devtools 1.4.0", "ethcore-io 1.4.0", @@ -529,6 +534,7 @@ version = "1.4.0" dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "eth-secp256k1 0.5.4 (git+https://github.com/ethcore/rust-secp256k1)", @@ -582,6 +588,7 @@ dependencies = [ name = "ethkey" version = "0.2.0" dependencies = [ + "docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)", "eth-secp256k1 0.5.4 (git+https://github.com/ethcore/rust-secp256k1)", "ethcore-bigint 0.1.0", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -594,6 +601,7 @@ dependencies = [ name = "ethstore" version = "0.1.0" dependencies = [ + "docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)", "ethcrypto 0.1.0", "ethkey 0.2.0", "itertools 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -613,6 +621,7 @@ dependencies = [ name = "ethsync" version = "1.4.0" dependencies = [ + "clippy 0.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.4.0", "ethcore-io 1.4.0", @@ -630,6 +639,13 @@ dependencies = [ "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "evmjit" +version = "1.4.0" +dependencies = [ + "tiny-keccak 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fdlimit" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index da7e252f4..38003e7a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,6 +63,13 @@ ui = ["dapps", "ethcore-signer/ui"] use-precompiled-js = ["ethcore-dapps/use-precompiled-js", "ethcore-signer/use-precompiled-js"] dapps = ["ethcore-dapps"] ipc = ["ethcore/ipc", "ethsync/ipc"] +jit = ["ethcore/jit"] +dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev", "ethcore-rpc/dev", "ethcore-dapps/dev", "ethcore-signer/dev"] +json-tests = ["ethcore/json-tests"] +stratum = ["ipc"] +ethkey-cli = ["ethcore/ethkey-cli"] +ethstore-cli = ["ethcore/ethstore-cli"] +evm-debug = ["ethcore/evm-debug"] evm-debug-tests = ["ethcore/evm-debug-tests"] slow-blocks = ["ethcore/slow-blocks"] From a7e09d88427e64611e0f8f0562c43fc2e9fcb905 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Wed, 5 Oct 2016 10:36:09 +0300 Subject: [PATCH 3/3] Update codegen.rs --- ipc/codegen/src/codegen.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/codegen/src/codegen.rs b/ipc/codegen/src/codegen.rs index 9c7b33be8..9caa436bc 100644 --- a/ipc/codegen/src/codegen.rs +++ b/ipc/codegen/src/codegen.rs @@ -49,7 +49,7 @@ pub fn expand_ipc_implementation( let item = match *annotatable { Annotatable::Item(ref item) => item, _ => { - cx.span_err(meta_item.span, "`#[ipc]` may only be applied to struct implementations"); + cx.span_err(meta_item.span, "`#[ipc]` may only be applied to implementations and traits"); return; }, };