]> xenbits.xensource.com Git - xenclient/toolstack.git/commitdiff
Fix code-generators and standalone build after integration re-org and renaming
authorPrashanth Mundkur <prashanth.mundkur@citrix.com>
Thu, 23 Apr 2009 21:12:43 +0000 (14:12 -0700)
committerPrashanth Mundkur <prashanth.mundkur@citrix.com>
Thu, 23 Apr 2009 21:12:43 +0000 (14:12 -0700)
16 files changed:
OMakefile [new file with mode: 0644]
OMakeroot [new file with mode: 0644]
gen/json_conv/OMakefile
gen/json_conv/codegen.ml
gen/json_conv/tests/OMakefile
gen/json_conv/tests/test_json_conv.ml
gen/rpc/OMakefile
gen/rpc/codegen.ml
gen/rpc/syntax_json_conv.ml
gen/rpc/tests/OMakefile
gen/rpc/tests/test_rpc.ml
libs/json/OMakefile
libs/json/OMakeroot [deleted file]
libs/json/parser_tests/OMakefile
libs/json/parser_tests/test_parser.ml
libs/jsonrpc/OMakefile [new file with mode: 0644]

diff --git a/OMakefile b/OMakefile
new file mode 100644 (file)
index 0000000..752fc9b
--- /dev/null
+++ b/OMakefile
@@ -0,0 +1,14 @@
+JSON_LIB_DIR      = $(dir libs/json)
+JSON_GEN_CONV_DIR = $(dir gen/json_conv)
+JSON_RPC_LIB_DIR  = $(dir libs/jsonrpc)
+JSON_GEN_RPC_DIR  = $(dir gen/rpc)
+
+OCAMLFLAGS += -dtypes
+
+.SUBDIRS: libs/json libs/jsonrpc
+
+.SUBDIRS: gen/json_conv
+       include OMakefile
+       export
+
+.SUBDIRS: gen/rpc
diff --git a/OMakeroot b/OMakeroot
new file mode 100644 (file)
index 0000000..78ebe81
--- /dev/null
+++ b/OMakeroot
@@ -0,0 +1,12 @@
+open build/OCaml
+
+#
+# The command-line variables are defined *after* the
+# standard configuration has been loaded.
+#
+DefineCommandVars()
+
+#
+# Include the OMakefile in this directory.
+#
+.SUBDIRS: .
index 0bb914289810b2256cb139828bffdd7a0ff3ba70..982c926a674e83648f1e7d7c0df6466ca7493ac9 100644 (file)
@@ -4,6 +4,7 @@ GEN_FILES = parser.mli parser.ml lexer.ml
 OCamlGeneratedFiles($(GEN_FILES))
 
 OCAML_OTHER_LIBS[] += unix
+
 CONV_FILES[] =
        lexer
        parser
index 2b993553114f8b63057c59e0aa38250c5c9d18c9..541007f55877bd7cab59c56d3895f699361c8374 100644 (file)
@@ -24,8 +24,11 @@ let add_known_type ident = known_types := ident :: !known_types
 let reset_known_types () = known_types := []
 
 let base_to_str = function
-       | B_string -> "string"  | B_int -> "int"        | B_int64 -> "int64"
-       | B_bool -> "bool"      | B_ident s -> s
+       | B_string -> "Json_conv.string"
+       | B_int -> "Json_conv.int"
+       | B_int64 -> "Json_conv.int64"
+       | B_bool -> "Json_conv.bool"
+       | B_ident s -> s
 
 type var = { stem: string; mark: int }
 
@@ -97,7 +100,7 @@ module To = struct
 
        let to_array_str ?(constr="") vlist =
                let elems = List.map name_of_var vlist in
-               let constr = if constr = "" then "" else "(string_to_json \"" ^ constr ^ "\"); " in
+               let constr = if constr = "" then "" else "(Json_conv.string_to_json \"" ^ constr ^ "\"); " in
                "[| " ^ constr ^ (String.concat "; " elems) ^ " |]"
 
        let to_object_str fn_list fv_list =
@@ -123,7 +126,7 @@ module To = struct
                | C_option optt ->
                        let optv, venv = Var_env.new_ident_from_type venv optt in
                        fprintf ff "(match %s with@," v;
-                       fprintf ff "| None -> Json_null@,";
+                       fprintf ff "| None -> Json.Null@,";
                        fprintf ff "@[<v 8>| Some %s ->@," (name_of_var optv);
                        to_json ff venv optv optt;
                        fprintf ff "@]@,)"
@@ -135,7 +138,7 @@ module To = struct
                        fprintf ff "@[<v 8>(fun %s ->@," (name_of_var elemv);
                        to_json ff venv elemv elemt;
                        fprintf ff "@]@,) %s in@]@," v;
-                       fprintf ff "Json_array (Array.of_list %s)" jlistvn
+                       fprintf ff "Json.Array (Array.of_list %s)" jlistvn
                | C_array elemt ->
                        let elemv, venv = Var_env.new_ident_from_type venv elemt in
                        let jarrayv, venv = Var_env.new_ident_from_name venv v ~suffix:"_jarray" in
@@ -144,7 +147,7 @@ module To = struct
                        fprintf ff "@[<v 8>(fun %s ->@," (name_of_var elemv);
                        to_json ff venv elemv elemt;
                        fprintf ff "@]@,) %s in@]@," v;
-                       fprintf ff "Json_array %s" jarrayvn
+                       fprintf ff "Json.Array %s" jarrayvn
                | C_tuple ctlist ->
                        let cvlist, venv = Var_env.new_idents_from_types venv ctlist in
                        let letvlist, venv = Var_env.new_idents_from_vars venv ~prefix:"j_" cvlist in
@@ -154,7 +157,7 @@ module To = struct
                        List.iter2 (fun letv (cv, ct) ->
                                        let_bind ff venv letv cv ct
                                   ) letvlist cvtlist;
-                       fprintf ff "Json_array %s@]@,)" (to_array_str letvlist)
+                       fprintf ff "Json.Array %s@]@,)" (to_array_str letvlist)
                | C_record cls ->
                        let fnlist, ftlist = List.split cls in
                        let fvlist, venv = Var_env.new_idents_from_types venv ftlist in
@@ -164,7 +167,7 @@ module To = struct
                        List.iter2 (fun letv (fv, ft) ->
                                        let_bind ff venv letv fv ft
                                   ) letvlist (List.combine fvlist ftlist);
-                       fprintf ff "Json_object %s@]@,)" (to_object_str fnlist letvlist)
+                       fprintf ff "Json.Object %s@]@,)" (to_object_str fnlist letvlist)
                | C_variant cdlist ->
                        fprintf ff "(match %s with@," v;
                        List.iter (fun cd -> variant ff venv cd) cdlist;
@@ -180,7 +183,7 @@ module To = struct
                List.iter2 (fun letv (v, vt) ->
                                let_bind ff venv letv v vt
                           ) letvlist (List.combine vlist vtlist);
-               fprintf ff "Json_array %s@]@," (to_array_str ~constr:vname letvlist)
+               fprintf ff "Json.Array %s@]@," (to_array_str ~constr:vname letvlist)
 
        and let_bind ff venv letv inv typ =
                fprintf ff "@[<v 8>let %s =@," (name_of_var letv);
@@ -222,7 +225,7 @@ module From = struct
                | C_option optt ->
                        let optv, venv = Var_env.new_ident_from_type venv optt in
                        fprintf ff "(match %s with@," v;
-                       fprintf ff "| Json_null -> None@,";
+                       fprintf ff "| Json.Null -> None@,";
                        fprintf ff "@[<v 8>| %s -> @,Some (" (name_of_var optv);
                        of_json ff venv optv optt tname;
                        fprintf ff ")@]@,)"
@@ -233,7 +236,7 @@ module From = struct
                        fprintf ff "@[<v 8>let %s = Array.map@," oarrayvn;
                        fprintf ff "@[<v 8>(fun %s ->@," (name_of_var elemv);
                        of_json ff venv elemv elemt tname;
-                       fprintf ff "@]@,) (get_array %s) in@]@," v;
+                       fprintf ff "@]@,) (Json_conv.get_array %s) in@]@," v;
                        fprintf ff "Array.to_list %s" oarrayvn
                | C_array elemt ->
                        let elemv, venv = Var_env.new_ident_from_type venv elemt in
@@ -242,14 +245,14 @@ module From = struct
                        fprintf ff "@[<v 8>let %s = Array.map@," oarrayvn;
                        fprintf ff "@[<v 8>(fun %s ->@," (name_of_var elemv);
                        of_json ff venv elemv elemt tname;
-                       fprintf ff "@]@,) (get_array %s) in@]@," v;
+                       fprintf ff "@]@,) (Json_conv.get_array %s) in@]@," v;
                        fprintf ff "%s" oarrayvn
                | C_tuple ctlist ->
                        let jarrayv, venv = Var_env.new_ident_from_name venv v ~suffix:"_jarray" in
                        let jarrayvn = name_of_var jarrayv in
                        let letvlist, venv = Var_env.new_idents_from_types venv ctlist in
-                       fprintf ff "let %s = get_array %s in@," jarrayvn v;
-                       fprintf ff "check_array_with_length %s %d;@," jarrayvn (List.length ctlist);
+                       fprintf ff "let %s = Json_conv.get_array %s in@," jarrayvn v;
+                       fprintf ff "Json_conv.check_array_with_length %s %d;@," jarrayvn (List.length ctlist);
                        ignore (List.fold_left (fun indx (letv, ct) ->
                                                        let inv, venv = Var_env.new_ident_from_name venv "tindx" in
                                                        fprintf ff "let %s = %s.(%d) in@," (name_of_var inv) jarrayvn indx;
@@ -262,11 +265,11 @@ module From = struct
                        let letvlist, venv = Var_env.new_idents_from_types venv ftlist in
                        let objtv, venv = Var_env.new_ident_from_name venv v ~suffix:"_ftable" in
                        let objtvn = name_of_var objtv in
-                       fprintf ff "let %s = get_object_table %s in@," objtvn v;
+                       fprintf ff "let %s = Json_conv.get_object_table %s in@," objtvn v;
                        List.iter2 (fun letv (fn, ft) ->
                                        let fvar, venv = Var_env.new_ident_from_name venv ~suffix:"_f" fn in
                                        let optional = match ft with C_option _ -> "optional_" | _ -> "" in
-                                       fprintf ff "let %s = get_%sobject_field %s \"%s\" in@," (name_of_var fvar) optional objtvn fn;
+                                       fprintf ff "let %s = Json_conv.get_%sobject_field %s \"%s\" in@," (name_of_var fvar) optional objtvn fn;
                                        let_bind ff venv letv fvar ft tname
                                   ) letvlist cls;
                        fprintf ff "%s" (to_record_str fnlist letvlist)
@@ -276,12 +279,12 @@ module From = struct
                        let argsv, venv = Var_env.new_ident_from_name venv "args" in
                        let defmatchv, venv = Var_env.new_ident_from_name venv "s" in
                        let defmatchvn = name_of_var defmatchv in
-                       fprintf ff "let %s, %s = get_variant_constructor %s in@,"
+                       fprintf ff "let %s, %s = Json_conv.get_variant_constructor %s in@,"
                                consvn (name_of_var argsv) v;
                        fprintf ff "(match %s with@," consvn;
                        List.iter (fun cd -> variant ff venv argsv cd tname) cdlist;
                        (* need to write a default match case *)
-                       fprintf ff "| %s -> raise_unknown_constructor \"%s\" %s@,)"
+                       fprintf ff "| %s -> Json_conv.raise_unknown_constructor \"%s\" %s@,)"
                                defmatchvn tname defmatchvn
 
        and variant ff venv argsv (CD_tuple (vname, vtlist)) tname =
@@ -291,7 +294,7 @@ module From = struct
                let letvlist, venv = Var_env.new_idents_from_vars venv ~prefix:"o_" vlist in
                fprintf ff "@[<v 8>| \"%s\" ->@," vname;
                if vtlen > 0 then
-                       fprintf ff "check_array_with_length %s %d;@," argsvn (vtlen + 1);
+                       fprintf ff "Json_conv.check_array_with_length %s %d;@," argsvn (vtlen + 1);
                ignore (List.fold_left (fun indx (letv, vt) ->
                                                let inv, venv = Var_env.new_ident_from_name venv "aindx" in
                                                fprintf ff "let %s = %s.(%d) in@," (name_of_var inv) argsvn indx;
@@ -324,8 +327,6 @@ let generate_header ff ifn =
        let md = Filename.basename (Filename.chop_extension ifn) in
        let call = String.concat " " (Array.to_list Sys.argv) in
        fprintf ff "(* This file has been auto-generated using \"%s\". *)@\n@\n" call;
-       fprintf ff "open Json@\n";
-       fprintf ff "open Json_conv@\n";
        fprintf ff "open %s@\n@\n" (String.capitalize md)
 
 let generate_one_defn ff td =
@@ -340,6 +341,7 @@ let generate_one_defn ff td =
 
 let generate defn_list ofn ifn =
        reset_known_types ();
+       (try Unix.unlink ofn with _ -> ());
        let op_flags = [ Open_wronly ; Open_creat; Open_trunc; Open_text ] in
        let oc = open_out_gen op_flags 0o444 ofn in
        let ff = formatter_of_out_channel oc in
index 466f50d15dab30f65cdd1cea32c97f1c67decb7c..440dda98ed65f071ecdc6bfa3b9d5afc5b689c8b 100644 (file)
@@ -1,9 +1,9 @@
 .PHONY: clean
 
-OCAMLFLAGS += -I .. -I ../..
+OCAMLFLAGS += -I $(JSON_LIB_DIR)
 
 test_types_json_conv.ml: test_types.ml $(JSON_CONV)
-       ../$(JSON_CONV_PROG) -i $< -o $@
+       $(JSON_GEN_CONV_DIR)/$(JSON_CONV_PROG) -i $< -o $@
 
 TESTER_FILES[] =
        test_types
@@ -11,7 +11,7 @@ TESTER_FILES[] =
        test_json_conv
 
 OCAML_LIBS[] +=
-       ../../json
+        $(JSON_LIB_DIR)/json
 
 TESTER_PROG = test_json_conv
 TESTER = $(OCamlProgram $(TESTER_PROG), $(TESTER_FILES))
index b26fa421d88beab8ae5a3a9e265b8b4394ca8c42..0bda337504d3209862b6b4772cafc076c5e168aa 100644 (file)
@@ -8,7 +8,7 @@ let test_list to_j of_j o_list =
                        let j = to_j t in
                        let o = of_j j in
                        if !do_print then
-                               Printf.printf "testing of_j(to_j(.) == . for %s\n" (Json.json_to_string j);
+                               Printf.printf "testing of_j(to_j(.) == . for %s\n" (Json.to_string j);
                        assert (o = t)
                  ) o_list;
        let j_list = List.map to_j o_list in
@@ -16,7 +16,7 @@ let test_list to_j of_j o_list =
                        let o = of_j t in
                        let j = to_j o in
                        if !do_print then
-                               Printf.printf "testing to_j(of_j(.) == . for %s\n" (Json.json_to_string j);
+                               Printf.printf "testing to_j(of_j(.) == . for %s\n" (Json.to_string j);
                        assert (j = t)
                  ) j_list
 
index cdf6c6e712a659bff53b03787221446fa84504e2..c7ace70ec894df5e7a937ee139c18432c0485815 100644 (file)
@@ -1,9 +1,9 @@
 .PHONY: clean
 
 syntax_json_conv.ml: syntax.ml $(JSON_CONV)
-       ../gen_json_conv/$(JSON_CONV_PROG) -i $< -o $@
+       $(JSON_GEN_CONV_DIR)/$(JSON_CONV_PROG) -i $< -o $@
 
-OCAMLFLAGS += -I ..
+OCAMLFLAGS += -I $(JSON_LIB_DIR)
 
 GEN_RPC_FILES[] =
        syntax
@@ -12,7 +12,7 @@ GEN_RPC_FILES[] =
        codegen
        gen_rpc
 
-OCAML_LIBS += ../json
+OCAML_LIBS += $(JSON_LIB_DIR)/json
 
 GEN_RPC_PROG = gen_rpc
 GEN_RPC = $(OCamlProgram $(GEN_RPC_PROG), $(GEN_RPC_FILES))
index 659d120b171402e407f81f0a6b31d68a35d39d61..51192ef4d8494d980134da590913bd9d24927dd4 100644 (file)
@@ -81,7 +81,7 @@ module Server = struct
                                fprintf ff "@,%s: %s;" n.rpc_request.request_handler (String.concat " -> " sg)
                          ) notif_list;
                fprintf ff "@,@,(* Exception error handler *)";
-               fprintf ff "@,%s: exn -> Json_rpc.rpc_error" server.server_error_handler;
+               fprintf ff "@,%s: exn -> Jsonrpc.rpc_error" server.server_error_handler;
                fprintf ff "@]@\n}@\n@\n";
                sig_name
 
@@ -96,7 +96,7 @@ module Server = struct
                let methname = rpc.rpc_request.request_handler in
                let params = rpc.rpc_request.request_params in
                fprintf ff "@[<v 8>| \"%s\" ->@," rpc.rpc_request.request_name;
-               fprintf ff "let %s = Json_conv.get_array %s.Json_rpc.params in@," arrvn reqvn;
+               fprintf ff "let %s = Json_conv.get_array %s.Jsonrpc.params in@," arrvn reqvn;
                fprintf ff "Json_conv.check_array_with_length %s %d;@," arrvn (List.length params);
                let paramsv, venv, _ =
                        List.fold_left (fun (alist, venv, i) p ->
@@ -109,7 +109,7 @@ module Server = struct
                let args_str = String.concat " " (List.map (fun v -> name_of_var v) (List.rev paramsv)) in
                fprintf ff "let %s = %s.%s %s in@," respvn impl_module methname args_str;
                fprintf ff "let %s = %s_to_json %s in@," respjvn resp.response_value.param_type respvn;
-               fprintf ff "Json_rpc.Result { Json_rpc.result = %s }@]@," respjvn
+               fprintf ff "Jsonrpc.Result { Jsonrpc.result = %s }@]@," respjvn
 
        let gen_notification ff venv reqv impl_module rpc =
                let arrv, venv = Var_env.new_ident_from_name venv "params" in
@@ -117,7 +117,7 @@ module Server = struct
                let methname = rpc.rpc_request.request_handler in
                let params = rpc.rpc_request.request_params in
                fprintf ff "@[<v 8>| \"%s\" ->@," rpc.rpc_request.request_name;
-               fprintf ff "let %s = Json_conv.get_array %s.Json_rpc.params in@," arrvn reqvn;
+               fprintf ff "let %s = Json_conv.get_array %s.Jsonrpc.params in@," arrvn reqvn;
                fprintf ff "Json_conv.check_array_with_length %s %d;@," arrvn (List.length params);
                let paramsv, venv, _ =
                        List.fold_left (fun (alist, venv, i) p ->
@@ -133,9 +133,9 @@ module Server = struct
                let implv, venv = Var_env.new_ident_from_name venv impl_module in
                let reqvn, implvn = name_of_var reqv, name_of_var implv in
                fprintf ff "@[<v 8>let %s (%s : %s) %s =@," (name_of_var dispv) implvn impl_module reqvn;
-               fprintf ff "match %s.Json_rpc.method_name with@," reqvn;
+               fprintf ff "match %s.Jsonrpc.method_name with@," reqvn;
                List.iter (fun n -> gen_notification ff venv reqv implvn n) nlist;
-               fprintf ff "| _ -> raise (Json_rpc.JSONRPC_unknown_request %s.Json_rpc.method_name)@]@,@\n" reqvn
+               fprintf ff "| _ -> raise (Jsonrpc.JSONRPC_unknown_request %s.Jsonrpc.method_name)@]@,@\n" reqvn
 
        let gen_rpc_dispatch ff venv server impl_module rpcs =
                let dispv, venv = Var_env.new_ident_from_name venv "dispatch_rpc" in
@@ -147,22 +147,22 @@ module Server = struct
                fprintf ff "@[<v 8>let %s (%s : %s) %s %s =@," (name_of_var dispv) implvn impl_module reqidjvn reqvn;
                fprintf ff "@[<v 8>let %s =@," pvn;
                fprintf ff "@[<v 8>(try@,";
-               fprintf ff "match %s.Json_rpc.method_name with@," reqvn;
+               fprintf ff "match %s.Jsonrpc.method_name with@," reqvn;
                List.iter (fun (rpc, resp) -> gen_request ff venv reqv implvn rpc resp) rpcs;
-               fprintf ff "| _ -> raise (Json_rpc.JSONRPC_unknown_request %s.Json_rpc.method_name)@]@," reqvn;
+               fprintf ff "| _ -> raise (Jsonrpc.JSONRPC_unknown_request %s.Jsonrpc.method_name)@]@," reqvn;
                let ev, venv = Var_env.new_ident_from_name venv "e" in
                let errv, venv = Var_env.new_ident_from_name venv "err" in
                let evn, errvn = name_of_var ev, name_of_var errv in
                fprintf ff "@[<v 8> with %s ->@," evn;
                fprintf ff "let %s = %s.%s %s in@," errvn implvn server.server_error_handler evn;
-               fprintf ff "Json_rpc.Error %s)@]@]@," errvn;
+               fprintf ff "Jsonrpc.Error %s)@]@]@," errvn;
                fprintf ff "in@,";
-               fprintf ff "Json_rpc.rpc_response_to_json (%s, %s)@]@,@\n" reqidjvn pvn
+               fprintf ff "Jsonrpc.rpc_response_to_json (%s, %s)@]@,@\n" reqidjvn pvn
 
        let gen_dispatch ff impl_name =
                fprintf ff "@[<v 8>let dispatch (%s : %s) req_j =@," impl_name impl_name;
-               fprintf ff "let req = Json_rpc.rpc_request_of_json req_j in@,";
-               fprintf ff "match req.Json_rpc.request_id with@,";
+               fprintf ff "let req = Jsonrpc.rpc_request_of_json req_j in@,";
+               fprintf ff "match req.Jsonrpc.request_id with@,";
                fprintf ff "| None -> ignore (dispatch_notification %s req); None@," impl_name;
                fprintf ff "| Some id -> Some (dispatch_rpc %s id req)@]@,@\n" impl_name
 end
@@ -170,7 +170,7 @@ end
 module Client = struct
        let start_maker ff s =
                let rpcid_maker = "Rpc_id_maker" in
-               fprintf ff "module Make_%s_client (%s : Json_rpc.Rpc_id_generator) =@\n" (String.lowercase s.server_name) rpcid_maker ;
+               fprintf ff "module Make_%s_client (%s : Jsonrpc.Rpc_id_generator) =@\n" (String.lowercase s.server_name) rpcid_maker ;
                fprintf ff "@[<v 8>struct";
                rpcid_maker
 
@@ -192,9 +192,9 @@ module Client = struct
                (match rpc.rpc_response with
                | None ->   fprintf ff "let %s = None in@," rpcvn
                | Some _ -> fprintf ff "let %s = Some (%s.get_rpc_request_id ()) in@," rpcvn rpcid_maker);
-               fprintf ff "@[<v 2>{ Json_rpc.request_id = %s;@," rpcvn;
-               fprintf ff "Json_rpc.method_name = \"%s\";@," rpc.rpc_request.request_name;
-               fprintf ff "Json_rpc.params = Json.Json_array (Array.of_list [ %s ])" args_str;
+               fprintf ff "@[<v 2>{ Jsonrpc.request_id = %s;@," rpcvn;
+               fprintf ff "Jsonrpc.method_name = \"%s\";@," rpc.rpc_request.request_name;
+               fprintf ff "Jsonrpc.params = Json.Array (Array.of_list [ %s ])" args_str;
                fprintf ff "@]@,}@]"
 end
 
@@ -207,6 +207,7 @@ let generate_opens ff spec =
        fprintf ff "@\n"
 
 let open_output fn =
+       (try Unix.unlink fn with _ -> ());
        let op_flags = [ Open_wronly ; Open_creat; Open_trunc; Open_text ] in
        let oc = open_out_gen op_flags 0o444 fn in
        let ff = formatter_of_out_channel oc in
index 26922f4d4185c99115f8965ee8f27f60f4e6c967..f08a9d071eb890b2f877a261bcb6a7d119bc54c1 100644 (file)
@@ -1,6 +1,5 @@
-(* This file has been auto-generated using "/home/prashanth/xenclient/build/repo/xenclient-toolstack/libs/json/gen_json_conv/gen_json_conv -i syntax.ml -o syntax_json_conv.ml". *)
+(* This file has been auto-generated using "/home/prashanth/xenclient/build/repo/xenclient-toolstack/gen/json_conv/gen_json_conv -i syntax.ml -o syntax_json_conv.ml". *)
 
-open Json_conv
 open Syntax
 
 let rec use_to_json o =
@@ -9,20 +8,20 @@ let rec use_to_json o =
                 let j_lst =
                         let lst_jlist = List.map
                                 (fun str ->
-                                        string_to_json str
+                                        Json_conv.string_to_json str
                                 ) lst in
                         Json.Array (Array.of_list lst_jlist) in
                 Json.Object [| ("use_modules", j_lst) |]
         )
 
 let rec use_of_json j =
-        let j_ftable = get_object_table j in
-        let use_modules_f = get_object_field j_ftable "use_modules" in
+        let j_ftable = Json_conv.get_object_table j in
+        let use_modules_f = Json_conv.get_object_field j_ftable "use_modules" in
         let lst =
                 let use_modules_f_oarray = Array.map
                         (fun str ->
-                                string_of_json str
-                        ) (get_array use_modules_f) in
+                                Json_conv.string_of_json str
+                        ) (Json_conv.get_array use_modules_f) in
                 Array.to_list use_modules_f_oarray in
         { use_modules = lst }
 
@@ -30,61 +29,61 @@ let rec server_to_json o =
         (match o with
         | { server_name = str; server_doc = str_1; server_error_handler = str_2 } ->
                 let j_str =
-                        string_to_json str in
+                        Json_conv.string_to_json str in
                 let j_str_1 =
-                        string_to_json str_1 in
+                        Json_conv.string_to_json str_1 in
                 let j_str_2 =
-                        string_to_json str_2 in
+                        Json_conv.string_to_json str_2 in
                 Json.Object [| ("server_name", j_str); ("server_doc", j_str_1); ("server_error_handler", j_str_2) |]
         )
 
 let rec server_of_json j =
-        let j_ftable = get_object_table j in
-        let server_name_f = get_object_field j_ftable "server_name" in
+        let j_ftable = Json_conv.get_object_table j in
+        let server_name_f = Json_conv.get_object_field j_ftable "server_name" in
         let str =
-                string_of_json server_name_f in
-        let server_doc_f = get_object_field j_ftable "server_doc" in
+                Json_conv.string_of_json server_name_f in
+        let server_doc_f = Json_conv.get_object_field j_ftable "server_doc" in
         let str_1 =
-                string_of_json server_doc_f in
-        let server_error_handler_f = get_object_field j_ftable "server_error_handler" in
+                Json_conv.string_of_json server_doc_f in
+        let server_error_handler_f = Json_conv.get_object_field j_ftable "server_error_handler" in
         let str_2 =
-                string_of_json server_error_handler_f in
+                Json_conv.string_of_json server_error_handler_f in
         { server_name = str; server_doc = str_1; server_error_handler = str_2 }
 
 let rec param_to_json o =
         (match o with
         | { param_name = str; param_doc = str_1; param_type = str_2 } ->
                 let j_str =
-                        string_to_json str in
+                        Json_conv.string_to_json str in
                 let j_str_1 =
-                        string_to_json str_1 in
+                        Json_conv.string_to_json str_1 in
                 let j_str_2 =
-                        string_to_json str_2 in
+                        Json_conv.string_to_json str_2 in
                 Json.Object [| ("param_name", j_str); ("param_doc", j_str_1); ("param_type", j_str_2) |]
         )
 
 let rec param_of_json j =
-        let j_ftable = get_object_table j in
-        let param_name_f = get_object_field j_ftable "param_name" in
+        let j_ftable = Json_conv.get_object_table j in
+        let param_name_f = Json_conv.get_object_field j_ftable "param_name" in
         let str =
-                string_of_json param_name_f in
-        let param_doc_f = get_object_field j_ftable "param_doc" in
+                Json_conv.string_of_json param_name_f in
+        let param_doc_f = Json_conv.get_object_field j_ftable "param_doc" in
         let str_1 =
-                string_of_json param_doc_f in
-        let param_type_f = get_object_field j_ftable "param_type" in
+                Json_conv.string_of_json param_doc_f in
+        let param_type_f = Json_conv.get_object_field j_ftable "param_type" in
         let str_2 =
-                string_of_json param_type_f in
+                Json_conv.string_of_json param_type_f in
         { param_name = str; param_doc = str_1; param_type = str_2 }
 
 let rec request_to_json o =
         (match o with
         | { request_name = str; request_doc = str_1; request_handler = str_2; request_params = lst } ->
                 let j_str =
-                        string_to_json str in
+                        Json_conv.string_to_json str in
                 let j_str_1 =
-                        string_to_json str_1 in
+                        Json_conv.string_to_json str_1 in
                 let j_str_2 =
-                        string_to_json str_2 in
+                        Json_conv.string_to_json str_2 in
                 let j_lst =
                         let lst_jlist = List.map
                                 (fun param ->
@@ -95,22 +94,22 @@ let rec request_to_json o =
         )
 
 let rec request_of_json j =
-        let j_ftable = get_object_table j in
-        let request_name_f = get_object_field j_ftable "request_name" in
+        let j_ftable = Json_conv.get_object_table j in
+        let request_name_f = Json_conv.get_object_field j_ftable "request_name" in
         let str =
-                string_of_json request_name_f in
-        let request_doc_f = get_object_field j_ftable "request_doc" in
+                Json_conv.string_of_json request_name_f in
+        let request_doc_f = Json_conv.get_object_field j_ftable "request_doc" in
         let str_1 =
-                string_of_json request_doc_f in
-        let request_handler_f = get_object_field j_ftable "request_handler" in
+                Json_conv.string_of_json request_doc_f in
+        let request_handler_f = Json_conv.get_object_field j_ftable "request_handler" in
         let str_2 =
-                string_of_json request_handler_f in
-        let request_params_f = get_object_field j_ftable "request_params" in
+                Json_conv.string_of_json request_handler_f in
+        let request_params_f = Json_conv.get_object_field j_ftable "request_params" in
         let lst =
                 let request_params_f_oarray = Array.map
                         (fun param ->
                                 param_of_json param
-                        ) (get_array request_params_f) in
+                        ) (Json_conv.get_array request_params_f) in
                 Array.to_list request_params_f_oarray in
         { request_name = str; request_doc = str_1; request_handler = str_2; request_params = lst }
 
@@ -118,23 +117,23 @@ let rec response_to_json o =
         (match o with
         | { response_doc = str; response_handler = str_1; response_value = param } ->
                 let j_str =
-                        string_to_json str in
+                        Json_conv.string_to_json str in
                 let j_str_1 =
-                        string_to_json str_1 in
+                        Json_conv.string_to_json str_1 in
                 let j_param =
                         param_to_json param in
                 Json.Object [| ("response_doc", j_str); ("response_handler", j_str_1); ("response_value", j_param) |]
         )
 
 let rec response_of_json j =
-        let j_ftable = get_object_table j in
-        let response_doc_f = get_object_field j_ftable "response_doc" in
+        let j_ftable = Json_conv.get_object_table j in
+        let response_doc_f = Json_conv.get_object_field j_ftable "response_doc" in
         let str =
-                string_of_json response_doc_f in
-        let response_handler_f = get_object_field j_ftable "response_handler" in
+                Json_conv.string_of_json response_doc_f in
+        let response_handler_f = Json_conv.get_object_field j_ftable "response_handler" in
         let str_1 =
-                string_of_json response_handler_f in
-        let response_value_f = get_object_field j_ftable "response_value" in
+                Json_conv.string_of_json response_handler_f in
+        let response_value_f = Json_conv.get_object_field j_ftable "response_value" in
         let param =
                 param_of_json response_value_f in
         { response_doc = str; response_handler = str_1; response_value = param }
@@ -143,24 +142,24 @@ let rec rpc_to_json o =
         (match o with
         | { rpc_type = str; rpc_server = str_1; rpc_doc = str_2; rpc_version = str_3; rpc_deprecated = opt; rpc_label_arguments = opt_1; rpc_request = request; rpc_response = opt_2 } ->
                 let j_str =
-                        string_to_json str in
+                        Json_conv.string_to_json str in
                 let j_str_1 =
-                        string_to_json str_1 in
+                        Json_conv.string_to_json str_1 in
                 let j_str_2 =
-                        string_to_json str_2 in
+                        Json_conv.string_to_json str_2 in
                 let j_str_3 =
-                        string_to_json str_3 in
+                        Json_conv.string_to_json str_3 in
                 let j_opt =
                         (match opt with
                         | None -> Json.Null
                         | Some str_4 ->
-                                string_to_json str_4
+                                Json_conv.string_to_json str_4
                         ) in
                 let j_opt_1 =
                         (match opt_1 with
                         | None -> Json.Null
                         | Some bool ->
-                                bool_to_json bool
+                                Json_conv.bool_to_json bool
                         ) in
                 let j_request =
                         request_to_json request in
@@ -174,37 +173,37 @@ let rec rpc_to_json o =
         )
 
 let rec rpc_of_json j =
-        let j_ftable = get_object_table j in
-        let rpc_type_f = get_object_field j_ftable "rpc_type" in
+        let j_ftable = Json_conv.get_object_table j in
+        let rpc_type_f = Json_conv.get_object_field j_ftable "rpc_type" in
         let str =
-                string_of_json rpc_type_f in
-        let rpc_server_f = get_object_field j_ftable "rpc_server" in
+                Json_conv.string_of_json rpc_type_f in
+        let rpc_server_f = Json_conv.get_object_field j_ftable "rpc_server" in
         let str_1 =
-                string_of_json rpc_server_f in
-        let rpc_doc_f = get_object_field j_ftable "rpc_doc" in
+                Json_conv.string_of_json rpc_server_f in
+        let rpc_doc_f = Json_conv.get_object_field j_ftable "rpc_doc" in
         let str_2 =
-                string_of_json rpc_doc_f in
-        let rpc_version_f = get_object_field j_ftable "rpc_version" in
+                Json_conv.string_of_json rpc_doc_f in
+        let rpc_version_f = Json_conv.get_object_field j_ftable "rpc_version" in
         let str_3 =
-                string_of_json rpc_version_f in
-        let rpc_deprecated_f = get_optional_object_field j_ftable "rpc_deprecated" in
+                Json_conv.string_of_json rpc_version_f in
+        let rpc_deprecated_f = Json_conv.get_optional_object_field j_ftable "rpc_deprecated" in
         let opt =
                 (match rpc_deprecated_f with
                 | Json.Null -> None
                 | str_4 -> 
-                        Some (string_of_json str_4)
+                        Some (Json_conv.string_of_json str_4)
                 ) in
-        let rpc_label_arguments_f = get_optional_object_field j_ftable "rpc_label_arguments" in
+        let rpc_label_arguments_f = Json_conv.get_optional_object_field j_ftable "rpc_label_arguments" in
         let opt_1 =
                 (match rpc_label_arguments_f with
                 | Json.Null -> None
                 | bool -> 
-                        Some (bool_of_json bool)
+                        Some (Json_conv.bool_of_json bool)
                 ) in
-        let rpc_request_f = get_object_field j_ftable "rpc_request" in
+        let rpc_request_f = Json_conv.get_object_field j_ftable "rpc_request" in
         let request =
                 request_of_json rpc_request_f in
-        let rpc_response_f = get_optional_object_field j_ftable "rpc_response" in
+        let rpc_response_f = Json_conv.get_optional_object_field j_ftable "rpc_response" in
         let opt_2 =
                 (match rpc_response_f with
                 | Json.Null -> None
index 7f265b8c7a0ac82e11e9b489efa584a9e3a638c1..021a835101b7a1e290d18d2e4835f6f3d9b231c1 100644 (file)
@@ -1,12 +1,12 @@
 .PHONY: clean
 
 rpc_types_json_conv.ml: rpc_types.ml $(JSON_CONV)
-       ../../gen_json_conv/$(JSON_CONV_PROG) -i $< -o $@
+       $(JSON_GEN_CONV_DIR)/$(JSON_CONV_PROG) -i $< -o $@
 
 rpc_defns_client.ml rpc_defns_server.ml: rpc_defns.json $(GEN_RPC)
-       ../$(GEN_RPC_PROG) $<
+       $(JSON_GEN_RPC_DIR)/$(GEN_RPC_PROG) $<
 
-OCAMLFLAGS += -I ../..
+OCAMLFLAGS += -I $(JSON_LIB_DIR) -I $(JSON_RPC_LIB_DIR)
 
 RPC_TEST_FILES[] =
        rpc_types
@@ -16,7 +16,7 @@ RPC_TEST_FILES[] =
        test_rpc
 
 
-OCAML_LIBS = ../../json
+OCAML_LIBS = $(JSON_LIB_DIR)/json $(JSON_RPC_LIB_DIR)/jsonrpc
 
 RPC_TEST_PROG = test
 RPC_TEST = $(OCamlProgram $(RPC_TEST_PROG), $(RPC_TEST_FILES))
index 2fe2564255cab6e931043054df7f3035f912b35d..61a01fad955cc350e7a06dcff484869ce96d53f8 100644 (file)
@@ -4,13 +4,13 @@ open Rpc_defns_server
 open Rpc_defns_client
 
 (* First, implement the Json-rpc id generator. *)
-module I : Json_rpc.Rpc_id_generator = struct
+module I : Jsonrpc.Rpc_id_generator = struct
        let cur_id = ref 0L
 
        let get_rpc_request_id () =
                let id = !cur_id in
                cur_id := Int64.add !cur_id 1L;
-               Json.Json_int id
+               Json.Int id
 end
 
 (* Now, create the client-side wrappers. *)
@@ -35,9 +35,9 @@ module S = struct
                        && arg3)
 
        let error_handler e =
-               { Json_rpc.code = 2;
-                 Json_rpc.message = Printexc.to_string e;
-                 Json_rpc.data = Some (Json.Json_string "details")
+               { Jsonrpc.code = 2;
+                 Jsonrpc.message = Printexc.to_string e;
+                 Jsonrpc.data = Some (Json.String "details")
                }
 
        let server_impl =
@@ -52,10 +52,10 @@ let rpc_invoke req resp_fun =
        (* Client-side request processing: *)
 
        (* 1) create the corresponding json-rpc request object to send over the wire. *)
-       let jreq_c = Json_rpc.rpc_request_to_json req in
+       let jreq_c = Jsonrpc.rpc_request_to_json req in
 
        (* 2) send it over the wire. *)
-       let jnet_c = Json.json_to_string jreq_c in
+       let jnet_c = Json.to_string jreq_c in
        let _ = Printf.printf "Sending request: %s\n" jnet_c in
 
        (* Server-side processing: *)
@@ -75,7 +75,7 @@ let rpc_invoke req resp_fun =
                        | Some j -> j in
 
        (* iv) send it over the wire *)
-       let jnet_s = Json.json_to_string resp_j in
+       let jnet_s = Json.to_string resp_j in
        let _ = Printf.printf "Sending response: %s\n" jnet_s in
 
        (* Client-side response processing: *)
@@ -87,7 +87,7 @@ let rpc_invoke req resp_fun =
                        | Json_parse.Json_parse_incomplete _ -> raise (Failure "client json parsing") in
 
        (* b) extract the response *)
-       let resp = Json_rpc.rpc_response_of_json jresp_c in
+       let resp = Jsonrpc.rpc_response_of_json jresp_c in
 
        (* c) process that response *)
        resp_fun resp
@@ -96,10 +96,10 @@ let notification_invoke testname req =
        (* Client-side request processing: *)
 
        (* 1) create the corresponding json-rpc request object to send over the wire. *)
-       let jreq_c = Json_rpc.rpc_request_to_json req in
+       let jreq_c = Jsonrpc.rpc_request_to_json req in
 
        (* 2) send it over the wire. *)
-       let jnet_c = Json.json_to_string jreq_c in
+       let jnet_c = Json.to_string jreq_c in
        let _ = Printf.printf "Sending request: %s\n" jnet_c in
 
        (* Server-side processing: *)
@@ -129,10 +129,10 @@ let default_error_check e =
 
 let test_invoke req ?(id_check=default_id_check) ?(error_check=default_error_check) result_check =
        let resp_fun (resp_id, resp) =
-               id_check req.Json_rpc.request_id resp_id;
+               id_check req.Jsonrpc.request_id resp_id;
                match resp with
-               | Json_rpc.Result r -> result_check r
-               | Json_rpc.Error e -> error_check e
+               | Jsonrpc.Result r -> result_check r
+               | Jsonrpc.Error e -> error_check e
        in
        rpc_invoke req resp_fun
 
@@ -142,7 +142,7 @@ let test_server () =
                let exp_resp = S.req1_handler arg1 in
                let resp_to_str r = match r with |None -> "None" | Some b -> if b then "Some true" else "Some false" in
                let resp_checker r =
-                       let got_resp = resp1_type_of_json r.Json_rpc.result in
+                       let got_resp = resp1_type_of_json r.Jsonrpc.result in
                        if got_resp <> exp_resp
                        then raise (Failure (Printf.sprintf "req1, test %s: got \"%s\", expected \"%s\"!"
                                               test_id (resp_to_str got_resp) (resp_to_str exp_resp)))
@@ -157,7 +157,7 @@ let test_server () =
                let req = C.jrpc_request2 arg1 arg2 arg3 in
                let exp_resp = S.req2_handler arg1 arg2 arg3 in
                let resp_checker r =
-                       let got_resp = resp2_type_of_json r.Json_rpc.result in
+                       let got_resp = resp2_type_of_json r.Jsonrpc.result in
                        if got_resp <> exp_resp
                        then raise (Failure (Printf.sprintf "req2, test %s: got \"%s\", expected \"%s\"!" test_id got_resp exp_resp))
                in
index bb34760a13d931d42d18397e05080b811b84125f..5ce3b3d1f9bbdf2a29b5dbc3087eda4f8fea3cd7 100644 (file)
@@ -1,12 +1,9 @@
 .PHONY: clean
 
-OCAMLFLAGS += -dtypes
-
 JSON_FILES[] =
        json
        json_parse
        json_conv
-       json_rpc
 
 LIB = json
 JSON_LIB = $(OCamlLibrary $(LIB), $(JSON_FILES))
@@ -17,10 +14,3 @@ clean:
     rm -f $(filter-proper-targets $(ls R, .)) *.annot *.cmo
 
 .SUBDIRS: parser_tests
-
-.SUBDIRS: gen_json_conv
-       include OMakefile
-       export
-
-.SUBDIRS: gen_rpc
-
diff --git a/libs/json/OMakeroot b/libs/json/OMakeroot
deleted file mode 100644 (file)
index 78ebe81..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-open build/OCaml
-
-#
-# The command-line variables are defined *after* the
-# standard configuration has been loaded.
-#
-DefineCommandVars()
-
-#
-# Include the OMakefile in this directory.
-#
-.SUBDIRS: .
index 858f3460c5ab4d05b48f2000e11fecf2ef928e01..1380ba842ecfbda1908cd7066dc9fbccfe91dd1c 100644 (file)
@@ -1,9 +1,9 @@
 
 .PHONY: clean
 
-OCAMLFLAGS += -I ..
+OCAMLFLAGS += -I $(JSON_LIB_DIR)
 
-OCAML_LIBS += ../json
+OCAML_LIBS += $(JSON_LIB_DIR)/json
 
 TEST_PARSER_PROG = test_parser
 TEST_PARSER = $(OCamlProgram $(TEST_PARSER_PROG), test_parser)
index 475c8c6fc327bc54d12e656cf07b1384c4dc06fd..1f620c5100560056827bec662816989e712f1597 100644 (file)
@@ -43,7 +43,7 @@ let parse_file f =
                match Json_parse.parse !state !input with
                | Json_parse.Json_value (v, rem) ->
                        if !do_print then
-                               Printf.printf "%s\n" (Json.json_to_string v);
+                               Printf.printf "%s\n" (Json.to_string v);
                        input := rem;
                        state := Json_parse.init_parse_state ()
                | Json_parse.Json_parse_incomplete st ->
@@ -51,7 +51,7 @@ let parse_file f =
                        state := st
        done;
        match Json_parse.finish_parse !state with
-       | Some v -> Printf.printf "%s\n" (Json.json_to_string v)
+       | Some v -> Printf.printf "%s\n" (Json.to_string v)
        | None -> ()
 
 let print_exception e =
diff --git a/libs/jsonrpc/OMakefile b/libs/jsonrpc/OMakefile
new file mode 100644 (file)
index 0000000..7b88d3e
--- /dev/null
@@ -0,0 +1,15 @@
+.PHONY: clean
+
+OCAMLFLAGS += -I $(JSON_LIB_DIR)
+
+JSONRPC_FILES[] =
+       jsonrpc
+
+LIB = jsonrpc
+JSONRPC_LIB = $(OCamlLibrary $(LIB), $(JSONRPC_FILES))
+
+.DEFAULT: $(JSONRPC_LIB)
+
+clean:
+    rm -f $(filter-proper-targets $(ls R, .)) *.annot *.cmo
+