servo / rust-mozjs

DEPRECATED - moved to servo/mozjs instead.
Mozilla Public License 2.0
293 stars 122 forks source link

typedarray: Use a Cell for handling interior mutability. #408

Closed emilio closed 6 years ago

emilio commented 6 years ago

The typed array wrapper has a "computed" option that uses to cache its data.

That means that you need a mutable reference to the typed array in order to read it, which is not great.

In particular, it's plain impossible when the typed array is provided as a member of a struct via WebIDL.

Use a Cell and expose to_vec and as_slice in non-mutable references.


This change is Reviewable

emilio commented 6 years ago

r? @jdm

jdm commented 6 years ago

@bors-servo r+

bors-servo commented 6 years ago

:pushpin: Commit fbef376 has been approved by jdm

bors-servo commented 6 years ago

:hourglass: Testing commit fbef3765199e95e68b92094a20e458ad34d8f479 with merge 8736791cf46cdf07b0c85356b7a66ddde694e4bd...

bors-servo commented 6 years ago

:sunny: Test successful - status-appveyor, status-travis Approved by: jdm Pushing 8736791cf46cdf07b0c85356b7a66ddde694e4bd to master...