forgotten upper files

This commit is contained in:
NikVolf 2016-03-30 02:21:47 +03:00
parent be40553674
commit 7097451323
2 changed files with 12 additions and 6 deletions

View File

@ -258,7 +258,9 @@ fn push_proxy(
fn implement_proxy_method_body(
cx: &ExtCtxt,
builder: &aster::AstBuilder,
dispatch: &Dispatch)
index: u16,
dispatch: &Dispatch,
)
-> P<ast::Expr>
{
let request = if dispatch.input_arg_names.len() > 0 {
@ -329,8 +331,10 @@ fn implement_proxy_method_body(
request_serialization_statements.push(
quote_stmt!(cx, let serialized_payload = ::bincode::serde::serialize(&payload, ::bincode::SizeLimit::Infinite).unwrap()));
let index_ident = builder.id(format!("{}", index).as_str());
request_serialization_statements.push(
quote_stmt!(cx, ::ipc::invoke(0, &Some(serialized_payload), &mut socket)));
quote_stmt!(cx, ::ipc::invoke($index_ident, &Some(serialized_payload), &mut socket)));
request_serialization_statements
@ -361,11 +365,12 @@ fn implement_proxy_method_body(
fn implement_proxy_method(
cx: &ExtCtxt,
builder: &aster::AstBuilder,
index: u16,
dispatch: &Dispatch)
-> ast::ImplItem
{
let method_name = builder.id(dispatch.function_name.as_str());
let body = implement_proxy_method_body(cx, builder, dispatch);
let body = implement_proxy_method_body(cx, builder, index, dispatch);
let ext_cx = &*cx;
// expanded version of this
@ -418,8 +423,9 @@ fn push_proxy_implementation(
dispatches: &[Dispatch],
push: &mut FnMut(Annotatable))
{
let mut index = -1i32;
let items = dispatches.iter()
.map(|dispatch| P(implement_proxy_method(cx, builder, dispatch)))
.map(|dispatch| { index = index + 1; P(implement_proxy_method(cx, builder, index as u16, dispatch)) })
.collect::<Vec<P<ast::ImplItem>>>();
let implement = quote_item!(cx,

View File

@ -24,8 +24,8 @@ pub trait IpcInterface<T> {
pub fn invoke<W>(method_num: u16, params: &Option<Vec<u8>>, w: &mut W) where W: ::std::io::Write {
let buf_len = match *params { None => 2, Some(ref val) => val.len() + 2 };
let mut buf = vec![0u8; buf_len];
buf[0] = (method_num & (255<<8)) as u8;
buf[1] = (method_num >> 8) as u8;
buf[1] = (method_num & 255) as u8;
buf[0] = (method_num >> 8) as u8;
if params.is_some() {
buf[2..buf_len].clone_from_slice(params.as_ref().unwrap());
}