Merge pull request #2460 from ethcore/ipc-codegen

Merge IPC codegen attributes into one
This commit is contained in:
Nikolay Volf 2016-10-05 14:30:21 +04:00 committed by GitHub
commit 1782b659d1
14 changed files with 14 additions and 20 deletions

View File

@ -62,7 +62,7 @@ default = ["ui", "use-precompiled-js", "ipc"]
ui = ["dapps", "ethcore-signer/ui"] ui = ["dapps", "ethcore-signer/ui"]
use-precompiled-js = ["ethcore-dapps/use-precompiled-js", "ethcore-signer/use-precompiled-js"] use-precompiled-js = ["ethcore-dapps/use-precompiled-js", "ethcore-signer/use-precompiled-js"]
dapps = ["ethcore-dapps"] dapps = ["ethcore-dapps"]
ipc = ["ethcore/ipc"] ipc = ["ethcore/ipc", "ethsync/ipc"]
jit = ["ethcore/jit"] jit = ["ethcore/jit"]
dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev", "ethcore-rpc/dev", "ethcore-dapps/dev", "ethcore-signer/dev"] dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev", "ethcore-rpc/dev", "ethcore-dapps/dev", "ethcore-signer/dev"]
json-tests = ["ethcore/json-tests"] json-tests = ["ethcore/json-tests"]

View File

@ -157,7 +157,7 @@ impl Drop for Database {
} }
} }
#[derive(Ipc)] #[ipc]
impl DatabaseService for Database { impl DatabaseService for Database {
fn open(&self, config: DatabaseConfig, path: String) -> Result<(), Error> { fn open(&self, config: DatabaseConfig, path: String) -> Result<(), Error> {
let mut db = self.db.write(); let mut db = self.db.write();

View File

@ -18,7 +18,7 @@ use ipc::IpcConfig;
use util::H256; use util::H256;
/// Represents what has to be handled by actor listening to chain events /// Represents what has to be handled by actor listening to chain events
#[derive(Ipc)] #[ipc]
pub trait ChainNotify : Send + Sync { pub trait ChainNotify : Send + Sync {
/// fires when chain has new blocks. /// fires when chain has new blocks.
fn new_blocks(&self, fn new_blocks(&self,

View File

@ -38,7 +38,6 @@ use ipc::IpcConfig;
use types::blockchain_info::BlockChainInfo; use types::blockchain_info::BlockChainInfo;
use types::block_status::BlockStatus; use types::block_status::BlockStatus;
#[derive(Ipc)]
#[ipc(client_ident="RemoteClient")] #[ipc(client_ident="RemoteClient")]
/// Blockchain database client. Owns and manages a blockchain and a block queue. /// Blockchain database client. Owns and manages a blockchain and a block queue.
pub trait BlockChainClient : Sync + Send { pub trait BlockChainClient : Sync + Send {

View File

@ -22,7 +22,6 @@ use ipc::IpcConfig;
/// This handles: /// This handles:
/// - restoration of snapshots to temporary databases. /// - restoration of snapshots to temporary databases.
/// - responding to queries for snapshot manifests and chunks /// - responding to queries for snapshot manifests and chunks
#[derive(Ipc)]
#[ipc(client_ident="RemoteSnapshotService")] #[ipc(client_ident="RemoteSnapshotService")]
pub trait SnapshotService : Sync + Send { pub trait SnapshotService : Sync + Send {
/// Query the most recent manifest data. /// Query the most recent manifest data.

View File

@ -49,7 +49,7 @@ pub fn expand_ipc_implementation(
let item = match *annotatable { let item = match *annotatable {
Annotatable::Item(ref item) => item, 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 implementations and traits");
return; return;
}, },
}; };
@ -832,7 +832,7 @@ fn implement_interface(
_ => { _ => {
cx.span_err( cx.span_err(
item.span, item.span,
"`#[derive(Ipc)]` may only be applied to implementations and traits"); "`#[ipc]` may only be applied to implementations and traits");
return Err(Error); return Err(Error);
}, },
}; };

View File

@ -83,7 +83,7 @@ pub fn register(reg: &mut syntex::Registry) {
reg.add_attr("feature(custom_derive)"); reg.add_attr("feature(custom_derive)");
reg.add_attr("feature(custom_attribute)"); 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_decorator("derive_Binary", serialization::expand_serialization_implementation);
reg.add_post_expansion_pass(strip_attributes); reg.add_post_expansion_pass(strip_attributes);
@ -92,7 +92,7 @@ pub fn register(reg: &mut syntex::Registry) {
#[cfg(not(feature = "with-syntex"))] #[cfg(not(feature = "with-syntex"))]
pub fn register(reg: &mut rustc_plugin::Registry) { pub fn register(reg: &mut rustc_plugin::Registry) {
reg.register_syntax_extension( reg.register_syntax_extension(
syntax::parse::token::intern("derive_Ipc"), syntax::parse::token::intern("ipc"),
syntax::ext::base::MultiDecorator( syntax::ext::base::MultiDecorator(
Box::new(codegen::expand_ipc_implementation))); Box::new(codegen::expand_ipc_implementation)));
reg.register_syntax_extension( reg.register_syntax_extension(

View File

@ -40,12 +40,12 @@ pub struct ModuleState {
} }
#[derive(Ipc)] #[ipc]
pub trait ControlService { pub trait ControlService {
fn shutdown(&self) -> bool; fn shutdown(&self) -> bool;
} }
#[derive(Ipc)] #[ipc]
impl HypervisorService { impl HypervisorService {
// return type for making method synchronous // return type for making method synchronous
fn module_ready(&self, module_id: u64, control_url: String) -> bool { fn module_ready(&self, module_id: u64, control_url: String) -> bool {

View File

@ -33,7 +33,7 @@ impl IpcConfig for DBWriter {}
#[derive(Binary)] #[derive(Binary)]
pub enum DBError { Write, Read } pub enum DBError { Write, Read }
#[derive(Ipc)] #[ipc]
impl<L: Sized> DBWriter for DB<L> { impl<L: Sized> DBWriter for DB<L> {
fn write(&self, data: Vec<u8>) -> Result<(), DBError> { fn write(&self, data: Vec<u8>) -> Result<(), DBError> {
let mut writes = self.writes.write().unwrap(); let mut writes = self.writes.write().unwrap();
@ -48,7 +48,7 @@ impl<L: Sized> DBWriter for DB<L> {
} }
} }
#[derive(Ipc)] #[ipc]
trait DBNotify { trait DBNotify {
fn notify(&self, a: u64, b: u64) -> bool; fn notify(&self, a: u64, b: u64) -> bool;
} }

View File

@ -28,7 +28,7 @@ pub struct CustomData {
pub b: u64, pub b: u64,
} }
#[derive(Ipc)] #[ipc]
impl Service { impl Service {
fn commit(&self, f: u32) -> u32 { fn commit(&self, f: u32) -> u32 {
let mut lock = self.commits.write().unwrap(); let mut lock = self.commits.write().unwrap();

View File

@ -18,7 +18,6 @@ use ipc::IpcConfig;
pub struct BadlyNamedService; pub struct BadlyNamedService;
#[derive(Ipc)]
#[ipc(client_ident="PrettyNamedClient")] #[ipc(client_ident="PrettyNamedClient")]
impl BadlyNamedService { impl BadlyNamedService {
fn is_zero(&self, x: u64) -> bool { fn is_zero(&self, x: u64) -> bool {

View File

@ -32,7 +32,6 @@ impl From<std::io::Error> for Error {
} }
} }
#[derive(Ipc)]
#[ipc(client_ident="RemoteJobDispatcher")] #[ipc(client_ident="RemoteJobDispatcher")]
/// Interface that can provide pow/blockchain-specific responses for the clients /// Interface that can provide pow/blockchain-specific responses for the clients
pub trait JobDispatcher: Send + Sync { pub trait JobDispatcher: Send + Sync {
@ -44,7 +43,6 @@ pub trait JobDispatcher: Send + Sync {
fn job(&self, _worker_id: String) -> Option<String> { None } fn job(&self, _worker_id: String) -> Option<String> { None }
} }
#[derive(Ipc)]
#[ipc(client_ident="RemoteWorkHandler")] #[ipc(client_ident="RemoteWorkHandler")]
/// Interface that can handle requests to push job for workers /// Interface that can handle requests to push job for workers
pub trait PushWorkHandler: Send + Sync { pub trait PushWorkHandler: Send + Sync {

View File

@ -29,5 +29,6 @@ ethcore-ipc-nano = { path = "../ipc/nano" }
parking_lot = "0.2.6" parking_lot = "0.2.6"
[features] [features]
default = [] default = ["ipc"]
dev = ["clippy", "ethcore/dev", "ethcore-util/dev"] dev = ["clippy", "ethcore/dev", "ethcore-util/dev"]
ipc = []

View File

@ -88,7 +88,6 @@ impl EthSync {
} }
} }
#[derive(Ipc)]
#[ipc(client_ident="SyncClient")] #[ipc(client_ident="SyncClient")]
impl SyncProvider for EthSync { impl SyncProvider for EthSync {
/// Get sync status /// Get sync status
@ -184,7 +183,6 @@ pub trait ManageNetwork : Send + Sync {
} }
#[derive(Ipc)]
#[ipc(client_ident="NetworkManagerClient")] #[ipc(client_ident="NetworkManagerClient")]
impl ManageNetwork for EthSync { impl ManageNetwork for EthSync {
fn accept_unreserved_peers(&self) { fn accept_unreserved_peers(&self) {