From 7d3531278509e0fa775ed343fd2d9e20e9df6d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulysse=20G=C3=A9rard?= Date: Sun, 8 Dec 2024 15:08:07 +0100 Subject: [PATCH] More base types --- vendor/ppx_deriving_jsont/src/ppx_deriving_jsont.ml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vendor/ppx_deriving_jsont/src/ppx_deriving_jsont.ml b/vendor/ppx_deriving_jsont/src/ppx_deriving_jsont.ml index cfe5968..87f95ab 100644 --- a/vendor/ppx_deriving_jsont/src/ppx_deriving_jsont.ml +++ b/vendor/ppx_deriving_jsont/src/ppx_deriving_jsont.ml @@ -63,18 +63,24 @@ let jsont_sig_item ~loc ~name type_ = let rec of_core_type (core_type : Parsetree.core_type) = let loc = core_type.ptyp_loc in + (* TODO we should provide finer user control for handling int and floats *) match core_type with | [%type: unit] -> [%expr Jsont.null ()] | [%type: string] -> [%expr Jsont.string] | [%type: bool] -> [%expr Jsont.bool] - | [%type: int] -> - (* TODO we should provide finer user control here *) [%expr Jsont.int] + | [%type: float] -> [%expr Jsont.number] + | [%type: int] -> [%expr Jsont.int] + | [%type: int32] -> [%expr Jsont.int32] + | [%type: int64] -> [%expr Jsont.int64] | [%type: [%t? typ] option] -> let jsont = of_core_type typ in [%expr Jsont.option [%e jsont]] | [%type: [%t? typ] list] -> let jsont = of_core_type typ in [%expr Jsont.list [%e jsont]] + | [%type: [%t? typ] array] -> + let jsont = of_core_type typ in + [%expr Jsont.array [%e jsont]] | { ptyp_desc = Ptyp_constr ({ txt = lid; loc }, _args); _ } -> (* TODO: arguments ? quoting ? *) Exp.ident