Skip to content
This repository has been archived by the owner on May 22, 2018. It is now read-only.

Commit

Permalink
Merge pull request #122 from jonludlam/rpc-light-int32
Browse files Browse the repository at this point in the history
Add the Int32 type to rpc-light.
  • Loading branch information
Jon Ludlam committed Jan 29, 2013
2 parents 6b42ec0 + c56c959 commit 7a0e40e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions rpc-light/jsonrpc.ml
Expand Up @@ -44,6 +44,7 @@ let escape_string s =
let rec to_fct t f =
match t with
| Int i -> f (Printf.sprintf "%Ld" i)
| Int32 i -> f (Printf.sprintf "%ld" i)
| Bool b -> f (string_of_bool b)
| Float r -> f (Printf.sprintf "%f" r)
| String s -> f (escape_string s)
Expand Down
2 changes: 2 additions & 0 deletions rpc-light/rpc.ml
Expand Up @@ -19,6 +19,7 @@ let lower = String.lowercase

type t =
| Int of int64
| Int32 of int32
| Bool of bool
| Float of float
| String of string
Expand All @@ -34,6 +35,7 @@ open Printf
let map_strings sep fn l = String.concat sep (List.map fn l)
let rec to_string t = match t with
| Int i -> sprintf "I(%Li)" i
| Int32 i -> sprintf "I32(%li)" i
| Bool b -> sprintf "B(%b)" b
| Float f -> sprintf "F(%g)" f
| String s -> sprintf "S(%s)" s
Expand Down
1 change: 1 addition & 0 deletions rpc-light/rpc.mli
Expand Up @@ -16,6 +16,7 @@

type t =
Int of int64
| Int32 of int32
| Bool of bool
| Float of float
| String of string
Expand Down
5 changes: 5 additions & 0 deletions rpc-light/xmlrpc.ml
Expand Up @@ -65,6 +65,11 @@ let rec add_value f = function
f (Int64.to_string i);
f "</value>"

| Int32 i ->
f "<value><i4>";
f (Int32.to_string i);
f "</i4></value>"

| Bool b ->
f "<value><boolean>";
f (if b then "1" else "0");
Expand Down

0 comments on commit 7a0e40e

Please sign in to comment.