forgotten upper files
This commit is contained in:
parent
be40553674
commit
7097451323
@ -258,7 +258,9 @@ fn push_proxy(
|
|||||||
fn implement_proxy_method_body(
|
fn implement_proxy_method_body(
|
||||||
cx: &ExtCtxt,
|
cx: &ExtCtxt,
|
||||||
builder: &aster::AstBuilder,
|
builder: &aster::AstBuilder,
|
||||||
dispatch: &Dispatch)
|
index: u16,
|
||||||
|
dispatch: &Dispatch,
|
||||||
|
)
|
||||||
-> P<ast::Expr>
|
-> P<ast::Expr>
|
||||||
{
|
{
|
||||||
let request = if dispatch.input_arg_names.len() > 0 {
|
let request = if dispatch.input_arg_names.len() > 0 {
|
||||||
@ -329,8 +331,10 @@ fn implement_proxy_method_body(
|
|||||||
request_serialization_statements.push(
|
request_serialization_statements.push(
|
||||||
quote_stmt!(cx, let serialized_payload = ::bincode::serde::serialize(&payload, ::bincode::SizeLimit::Infinite).unwrap()));
|
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(
|
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
|
request_serialization_statements
|
||||||
@ -361,11 +365,12 @@ fn implement_proxy_method_body(
|
|||||||
fn implement_proxy_method(
|
fn implement_proxy_method(
|
||||||
cx: &ExtCtxt,
|
cx: &ExtCtxt,
|
||||||
builder: &aster::AstBuilder,
|
builder: &aster::AstBuilder,
|
||||||
|
index: u16,
|
||||||
dispatch: &Dispatch)
|
dispatch: &Dispatch)
|
||||||
-> ast::ImplItem
|
-> ast::ImplItem
|
||||||
{
|
{
|
||||||
let method_name = builder.id(dispatch.function_name.as_str());
|
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;
|
let ext_cx = &*cx;
|
||||||
// expanded version of this
|
// expanded version of this
|
||||||
@ -418,8 +423,9 @@ fn push_proxy_implementation(
|
|||||||
dispatches: &[Dispatch],
|
dispatches: &[Dispatch],
|
||||||
push: &mut FnMut(Annotatable))
|
push: &mut FnMut(Annotatable))
|
||||||
{
|
{
|
||||||
|
let mut index = -1i32;
|
||||||
let items = dispatches.iter()
|
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>>>();
|
.collect::<Vec<P<ast::ImplItem>>>();
|
||||||
|
|
||||||
let implement = quote_item!(cx,
|
let implement = quote_item!(cx,
|
||||||
|
@ -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 {
|
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 buf_len = match *params { None => 2, Some(ref val) => val.len() + 2 };
|
||||||
let mut buf = vec![0u8; buf_len];
|
let mut buf = vec![0u8; buf_len];
|
||||||
buf[0] = (method_num & (255<<8)) as u8;
|
buf[1] = (method_num & 255) as u8;
|
||||||
buf[1] = (method_num >> 8) as u8;
|
buf[0] = (method_num >> 8) as u8;
|
||||||
if params.is_some() {
|
if params.is_some() {
|
||||||
buf[2..buf_len].clone_from_slice(params.as_ref().unwrap());
|
buf[2..buf_len].clone_from_slice(params.as_ref().unwrap());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user