Skip to content

Commit

Permalink
[rpc-light.idl] Functorise generated Client module
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
  • Loading branch information
robhoes committed Nov 25, 2011
1 parent 7dbffb9 commit 66476cb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions rpc-light/p4_idl.ml
Expand Up @@ -137,7 +137,7 @@ struct
let arg_path = MyRpcLight.arg_path rpc.loc (rpc.namespace @ [cap_name]) in
<:expr<
let call = $create_call rpc$ in
let response = rpc call in
let response = R.rpc call in
if response.Rpc.success
then Args.$arg_path$.response_of_rpc response.Rpc.contents
else
Expand All @@ -147,7 +147,7 @@ struct

let gen_client_fun rpc =
let n = List.length rpc.args - 1 in
<:str_item< value $lid:rpc.fname$ = fun rpc ->
<:str_item< value $lid:rpc.fname$ =
$MyRpcLight.list_foldi (fun accu arg i ->
let lid = MyRpcLight.argi (n-i) in
match arg.MyRpcLight.kind with
Expand All @@ -170,7 +170,7 @@ struct
end >>
else <:str_item< >>) items
in
<:str_item< module Client = struct $list: gen_str_items rpcs$ end >>
<:str_item< module Client = functor(R: RPC) -> struct $list: gen_str_items rpcs$ end >>

(* Generates a signature for a server module - again, very similar to the original
idl module, but in this one a 'context' is defined - a way of passing in any
Expand Down Expand Up @@ -316,11 +316,17 @@ struct
exception RpcFailure of (string * list (string * string))
>>
in
let rpc_type =
let t = <:ctyp< Rpc.call -> Rpc.response >> in
let s = <:sig_item< value rpc: $typ:t$ >> in
<:str_item< module type RPC = sig $sigi:s$ end >>
in
let flat_rpcs = flatten_rpcs rpcs in
let sis = Ast.list_of_str_item si [] in
<:str_item< $list: (List.map filter_types sis) @
[ failure_bits;
make_args rpcs;
rpc_type;
make_client rpcs;
make_server_sig rpcs;
make_server_functor flat_rpcs ] $ >>
Expand Down

0 comments on commit 66476cb

Please sign in to comment.