Skip to content

Commit 8265044

Browse files
authored
Merge pull request #4701 from rescript-lang/clean_up_attributes
bs.xx -> xx transition, no bs prefix needed
2 parents 7a48974 + 69af0f0 commit 8265044

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+880
-1055
lines changed

jscomp/core/js_call_info.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type call_info =
3737
| Call_ml (* called by plain ocaml expression *)
3838
| Call_builtin_runtime (* built-in externals *)
3939
| Call_na
40-
(* either from [@@bs.val] or not available,
40+
(* either from [@@val] or not available,
4141
such calls does not follow such rules
4242
{[ fun x y -> (f x y) === f ]} when [f] is an atom
4343

jscomp/core/js_call_info.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type call_info =
4040
| Call_ml (* called by plain ocaml expression *)
4141
| Call_builtin_runtime (* built-in externals *)
4242
| Call_na
43-
(* either from [@@bs.val] or not available,
43+
(* either from [@@val] or not available,
4444
such calls does not follow such rules
4545
{[ fun x y -> f x y === f ]} when [f] is an atom
4646
*)

jscomp/core/lam.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ exception Not_simple_form
287287
where [wrap] used to be simple instructions
288288
Note that [external] functions are forced to do eta-conversion
289289
when combined with [|>] operator, we need to make sure beta-reduction
290-
is applied though since `[@bs.splice]` needs such guarantee.
291-
Since `[@bs.splice] is the tail position
290+
is applied though since `[@variadic]` needs such guarantee.
291+
Since `[@variadic] is the tail position
292292
*)
293293
let rec is_eta_conversion_exn
294294
params inner_args outer_args : t list =
@@ -819,7 +819,7 @@ let sequand l r = if_ l r false_
819819
(** only [handle_bs_non_obj_ffi] will be used outside *)
820820
(**
821821
[no_auto_uncurried_arg_types xs]
822-
check if the FFI have [@@bs.uncurry] attribute.
822+
check if the FFI have @uncurry attribute.
823823
if it does not we wrap it in a nomral way otherwise
824824
*)
825825
let rec no_auto_uncurried_arg_types

jscomp/core/lam_compile_external_call.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ let append_list x xs =
7878
unbox it in the first place.
7979
8080
Note when optional value is not passed, the unboxed value would be
81-
[undefined], with the combination of `[@bs.int]` it would be still be
81+
[undefined], with the combination of `[@int]` it would be still be
8282
[undefined], this by default is still correct..
8383
{[
8484
(function () {
@@ -252,7 +252,7 @@ let translate_scoped_module_val
252252
Ext_list.fold_left (Ext_list.append rest [fn]) start E.dot
253253
end
254254
| None ->
255-
(* no [@@bs.module], assume it's global *)
255+
(* no [@@module], assume it's global *)
256256
begin match scopes with
257257
| [] ->
258258
E.js_global fn
@@ -309,7 +309,7 @@ let translate_ffi
309309
| Js_new { external_module_name = module_name;
310310
name = fn;
311311
scopes
312-
} -> (* handle [@@bs.new]*)
312+
} -> (* handle [@@new]*)
313313
(* This has some side effect, it will
314314
mark its identifier (If it has) as an object,
315315
ATTENTION:
@@ -356,7 +356,7 @@ let translate_ffi
356356
begin match args with
357357
| self :: args ->
358358
(* PR2162 [self_type] more checks in syntax:
359-
- should not be [bs.as] *)
359+
- should not be [@as] *)
360360
let [@warning"-8"] ( _self_type::arg_types )
361361
= arg_types in
362362
if splice then
@@ -382,7 +382,7 @@ let translate_ffi
382382

383383
(* TODO #11
384384
1. check args -- error checking
385-
2. support [@@bs.scope "window"]
385+
2. support [@@scope "window"]
386386
we need know whether we should call [add_js_module] or not
387387
*)
388388
translate_scoped_module_val external_module_name name scopes

jscomp/core/lam_compile_external_call.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ val translate_ffi :
4545

4646
(** TODO: document supported attributes
4747
Attributes starting with `js` are reserved
48-
examples: "bs.splice"
48+
examples: "variadic"
4949
*)

jscomp/core/lam_convert.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,15 +904,15 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
904904
]}
905905
is also wrong.
906906
907-
It seems, we need handle [@bs.splice] earlier
907+
It seems, we need handle [@variadic] earlier
908908
909909
or
910910
{[
911911
(fun x y -> f x y) ([|1;2;3|]) -->
912912
let x0, x1, x2 =1,2,3 in
913913
(fun y -> f [|x0;x1;x2|] y)
914914
]}
915-
But this still need us to know [@bs.splice] in advance
915+
But this still need us to know [@variadic] in advance
916916
917917
918918
we should not remove it immediately, since we have to be careful

jscomp/core/lam_eta_conversion.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ let transform_under_supply n ap_info fn args =
119119
cautiously, since
120120
[let u = f] and we are chaning the arity of [f] it will affect
121121
the collection of [u]
122-
A typical use case is to pass an OCaml function to JS side as a callback (i.e, [@bs.uncurry])
122+
A typical use case is to pass an OCaml function to JS side as a callback (i.e, [@uncurry])
123123
*)
124124
let unsafe_adjust_to_arity loc ~(to_:int) ?(from : int option) (fn : Lam.t) : Lam.t =
125125
let ap_info : Lam.ap_info = {ap_loc = loc; ap_inlined = Default_inline; ap_status = App_na } in

jscomp/core/record_attributes_check.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type label = Types.label_description
2626

2727
let find_name (attr : Parsetree.attribute) =
2828
match attr with
29-
| {txt = "bs.as"}, PStr
29+
| {txt = "bs.as" | "as"}, PStr
3030
[{pstr_desc = Pstr_eval ({pexp_desc = Pexp_constant (Pconst_string(s,_))},_ )}] ->
3131
Some s
3232
| _ -> None
@@ -35,7 +35,7 @@ let find_name (attr : Parsetree.attribute) =
3535
let find_name_with_loc (attr : Parsetree.attribute) :
3636
string Asttypes.loc option =
3737
match attr with
38-
| {txt = "bs.as";loc}, PStr
38+
| {txt = "bs.as" | "as";loc}, PStr
3939
[{pstr_desc = Pstr_eval ({pexp_desc = Pexp_constant (Pconst_string(s,_))},_ )}] ->
4040
Some {txt = s; loc}
4141
| _ -> None
@@ -79,7 +79,7 @@ let rec check_duplicated_labels_aux
7979
| Some ({txt = s;} as l) ->
8080
if Set_string.mem coll s
8181
(*use coll to make check a bit looser
82-
allow cases like [ x : int [@bs.as "x"]]
82+
allow cases like [ x : int [@as "x"]]
8383
*) then
8484
Some l
8585
else

jscomp/ext/ext_array.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ let find_and_split arr cmp v : _ split =
207207

208208
(** TODO: available since 4.03, use {!Array.exists} *)
209209

210-
let exists p a =
210+
let exists a p =
211211
let n = Array.length a in
212212
let rec loop i =
213213
if i = n then false

jscomp/ext/ext_array.mli

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ val find_and_split :
7575
('a -> 'b -> bool) ->
7676
'b -> 'a split
7777

78-
val exists : ('a -> bool) -> 'a array -> bool
78+
val exists :
79+
'a array ->
80+
('a -> bool) ->
81+
bool
7982

8083
val is_empty : 'a array -> bool
8184

0 commit comments

Comments
 (0)