resolved remaining issues & error binary serialization

This commit is contained in:
Nikolay Volf 2016-05-15 00:51:02 +03:00
parent 2d992d0c29
commit 483687b6bf
7 changed files with 27 additions and 9 deletions

View File

@ -61,7 +61,7 @@ pub struct Executed {
}
/// Result of executing the transaction.
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Debug, Binary)]
pub enum ExecutionError {
/// Returned when there gas paid for transaction execution is
/// lower than base gas required.

View File

@ -28,6 +28,7 @@ use log_entry::{LogEntry, LocalizedLogEntry};
use ipc::binary::BinaryConvertError;
use std::mem;
use std::collections::VecDeque;
use rustc_serialize::hex::FromHex;
/// Information describing execution of a transaction.
#[derive(Default, Debug, Clone, Binary)]

View File

@ -29,6 +29,8 @@ use ethjson;
use ipc::binary::BinaryConvertError;
use std::mem;
use std::collections::VecDeque;
use rustc_serialize::hex::FromHex;
use util::crypto::KeyPair;
#[derive(Debug, Clone, PartialEq, Eq, Binary)]
/// Transaction action type.

View File

@ -382,6 +382,8 @@ fn fields_sequence(
use syntax::parse::token;
use syntax::ast::TokenTree::Token;
let named_members = fields.iter().any(|f| f.ident.is_some());
::quasi::parse_expr_panic(&mut ::syntax::parse::new_parser_from_tts(
ext_cx.parse_sess(),
ext_cx.cfg(),
@ -389,7 +391,12 @@ fn fields_sequence(
let _sp = ext_cx.call_site();
let mut tt = ::std::vec::Vec::new();
tt.push(Token(_sp, token::Ident(variant_ident.clone())));
if named_members {
tt.push(Token(_sp, token::OpenDelim(token::Brace)));
}
else {
tt.push(Token(_sp, token::OpenDelim(token::Paren)));
}
for (idx, field) in fields.iter().enumerate() {
if field.ident.is_some() {
@ -450,8 +457,12 @@ fn fields_sequence(
tt.push(Token(_sp, token::CloseDelim(token::Paren)));
tt.push(Token(_sp, token::Comma));
}
if named_members {
tt.push(Token(_sp, token::CloseDelim(token::Brace)));
}
else {
tt.push(Token(_sp, token::CloseDelim(token::Paren)));
}
tt
})
).unwrap()
@ -620,7 +631,6 @@ fn binary_expr_variant(
.map(|(id, field)|(field.ident.unwrap(), builder.pat().ref_id(id))))
.build();
let binary_expr = try!(binary_expr_struct(
cx,
&builder,
@ -640,7 +650,7 @@ fn binary_expr_variant(
let buffer = &mut buffer[1..];
$write_expr
}),
read: quote_arm!(cx, $pat => { $read_expr } ),
read: quote_arm!(cx, $variant_index_ident => { $read_expr } ),
})
},
}

View File

@ -17,7 +17,7 @@
//! Binary representation of types
use util::bytes::Populatable;
use util::numbers::{U256, H256, H2048, Address};
use util::numbers::{U256, U512, H256, H2048, Address};
use std::mem;
use std::collections::VecDeque;
use std::ops::Range;
@ -422,6 +422,7 @@ binary_fixed_size!(usize);
binary_fixed_size!(i32);
binary_fixed_size!(bool);
binary_fixed_size!(U256);
binary_fixed_size!(U512);
binary_fixed_size!(H256);
binary_fixed_size!(H2048);
binary_fixed_size!(Address);

View File

@ -36,3 +36,9 @@ pub struct DoubleRoot {
pub struct ReferenceStruct<'a> {
pub ref_data: &'a u64,
}
#[derive(Binary, PartialEq, Debug)]
pub enum EnumWithStruct {
Left,
Right { how_much: u64 },
}

View File

@ -16,9 +16,7 @@
#![allow(dead_code)]
extern crate bincode;
extern crate ethcore_ipc as ipc;
extern crate serde;
extern crate ethcore_devtools as devtools;
extern crate semver;
extern crate nanomsg;