summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Ballier <aballier@gentoo.org>2016-05-01 20:10:24 +0200
committerAlexis Ballier <aballier@gentoo.org>2016-05-03 11:13:52 +0200
commit596ea1e96d7378bc8ea31648d882a0bceefec14e (patch)
tree145794e9b6bc1aa063774eac49016b6fe2852ac9 /dev-ml/ppx_sexp_conv
parentdev-ml/ppx_type_conv: fix build with ocaml 4.03 (diff)
downloadgentoo-596ea1e96d7378bc8ea31648d882a0bceefec14e.tar.gz
gentoo-596ea1e96d7378bc8ea31648d882a0bceefec14e.tar.bz2
gentoo-596ea1e96d7378bc8ea31648d882a0bceefec14e.zip
dev-ml/ppx_sexp_conv: fix build with ocaml 4.03
Package-Manager: portage-2.2.28 Signed-off-by: Alexis Ballier <aballier@gentoo.org>
Diffstat (limited to 'dev-ml/ppx_sexp_conv')
-rw-r--r--dev-ml/ppx_sexp_conv/files/oc43.patch145
-rw-r--r--dev-ml/ppx_sexp_conv/ppx_sexp_conv-113.33.00.ebuild6
2 files changed, 150 insertions, 1 deletions
diff --git a/dev-ml/ppx_sexp_conv/files/oc43.patch b/dev-ml/ppx_sexp_conv/files/oc43.patch
new file mode 100644
index 000000000000..d95c46c3371e
--- /dev/null
+++ b/dev-ml/ppx_sexp_conv/files/oc43.patch
@@ -0,0 +1,145 @@
+diff -uNr ppx_sexp_conv-113.33.00/expander/ppx_sexp_conv_expander.ml ppx_sexp_conv-113.33.00+4.03/expander/ppx_sexp_conv_expander.ml
+--- ppx_sexp_conv-113.33.00/expander/ppx_sexp_conv_expander.ml 2016-03-09 16:44:54.000000000 +0100
++++ ppx_sexp_conv-113.33.00+4.03/expander/ppx_sexp_conv_expander.ml 2016-03-22 15:13:51.000000000 +0100
+@@ -491,30 +491,33 @@
+ let lid = Located.map lident cnstr in
+ let str = estring ~loc cnstr.txt in
+ match cd.pcd_args with
+- | [] ->
+- ppat_construct ~loc lid None --> [%expr Sexplib.Sexp.Atom [%e str]]
+- | args ->
+- match args with
+- | [ [%type: [%t? tp] sexp_list ] ] ->
+- let cnv_expr = Fun_or_match.expr ~loc (sexp_of_type renaming tp) in
+- ppat_construct ~loc lid (Some [%pat? l]) -->
+- [%expr
+- Sexplib.Sexp.List
+- (Sexplib.Sexp.Atom [%e str] ::
+- Sexplib.Conv.list_map [%e cnv_expr] l)]
+- | _ ->
+- let sexp_of_args = List.map ~f:(sexp_of_type renaming) args in
+- let cnstr_expr = [%expr Sexplib.Sexp.Atom [%e str] ] in
+- let bindings, patts, vars = Fun_or_match.map_tmp_vars ~loc sexp_of_args in
+- let patt =
+- match patts with
+- | [patt] -> patt
+- | _ -> ppat_tuple ~loc patts
+- in
+- ppat_construct ~loc lid (Some patt) -->
+- pexp_let ~loc Nonrecursive bindings
+- [%expr Sexplib.Sexp.List [%e elist ~loc (cnstr_expr :: vars)]]
+- )
++ | Pcstr_record _ -> failwith "Pcstr_record unsupported"
++ | Pcstr_tuple pcd_args ->
++ match pcd_args with
++ | [] ->
++ ppat_construct ~loc lid None --> [%expr Sexplib.Sexp.Atom [%e str]]
++ | args ->
++ match args with
++ | [ [%type: [%t? tp] sexp_list ] ] ->
++ let cnv_expr = Fun_or_match.expr ~loc (sexp_of_type renaming tp) in
++ ppat_construct ~loc lid (Some [%pat? l]) -->
++ [%expr
++ Sexplib.Sexp.List
++ (Sexplib.Sexp.Atom [%e str] ::
++ Sexplib.Conv.list_map [%e cnv_expr] l)]
++ | _ ->
++ let sexp_of_args = List.map ~f:(sexp_of_type renaming) args in
++ let cnstr_expr = [%expr Sexplib.Sexp.Atom [%e str] ] in
++ let bindings, patts, vars = Fun_or_match.map_tmp_vars ~loc sexp_of_args in
++ let patt =
++ match patts with
++ | [patt] -> patt
++ | _ -> ppat_tuple ~loc patts
++ in
++ ppat_construct ~loc lid (Some patt) -->
++ pexp_let ~loc Nonrecursive bindings
++ [%expr Sexplib.Sexp.List [%e elist ~loc (cnstr_expr :: vars)]]
++ )
+
+ let sexp_of_sum tps cds = Fun_or_match.Match (branch_sum tps cds)
+
+@@ -730,14 +733,14 @@
+ let expr =
+ match ec with
+ | {pext_name = {loc; txt = cnstr};
+- pext_kind = Pext_decl ([], None); _;} ->
++ pext_kind = Pext_decl (Pcstr_tuple [], None); _;} ->
+ [%expr
+ Sexplib.Exn_magic.register [%e pexp_construct ~loc
+ (Located.lident ~loc cnstr) None]
+ [%e estring ~loc (get_full_cnstr cnstr)]
+ ]
+ | {pext_name = {loc; txt = cnstr};
+- pext_kind = Pext_decl (_::_ as tps, None); _;} ->
++ pext_kind = Pext_decl (Pcstr_tuple ((_::_) as tps), None); _;} ->
+ let fps = List.map ~f:(fun tp -> sexp_of_type renaming tp) tps in
+ let sexp_converters = List.map fps ~f:Fun_or_match.(expr ~loc) in
+ let _, patts, vars = Fun_or_match.map_tmp_vars ~loc fps in
+@@ -761,6 +764,8 @@
+ eapply ~loc partial sexp_converters
+ in
+ [%expr [%e call] ]
++ | { pext_kind = Pext_decl (Pcstr_record _, _); _;} ->
++ failwith "Pcstr_record not supported"
+ | { pext_kind = Pext_decl (_, Some _); _} ->
+ Location.raise_errorf ~loc "sexp_of_exn/:"
+ | { pext_kind = Pext_rebind _; _} ->
+@@ -1089,13 +1094,14 @@
+ (* Generate matching code for well-formed S-expressions wrt. sum types *)
+ let mk_good_sum_matches (loc,cds) =
+ List.map cds ~f:(function
+- | { pcd_name = cnstr; pcd_args = []; _} ->
++ | { pcd_args = Pcstr_record _; _} -> failwith "Pcstr_record unsupported"
++ | { pcd_name = cnstr; pcd_args = Pcstr_tuple []; _} ->
+ let lcstr = pstring ~loc (String.uncapitalize cnstr.txt) in
+ let str = pstring ~loc cnstr.txt in
+ [%pat? Sexplib.Sexp.Atom ([%p lcstr] | [%p str])] -->
+ pexp_construct ~loc (Located.lident ~loc cnstr.txt) None
+
+- | { pcd_name = cnstr; pcd_args = (_::_ as tps); _} ->
++ | { pcd_name = cnstr; pcd_args = Pcstr_tuple (_::_ as tps); _} ->
+ let lcstr = pstring ~loc (String.uncapitalize cnstr.txt) in
+ let str = pstring ~loc cnstr.txt in
+ [%pat? (Sexplib.Sexp.List
+@@ -1109,14 +1115,15 @@
+ wrt. sum types *)
+ let mk_bad_sum_matches (loc,cds) =
+ List.map cds ~f:(function
+- | { pcd_name = cnstr; pcd_args = []; _} ->
++ | { pcd_args = Pcstr_record _; _} -> failwith "Pcstr_record unsupported"
++ | { pcd_name = cnstr; pcd_args = Pcstr_tuple []; _} ->
+ let lcstr = pstring ~loc (String.uncapitalize cnstr.txt) in
+ let str = pstring ~loc cnstr.txt in
+ [%pat? Sexplib.Sexp.List
+ (Sexplib.Sexp.Atom ([%p lcstr] | [%p str]) :: _) as sexp
+ ] -->
+ [%expr Sexplib.Conv_error.stag_no_args _tp_loc sexp]
+- | { pcd_name = cnstr; pcd_args = _::_; _} ->
++ | { pcd_name = cnstr; pcd_args = Pcstr_tuple (_::_); _} ->
+ let lcstr = pstring ~loc (String.uncapitalize cnstr.txt) in
+ let str = pstring ~loc cnstr.txt in
+ [%pat? Sexplib.Sexp.Atom ([%p lcstr] | [%p str]) as sexp] -->
+diff -uNr ppx_sexp_conv-113.33.00/_oasis ppx_sexp_conv-113.33.00+4.03/_oasis
+--- ppx_sexp_conv-113.33.00/_oasis 2016-03-09 16:44:54.000000000 +0100
++++ ppx_sexp_conv-113.33.00+4.03/_oasis 2016-03-22 15:13:51.000000000 +0100
+@@ -1,8 +1,8 @@
+ OASISFormat: 0.4
+-OCamlVersion: >= 4.02.3
++OCamlVersion: >= 4.03.0
+ FindlibVersion: >= 1.3.2
+ Name: ppx_sexp_conv
+-Version: 113.33.00
++Version: 113.33.00+4.03
+ Synopsis: Generation of S-expression conversion functions from type definitions
+ Authors: Jane Street Group, LLC <opensource@janestreet.com>
+ Copyrights: (C) 2015-2016 Jane Street Group LLC <opensource@janestreet.com>
+diff -uNr ppx_sexp_conv-113.33.00/opam ppx_sexp_conv-113.33.00+4.03/opam
+--- ppx_sexp_conv-113.33.00/opam 2016-03-18 12:08:01.000000000 +0100
++++ ppx_sexp_conv-113.33.00+4.03/opam 2016-03-22 17:51:37.000000000 +0100
+@@ -17,4 +17,4 @@
+ "ppx_type_conv"
+ "sexplib"
+ ]
+-available: [ ocaml-version >= "4.02.3" ]
++available: [ ocaml-version >= "4.03.0" ]
diff --git a/dev-ml/ppx_sexp_conv/ppx_sexp_conv-113.33.00.ebuild b/dev-ml/ppx_sexp_conv/ppx_sexp_conv-113.33.00.ebuild
index c94e89c8eee8..b3c39073cb5a 100644
--- a/dev-ml/ppx_sexp_conv/ppx_sexp_conv-113.33.00.ebuild
+++ b/dev-ml/ppx_sexp_conv/ppx_sexp_conv-113.33.00.ebuild
@@ -4,7 +4,7 @@
EAPI="5"
-inherit oasis
+inherit oasis eutils
DESCRIPTION="Support Library for type-driven code generators"
HOMEPAGE="http://www.janestreet.com/ocaml"
@@ -24,6 +24,10 @@ DEPEND="dev-ml/ppx_tools:=
RDEPEND="${DEPEND}"
DEPEND="${DEPEND} dev-ml/opam"
+src_prepare() {
+ has_version '>=dev-lang/ocaml-4.03' && epatch "${FILESDIR}/oc43.patch"
+}
+
src_configure() {
emake setup.exe
OASIS_SETUP_COMMAND="./setup.exe" oasis_src_configure