servo / rust-mozjs

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

Extract InCompartment API helper from Servo #491

Open jdm opened 4 years ago

jdm commented 4 years ago

https://github.com/servo/servo/blob/da559d47b93854e4c7d4acf0a0d2029a9e643794/components/script/compartments.rs

We should bring the AlreadyInCompartment and InCompartment types into this crate (renaming them to AlreadyInRealm and InRealm in the process), and make the assert method take a *mut JSObject object instead. This will allow us to add a InCompartment argument to ToJSValConvertible, avoiding a source of crashes.

jdm commented 4 years ago

We could also add it to the typed array construction API in https://github.com/servo/rust-mozjs/blob/9b0d063ba062f4cc60c3bab9250218d6935d647b/src/typedarray.rs#L268.