Skip to content

Commit

Permalink
Fix int32 values returned from bigarrays when wrapping Uint32Array ob…
Browse files Browse the repository at this point in the history
…jects.
  • Loading branch information
dbuenzli authored and hhugo committed Jun 20, 2023
1 parent da3ebfb commit cc19edd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
## Features/Changes
* Misc: Bump magic number for ocaml 5.1
* Misc: changes to stay compatible with the next version of ppx_expect
* Runtime: support conversion of Uint8ClampedArray typed arrays to bigarrays.

* Runtime: support conversion of Uint8ClampedArray typed arrays to bigarrays (#1472)

## Bug fixes
* Compiler: fix location for parsing errors when last token is a virtual semicolon
Expand All @@ -12,6 +11,7 @@
* Compiler: consise body should allow any expression but object literals
* Compiler: preserve [new] without arguments [new C] (vs [new C()]
* Compiler: remove invalid rewriting of js (#1471, #1469)
* Runtime: fix int32 values returned from bigarrays when wrapping Uint32Array objects (#1472)

# 5.2.0 (2023-04-28) - Lille
## Features/Changes
Expand Down
5 changes: 5 additions & 0 deletions runtime/bigarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,5 +895,10 @@ function caml_ba_kind_of_typed_array(ta){
//Requires: caml_ba_create_unsafe
function caml_ba_from_typed_array(ta){
var kind = caml_ba_kind_of_typed_array(ta);
var ta =
/* Needed to avoid unsigned setters overflowing
the range of OCaml [int32] values. */
ta instanceof Uint32Array ?
new Int32Array(ta.buffer ,ta.byteOffset, ta.length) : ta;
return caml_ba_create_unsafe(kind, 0, [ta.length], ta);
}

0 comments on commit cc19edd

Please sign in to comment.