Skip to content

Commit 165bf28

Browse files
Merge pull request #11 from andersfugmann/ppxlib
Use ppxlib rather than ppx_type_conv.
2 parents ac80aea + 4c450d3 commit 165bf28

9 files changed

Lines changed: 40 additions & 45 deletions

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313
- PACKAGE="ppx_protocol_conv" OCAML_VERSION=4.04
1414
- PACKAGE="ppx_protocol_conv" OCAML_VERSION=4.05
1515
- PACKAGE="ppx_protocol_conv" OCAML_VERSION=4.06
16-
16+
- PACKAGE="ppx_protocol_conv" OCAML_VERSION=4.07
1717
- PACKAGE="ppx_protocol_conv_json" OCAML_VERSION=4.07
1818
- PACKAGE="ppx_protocol_conv_msgpack" OCAML_VERSION=4.07
1919
- PACKAGE="ppx_protocol_conv_xml_light" OCAML_VERSION=4.07

ppx/dune

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
(name ppx_protocol_conv)
33
(public_name ppx_protocol_conv)
44
(kind ppx_deriver)
5-
(libraries base ppx_type_conv ppx_core)
6-
;(ppx_runtime_libraries ppxlib ppx_core ppx_type_conv ppx_driver)
5+
(libraries base ppxlib)
76
(preprocess (pps ppxlib.metaquot))
87
(synopsis "ppx to derive (de)serialisers of a type")
98
)

ppx/ppx_protocol_conv.ml

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
open !Ppx_type_conv.Std
2-
open Ppx_core
1+
open Ppxlib
32
open Ast_builder.Default
43
open !Printf
54
open Base
@@ -127,9 +126,9 @@ let test_row_mapping t rows =
127126
| Rtag (name, attrs, _, _) -> name, attrs
128127
in
129128
match Attribute.get t.row_attrib row with
130-
| Some name when String.equal row_name name -> `Fst name
129+
| Some name when String.equal row_name.txt name -> `Fst name
131130
| Some name -> `Snd (name, attrs)
132-
| None -> `Fst row_name
131+
| None -> `Fst row_name.txt
133132
) rows
134133
in
135134
let _: string list = List.fold_left ~init:base
@@ -199,7 +198,7 @@ let rec serialize_expr_of_type_descr t ~loc = function
199198
raise_errorf ~loc "Inherited types not supported"
200199
| Rtag (name, _attributes, _bool, core_types) as row ->
201200
let lhs =
202-
ppat_variant ~loc name (mk_pattern core_types)
201+
ppat_variant ~loc name.txt (mk_pattern core_types)
203202
in
204203
let args =
205204
List.mapi ~f:(
@@ -212,7 +211,7 @@ let rec serialize_expr_of_type_descr t ~loc = function
212211
let rhs =
213212
let constr_name = match Attribute.get t.row_attrib row with
214213
| Some key -> key
215-
| None -> name
214+
| None -> name.txt
216215
in
217216
[%expr ( [%e estring ~loc constr_name ],
218217
[%e args |> list_expr ~loc] )]
@@ -290,7 +289,7 @@ let rec deserialize_expr_of_type_descr t ~loc = function
290289
let lhs =
291290
let constr_name = match Attribute.get t.row_attrib row with
292291
| Some key -> key
293-
| None -> name
292+
| None -> name.txt
294293
in
295294
let pcstr s pat = ppat_construct ~loc { loc; txt=Lident s } pat in
296295
core_types
@@ -316,7 +315,7 @@ let rec deserialize_expr_of_type_descr t ~loc = function
316315
|> pexp_tuple ~loc
317316
|> Option.some
318317
in
319-
pexp_variant ~loc name args
318+
pexp_variant ~loc name.txt args
320319
in
321320
case ~lhs ~guard:None ~rhs
322321
in
@@ -706,25 +705,25 @@ let mk_str_type_decl =
706705
f t recflag ~loc tydecls
707706

708707
let () =
709-
let driver = Type_conv.Args.(arg "driver" (pexp_pack __)) in
710-
let flags = Type_conv.Args.(arg "flags" __) in
711-
Type_conv.add "protocol"
712-
~str_type_decl:(Type_conv.Generator.make
713-
Type_conv.Args.(empty +> driver +> flags)
708+
let driver = Ppxlib.Deriving.Args.(arg "driver" (pexp_pack __)) in
709+
let flags = Ppxlib.Deriving.Args.(arg "flags" __) in
710+
Deriving.add "protocol"
711+
~str_type_decl:(Deriving.Generator.make
712+
Deriving.Args.(empty +> driver +> flags)
714713
(mk_str_type_decl protocol_str_type_decls))
715-
~sig_type_decl:(Type_conv.Generator.make Type_conv.Args.(empty +> driver) protocol_sig_type_decls)
716-
|> Type_conv.ignore;
714+
~sig_type_decl:(Deriving.Generator.make Deriving.Args.(empty +> driver) protocol_sig_type_decls)
715+
|> Ppxlib.Deriving.ignore;
717716

718-
Type_conv.add "of_protocol"
719-
~str_type_decl:(Type_conv.Generator.make
720-
Type_conv.Args.(empty +> driver +> flags)
717+
Deriving.add "of_protocol"
718+
~str_type_decl:(Deriving.Generator.make
719+
Deriving.Args.(empty +> driver +> flags)
721720
(mk_str_type_decl of_protocol_str_type_decls))
722-
~sig_type_decl:(Type_conv.Generator.make Type_conv.Args.(empty +> driver) of_protocol_sig_type_decls)
723-
|> Type_conv.ignore;
721+
~sig_type_decl:(Deriving.Generator.make Deriving.Args.(empty +> driver) of_protocol_sig_type_decls)
722+
|> Deriving.ignore;
724723

725-
Type_conv.add "to_protocol"
726-
~str_type_decl:(Type_conv.Generator.make
727-
Type_conv.Args.(empty +> driver +> flags)
724+
Deriving.add "to_protocol"
725+
~str_type_decl:(Deriving.Generator.make
726+
Deriving.Args.(empty +> driver +> flags)
728727
(mk_str_type_decl to_protocol_str_type_decls))
729-
~sig_type_decl:(Type_conv.Generator.make Type_conv.Args.(empty +> driver) to_protocol_sig_type_decls)
730-
|> Type_conv.ignore;
728+
~sig_type_decl:(Deriving.Generator.make Deriving.Args.(empty +> driver) to_protocol_sig_type_decls)
729+
|> Deriving.ignore;

ppx_protocol_conv.opam

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@ build: [
1111
]
1212
depends: [
1313
"ocaml" {>= "4.04"}
14-
"base"
15-
"ppx_type_conv"
16-
"ppx_driver"
17-
"ppx_core"
14+
"base" {< "v0.12"}
1815
"dune" {build}
19-
"ppxlib"
20-
"ppx_sexp_conv" {with-test}
21-
"sexplib" {with-test}
16+
"ppxlib" {>= "0.3.0"}
17+
"ppx_sexp_conv" {with-test & < "v0.12"}
18+
"sexplib" {with-test & < "v0.12"}
2219
"ounit" {with-test}
2320
]
2421
synopsis:

ppx_protocol_conv_json.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ depends: [
1414
"ppx_protocol_conv" {>= "3.1.1"}
1515
"yojson"
1616
"dune" {build}
17-
"ppx_sexp_conv" {with-test}
18-
"sexplib" {with-test}
17+
"ppx_sexp_conv" {with-test & < "v0.12"}
18+
"sexplib" {with-test & < "v0.12"}
1919
"ounit" {with-test}
2020
]
2121
synopsis: "Json driver for Ppx_protocol_conv"

ppx_protocol_conv_jsonm.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ depends: [
1414
"ppx_protocol_conv" {>= "3.1.1"}
1515
"ezjsonm"
1616
"dune" {build}
17-
"ppx_sexp_conv" {with-test}
18-
"sexplib" {with-test}
17+
"ppx_sexp_conv" {with-test & < "v0.12"}
18+
"sexplib" {with-test & < "v0.12"}
1919
"ounit" {with-test}
2020
]
2121
synopsis: "Jsonm driver for Ppx_protocol_conv"

ppx_protocol_conv_msgpack.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ depends: [
1414
"ppx_protocol_conv" {>= "3.1.1"}
1515
"msgpck"
1616
"dune" {build}
17-
"ppx_sexp_conv" {with-test}
18-
"sexplib" {with-test}
17+
"ppx_sexp_conv" {with-test & < "v0.12"}
18+
"sexplib" {with-test & < "v0.12"}
1919
"ounit" {with-test}
2020
]
2121
synopsis: "MessagePack driver for Ppx_protocol_conv"

ppx_protocol_conv_xml_light.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ depends: [
1414
"ppx_protocol_conv" {>= "3.1.1"}
1515
"xml-light"
1616
"dune" {build}
17-
"ppx_sexp_conv" {with-test}
18-
"sexplib" {with-test}
17+
"ppx_sexp_conv" {with-test & < "v0.12"}
18+
"sexplib" {with-test & < "v0.12"}
1919
"ounit" {with-test}
2020
]
2121
synopsis: "Xml driver for Ppx_protocol_conv"

ppx_protocol_conv_yaml.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ depends: [
1414
"ppx_protocol_conv" {>= "3.1.1"}
1515
"yaml"
1616
"dune" {build}
17-
"ppx_sexp_conv" {with-test}
18-
"sexplib" {with-test}
17+
"ppx_sexp_conv" {with-test & < "v0.12"}
18+
"sexplib" {with-test & < "v0.12"}
1919
"ounit" {with-test}
2020
]
2121
synopsis: "Json driver for Ppx_protocol_conv"

0 commit comments

Comments
 (0)