Skip to content

Commit

Permalink
runtime(Js.Typed_array): port @mel.send externals to use @mel.this (
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro authored Jan 20, 2025
1 parent 6adf632 commit 5a88bab
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions jscomp/runtime/js_typed_array.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module ArrayBuffer = struct

external byteLength : t -> int = "byteLength" [@@mel.get]

external slice : ?start:int -> ?end_:int -> t -> Js.arrayBuffer = "slice"
external slice : ?start:int -> ?end_:int -> (t[@mel.this]) -> Js.arrayBuffer = "slice"
[@@mel.send]
end

Expand All @@ -60,39 +60,39 @@ end
external byteLength : t -> int = "byteLength" [@@mel.get]\
external byteOffset : t -> int = "byteOffset" [@@mel.get]\
\
external setArray : elt array -> unit = "set" [@@mel.send.pipe: t]\
external setArrayOffset : elt array -> int -> unit = "set" [@@mel.send.pipe: t]\
external setArray : elt array -> (t[@mel.this]) -> unit = "set" [@@mel.send]\
external setArrayOffset : elt array -> int -> (t[@mel.this]) -> unit = "set" [@@mel.send]\
(* There's also an overload for typed arrays, but don't know how to model that without subtyping *)\
\
(* Array interface(-ish) *)\
external length : t -> int = "length" [@@mel.get]\
\
(* Mutator functions *)\
external copyWithin : to_:int -> ?start:int -> ?end_:int -> t -> t = "copyWithin" [@@mel.send]\
external copyWithin : to_:int -> ?start:int -> ?end_:int -> (t[@mel.this]) -> t = "copyWithin" [@@mel.send]\
\
external fill : elt -> ?start:int -> ?end_:int -> t = "fill" [@@mel.send.pipe: t]\
external fill : elt -> ?start:int -> ?end_:int -> (t[@mel.this]) -> t = "fill" [@@mel.send]\
\
external reverseInPlace : t -> t = "reverse" [@@mel.send]\
\
external sortInPlace : t -> t = "sort" [@@mel.send]\
external sortInPlaceWith : f:(elt -> elt -> int [@mel.uncurry]) -> t -> t = "sort" [@@mel.send]\
external sortInPlaceWith : f:(elt -> elt -> int [@mel.uncurry]) -> (t[@mel.this]) -> t = "sort" [@@mel.send]\
\
(* Accessor functions *)\
external includes : value:elt -> t -> bool = "includes" [@@mel.send] (* ES2016 *)\
external includes : value:elt -> (t[@mel.this]) -> bool = "includes" [@@mel.send] (* ES2016 *)\
\
external indexOf : value:elt -> ?start:int -> t -> int = "indexOf" [@@mel.send]\
external indexOf : value:elt -> ?start:int -> (t[@mel.this]) -> int = "indexOf" [@@mel.send]\
\
external join : ?sep:string -> t -> string = "join" [@@mel.send]\
external join : ?sep:string -> (t[@mel.this]) -> string = "join" [@@mel.send]\
\
external lastIndexOf : value:elt -> t -> int = "lastIndexOf" [@@mel.send]\
external lastIndexOfFrom : value:elt -> from:int -> t -> int = "lastIndexOf" [@@mel.send]\
external lastIndexOf : value:elt -> (t[@mel.this]) -> int = "lastIndexOf" [@@mel.send]\
external lastIndexOfFrom : value:elt -> from:int -> (t[@mel.this]) -> int = "lastIndexOf" [@@mel.send]\
\
external slice : ?start:int -> ?end_:int -> t -> t = "slice" [@@mel.send]\
external slice : ?start:int -> ?end_:int -> (t[@mel.this]) -> t = "slice" [@@mel.send]\
(** [start] is inclusive, [end_] exclusive *)\
\
external copy : t -> t = "slice" [@@mel.send]\
\
external subarray : ?start:int -> ?end_:int -> t -> t = "subarray" [@@mel.send]\
external subarray : ?start:int -> ?end_:int -> (t[@mel.this]) -> t = "subarray" [@@mel.send]\
(** [start] is inclusive, [end_] exclusive *)\
\
external toString : t -> string = "toString" [@@mel.send]\
Expand All @@ -101,35 +101,35 @@ end
(* Iteration functions *)\
external entries : t -> (int * elt) Js.iterator = "entries" [@@mel.send]\
\
external every : f:(elt -> bool [@mel.uncurry]) -> t -> bool = "every" [@@mel.send]\
external everyi : f:(elt -> int -> bool [@mel.uncurry]) -> t -> bool = "every" [@@mel.send]\
external every : f:(elt -> bool [@mel.uncurry]) -> (t[@mel.this]) -> bool = "every" [@@mel.send]\
external everyi : f:(elt -> int -> bool [@mel.uncurry]) -> (t[@mel.this]) -> bool = "every" [@@mel.send]\
\
\
external filter : f:(elt -> bool [@mel.uncurry]) -> t -> t = "filter" [@@mel.send]\
external filteri : f:(elt -> int -> bool [@mel.uncurry]) -> t -> t = "filter" [@@mel.send]\
external filter : f:(elt -> bool [@mel.uncurry]) -> (t[@mel.this]) -> t = "filter" [@@mel.send]\
external filteri : f:(elt -> int -> bool [@mel.uncurry]) -> (t[@mel.this]) -> t = "filter" [@@mel.send]\
\
external find : f:(elt -> bool [@mel.uncurry]) -> t -> elt Js.undefined = "find" [@@mel.send]\
external findi : f:(elt -> int -> bool [@mel.uncurry]) -> t -> elt Js.undefined = "find" [@@mel.send]\
external find : f:(elt -> bool [@mel.uncurry]) -> (t[@mel.this]) -> elt Js.undefined = "find" [@@mel.send]\
external findi : f:(elt -> int -> bool [@mel.uncurry]) -> (t[@mel.this]) -> elt Js.undefined = "find" [@@mel.send]\
\
external findIndex : f:(elt -> bool [@mel.uncurry]) -> t -> int = "findIndex" [@@mel.send]\
external findIndexi : f:(elt -> int -> bool [@mel.uncurry]) -> t -> int = "findIndex" [@@mel.send]\
external findIndex : f:(elt -> bool [@mel.uncurry]) -> (t[@mel.this]) -> int = "findIndex" [@@mel.send]\
external findIndexi : f:(elt -> int -> bool [@mel.uncurry]) -> (t[@mel.this]) -> int = "findIndex" [@@mel.send]\
\
external forEach : f:(elt -> unit [@mel.uncurry]) -> t -> unit = "forEach" [@@mel.send]\
external forEachi : f:(elt -> int -> unit [@mel.uncurry]) -> t -> unit = "forEach" [@@mel.send]\
external forEach : f:(elt -> unit [@mel.uncurry]) -> (t[@mel.this]) -> unit = "forEach" [@@mel.send]\
external forEachi : f:(elt -> int -> unit [@mel.uncurry]) -> (t[@mel.this]) -> unit = "forEach" [@@mel.send]\
\
external keys : t -> int Js.iterator = "keys" [@@mel.send]\
\
external map : f:(elt -> 'b [@mel.uncurry]) -> t -> 'b typed_array = "map" [@@mel.send]\
external mapi : f:(elt -> int -> 'b [@mel.uncurry]) -> t -> 'b typed_array = "map" [@@mel.send]\
external map : f:(elt -> 'b [@mel.uncurry]) -> (t[@mel.this]) -> 'b typed_array = "map" [@@mel.send]\
external mapi : f:(elt -> int -> 'b [@mel.uncurry]) -> (t[@mel.this]) -> 'b typed_array = "map" [@@mel.send]\
\
external reduce : f:('b -> elt -> 'b [@mel.uncurry]) -> init:'b -> t -> 'b = "reduce" [@@mel.send]\
external reducei : f:('b -> elt -> int -> 'b [@mel.uncurry]) -> init:'b -> t -> 'b = "reduce" [@@mel.send]\
external reduce : f:('b -> elt -> 'b [@mel.uncurry]) -> init:'b -> (t[@mel.this]) -> 'b = "reduce" [@@mel.send]\
external reducei : f:('b -> elt -> int -> 'b [@mel.uncurry]) -> init:'b -> (t[@mel.this]) -> 'b = "reduce" [@@mel.send]\
\
external reduceRight : f:('b -> elt -> 'b [@mel.uncurry]) -> init:'b -> t -> 'b = "reduceRight" [@@mel.send]\
external reduceRighti : f:('b -> elt -> int -> 'b [@mel.uncurry]) -> init:'b -> t -> 'b = "reduceRight" [@@mel.send]\
external reduceRight : f:('b -> elt -> 'b [@mel.uncurry]) -> init:'b -> (t[@mel.this]) -> 'b = "reduceRight" [@@mel.send]\
external reduceRighti : f:('b -> elt -> int -> 'b [@mel.uncurry]) -> init:'b -> (t[@mel.this]) -> 'b = "reduceRight" [@@mel.send]\
\
external some : f:(elt -> bool [@mel.uncurry]) -> t -> bool = "some" [@@mel.send]\
external somei : f:(elt -> int -> bool [@mel.uncurry]) -> t -> bool = "some" [@@mel.send]\
external some : f:(elt -> bool [@mel.uncurry]) -> (t[@mel.this]) -> bool = "some" [@@mel.send]\
external somei : f:(elt -> int -> bool [@mel.uncurry]) -> (t[@mel.this]) -> bool = "some" [@@mel.send]\
\
external _BYTES_PER_ELEMENT: int = STRINGIFY(moduleName.BYTES_PER_ELEMENT) \
\
Expand Down

0 comments on commit 5a88bab

Please sign in to comment.