summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephane Glondu <steph@glondu.net>2020-08-26 11:44:16 +0200
committerStephane Glondu <steph@glondu.net>2020-08-26 11:44:16 +0200
commit017104a4a8adab2f844a84cbf4f480cc9491d5e1 (patch)
treef169c4cc4bb1d0d725d41ae5c617dc4e914a91c6
parent9b8ba1c492d51e13e97ad307475e1a164bfc6536 (diff)
New upstream version 1.2.3
-rw-r--r--dune-project2
-rw-r--r--obus.opam1
-rw-r--r--src/ppx/dune2
-rw-r--r--src/ppx/ppx_obus.ml33
4 files changed, 16 insertions, 22 deletions
diff --git a/dune-project b/dune-project
index f5fb24d..ba417fe 100644
--- a/dune-project
+++ b/dune-project
@@ -1,2 +1,2 @@
-(lang dune 1.1)
+(lang dune 1.4)
(using menhir 2.0)
diff --git a/obus.opam b/obus.opam
index f75a464..85a5095 100644
--- a/obus.opam
+++ b/obus.opam
@@ -21,6 +21,5 @@ depends: [
"lwt_ppx"
"lwt_log"
"lwt_react"
- "ocaml-migrate-parsetree"
"ppxlib"
]
diff --git a/src/ppx/dune b/src/ppx/dune
index 7753460..f410913 100644
--- a/src/ppx/dune
+++ b/src/ppx/dune
@@ -3,5 +3,5 @@
(public_name obus.ppx)
(kind ppx_rewriter)
(synopsis "Utility syntax for defining D-Bus errors")
- (libraries ocaml-migrate-parsetree)
+ (libraries ppxlib)
(preprocess (pps ppxlib.metaquot)))
diff --git a/src/ppx/ppx_obus.ml b/src/ppx/ppx_obus.ml
index 998e227..e07c3e3 100644
--- a/src/ppx/ppx_obus.ml
+++ b/src/ppx/ppx_obus.ml
@@ -1,24 +1,17 @@
-open Migrate_parsetree
-open Ast_408.Parsetree
+open Ppxlib
let rewriter_name = "ppx_obus"
-let raise_errorf ?sub ?loc message =
- message |> Printf.kprintf (fun str ->
- let err = Location.error ?sub ?loc str in
- raise (Location.Error err))
-
-
let find_attr_expr s attrs =
let expr_of_payload = function
| PStr [{ pstr_desc = Pstr_eval (e, _); _ }] -> Some e
| _ -> None in
try expr_of_payload (
let payload =
- List.find (fun attr -> attr.Ast_408.Parsetree.attr_name.txt = s) attrs
+ List.find (fun attr -> attr.attr_name.txt = s) attrs
in
- payload.Ast_408.Parsetree.attr_payload)
+ payload.attr_payload)
with Not_found -> None
@@ -52,7 +45,7 @@ let register_obus_exception = function
| Pext_decl (Pcstr_tuple [typ], None) ->
Some (registerer typ)
| _ ->
- raise_errorf ~loc:pstr_loc
+ Location.raise_errorf ~loc:pstr_loc
"%s: OBus exceptions take a single string argument" rewriter_name)
| _ ->
None)
@@ -60,20 +53,22 @@ let register_obus_exception = function
None
-let obus_mapper =
- { Ast_408.Ast_mapper.default_mapper with
- structure = fun mapper items ->
- List.fold_right (fun item acc ->
- let item' = Ast_408.Ast_mapper.default_mapper.structure_item mapper item in
+let obus_mapper = object(self)
+ inherit Ast_traverse.map
+
+ method! structure items =
+ List.fold_right (fun item acc ->
+ let item' = self#structure_item item in
match register_obus_exception item with
| Some reg ->
item' :: reg :: acc
| None ->
item' :: acc)
items []
- }
+end
let () =
- Driver.register ~name:rewriter_name Versions.ocaml_408
- (fun _ _ -> obus_mapper)
+ Driver.register_transformation
+ ~impl:(fun structure -> obus_mapper#structure structure)
+ rewriter_name