]> xenbits.xensource.com Git - xcp/xen-api-libs.git/commitdiff
[rpc-light] Add some basic RPC int functions.
authorThomas Gazagnaire <thomas.gazagnaire@eu.citrix.com>
Mon, 11 Jan 2010 17:44:38 +0000 (17:44 +0000)
committerThomas Gazagnaire <thomas.gazagnaire@eu.citrix.com>
Mon, 11 Jan 2010 17:44:38 +0000 (17:44 +0000)
This patch adds rpc_of_{int,int32,int64} and {int,int32,int64}_of_rpc

Signed-off-by: Thomas Gazagnaire <thomas.gazagnaire@citrix.com>
rpc-light/rpc.ml
rpc-light/rpc.mli

index 380ab3fa72aa49e07347a02dc9197a606f0fb281..5c87bfb48a46025a3b83a1f169a8aa9690981cc8 100644 (file)
@@ -42,14 +42,30 @@ let rec to_string t = match t with
 
 let rpc_of_t x = x
 let rpc_of_int64 i = Int i
+let rpc_of_int32 i = Int (Int64.of_int32 i)
+let rpc_of_int i = Int (Int64.of_int i)
 let rpc_of_bool b = Bool b
 let rpc_of_float f = Float f
 let rpc_of_string s = String s
 
 let t_of_rpc x = x
-let int64_of_rpc = function Int i -> i | _ -> failwith "int64_of_rpc"
+let int64_of_rpc = function
+       | Int i    -> i 
+       | String s -> Int64.of_string s
+       | _ -> failwith "int64_of_rpc"
+let int32_of_rpc = function
+       | Int i    -> Int64.to_int32 i
+       | String s -> Int32.of_string s
+       | _ -> failwith "int32_of_rpc"
+let int_of_rpc = function
+       | Int i    -> Int64.to_int i
+       | String s -> int_of_string s
+       | _ -> failwith "int_of_rpc"
 let bool_of_rpc = function Bool b -> b | _ -> failwith "bool_of_rpc"
-let float_of_rpc = function Float f -> f | _ -> failwith "float_of_rpc"
+let float_of_rpc = function
+       | Float f  -> f 
+       | String s -> float_of_string s
+       | _ -> failwith "float_of_rpc"
 let string_of_rpc = function String s -> s | _ -> failwith "string_of_rpc"
 
 type callback = string list -> t -> unit
index ba12ef7f3757bec32aa711e8b3cf23f77ffd3b00..76a6745911719b14c637e6b220ce377311143a6d 100644 (file)
@@ -30,6 +30,12 @@ val to_string : t -> string
 val int64_of_rpc : t -> int64
 val rpc_of_int64 : int64 -> t
 
+val int32_of_rpc : t -> int32
+val rpc_of_int32 : int32 -> t
+
+val int_of_rpc : t -> int
+val rpc_of_int : int -> t
+
 val bool_of_rpc : t -> bool
 val rpc_of_bool : bool -> t