@@ -17051,10 +17051,11 @@ type cst = private
17051
17051
17052
17052
17053
17053
type label = private
17054
- | Label of {name : string ; cst : cst option }
17055
- | Empty
17056
- | EmptyCst of cst
17057
- | Optional of {name : string}
17054
+ | Obj_label of {name : string}
17055
+ (* | Obj_labelCst of {name : string ; cst : cst} *)
17056
+ | Obj_empty
17057
+
17058
+ | Obj_optional of {name : string}
17058
17059
(* it will be ignored , side effect will be recorded *)
17059
17060
17060
17061
type attr =
@@ -17071,31 +17072,33 @@ type attr =
17071
17072
17072
17073
17073
17074
type label_noname =
17074
- | Label
17075
- | Empty
17076
- | Optional
17075
+ | Arg_label
17076
+ | Arg_empty
17077
+ | Arg_optional
17077
17078
17078
- type t =
17079
+ type obj_param =
17079
17080
{
17080
- arg_type : attr;
17081
- arg_label :label
17081
+ obj_arg_type : attr;
17082
+ obj_arg_label :label
17082
17083
}
17083
17084
17084
- type t_noname = {
17085
+ type param = {
17085
17086
arg_type : attr;
17086
17087
arg_label : label_noname
17087
17088
}
17088
- type params = t_noname list
17089
+
17090
+ type obj_params = obj_param list
17091
+ type params = param list
17089
17092
17090
17093
val cst_json : Location.t -> string -> cst
17091
17094
val cst_int : int -> cst
17092
17095
val cst_string : string -> cst
17093
17096
17094
17097
val empty_label : label
17095
- val empty_lit : cst -> label
17096
- val label : string -> cst option -> label
17098
+ (* val empty_lit : cst -> label *)
17099
+ val obj_label : string -> label
17097
17100
val optional : string -> label
17098
- val empty_kind : attr -> t
17101
+ val empty_kind : attr -> obj_param
17099
17102
17100
17103
end = struct
17101
17104
#1 "external_arg_spec.ml"
@@ -17135,15 +17138,15 @@ type cst =
17135
17138
| Arg_js_json of string
17136
17139
17137
17140
type label_noname =
17138
- | Label
17139
- | Empty
17140
- | Optional
17141
+ | Arg_label
17142
+ | Arg_empty
17143
+ | Arg_optional
17141
17144
17142
17145
type label =
17143
- | Label of {name : string ; cst : cst option }
17144
- | Empty
17145
- | EmptyCst of cst
17146
- | Optional of {name : string }
17146
+ | Obj_label of {name : string }
17147
+ (* | Obj_labelCst of {name : string} *)
17148
+ | Obj_empty
17149
+ | Obj_optional of {name : string }
17147
17150
(* it will be ignored , side effect will be recorded *)
17148
17151
17149
17152
type attr =
@@ -17158,20 +17161,20 @@ type attr =
17158
17161
| Ignore
17159
17162
| Unwrap
17160
17163
17161
- type t_noname = {
17164
+ type param = {
17162
17165
arg_type : attr;
17163
17166
arg_label : label_noname
17164
17167
}
17165
17168
17166
- type t =
17169
+ type obj_param =
17167
17170
{
17168
- arg_type : attr;
17169
- arg_label : label
17171
+ obj_arg_type : attr;
17172
+ obj_arg_label : label
17170
17173
}
17171
17174
17172
17175
17173
-
17174
- type params = t_noname list
17176
+ type obj_params = obj_param list
17177
+ type params = param list
17175
17178
17176
17179
exception Error of Location.t * Ext_json_parse.error
17177
17180
@@ -17206,12 +17209,14 @@ let cst_json (loc : Location.t) s : cst =
17206
17209
17207
17210
let cst_int i = Arg_int_lit i
17208
17211
let cst_string s = Arg_string_lit s
17209
- let empty_label = Empty
17210
- let empty_lit s = EmptyCst s
17211
- let label name cst = Label {name ; cst}
17212
- let optional name = Optional {name}
17212
+ let empty_label = Obj_empty
17213
17213
17214
- let empty_kind arg_type = { arg_label = empty_label ; arg_type }
17214
+ let obj_label name =
17215
+ Obj_label {name }
17216
+
17217
+ let optional name = Obj_optional {name}
17218
+
17219
+ let empty_kind obj_arg_type = { obj_arg_label = empty_label ; obj_arg_type }
17215
17220
17216
17221
end
17217
17222
module Ast_polyvar : sig
@@ -18128,7 +18133,7 @@ type t =
18128
18133
External_arg_spec.params *
18129
18134
return_wrapper *
18130
18135
external_spec
18131
- | Ffi_obj_create of External_arg_spec.t list
18136
+ | Ffi_obj_create of External_arg_spec.obj_params
18132
18137
| Ffi_inline_const of Lam_constant.t
18133
18138
| Ffi_normal
18134
18139
(* When it's normal, it is handled as normal c functional ffi call *)
@@ -18285,7 +18290,7 @@ type t =
18285
18290
[return] means return value is unit or not,
18286
18291
[true] means is [unit]
18287
18292
*)
18288
- | Ffi_obj_create of External_arg_spec.t list
18293
+ | Ffi_obj_create of External_arg_spec.obj_params
18289
18294
| Ffi_inline_const of Lam_constant.t
18290
18295
| Ffi_normal
18291
18296
(* When it's normal, it is handled as normal c functional ffi call *)
@@ -19274,30 +19279,30 @@ let process_obj
19274
19279
else
19275
19280
Location.raise_errorf ~loc "expect label, optional, or unit here"
19276
19281
| Labelled name ->
19277
- let new_ty, arg_type = refine_arg_type ~nolabel:false ty in
19278
- begin match arg_type with
19282
+ let new_ty, obj_arg_type = refine_arg_type ~nolabel:false ty in
19283
+ begin match obj_arg_type with
19279
19284
| Ignore ->
19280
- External_arg_spec.empty_kind arg_type ,
19285
+ External_arg_spec.empty_kind obj_arg_type ,
19281
19286
{param_type with ty = new_ty}::arg_types, result_types
19282
- | Arg_cst i ->
19287
+ | Arg_cst _ ->
19283
19288
let s = Lam_methname.translate name in
19284
- {arg_label = External_arg_spec.label s (Some i) ;
19285
- arg_type },
19289
+ {obj_arg_label = External_arg_spec.obj_label s ;
19290
+ obj_arg_type },
19286
19291
arg_types, (* ignored in [arg_types], reserved in [result_types] *)
19287
19292
(({Asttypes.txt = name; loc} , [], new_ty) :: result_types)
19288
19293
| Nothing ->
19289
19294
let s = (Lam_methname.translate name) in
19290
- {arg_label = External_arg_spec.label s None ; arg_type },
19295
+ {obj_arg_label = External_arg_spec.obj_label s ; obj_arg_type },
19291
19296
{param_type with ty = new_ty}::arg_types,
19292
19297
(({Asttypes.txt = name; loc} , [], new_ty) :: result_types)
19293
19298
| Int _ ->
19294
19299
let s = Lam_methname.translate name in
19295
- {arg_label = External_arg_spec.label s None; arg_type },
19300
+ {obj_arg_label = External_arg_spec.obj_label s; obj_arg_type },
19296
19301
{param_type with ty = new_ty}::arg_types,
19297
19302
(({Asttypes.txt = name; loc}, [], Ast_literal.type_int ~loc ()) :: result_types)
19298
19303
| NullString _ ->
19299
19304
let s = Lam_methname.translate name in
19300
- {arg_label = External_arg_spec.label s None; arg_type },
19305
+ {obj_arg_label = External_arg_spec.obj_label s; obj_arg_type },
19301
19306
{param_type with ty = new_ty }::arg_types,
19302
19307
(({Asttypes.txt = name; loc}, [], Ast_literal.type_string ~loc ()) :: result_types)
19303
19308
| Fn_uncurry_arity _ ->
@@ -19313,24 +19318,24 @@ let process_obj
19313
19318
"bs.obj label %s does not support [@bs.unwrap] arguments" name
19314
19319
end
19315
19320
| Optional name ->
19316
- let arg_type = get_opt_arg_type ~nolabel:false ty in
19317
- begin match arg_type with
19321
+ let obj_arg_type = get_opt_arg_type ~nolabel:false ty in
19322
+ begin match obj_arg_type with
19318
19323
| Ignore ->
19319
- External_arg_spec.empty_kind arg_type ,
19324
+ External_arg_spec.empty_kind obj_arg_type ,
19320
19325
param_type::arg_types, result_types
19321
19326
| Nothing ->
19322
19327
let s = (Lam_methname.translate name) in
19323
- {arg_label = External_arg_spec.optional s; arg_type },
19328
+ {obj_arg_label = External_arg_spec.optional s; obj_arg_type },
19324
19329
param_type :: arg_types,
19325
19330
( ({Asttypes.txt = name; loc}, [], Ast_comb.to_undefined_type loc ty) :: result_types)
19326
19331
| Int _ ->
19327
19332
let s = Lam_methname.translate name in
19328
- {arg_label = External_arg_spec.optional s ; arg_type },
19333
+ {obj_arg_label = External_arg_spec.optional s ; obj_arg_type },
19329
19334
param_type :: arg_types,
19330
19335
(({Asttypes.txt = name; loc}, [], Ast_comb.to_undefined_type loc @@ Ast_literal.type_int ~loc ()) :: result_types)
19331
19336
| NullString _ ->
19332
19337
let s = Lam_methname.translate name in
19333
- {arg_label = External_arg_spec.optional s ; arg_type },
19338
+ {obj_arg_label = External_arg_spec.optional s ; obj_arg_type },
19334
19339
param_type::arg_types,
19335
19340
(({Asttypes.txt = name; loc}, [], Ast_comb.to_undefined_type loc @@ Ast_literal.type_string ~loc ()) :: result_types)
19336
19341
| Arg_cst _
@@ -19722,7 +19727,7 @@ let handle_attributes
19722
19727
Location.raise_errorf ~loc:obj.ptyp_loc "[@bs.as] is not supported in bs.send type "
19723
19728
| _ ->
19724
19729
(* more error checking *)
19725
- [{arg_label = Empty ; arg_type}],
19730
+ [{arg_label = Arg_empty ; arg_type}],
19726
19731
[{label = Nolabel;
19727
19732
ty = new_ty;
19728
19733
attr = [];
@@ -19760,22 +19765,22 @@ let handle_attributes
19760
19765
~loc
19761
19766
"[@@bs.string] does not work with optional when it has arities in label %s" s
19762
19767
| _ ->
19763
- Optional , arg_type,
19768
+ Arg_optional , arg_type,
19764
19769
param_type :: arg_types end
19765
19770
| Labelled s ->
19766
19771
begin match refine_arg_type ~nolabel:false ty with
19767
19772
| new_ty, (Arg_cst _ as arg_type) ->
19768
- Label , arg_type, arg_types
19773
+ Arg_label , arg_type, arg_types
19769
19774
| new_ty, arg_type ->
19770
- Label , arg_type,
19775
+ Arg_label , arg_type,
19771
19776
{param_type with ty = new_ty} :: arg_types
19772
19777
end
19773
19778
| Nolabel ->
19774
19779
begin match refine_arg_type ~nolabel:true ty with
19775
19780
| new_ty , (Arg_cst _ as arg_type) ->
19776
- Empty , arg_type, arg_types
19781
+ Arg_empty , arg_type, arg_types
19777
19782
| new_ty , arg_type ->
19778
- Empty , arg_type, {param_type with ty = new_ty} :: arg_types
19783
+ Arg_empty , arg_type, {param_type with ty = new_ty} :: arg_types
19779
19784
end
19780
19785
in
19781
19786
({ arg_label ;
@@ -19821,14 +19826,14 @@ let handle_attributes_as_string
19821
19826
19822
19827
let pval_prim_of_labels (labels : string Asttypes.loc list) =
19823
19828
let arg_kinds =
19824
- Ext_list.fold_right labels ([] : External_arg_spec.t list )
19829
+ Ext_list.fold_right labels ([] : External_arg_spec.obj_params )
19825
19830
(fun {loc ; txt } arg_kinds
19826
19831
->
19827
- let arg_label =
19828
- External_arg_spec.label
19829
- (Lam_methname.translate txt) None in
19830
- {arg_type = Nothing ;
19831
- arg_label } :: arg_kinds
19832
+ let obj_arg_label =
19833
+ External_arg_spec.obj_label
19834
+ (Lam_methname.translate txt) in
19835
+ {obj_arg_type = Nothing ;
19836
+ obj_arg_label } :: arg_kinds
19832
19837
) in
19833
19838
let encoding =
19834
19839
External_ffi_types.to_string (Ffi_obj_create arg_kinds) in
@@ -19846,13 +19851,13 @@ let pval_prim_of_option_labels
19846
19851
(fun (is_option,{loc ; txt }) arg_kinds
19847
19852
->
19848
19853
let label_name = Lam_methname.translate txt in
19849
- let arg_label =
19854
+ let obj_arg_label =
19850
19855
if is_option then
19851
19856
External_arg_spec.optional label_name
19852
- else External_arg_spec.label label_name None
19857
+ else External_arg_spec.obj_label label_name
19853
19858
in
19854
- {arg_type = Nothing ;
19855
- arg_label } :: arg_kinds) in
19859
+ {obj_arg_type = Nothing ;
19860
+ obj_arg_label } :: arg_kinds) in
19856
19861
let encoding =
19857
19862
External_ffi_types.to_string (Ffi_obj_create arg_kinds) in
19858
19863
[""; encoding]
@@ -22513,7 +22518,7 @@ let handleTdcl
22513
22518
["" ; (* Not needed actually*)
22514
22519
External_ffi_types.to_string
22515
22520
(Ffi_bs (
22516
- [{arg_type = Nothing; arg_label = Empty }],
22521
+ [{arg_type = Nothing; arg_label = Arg_empty }],
22517
22522
Return_identity,
22518
22523
Js_get {js_get_name = prim_as_name; js_get_scopes = []}
22519
22524
))] )
0 commit comments