IPC (feature-gated) (#1654)

* moving ipc deriving to trait

* refactoring of the client

* all compiled

* proved all working

* warnings purged

* allow hypervisor to specify initialization payload in two ways

* using binary initialisation payload for sync

* some docs

* logger to separate crate

* log settings for sync bin

* forwarding logging arguments to the sync
This commit is contained in:
Nikolay Volf
2016-07-20 18:13:56 +02:00
committed by Arkadiy Paronyan
parent 7ae9e61d6c
commit 8ab56ea3d1
22 changed files with 439 additions and 88 deletions

View File

@@ -273,7 +273,12 @@ fn implement_dispatch_arm(
{
let index_ident = builder.id(format!("{}", index + (RESERVED_MESSAGE_IDS as u32)).as_str());
let invoke_expr = implement_dispatch_arm_invoke(cx, builder, dispatch, buffer);
quote_arm!(cx, $index_ident => { $invoke_expr } )
let dispatching_trace = "Dispatching: ".to_owned() + &dispatch.function_name;
let dispatching_trace_literal = builder.expr().lit().str::<&str>(&dispatching_trace);
quote_arm!(cx, $index_ident => {
trace!(target: "ipc", $dispatching_trace_literal);
$invoke_expr
})
}
fn implement_dispatch_arms(
@@ -420,17 +425,22 @@ fn implement_client_method_body(
request_serialization_statements
};
let invocation_trace = "Invoking: ".to_owned() + &dispatch.function_name;
let invocation_trace_literal = builder.expr().lit().str::<&str>(&invocation_trace);
if let Some(ref return_ty) = dispatch.return_type_ty {
let return_expr = quote_expr!(cx,
::ipc::binary::deserialize_from::<$return_ty, _>(&mut *socket).unwrap()
);
quote_expr!(cx, {
trace!(target: "ipc", $invocation_trace_literal);
$request
$return_expr
})
}
else {
quote_expr!(cx, {
trace!(target: "ipc", $invocation_trace_literal);
$request
})
}

View File

@@ -261,6 +261,10 @@ fn binary_expr_struct(
let raw_ident = ::syntax::print::pprust::ty_to_string(&codegen::strip_ptr(&field.ty));
let range_ident = builder.id(format!("r{}", index));
let error_message = "Error serializing member: ".to_owned() + &::syntax::print::pprust::expr_to_string(&member_expr);
let error_message_literal = builder.expr().lit().str::<&str>(&error_message);
match raw_ident.as_ref() {
"u8" => {
write_stmts.push(quote_stmt!(cx, let next_line = offset + 1;).unwrap());
@@ -280,7 +284,13 @@ fn binary_expr_struct(
}).unwrap());
write_stmts.push(quote_stmt!(cx, let $range_ident = offset..next_line; ).unwrap());
post_write_stmts.push(quote_stmt!(cx,
if let Err(e) = $member_expr .to_bytes(&mut buffer[$range_ident], length_stack) { return Err(e) };).unwrap());
if $range_ident.end - $range_ident.start > 0 {
if let Err(e) = $member_expr .to_bytes(&mut buffer[$range_ident], length_stack) {
warn!(target: "ipc", $error_message_literal);
return Err(e)
};
}
).unwrap());
}
}