|
|
|
|
|
|
|
|
|
|
xen-api
[Xen-API] [PATCH 03 of 17] [rpc-light] test (un)marshalling of phatom ty
# HG changeset patch
# User Thomas Gazagnaire <thomas.gazagnaire@xxxxxxxxxx>
# Date 1262958466 0
# Node ID b1d07ffe0323c8e7384c2c7042098d12dac2eb23
# Parent 383e08728219228b6818b5f5274202e96c89786e
[rpc-light] test (un)marshalling of phatom types.
'type 'a t = string with rpc' has to work.
Signed-off-by: Thomas Gazagnaire <thomas.gazagnaire@xxxxxxxxxx>
diff -r 383e08728219 -r b1d07ffe0323 rpc-light/examples/Makefile
--- a/rpc-light/examples/Makefile Fri Jan 08 13:47:46 2010 +0000
+++ b/rpc-light/examples/Makefile Fri Jan 08 13:47:46 2010 +0000
@@ -3,7 +3,7 @@
OCAMLFLAGS = -annot -g
PACKS = rpc-light
-EXAMPLES = all_types
+EXAMPLES = all_types phantom
EXECS=$(foreach example, $(EXAMPLES), $(example).opt)
@@ -18,7 +18,7 @@
%_gen: %.ml
camlp4o $(shell ocamlfind query rpc-light.syntax -r -format "-I %d %a"
-predicates syntax,preprocessor) $< -printer o > $@.ml
- $(OCAMLOPT) -package $(PACKS) -c -o $@ $@.ml
+ $(OCAMLOPT) $(OCAMLFLAGS) -package $(PACKS) -c -o $@ $@.ml
clean:
rm -f *.cmx *.cmi *.cmo *.cmxa *.o $(EXECS)
\ No newline at end of file
diff -r 383e08728219 -r b1d07ffe0323 rpc-light/examples/phantom.ml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/rpc-light/examples/phantom.ml Fri Jan 08 13:47:46 2010 +0000
@@ -0,0 +1,42 @@
+module P : sig
+ type 'a t
+ val rpc_of_t: ('a -> Rpc.t) -> 'a t -> Rpc.t
+ val t_of_rpc: (Rpc.t -> 'a) -> Rpc.t -> 'a t
+ val to_string: 'a t -> string
+ val of_string: string -> 'a t
+end = struct
+ type 'a t = string with rpc
+ let to_string x = x
+ let of_string x = x
+end
+
+module Q = struct
+ include P
+ let rpc_of_t _ x = Rpc.rpc_of_string (to_string x)
+ let t_of_rpc _ x = of_string (Rpc.string_of_rpc x)
+end
+
+type x = [`foo] Q.t with rpc
+type y = [`bar] Q.t with rpc
+
+let _ =
+ let p : [`p] P.t = P.of_string "foo" in
+ let q : [`q] P.t = P.of_string "foo" in
+ let x : x = P.of_string "foo" in
+ let y : y = P.of_string "foo" in
+
+ let p_rpc = Q.rpc_of_t () p in
+ let q_rpc = Q.rpc_of_t () q in
+ let x_rpc = rpc_of_x x in
+ let y_rpc = rpc_of_y y in
+
+ let _ : [`p] P.t = Q.t_of_rpc () p_rpc in
+ let _ : [`q] P.t = Q.t_of_rpc () q_rpc in
+ let _ : x = x_of_rpc x_rpc in
+ let _ : y = y_of_rpc y_rpc in
+
+ Printf.printf "p=%s\n" (Xmlrpc.to_string p_rpc);
+ Printf.printf "q=%s\n" (Xmlrpc.to_string q_rpc);
+ Printf.printf "x=%s\n" (Xmlrpc.to_string x_rpc);
+ Printf.printf "y=%s\n" (Xmlrpc.to_string y_rpc)
+
2 files changed, 44 insertions(+), 2 deletions(-)
rpc-light/examples/Makefile | 4 +--
rpc-light/examples/phantom.ml | 42 +++++++++++++++++++++++++++++++++++++++++
xen-api-libs.hg-17.patch
Description: Text Data
_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
|
<Prev in Thread] |
Current Thread |
[Next in Thread>
|
- [Xen-API] [PATCH 00 of 17] Improvments to RPC-light, Thomas Gazagnaire
- [Xen-API] [PATCH 03 of 17] [rpc-light] test (un)marshalling of phatom types,
Thomas Gazagnaire <=
- [Xen-API] [PATCH 01 of 17] [rpc-light] Make the abstraction layer more uniform, especially for the error handling, Thomas Gazagnaire
- [Xen-API] [PATCH 04 of 17] [rpc-light] Add a function to parse XMLRPC from an input channel, Thomas Gazagnaire
- [Xen-API] [PATCH 06 of 17] [rpc-light] Add some basic RPC int functions, Thomas Gazagnaire
- [Xen-API] [PATCH 09 of 17] [rpc-light] Add some friendly error messages on runtime errors, Thomas Gazagnaire
- [Xen-API] [PATCH 08 of 17] [rpc-light] Add a function to marshal and unmarshal XMLRPC to a bigbuffer, Thomas Gazagnaire
- [Xen-API] [PATCH 07 of 17] [rpc-light] Add some basic RPC int functions, Thomas Gazagnaire
- [Xen-API] [PATCH 05 of 17] [rpc-light] Add some explicit runtime exceptions when an runtime error occurs, Thomas Gazagnaire
- [Xen-API] [PATCH 02 of 17] [rpc-light] Backport the value library and clean-up the Makefile and the library building, Thomas Gazagnaire
- [Xen-API] [PATCH 11 of 17] [rpc-light] Never call 'exit i' on error, because that's not good when you run it in a daemon, Thomas Gazagnaire
- [Xen-API] [PATCH 16 of 17] [rpc-light] when (un)marshaling variant, if it has no arguments then consider it as a string, Thomas Gazagnaire
|
|
|
|
|