Commits

camlspotter committed 24921df Merge

merge with dev for 1.1.0

Comments (0)

Files changed (8)

+1.1.0
+--------------
+
+* based on meta_conv 0.11.0
+
+1.0.1
+--------------
+
+* bug fixes
+
+1.0.0
+--------------
+
+* initial version
 OASISFormat: 0.2
 Name:        tiny_json_conv
-Version:     1.0.1
+Version:     1.1.0
 Synopsis:    Meta conv for Tiny Json
 Authors:     Jun FURUSE
 License:     LGPL-2.0 with OCaml linking exception
 name="tiny_json_conv"
-version="1.0.1"
+version="1.1.0"
 description="Meta conv for Tiny Json"
 requires="tiny_json, meta_conv"
 archive(byte)="tiny_json_conv.cma"
+name="tiny_json_conv"
+version="@version@"
+description="Meta conv for Tiny Json"
+requires="tiny_json, meta_conv"
+archive(byte)="tiny_json_conv.cma"
+archive(native)="tiny_json_conv.cmxa"
+linkopts = ""
 
 let errorf fmt = Printf.ksprintf (fun s -> raise (Failure s)) fmt
 
-module Decode = Meta_conv.Internal.Make_Decode_Adrs(struct
-  type t = Json.t
+module Decode = struct
   let tuple = function 
     | Array ts -> ts
     | _ -> errorf "Array expected for tuple"
   let record = function
     | Object alist -> alist
     | _ -> errorf "Object expected for record"
-end)
+end
 
 open Printf
 
 type 'a decoder = ('a, Json.t) Meta_conv.Types.Decoder.t
+type 'a decoder_exn = ('a, Json.t) Decoder.t_exn
 exception Error of Json.t Error.t
 
-let errorf v adrs fmt = 
-  kprintf (fun s -> `Error (Primitive_decoding_failure s, v, adrs)) fmt
+let errorf v fmt = 
+  kprintf (fun s -> `Error (Primitive_decoding_failure s, v)) fmt
 
-let string_of_json ?(adrs=Address.top) = function
+let string_of_json = function
   | String s -> `Ok s
-  | v -> errorf v adrs "string_of_json: String expected"
+  | v -> errorf v "string_of_json: String expected"
 
-let char_of_json ?(adrs=Address.top) = function
+let char_of_json = function
   | String s when String.length s = 1 -> `Ok s.[0]
-  | v -> errorf v adrs "char_of_json: a char expected"
+  | v -> errorf v "char_of_json: a char expected"
 
-let int_check name min max conv ?(adrs=Address.top) v = match v with
+let int_check name min max conv v = match v with
   | Number n -> 
       begin match integer_of_float min max conv n with
       | `Ok i -> `Ok i
-      | `Error s -> errorf v adrs "%s_of_json: %s" name s
+      | `Error s -> errorf v "%s_of_json: %s" name s
       end
-  | _ -> errorf v adrs "%s_of_json: Number expected" name
+  | _ -> errorf v "%s_of_json: Number expected" name
 
 let int_of_json =
   int_check "int" (float min_int) (float max_int) int_of_float
   let open Nativeint in
   int_check "nativeint" (to_float min_int) (to_float max_int) of_float
       
-let float_of_json ?(adrs=Address.top) = function
+let float_of_json = function
   | Number n -> `Ok n
-  | n -> errorf n adrs "float_of_json: Number expected"
+  | n -> errorf n "float_of_json: Number expected"
 
-let bool_of_json ?(adrs=Address.top) = function
+let bool_of_json = function
   | Bool b -> `Ok b
-  | v -> errorf v adrs "bool_of_json: Bool expected"
+  | v -> errorf v "bool_of_json: Bool expected"
 
-let unit_of_json ?(adrs=Address.top) = function
+let unit_of_json = function
   | Null -> `Ok ()
-  | v -> errorf v adrs "unit_of_json: Null expected"
+  | v -> errorf v "unit_of_json: Null expected"
   
 let list_of_json d = generic_list_of (function
   | Array xs -> Some xs
 
 let lazy_t_of_json f = generic_lazy_t_of (fun e -> raise (Error e)) f
 let mc_lazy_t_of_json = generic_mc_lazy_t_of 
+
+type 'a named_list = (string * 'a) list
+
+let json_of_mc_fields enc xs = Object (List.map (fun (name, a) -> (name, enc a)) xs)
+
+let mc_fields_of_json dec = generic_mc_fields_of (function Object js -> Some js | _ -> None) dec

lib/json_conv.mli

 val json_of_option : ('a -> Json.t) -> 'a option -> Json.t
 
 module Decode : sig
-  val tuple : Json.t * Address.t -> (Json.t * Address.t) list
-  val variant : Json.t * Address.t -> string * (Json.t * Address.t) list
-  val record : Json.t * Address.t -> (string * (Json.t * Address.t)) list
+  val tuple   : Json.t -> Json.t list
+  val variant : Json.t -> string * Json.t list
+  val record  : Json.t -> (string * Json.t) list
 end
 
 type 'a decoder = ('a, Json.t) Decoder.t
+type 'a decoder_exn = ('a, Json.t) Decoder.t_exn
 exception Error of Json.t Error.t
 
 val string_of_json    : string decoder
 val option_of_json    : 'a decoder -> 'a option decoder
 val lazy_t_of_json    : 'a decoder -> 'a lazy_t decoder
 val mc_lazy_t_of_json : 'a decoder -> ('a, Json.t) mc_lazy_t decoder
+
+type 'a named_list = (string * 'a) list
+
+val json_of_mc_fields : ('a -> Json.t) -> (string * 'a) list -> Json.t
+val mc_fields_of_json : 
+  ('a, Json.t) Decoder.t 
+  -> Json.t 
+  -> ((string * 'a) list, Json.t) Result.t

opam/template/opam

 ocaml-version: [>= "4.0.0"]
-depends: ["ocamlfind" "omake" "tiny_json" "meta_conv"]
+depends: ["ocamlfind" "omake" "tiny_json" "meta_conv" {>="0.11.0"}]
 (* setup.ml generated for the first time by OASIS v0.3.0 *)
 
 (* OASIS_START *)
-(* DO NOT EDIT (digest: 9bfac6d97f3d04c945dadc1a26665dcd) *)
+(* DO NOT EDIT (digest: 235f577a927105043e9f4ea15624dedd) *)
 (*
    Regenerated by OASIS v0.3.0
    Visit http://oasis.forge.ocamlcore.org for more information and
    documentation about functions used in this file.
 *)
 module OASISGettext = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISGettext.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISGettext.ml" *)
 
   let ns_ str =
     str
 end
 
 module OASISContext = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISContext.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISContext.ml" *)
 
   open OASISGettext
 
 end
 
 module OASISString = struct
-(* # 1 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISString.ml" *)
+(* # 1 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISString.ml" *)
 
 
 
 end
 
 module OASISUtils = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISUtils.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISUtils.ml" *)
 
   open OASISGettext
 
 end
 
 module PropList = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/PropList.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/PropList.ml" *)
 
   open OASISGettext
 
     let clear t =
       Hashtbl.clear t
 
-(* # 71 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/PropList.ml" *)
+(* # 71 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/PropList.ml" *)
   end
 
   module Schema =
 end
 
 module OASISMessage = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISMessage.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISMessage.ml" *)
 
 
   open OASISGettext
 end
 
 module OASISVersion = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISVersion.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISVersion.ml" *)
 
   open OASISGettext
 
 end
 
 module OASISLicense = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISLicense.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISLicense.ml" *)
 
   (** License for _oasis fields
       @author Sylvain Le Gall
 end
 
 module OASISExpr = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISExpr.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISExpr.ml" *)
 
 
 
 end
 
 module OASISTypes = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISTypes.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISTypes.ml" *)
 
 
 
 
   type plugin_data = (all_plugin * plugin_data_purpose * (unit -> unit)) list
 
-(* # 102 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISTypes.ml" *)
+(* # 102 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISTypes.ml" *)
 
   type 'a conditional = 'a OASISExpr.choices 
 
 end
 
 module OASISUnixPath = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISUnixPath.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISUnixPath.ml" *)
 
   type unix_filename = string
   type unix_dirname = string
 end
 
 module OASISHostPath = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISHostPath.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISHostPath.ml" *)
 
 
   open Filename
 end
 
 module OASISSection = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISSection.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISSection.ml" *)
 
   open OASISTypes
 
 end
 
 module OASISBuildSection = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISBuildSection.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISBuildSection.ml" *)
 
 end
 
 module OASISExecutable = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISExecutable.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISExecutable.ml" *)
 
   open OASISTypes
 
 end
 
 module OASISLibrary = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISLibrary.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISLibrary.ml" *)
 
   open OASISTypes
   open OASISUtils
 end
 
 module OASISFlag = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISFlag.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISFlag.ml" *)
 
 end
 
 module OASISPackage = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISPackage.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISPackage.ml" *)
 
 end
 
 module OASISSourceRepository = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISSourceRepository.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISSourceRepository.ml" *)
 
 end
 
 module OASISTest = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISTest.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISTest.ml" *)
 
 end
 
 module OASISDocument = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISDocument.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISDocument.ml" *)
 
 end
 
 module OASISExec = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISExec.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISExec.ml" *)
 
   open OASISGettext
   open OASISUtils
 end
 
 module OASISFileUtil = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/oasis/OASISFileUtil.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/oasis/OASISFileUtil.ml" *)
 
   open OASISGettext
 
 
 # 2142 "setup.ml"
 module BaseEnvLight = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseEnvLight.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseEnvLight.ml" *)
 
   module MapString = Map.Make(String)
 
 
 # 2240 "setup.ml"
 module BaseContext = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseContext.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseContext.ml" *)
 
   open OASISContext
 
 end
 
 module BaseMessage = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseMessage.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseMessage.ml" *)
 
   (** Message to user, overrid for Base
       @author Sylvain Le Gall
 end
 
 module BaseEnv = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseEnv.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseEnv.ml" *)
 
   open OASISGettext
   open OASISUtils
 end
 
 module BaseArgExt = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseArgExt.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseArgExt.ml" *)
 
   open OASISUtils
   open OASISGettext
 end
 
 module BaseCheck = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseCheck.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseCheck.ml" *)
 
   open BaseEnv
   open BaseMessage
 end
 
 module BaseOCamlcConfig = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseOCamlcConfig.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseOCamlcConfig.ml" *)
 
 
   open BaseEnv
 end
 
 module BaseStandardVar = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseStandardVar.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseStandardVar.ml" *)
 
 
   open OASISGettext
 end
 
 module BaseFileAB = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseFileAB.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseFileAB.ml" *)
 
   open BaseEnv
   open OASISGettext
 end
 
 module BaseLog = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseLog.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseLog.ml" *)
 
   open OASISUtils
 
 end
 
 module BaseBuilt = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseBuilt.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseBuilt.ml" *)
 
   open OASISTypes
   open OASISGettext
 end
 
 module BaseCustom = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseCustom.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseCustom.ml" *)
 
   open BaseEnv
   open BaseMessage
 end
 
 module BaseDynVar = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseDynVar.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseDynVar.ml" *)
 
 
   open OASISTypes
 end
 
 module BaseTest = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseTest.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseTest.ml" *)
 
   open BaseEnv
   open BaseMessage
 end
 
 module BaseDoc = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseDoc.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseDoc.ml" *)
 
   open BaseEnv
   open BaseMessage
 end
 
 module BaseSetup = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/base/BaseSetup.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/base/BaseSetup.ml" *)
 
   open BaseEnv
   open BaseMessage
 
 # 4480 "setup.ml"
 module InternalConfigurePlugin = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/plugins/internal/InternalConfigurePlugin.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/plugins/internal/InternalConfigurePlugin.ml" *)
 
   (** Configure using internal scheme
       @author Sylvain Le Gall
 end
 
 module InternalInstallPlugin = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/plugins/internal/InternalInstallPlugin.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/plugins/internal/InternalInstallPlugin.ml" *)
 
   (** Install using internal scheme
       @author Sylvain Le Gall
 
 # 5233 "setup.ml"
 module CustomPlugin = struct
-(* # 21 "/home/jun/.share/projects/externals/oasis/_build/src/plugins/custom/CustomPlugin.ml" *)
+(* # 21 "/mnt/home/jun/.opam/system/build/oasis.0.3.0/src/plugins/custom/CustomPlugin.ml" *)
 
   (** Generate custom configure/build/doc/test/install system
       @author
           ocaml_version = None;
           findlib_version = None;
           name = "tiny_json_conv";
-          version = "1.0.0";
+          version = "1.1.0";
           license =
             OASISLicense.DEP5License
               (OASISLicense.DEP5Unit
           };
      oasis_fn = Some "_oasis";
      oasis_version = "0.3.0";
-     oasis_digest = Some "\127\228\0167\143\1299l\242\236}\239\208Bq\199";
+     oasis_digest = Some "\147\029\228\228\005\180M\145\145\201-k;+\133\011";
      oasis_exec = None;
      oasis_setup_args = [];
      setup_update = false;