Skip to content

Commit

Permalink
Stop exposing numbers as floats
Browse files Browse the repository at this point in the history
This is for compatibility with wasm_of_ocaml, in which Javascript
numbers and floats cannot be manipulated using the same functions and
require conversions.
  • Loading branch information
OlivierNicole committed Aug 29, 2024
1 parent bb12339 commit 2b4f30e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/js_of_ocaml/js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,6 @@ module Js = struct

type string_array

type number_t = float

class type number = object
method toString : js_string t meth

Expand All @@ -271,7 +269,7 @@ module Js = struct

method charAt : int -> js_string t meth

method charCodeAt : int -> number_t meth
method charCodeAt : int -> number t meth

(* This may return NaN... *)
method concat : js_string t -> js_string t meth
Expand All @@ -291,7 +289,7 @@ module Js = struct

method lastIndexOf_from : js_string t -> int -> int meth

method localeCompare : js_string t -> number_t meth
method localeCompare : js_string t -> number t meth

method _match : regExp t -> match_result_handle t opt meth

Expand Down Expand Up @@ -354,6 +352,8 @@ module Js = struct

and normalization = js_string

type number_t = number t

(* string is used by ppx_js, it needs to come before any use of the
new syntax in this file *)
external string : string -> js_string t = "caml_jsstring_of_string"
Expand Down
8 changes: 4 additions & 4 deletions lib/js_of_ocaml/js.mli
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@ val nfkc : normalization t

(** Specification of Javascript number objects. *)

type number_t = float

class type number = object
method toString : js_string t meth

Expand All @@ -245,7 +243,7 @@ and js_string = object

method charAt : int -> js_string t meth

method charCodeAt : int -> number_t meth
method charCodeAt : int -> number t meth

(* This may return NaN... *)
method concat : js_string t -> js_string t meth
Expand All @@ -265,7 +263,7 @@ and js_string = object

method lastIndexOf_from : js_string t -> int -> int meth

method localeCompare : js_string t -> number_t meth
method localeCompare : js_string t -> number t meth

method _match : regExp t -> match_result_handle t opt meth

Expand Down Expand Up @@ -328,6 +326,8 @@ and regExp = object
method lastIndex : int prop
end

type number_t = number t

(** Specification of the string constructor, considered as an object. *)
class type string_constr = object
method fromCharCode : int -> js_string t meth
Expand Down

0 comments on commit 2b4f30e

Please sign in to comment.