summaryrefslogtreecommitdiff
blob: d328d5bc55fa2a7eecd97f3abc504992b85d768c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
diff -uNr ppx_bin_prot-113.33.00/_oasis ppx_bin_prot-113.33.00+4.03/_oasis
--- ppx_bin_prot-113.33.00/_oasis	2016-03-09 16:44:53.000000000 +0100
+++ ppx_bin_prot-113.33.00+4.03/_oasis	2016-03-22 15:13:49.000000000 +0100
@@ -1,8 +1,8 @@
 OASISFormat:      0.4
-OCamlVersion:     >= 4.02.3
+OCamlVersion:     >= 4.03.0
 FindlibVersion:   >= 1.3.2
 Name:             ppx_bin_prot
-Version:          113.33.00
+Version:          113.33.00+4.03
 Synopsis:         Generation of bin_prot readers and writers from types
 Authors:          Jane Street Group, LLC <opensource@janestreet.com>
 Copyrights:       (C) 2015-2016 Jane Street Group LLC <opensource@janestreet.com>
diff -uNr ppx_bin_prot-113.33.00/opam ppx_bin_prot-113.33.00+4.03/opam
--- ppx_bin_prot-113.33.00/opam	2016-03-18 12:08:01.000000000 +0100
+++ ppx_bin_prot-113.33.00+4.03/opam	2016-03-22 17:51:35.000000000 +0100
@@ -17,4 +17,4 @@
   "ppx_tools"     {>= "0.99.3"}
   "ppx_type_conv"
 ]
-available: [ ocaml-version >= "4.02.3" ]
+available: [ ocaml-version >= "4.03.0" ]
diff -uNr ppx_bin_prot-113.33.00/src/ppx_bin_prot.ml ppx_bin_prot-113.33.00+4.03/src/ppx_bin_prot.ml
--- ppx_bin_prot-113.33.00/src/ppx_bin_prot.ml	2016-03-09 16:44:53.000000000 +0100
+++ ppx_bin_prot-113.33.00+4.03/src/ppx_bin_prot.ml	2016-03-22 15:13:49.000000000 +0100
@@ -37,7 +37,7 @@
         ~init:result_type
         ~f:(fun (tp, _variance) acc ->
           let loc = tp.ptyp_loc in
-          ptyp_arrow ~loc "" (wrap_type ~loc tp) acc)
+          ptyp_arrow ~loc Nolabel (wrap_type ~loc tp) acc)
     in
     psig_value ~loc (value_description ~loc ~name ~type_:typ ~prim:[])
 
@@ -72,7 +72,12 @@
     | Rinherit _ -> false)
 ;;
 
-let atoms_in_variant cds = List.exists cds ~f:(fun cds -> cds.pcd_args = [])
+let atoms_in_variant cds =
+  List.exists cds ~f:(fun cds ->
+    match cds.pcd_args with
+    | Pcstr_tuple [] -> true
+    | Pcstr_tuple _ -> false
+    | Pcstr_record _ -> failwith "Pcstr_record not supported")
 
 let let_ins loc bindings expr =
   List.fold_right bindings ~init:expr ~f:(fun binding expr ->
@@ -327,8 +332,8 @@
            Location.raise_errorf ~loc:ty.ptyp_loc
              "bin_size_sum: GADTs are not supported by bin_prot");
         match cd.pcd_args with
-        | [] -> acc
-        | args ->
+        | Pcstr_tuple [] -> acc
+        | Pcstr_tuple args ->
           let get_tp tp = tp in
           let mk_patt loc v_name _ = pvar ~loc v_name in
           let patts, size_args =
@@ -344,7 +349,8 @@
               let size = [%e size_tag] in
               [%e size_args]
             ]
-          :: acc)
+          :: acc
+        | Pcstr_record _ -> failwith "Pcstr_record not supported")
     in
     let matchings =
       if atoms_in_variant alts then
@@ -585,13 +591,13 @@
            Location.raise_errorf ~loc:ty.ptyp_loc
              "bin_write_sum: GADTs are not supported by bin_prot");
         match cd.pcd_args with
-        | [] ->
+        | Pcstr_tuple [] ->
           let loc = cd.pcd_loc in
           case
             ~lhs:(pconstruct cd None)
             ~guard:None
             ~rhs:(eapply ~loc write_tag [eint ~loc i])
-        | args ->
+        | Pcstr_tuple args ->
           let get_tp tp = tp in
           let mk_patt loc v_name _ = pvar ~loc v_name in
           let patts, write_args =
@@ -606,7 +612,8 @@
             ~rhs:[%expr
               let pos = [%e write_tag] [%e eint ~loc i] in
               [%e write_args]
-            ])
+            ]
+        | Pcstr_record _ -> failwith "Pcstr_record not supported")
     in
     `Match matchings
 
@@ -934,13 +941,14 @@
          Location.raise_errorf ~loc:cd.pcd_loc
            "bin_read_sum: GADTs are not supported by bin_prot");
       match cd.pcd_args with
-      | [] ->
+      | Pcstr_tuple [] ->
         let loc = cd.pcd_loc in
         case ~lhs:(pint ~loc mi) ~guard:None ~rhs:(econstruct cd None)
-      | args ->
+      | Pcstr_tuple args ->
         let bindings, args_expr = handle_arg_tp loc full_type_name args in
         let rhs = let_ins loc bindings (econstruct cd (Some args_expr)) in
         case ~lhs:(pint ~loc mi) ~guard:None ~rhs
+      | Pcstr_record _ -> failwith "Pcstr_record not supported"
     in
     let mcs = List.mapi alts ~f:map in
     let n_alts = List.length alts in