This is an automated email from the git hooks/post-receive script. glondu pushed a commit to branch master in repository atdgen.
commit 62b0b8c6b02a5015c4b6581e241753a60d4590f2 Author: Stephane Glondu <st...@glondu.net> Date: Thu Aug 4 11:14:46 2016 +0200 Imported Upstream version 1.9.0 --- atdgen.install | 4 ++-- src/Makefile | 2 +- src/ag_main.ml | 17 ++++++++++++++--- src/ag_ob_emit.ml | 4 ++-- src/ag_ocaml.ml | 28 ++++++++++++++++------------ src/ag_oj_emit.ml | 4 ++-- src/ag_ov_emit.ml | 4 ++-- 7 files changed, 39 insertions(+), 24 deletions(-) diff --git a/atdgen.install b/atdgen.install index 1f5dc8c..f50dc83 100644 --- a/atdgen.install +++ b/atdgen.install @@ -1,6 +1,6 @@ bin: [ - "src/atdgen.run" - "src/atdgen" + "src/atdgen.run" {"atdgen.run"} + "src/atdgen" {"atdgen"} "atdgen-cppo/atdgen-cppo" "atdgen-cppo/cppo-json" ] diff --git a/src/Makefile b/src/Makefile index 1daea7f..c25441a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,4 +1,4 @@ -VERSION = 1.8.0 +VERSION = 1.9.0 ifeq "$(shell ocamlc -config |grep os_type)" "os_type: Win32" EXE=.exe else diff --git a/src/ag_main.ml b/src/ag_main.ml index 5080bdd..3a87e44 100644 --- a/src/ag_main.ml +++ b/src/ag_main.ml @@ -41,6 +41,10 @@ type mode = | `Validate (* -validate (deprecated) *) ] +type conv = + [ `Ppx of string list + | `Camlp4 of string list ] + let parse_ocaml_version () = let re = Str.regexp "^\\([0-9]+\\)\\.\\([0-9]+\\)" in if Str.string_match re Sys.ocaml_version 0 then @@ -78,15 +82,22 @@ let main () = let l = Str.split (Str.regexp " *, *\\| +") s in opens := List.rev_append l !opens in - let type_convs = ref [] in + let pp_convs : conv ref = ref (`Ppx []) in let options = [ "-type-conv", Arg.String (fun s -> - type_convs := Str.split (Str.regexp ",") s), + pp_convs := `Camlp4 (Str.split (Str.regexp ",") s)), " GEN1,GEN2,... Insert 'with GEN1, GEN2, ...' after OCaml type definitions for the type-conv preprocessor "; + "-deriving-conv", Arg.String (fun s -> + pp_convs := `Ppx (Str.split (Str.regexp ",") s)), + " + GEN1,GEN2,... + Insert 'with GEN1, GEN2, ...' after OCaml type definitions for the + ppx_deriving preprocessor + "; "-t", Arg.Unit (fun () -> set_once "output type" mode `T; set_once "no function definitions" with_fundefs false), @@ -414,7 +425,7 @@ Recommended usage: %s (-t|-b|-j|-v|-dep|-list) example.atd" Sys.argv.(0) in let with_default default = function None -> default | Some x -> x in make_ocaml_files - ~type_convs: !type_convs + ~pp_convs: !pp_convs ~opens ~with_typedefs: (with_default true !with_typedefs) ~with_create diff --git a/src/ag_ob_emit.ml b/src/ag_ob_emit.ml index 449d08d..71a11f0 100644 --- a/src/ag_ob_emit.ml +++ b/src/ag_ob_emit.ml @@ -1479,7 +1479,7 @@ let make_ocaml_files ~type_aliases ~force_defaults ~name_overlap - ~type_convs + ~pp_convs atd_file out = let ((head, m0), _) = match atd_file with @@ -1512,7 +1512,7 @@ let make_ocaml_files m1 = original type definitions after dependency analysis m2 = monomorphic type definitions after dependency analysis *) let ocaml_typedefs = - Ag_ocaml.ocaml_of_atd ~type_convs ~target:`Biniou ~type_aliases (head, m1) in + Ag_ocaml.ocaml_of_atd ~pp_convs ~target:`Biniou ~type_aliases (head, m1) in let defs = translate_mapping m2 in let header = let src = diff --git a/src/ag_ocaml.ml b/src/ag_ocaml.ml index f0003a4..086e0d9 100644 --- a/src/ag_ocaml.ml +++ b/src/ag_ocaml.ml @@ -597,13 +597,17 @@ let append_ocamldoc_comment x doc = let comment = make_ocamldoc_comment y in Label ((x, label), comment) -let format_type_conv_node node = function - | [] -> node +let format_pp_conv_node node = function + | `Camlp4 [] + | `Ppx [] -> node | converters -> - let converters = "with " ^ (String.concat ", " converters) in + let converters = + match converters with + | `Ppx cs -> "[@@deriving " ^ (String.concat ", " cs) ^ "]" + | `Camlp4 cs -> "with " ^ (String.concat ", " cs) in Label ((node, label), make_atom converters) -let rec format_module_item type_convs +let rec format_module_item pp_convs is_first (`Type def : ocaml_module_item) = let type_ = if is_first then "type" else "and" in let s, param = def.o_def_name in @@ -646,7 +650,7 @@ let rec format_module_item type_convs format_type_expr t ) in - format_type_conv_node (prepend_ocamldoc_comment doc part123) type_convs + format_pp_conv_node (prepend_ocamldoc_comment doc part123) pp_convs and prepend_type_param l tl = @@ -744,15 +748,15 @@ and format_variant kind (s, o, doc) = in append_ocamldoc_comment variant doc -let format_module_items type_convs is_rec (l : ocaml_module_body) = +let format_module_items pp_convs is_rec (l : ocaml_module_body) = match l with x :: l -> - format_module_item type_convs true x :: - List.map (fun x -> format_module_item type_convs false x) l + format_module_item pp_convs true x :: + List.map (fun x -> format_module_item pp_convs false x) l | [] -> [] -let format_module_bodies type_conv (l : (bool * ocaml_module_body) list) = - List.flatten (List.map (fun (is_rec, x) -> format_module_items type_conv is_rec x) l) +let format_module_bodies pp_conv (l : (bool * ocaml_module_body) list) = + List.flatten (List.map (fun (is_rec, x) -> format_module_items pp_conv is_rec x) l) let format_head (loc, an) = match Ag_doc.get_doc loc an with @@ -766,14 +770,14 @@ let format_all l = let ocaml_of_expr x : string = Easy_format.Pretty.to_string (format_type_expr x) -let ocaml_of_atd ?(type_convs=[]) ~target ~type_aliases +let ocaml_of_atd ?(pp_convs=`Ppx []) ~target ~type_aliases (head, (l : (bool * module_body) list)) : string = let head = format_head head in let bodies = List.map (fun (is_rec, m) -> (is_rec, map_module ~target ~type_aliases m)) l in - let body = format_module_bodies type_convs bodies in + let body = format_module_bodies pp_convs bodies in let x = format_all (head @ body) in Easy_format.Pretty.to_string x diff --git a/src/ag_oj_emit.ml b/src/ag_oj_emit.ml index c84088a..6463fec 100644 --- a/src/ag_oj_emit.ml +++ b/src/ag_oj_emit.ml @@ -1722,7 +1722,7 @@ let make_ocaml_files ~force_defaults ~preprocess_input ~name_overlap - ~type_convs + ~pp_convs atd_file out = let ((head, m0), _) = match atd_file with @@ -1754,7 +1754,7 @@ let make_ocaml_files m1 = original type definitions after dependency analysis m2 = monomorphic type definitions after dependency analysis *) let ocaml_typedefs = - Ag_ocaml.ocaml_of_atd ~type_convs ~target:`Json ~type_aliases (head, m1) in + Ag_ocaml.ocaml_of_atd ~pp_convs ~target:`Json ~type_aliases (head, m1) in let defs = translate_mapping m2 in let header = let src = diff --git a/src/ag_ov_emit.ml b/src/ag_ov_emit.ml index 56a0bcf..de9d803 100644 --- a/src/ag_ov_emit.ml +++ b/src/ag_ov_emit.ml @@ -473,7 +473,7 @@ let make_ocaml_files ~type_aliases ~force_defaults ~name_overlap - ~type_convs + ~pp_convs atd_file out = let ((head, m0), _) = match atd_file with @@ -506,7 +506,7 @@ let make_ocaml_files m1 = original type definitions after dependency analysis m2 = monomorphic type definitions after dependency analysis *) let ocaml_typedefs = - Ag_ocaml.ocaml_of_atd ~type_convs ~target:`Validate ~type_aliases (head, m1) in + Ag_ocaml.ocaml_of_atd ~pp_convs ~target:`Validate ~type_aliases (head, m1) in let defs = translate_mapping m2 in let header = let src = -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ocaml-maint/packages/atdgen.git _______________________________________________ Pkg-ocaml-maint-commits mailing list Pkg-ocaml-maint-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-ocaml-maint-commits