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>
This commit is contained in:
Alexis Ballier
2016-05-01 20:10:24 +02:00
parent ebedfa131a
commit 596ea1e96d
2 changed files with 150 additions and 1 deletions

View File

@@ -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" ]

View File

@@ -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