I have a branch of rust-mozjs where I attempted to implement a Rust
version of CustomAutoRooter/AutoGCRooter from SpiderMonkey:
https://github.com/jdm/rust-mozjs/commit/ff89d9609e17e7727c038c8ea8deab88bae4333e
This compiles fine, but I hit problems when I attempted to integrate it
with my previous work for a safe Rust interface to SM's typed arrays:
https://github.com/servo/servo/pull/6779
Specifically, my problems stem from this - given that creating a typed
array is fallible, as is wrapping an existing typed array reflector, we
decided to make the constructors for the typed array APIs return Result
values. Unfortunately this interacts poorly with AutoGCRooter, since it
stores pointers to Rust objects that end up moving when unwrapping the
Result
(https://github.com/jdm/rust-mozjs/commit/ff89d9609e17e7727c038c8ea8deab88bae4333e#diff-5f5de62bd671c7658b23fd6be60ce6bfR41).
Can anybody think of a useful way around this problem, or are we doomed
to non-idiomatic APIs when we're trying to directly integrate with SM's
lists of rooted values?
_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo