File tree Expand file tree Collapse file tree 5 files changed +31
-1
lines changed Expand file tree Collapse file tree 5 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,10 @@ let type_int64 =
134134 Ast_helper.Typ. mk
135135 (Ptyp_constr ({ txt = Lident " int64" ; loc = Location. none}, [] ))
136136
137+ let type_float =
138+ Ast_helper.Typ. mk
139+ (Ptyp_constr ({ txt = Lident " float" ; loc = Location. none}, [] ))
140+
137141let type_any ?loc () =
138142 match loc with
139143 | None -> No_loc. type_any
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ val type_string : core_type_lit
6262val type_bool : core_type_lit
6363val type_int : core_type_lit
6464val type_int64 : Parsetree .core_type
65+ val type_float : Parsetree .core_type
6566val type_any : core_type_lit
6667
6768val pat_unit : pattern_lit
Original file line number Diff line number Diff line change @@ -259,7 +259,14 @@ let signature_item_mapper (self : mapper) (sigi : Parsetree.signature_item) =
259259 value_desc with
260260 pval_prim = External_ffi_types. inline_int64_primitive s;
261261 pval_attributes = [] ;
262- } }
262+ } }
263+ | Pexp_constant (Pconst_float(s ,None)) ->
264+ Bs_ast_invariant. warn_discarded_unused_attributes pval_attributes;
265+ {sigi with psig_desc = Psig_value {
266+ value_desc with
267+ pval_prim = External_ffi_types. inline_float_primitive s;
268+ pval_attributes = [] ;
269+ } }
263270 | Pexp_construct ({txt = Lident (" true" | " false" as txt)}, None )
264271 ->
265272 Bs_ast_invariant. warn_discarded_unused_attributes pval_attributes;
@@ -338,6 +345,16 @@ let structure_item_mapper (self : mapper) (str : Parsetree.structure_item) =
338345 pval_attributes = [] ;
339346 pval_prim = External_ffi_types. inline_int64_primitive s
340347 } }
348+ | Pexp_constant (Pconst_float (s, None ))
349+ ->
350+ Bs_ast_invariant. warn_discarded_unused_attributes pvb_attributes;
351+ {str with pstr_desc = Pstr_primitive {
352+ pval_name = pval_name ;
353+ pval_type = Ast_literal. type_float;
354+ pval_loc = pvb_loc;
355+ pval_attributes = [] ;
356+ pval_prim = External_ffi_types. inline_float_primitive s
357+ } }
341358 | Pexp_construct ({txt = Lident ("true" | "false" as txt ) } ,None ) ->
342359 Bs_ast_invariant. warn_discarded_unused_attributes pvb_attributes;
343360 {str with pstr_desc = Pstr_primitive {
Original file line number Diff line number Diff line change @@ -316,6 +316,11 @@ let inline_int64_primitive (i : int64) : string list =
316316 (Const_int64 i))
317317 ]
318318
319+ let inline_float_primitive (i : string ) : string list =
320+ [" " ;
321+ to_string
322+ (Ffi_inline_const (Const_float i))
323+ ]
319324let rec ffi_bs_aux acc (params : External_arg_spec.params ) =
320325 match params with
321326 | {arg_type = Nothing ; arg_label = Arg_empty }
Original file line number Diff line number Diff line change @@ -141,6 +141,9 @@ val inline_int64_primitive :
141141 int64 ->
142142 string list
143143
144+ val inline_float_primitive :
145+ string -> string list
146+
144147val ffi_bs :
145148 External_arg_spec .params ->
146149 return_wrapper ->
You can’t perform that action at this time.
0 commit comments