From c3a6ef32a79b42137738c8bc70c2223a39e44999 Mon Sep 17 00:00:00 2001 From: Boning <10731263+bn-d@users.noreply.github.com> Date: Sun, 20 Feb 2022 00:55:57 +0000 Subject: [PATCH] Update version and update compatibility (#13) --- dune-project | 6 +++--- ppx_pyformat.opam | 6 +++--- runtime/ppx_pyformat_runtime.ml | 11 ++++++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dune-project b/dune-project index 9c71de0..f4bd3c2 100644 --- a/dune-project +++ b/dune-project @@ -1,6 +1,6 @@ (lang dune 2.7) (name ppx_pyformat) -(version "0.1.1") +(version "0.1.2") (generate_opam_files true) @@ -15,8 +15,8 @@ (synopsis "Ppxlib based string format rewriter inspired by Python string `format`") (depends (ocaml (>= 4.08)) - (ppxlib (>= 0.22.0)) + (ppxlib (>= 0.23.0)) (ppx_make (>= 0.3.0)) - menhir + (menhir (>= 20200624)) (ounit2 :with-test))) (using menhir 2.1) diff --git a/ppx_pyformat.opam b/ppx_pyformat.opam index 41d3878..bb63965 100644 --- a/ppx_pyformat.opam +++ b/ppx_pyformat.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "0.1.1" +version: "0.1.2" synopsis: "Ppxlib based string format rewriter inspired by Python string `format`" maintainer: ["Boning "] @@ -12,9 +12,9 @@ bug-reports: "https://github.com/bn-d/ppx_pyformat/issues" depends: [ "dune" {>= "2.7"} "ocaml" {>= "4.08"} - "ppxlib" {>= "0.22.0"} + "ppxlib" {>= "0.23.0"} "ppx_make" {>= "0.3.0"} - "menhir" + "menhir" {>= "20200624"} "ounit2" {with-test} "odoc" {with-doc} ] diff --git a/runtime/ppx_pyformat_runtime.ml b/runtime/ppx_pyformat_runtime.ml index ad4f743..7ec204b 100644 --- a/runtime/ppx_pyformat_runtime.ml +++ b/runtime/ppx_pyformat_runtime.ml @@ -1,12 +1,17 @@ external format_int : string -> int -> string = "caml_format_int" +external bytes_unsafe_blit_string : + string -> int -> bytes -> int -> int -> unit + = "caml_blit_string" + [@@noalloc] + let align_left c w s = let len = String.length s in if len >= w then s else let b = Bytes.create w in - Bytes.unsafe_blit_string s 0 b 0 len; + bytes_unsafe_blit_string s 0 b 0 len; Bytes.unsafe_fill b len (w - len) c; Bytes.unsafe_to_string b @@ -17,7 +22,7 @@ let align_right c w s = else let b = Bytes.create w and fill_len = w - len in Bytes.unsafe_fill b 0 fill_len c; - Bytes.unsafe_blit_string s 0 b fill_len len; + bytes_unsafe_blit_string s 0 b fill_len len; Bytes.unsafe_to_string b let align_center c w s = @@ -29,7 +34,7 @@ let align_center c w s = let left_len = (w - len) / 2 in let right_len = w - len - left_len in Bytes.unsafe_fill b 0 left_len c; - Bytes.unsafe_blit_string s 0 b left_len len; + bytes_unsafe_blit_string s 0 b left_len len; Bytes.unsafe_fill b (left_len + len) right_len c; Bytes.unsafe_to_string b