Skip to content

Commit 2e68cb6

Browse files
committed
@bs.get/set -> @get/set
1 parent fdb269b commit 2e68cb6

21 files changed

+38
-39
lines changed

jscomp/frontend/ast_attributes.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ let process_method_attributes_rev (attrs : t) =
3131
({get = None; set = None}, [])
3232
(fun (st, acc) (({txt; loc}, payload) as attr) ->
3333
match txt with
34-
| "bs.get" | "get" (* @bs.get{null; undefined}*) ->
34+
| "get" (* @get{null; undefined}*) ->
3535
let result =
3636
Ext_list.fold_left (Ast_payload.ident_or_record_as_config loc payload)
3737
(false, false) (fun (null, undefined) ({txt; loc}, opt_expr) ->
@@ -56,7 +56,7 @@ let process_method_attributes_rev (attrs : t) =
5656
in
5757

5858
({st with get = Some result}, acc)
59-
| "bs.set" | "set" ->
59+
| "set" ->
6060
let result =
6161
Ext_list.fold_left (Ast_payload.ident_or_record_as_config loc payload)
6262
`Get (fun _st ({txt; loc}, opt_expr) ->
@@ -330,9 +330,9 @@ let is_bs (attr : attr) =
330330

331331
let res_uapp : attr = ({txt = "res.uapp"; loc = locg}, Ast_payload.empty)
332332

333-
let bs_get : attr = ({txt = "bs.get"; loc = locg}, Ast_payload.empty)
333+
let get : attr = ({txt = "get"; loc = locg}, Ast_payload.empty)
334334

335-
let bs_get_index : attr = ({txt = "bs.get_index"; loc = locg}, Ast_payload.empty)
335+
let get_index : attr = ({txt = "get_index"; loc = locg}, Ast_payload.empty)
336336

337337
let bs_get_arity : attr =
338338
( {txt = "internal.arity"; loc = locg},
@@ -344,7 +344,7 @@ let bs_get_arity : attr =
344344
};
345345
] )
346346

347-
let bs_set : attr = ({txt = "bs.set"; loc = locg}, Ast_payload.empty)
347+
let set : attr = ({txt = "set"; loc = locg}, Ast_payload.empty)
348348

349349
let internal_expansive : attr =
350350
({txt = "internal.expansive"; loc = locg}, Ast_payload.empty)

jscomp/frontend/ast_attributes.mli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ val is_bs : attr -> bool
7272
(* Attribute for uncurried application coming from the ReScript parser *)
7373
val res_uapp : attr
7474

75-
val bs_get : attr
75+
val get : attr
7676

77-
val bs_get_index : attr
77+
val get_index : attr
7878

7979
val bs_get_arity : attr
8080

81-
val bs_set : attr
81+
val set : attr
8282

8383
val bs_return_undefined : attr
8484

jscomp/frontend/ast_derive_abstract.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ let isAbstract (xs : Ast_payload.action list) =
5555
so we can still reuse existing frame work
5656
*)
5757
let get_optional_attrs =
58-
[Ast_attributes.bs_get; Ast_attributes.bs_return_undefined]
58+
[Ast_attributes.get; Ast_attributes.bs_return_undefined]
5959

6060
let get_attrs = [Ast_attributes.bs_get_arity]
6161

62-
let set_attrs = [Ast_attributes.bs_set]
62+
let set_attrs = [Ast_attributes.set]
6363

6464
let handleTdcl light (tdcl : Parsetree.type_declaration) :
6565
Parsetree.type_declaration * Parsetree.value_description list =

jscomp/frontend/ast_derive_js_mapper.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ let unsafeIndexGet =
7575
Str.primitive
7676
(Val.mk ~prim:[""]
7777
{loc = noloc; txt = unsafeIndex}
78-
~attrs:[Ast_attributes.bs_get_index]
78+
~attrs:[Ast_attributes.get_index]
7979
(Ast_compatible.arrow any (Ast_compatible.arrow any any)))
8080

8181
let unsafeIndexGetExp = Exp.ident {loc = noloc; txt = Lident unsafeIndex}

jscomp/frontend/ast_external_process.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,19 +387,19 @@ let parse_external_attributes (no_arguments : bool) (prim_name_check : string)
387387
| "bs.splice" | "bs.variadic" | "variadic" -> {st with splice = true}
388388
| "bs.send" | "send" ->
389389
{st with val_send = Some (name_from_payload_or_prim ~loc payload)}
390-
| "bs.set" | "set" ->
390+
| "set" ->
391391
{st with set_name = Some (name_from_payload_or_prim ~loc payload)}
392-
| "bs.get" | "get" ->
392+
| "get" ->
393393
{st with get_name = Some (name_from_payload_or_prim ~loc payload)}
394394
| "bs.new" | "new" ->
395395
{st with new_name = Some (name_from_payload_or_prim ~loc payload)}
396-
| "bs.set_index" | "set_index" ->
396+
| "set_index" ->
397397
if String.length prim_name_check <> 0 then
398398
Location.raise_errorf ~loc
399399
"%@set_index this particular external's name needs to be a \
400400
placeholder empty string";
401401
{st with set_index = true}
402-
| "bs.get_index" | "get_index" ->
402+
| "get_index" ->
403403
if String.length prim_name_check <> 0 then
404404
Location.raise_errorf ~loc
405405
"%@get_index this particular external's name needs to be a \
@@ -946,9 +946,9 @@ let external_desc_of_non_obj (loc : Location.t) (st : external_desc)
946946
Js_get {js_get_name = name; js_get_scopes = scopes}
947947
else
948948
Location.raise_errorf ~loc
949-
"Ill defined attribute %@bs.get (only one argument)"
949+
"Ill defined attribute %@get (only one argument)"
950950
| {get_name = Some _; _} ->
951-
Location.raise_errorf ~loc "Attribute found that conflicts with %@bs.get"
951+
Location.raise_errorf ~loc "Attribute found that conflicts with %@get"
952952

953953
(** Note that the passed [type_annotation] is already processed by visitor pattern before*)
954954
let handle_attributes (loc : Bs_loc.t) (type_annotation : Parsetree.core_type)

jscomp/gentype/Runtime.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ let isMutableObjectField name =
2828
String.length name >= 2
2929
&& (String.sub name (String.length name - 2) 2 [@doesNotRaise]) = "#="
3030

31-
(** Mutable fields, i.e. fields annotated "[@bs.set]"
31+
(** Mutable fields, i.e. fields annotated "[@set]"
3232
are represented as extra fields called "fieldName#="
3333
preceding the normal field. *)
3434
let checkMutableObjectField ~previousName ~name = previousName = name ^ "#="

jscomp/gentype/TranslateTypeExprFromTypes.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let translateObjType closedFlag fieldsTranslations =
3030
match fields with
3131
| (previousName, {type_ = _}) :: (name, {type_}) :: rest
3232
when Runtime.checkMutableObjectField ~previousName ~name ->
33-
(* The field was annotated "@bs.set" *)
33+
(* The field was annotated "@set" *)
3434
rest |> checkMutableField ~acc:((name, type_, Mutable) :: acc)
3535
| (name, {type_}) :: rest ->
3636
rest |> checkMutableField ~acc:((name, type_, Immutable) :: acc)

jscomp/others/jsxEventC.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ module Pointer = {
230230
/* Should return Dom.eventTarget */
231231

232232
/* PointerEvent */
233-
/* external pointerId : t -> Dom.eventPointerId = "pointerId" [@@bs.get] */
233+
/* external pointerId : t -> Dom.eventPointerId = "pointerId" [@@get] */
234234
@get external width: t => float = "width"
235235
@get external height: t => float = "height"
236236
@get external pressure: t => float = "pressure"
@@ -285,7 +285,7 @@ module UI = {
285285
})
286286

287287
@get external detail: t => int = "detail"
288-
/* external view : t -> Dom.window = "view" [@@bs.get] */
288+
/* external view : t -> Dom.window = "view" [@@get] */
289289
/* Should return DOMAbstractView/WindowProxy */
290290
}
291291

jscomp/others/jsxEventU.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ module Pointer = {
232232
/* Should return Dom.eventTarget */
233233

234234
/* PointerEvent */
235-
/* external pointerId : t -> Dom.eventPointerId = "pointerId" [@@bs.get] */
235+
/* external pointerId : t -> Dom.eventPointerId = "pointerId" [@@get] */
236236
@get external width: t => float = "width"
237237
@get external height: t => float = "height"
238238
@get external pressure: t => float = "pressure"
@@ -287,7 +287,7 @@ module UI = {
287287
})
288288

289289
@get external detail: t => int = "detail"
290-
/* external view : t -> Dom.window = "view" [@@bs.get] */
290+
/* external view : t -> Dom.window = "view" [@@get] */
291291
/* Should return DOMAbstractView/WindowProxy */
292292
}
293293

jscomp/ounit_tests/ounit_cmd_tests.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ let suites =
7373
let should_err = bsc_check_eval {|
7474
external ff :
7575
resp -> (_ [@as "x"]) -> int -> unit =
76-
"x" [@@bs.set]
76+
"x" [@@set]
7777
|} in
7878
OUnit.assert_bool __LOC__
7979
(Ext_string.contain_substring should_err.stderr

jscomp/syntax/tests/idempotency/bs-webapi/src/Webapi/Webapi__Canvas/Webapi__Canvas__Canvas2d.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ external setTransform: (
120120

121121
/* in re unused warnings
122122
awaiting release of https://github.com/rescript-lang/rescript-compiler/issues/1656
123-
to just use [@@bs.set] directly with an ignored (style a) */
123+
to just use [@@set] directly with an ignored (style a) */
124124
let setStrokeStyle = (type a, ctx: t, _: style<a>, v: a) => setStrokeStyle(ctx, v)
125125

126126
let setFillStyle = (type a, ctx: t, _: style<a>, v: a) => setFillStyle(ctx, v)

jscomp/syntax/tests/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__HtmlElement.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ module Impl = (
6161
external offsetParent: t_htmlElement => option<Dom.element> = "" /* experimental */
6262
@get external offsetTop: t_htmlElement => int = "" /* experimental, but widely supported */
6363
@get external offsetWidth: t_htmlElement => int = "" /* experimental */
64-
/* external properties : r => HTMLPropertiesCollection.t = "properties" [@@bs.get]; /* experimental */ */
64+
/* external properties : r => HTMLPropertiesCollection.t = "properties" [@@get]; /* experimental */ */
6565
@get external spellcheck: t_htmlElement => bool = ""
6666
@set external setSpellcheck: (t_htmlElement, bool) => unit = "spellcheck"
6767
/* let setSpellcheck : t_htmlElement => bool => unit = fun self value => setSpellcheck self (Js.Boolean.to_js_boolean value); */ /* temproarily removed to reduce codegen size */

jscomp/syntax/tests/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Node.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ module Impl = (
2020
@set external setNodeValue: (T.t, Js.null<string>) => unit = "nodeValue"
2121
/* let setNodeValue : T.t => option string => unit = fun self value => setNodeValue self (Js.Null.fromOption value); */ /* temporarily removed to reduce codegen size */
2222
/* Not supported yet
23-
external setNodeValue : T.t => string => unit = "nodeValue" [@@bs.set];
24-
external clearNodeValue : T.t => _ [@as {json|null|json}] => unit = "nodeValue" [@@bs.set];
23+
external setNodeValue : T.t => string => unit = "nodeValue" [@@set];
24+
external clearNodeValue : T.t => _ [@as {json|null|json}] => unit = "nodeValue" [@@set];
2525
*/
2626
/* outerText */
2727
@get external ownerDocument: T.t => Dom.document = ""

jscomp/syntax/tests/idempotency/genType/src/Runtime.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ let emitJSVariantWithPayload = (~label, x) =>
105105
let isMutableObjectField = name =>
106106
String.length(name) >= 2 && String.sub(name, String.length(name) - 2, 2) == "#="
107107

108-
/* Mutable fields, i.e. fields annotated "[@bs.set]"
108+
/* Mutable fields, i.e. fields annotated "[@set]"
109109
are represented as extra fields called "fieldName#="
110110
preceding the normal field. */
111111
let checkMutableObjectField = (~previousName, ~name) => previousName == name ++ "#="

jscomp/syntax/tests/idempotency/genType/src/TranslateTypeExprFromTypes.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ let translateConstr = (
321321
switch fields {
322322
| list{(previousName, {type_: _}), (name, {type_}), ...rest}
323323
if Runtime.checkMutableObjectField(~previousName, ~name) =>
324-
/* The field was annotated "@bs.set" */
324+
/* The field was annotated "@set" */
325325
rest |> checkMutableField(~acc=list{(name, type_, Mutable), ...acc})
326326
| list{(name, {type_}), ...rest} =>
327327
rest |> checkMutableField(~acc=list{(name, type_, Immutable), ...acc})

jscomp/syntax/tests/parsing/errors/typexpr/bsObjSugar.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type state = {
3030
}
3131

3232
type state = {
33-
@bs.set "age": ,
33+
@set "age": ,
3434
"name": string
3535
}
3636

jscomp/syntax/tests/parsing/errors/typexpr/expected/bsObjSugar.res.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@
7575

7676

7777
Syntax error!
78-
tests/parsing/errors/typexpr/bsObjSugar.res:33:18
78+
tests/parsing/errors/typexpr/bsObjSugar.res:33:15
7979

8080
31 │
8181
32 │ type state = {
82-
33 │ @bs.set "age": ,
82+
33 │ @set "age": ,
8383
34 │ "name": string
8484
35 │ }
8585

@@ -143,8 +143,7 @@ type nonrec state =
143143
type nonrec state = < url: string ;protocols: [%rescript.typehole ] >
144144
type nonrec state = < send: string -> [%rescript.typehole ] [@bs.meth ] >
145145
type nonrec state = < age: [%rescript.typehole ] ;name: string >
146-
type nonrec state =
147-
< age: [%rescript.typehole ] [@bs.set ] ;name: string >
146+
type nonrec state = < age: [%rescript.typehole ] [@set ] ;name: string >
148147
type nonrec state = < age: [%rescript.typehole ] ;.. >
149148
type nonrec state = < age: [%rescript.typehole ] ;name: string ;.. >
150149
type nonrec websocket =

jscomp/test/bs_qualified.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ external makeBuffer3: int => buffer = "makeBuffer3"
3535
type t
3636
@scope("mat4") @module("gl-matrix") external create: unit => t = "create"
3737

38-
/* external scope_f : t -> int = "" [@@bs.get] [@@bs.scope "hi"] */
38+
/* external scope_f : t -> int = "" [@@get] [@@bs.scope "hi"] */
3939

4040
@get_index @scope("a0") external getMockFn1: (t, int) => string = ""
4141

jscomp/test/ffi_test.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module Textarea = {
1515
}
1616

1717
/*
18-
external never_used : Textarea.t -> int -> int = "minHeight" [@@bs.get]
18+
external never_used : Textarea.t -> int -> int = "minHeight" [@@get]
1919
2020
let v = never_used (Textarea.create ()) 3
2121
*/

jscomp/test/gpr_1484.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ type t
44
/* TODO: more test cases */
55
/* external clearNodeValue2 : */
66
/* t -> (_ [@as {json|null|json}]) -> int -> unit = */
7-
/* "nodeValue" [@@bs.set] */
7+
/* "nodeValue" [@@set] */
88

99
let test = x => clearNodeValue(x)

jscomp/test/gpr_658.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
@obj external mk: (~hi: int, unit) => {"hi": int} = ""
44

5-
/* external set_name : < > -> string -> unit = "1name" [@@bs.set] */
5+
/* external set_name : < > -> string -> unit = "1name" [@@set] */

0 commit comments

Comments
 (0)