Commits

camlspotter committed 2c28ebd

meta_conv and module relocation

  • Participants
  • Parent commits c46f086

Comments (0)

Files changed (3)

 name="bitbucket"
 version="0.0.0"
 description="Bitbucket API for OCaml"
-requires="json-tc-custom,json-wheel,spotlib,curl,unix"
+requires="meta_conv,json-wheel,spotlib,curl,unix"
 archive(byte)="bitbucket.cmo"
 archive(native)="bitbucket.cmx"
 linkopts = ""
 OCAMLPACKS[] =
     curl
     json-wheel
-    json-tc-custom
+    meta_conv
     spotlib
 
 OCAMLFLAGS = -annot -w A-4-9-39 
-OCAMLDEPFLAGS= -syntax camlp4o -package json-tc-custom.syntax
-OCAMLPPFLAGS= -syntax camlp4o -package json-tc-custom.syntax
+OCAMLDEPFLAGS= -syntax camlp4o -package meta_conv.syntax
+OCAMLPPFLAGS= -syntax camlp4o -package meta_conv.syntax
 
 FILES[] =
     xcurl
 MyOCamlPackage(bitbucket, $(FILES), $(EMPTY), $(EMPTY))
 
 api.p4.ml: api.ml
-    camlp4o dynlink.cma -I $(HOME)/.opam/system/lib/type_conv pa_type_conv.cma -I $(HOME)/.opam/system/lib/json-tc-custom pa_json_tc.cmo -printer Camlp4OCamlPrinter -o api.p4.ml api.ml
+    camlp4o dynlink.cma -I $(HOME)/.opam/system/lib/type_conv pa_type_conv.cma -I $(HOME)/.opam/system/lib/meta_conv pa_json_tc.cmo -printer Camlp4OCamlPrinter -o api.p4.ml api.ml
 open Common
+open Json_wrap
+open Json_conv
 
 module Scheme = struct
-  type t = [ `hg | `git ] with json
-
-  let of_json = t_of_json
-  let to_json = json_of_t
+  type t = Hg(hg) | Git(git) with conv(json)
 end
 
-module Repository = struct
- 
-  type t = { 
-    owner      : string;
-    scm        : Scheme.t;
-    slug       : string;
-    is_private : bool;
-    name       : string
-  }
+module User = struct
 
-  and ts = t list
+  module Repository = struct
+   
+    type t = { 
+      owner      : string;
+      scm        : Scheme.t;
+      slug       : string;
+      is_private : bool;
+      name       : string
+    }
+  
+    and ts = t list
+  
+    with conv(json)
+  
+  end
 
-  with json
+  module Repositories = struct
 
-  let get_ts ~user ~password = 
-    ts_of_json (Json_io.json_of_string (Curl.get_string (fun h ->
-      h#set_url "https://api.bitbucket.org/1.0/user/repositories/";
-      h#set_userpwd (Printf.sprintf "%s:%s" user password))))
+    type t = Repository.t list with conv(json)
+
+    let get ~user ~password = 
+      t_of_json (Json_io.json_of_string (Curl.get_string (fun h ->
+        h#set_url "https://api.bitbucket.org/1.0/user/repositories/";
+        h#set_userpwd (Printf.sprintf "%s:%s" user password))))
+  end
+
 end