Skip to content

Commit

Permalink
Merge pull request #36 from thierry-martinez/411
Browse files Browse the repository at this point in the history
Add support for OCaml 4.11
  • Loading branch information
gasche authored Sep 24, 2020
2 parents 314de4d + 6398291 commit 12c291f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
19 changes: 12 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.t
script: bash -ex .travis-opam.sh
env:
global:
- TESTS=true
- PINS="ppx_deriving:https://github.com/ocaml-ppx/ppx_deriving.git#pre-ppxlib"
matrix:
- OCAML_VERSION=4.03 PACKAGE="ppx_deriving_protobuf"
- OCAML_VERSION=4.04 PACKAGE="ppx_deriving_protobuf"
- OCAML_VERSION=4.05 PACKAGE="ppx_deriving_protobuf"
- OCAML_VERSION=4.06 PACKAGE="ppx_deriving_protobuf"
- OCAML_VERSION=4.07 PACKAGE="ppx_deriving_protobuf"
- OCAML_VERSION=4.08 PACKAGE="ppx_deriving_protobuf"
- OCAML_VERSION=4.03
- OCAML_VERSION=4.04
- OCAML_VERSION=4.05
- OCAML_VERSION=4.06
- OCAML_VERSION=4.07
- OCAML_VERSION=4.08
- OCAML_VERSION=4.09
- OCAML_VERSION=4.10
- OCAML_VERSION=4.11.0+trunk OCAML_BETA=enable
PINS="ppx_tools:https://github.com/kit-ty-kate/ppx_tools.git#411
ppx_deriving:https://github.com/ocaml-ppx/ppx_deriving.git#pre-ppxlib"
os:
- linux
15 changes: 10 additions & 5 deletions src/ppx_deriving_protobuf.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1170,15 +1170,20 @@ let rec write_protoc ~fmt ~path:base_path ?(import=[])
let i = int_of_string sn in
#endif
Format.fprintf fmt " [default=%d]" i
| Some { pexp_desc = Pexp_constant (Pconst_string (s, _)) } ->
Format.fprintf fmt " [default=\"%s\"]" (escape ~pass_8bit:true s)
| Some [%expr Bytes.of_string [%e? { pexp_desc = Pexp_constant (Pconst_string (s, _)) }]] ->
Format.fprintf fmt " [default=\"%s\"]" (escape ~pass_8bit:false s)
| Some { pexp_desc = Pexp_construct ({ txt = Lident n }, _) }
| Some { pexp_desc = Pexp_variant (n, _) } ->
Format.fprintf fmt " [default=%s_tag]" n
| None -> ()
| Some { pexp_loc } -> raise (Error (Pberr_ocaml_expr pexp_loc))
| Some expr ->
let expr, pass_8bit =
match expr with
| [%expr Bytes.of_string [%e? sub_expr ]] -> sub_expr, false
| _ -> expr, true in
match Ppx_deriving.string_of_expression_opt expr with
| Some s ->
Format.fprintf fmt " [default=\"%s\"]" (escape ~pass_8bit s)
| None ->
raise (Error (Pberr_ocaml_expr expr.pexp_loc))
end;
Format.fprintf fmt ";"
in
Expand Down

0 comments on commit 12c291f

Please sign in to comment.