Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #8 from jeromemaloberti/master

Same as before, but cleaner :).
  • Loading branch information...
commit 0cd46f4e24e0c44a4e96d9f54762655236caf4bd 2 parents d85583b + b246933
@samoht authored
View
1  README.md
@@ -9,6 +9,7 @@ An RPC value is defined as follow:
| Bool of bool
| Float of float
| String of string
+ | DateTime of string
| Enum of t list
| Dict of (string * t) list
| Null
View
1  lib/jsonrpc.ml
@@ -47,6 +47,7 @@ let rec to_fct t f =
| Bool b -> f (string_of_bool b)
| Float r -> f (Printf.sprintf "%f" r)
| String s -> f (escape_string s)
+ | DateTime d -> f (escape_string d)
| Null -> f "null"
| Enum a ->
f "[";
View
4 lib/rpc.ml
@@ -21,6 +21,7 @@ type t =
| Bool of bool
| Float of float
| String of string
+ | DateTime of string
| Enum of t list
| Dict of (string * t) list
| Null
@@ -35,6 +36,7 @@ let rec to_string t = match t with
| Bool b -> sprintf "B(%b)" b
| Float f -> sprintf "F(%g)" f
| String s -> sprintf "S(%s)" s
+ | DateTime s -> sprintf "D(%s)" s
| Enum ts -> sprintf "[%s]" (map_strings ";" to_string ts)
| Dict ts -> sprintf "{%s}" (map_strings ";" (fun (s,t) -> sprintf "%s:%s" s (to_string t)) ts)
| Null -> "N"
@@ -47,6 +49,7 @@ 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 rpc_of_dateTime s = DateTime s
let rpc_of_unit () = Null
let t_of_rpc x = x
@@ -68,6 +71,7 @@ let float_of_rpc = function
| String s -> float_of_string s
| _ -> failwith "float_of_rpc"
let string_of_rpc = function String s -> s | _ -> failwith "string_of_rpc"
+let dateTime_of_rpc = function DateTime s -> s | _ -> failwith "dateTime_of_rpc"
let unit_of_rpc = function Null -> () | _ -> failwith "unit_of_rpc"
type callback = string list -> t -> unit
View
4 lib/rpc.mli
@@ -19,6 +19,7 @@ type t =
| Bool of bool
| Float of float
| String of string
+ | DateTime of string
| Enum of t list
| Dict of (string * t) list
| Null
@@ -45,6 +46,9 @@ val rpc_of_float : float -> t
val string_of_rpc : t -> string
val rpc_of_string : string -> t
+val dateTime_of_rpc : t -> string
+val rpc_of_dateTime : string -> t
+
val t_of_rpc : t -> t
val rpc_of_t : t -> t
View
14 lib/xmlrpc.ml
@@ -61,9 +61,9 @@ let rec add_value f = function
f "<value><nil/></value>"
| Int i ->
- f "<value>";
+ f "<value><int>";
f (Int64.to_string i);
- f "</value>"
+ f "</int></value>"
| Bool b ->
f "<value><boolean>";
@@ -81,6 +81,11 @@ let rec add_value f = function
f (encode s);
f "</value>"
+ | DateTime s ->
+ f "<value><dateTime.iso8601>";
+ f s;
+ f "</dateTime.iso8601></value>"
+
| Enum l ->
f "<value><array><data>";
List.iter (add_value f) l;
@@ -295,6 +300,7 @@ module Parser = struct
let make_bool = make (fun data -> Bool (if data = "1" then true else false))
let make_float = make (fun data -> Float (float_of_string data))
let make_string = make (fun data -> String data)
+ let make_dateTime = make (fun data -> DateTime data)
let make_enum = make (fun data -> Enum data)
let make_dict = make (fun data -> Dict data)
@@ -311,14 +317,16 @@ module Parser = struct
and basic_types ?callback accu input = function
| "int"
+ | "i8"
| "i4" -> make_int ?callback accu (get_data input)
| "boolean"-> make_bool ?callback accu (get_data input)
| "double" -> make_float ?callback accu (get_data input)
| "string" -> make_string ?callback accu (get_data input)
+ | "dateTime.iso8601" -> make_dateTime ?callback accu (get_data input)
| "array" -> make_enum ?callback accu (data (of_xmls ?callback accu) input)
| "struct" -> make_dict ?callback accu (members (fun name -> of_xml ?callback (name::accu)) input)
| "nil" -> make_null ?callback accu ()
- | tag -> parse_error (sprintf "open_tag(%s)" tag) "open_tag(int/i4/boolean/double/string/array/struct/nil)" input
+ | tag -> parse_error (sprintf "open_tag(%s)" tag) "open_tag(int/i8/i4/boolean/double/string/dateTime.iso8601/array/struct/nil)" input
and of_xmls ?callback accu input =
let r = ref [] in
Please sign in to comment.
Something went wrong with that request. Please try again.