mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Use safe JSContext in compartments
This commit is contained in:
parent
ce3778afcc
commit
b18fa8b8a7
2 changed files with 5 additions and 4 deletions
|
@ -4,7 +4,8 @@
|
|||
|
||||
use crate::dom::bindings::reflector::DomObject;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{GetCurrentRealmOrNull, JSAutoRealm, JSContext};
|
||||
use crate::script_runtime::JSContext;
|
||||
use js::jsapi::{GetCurrentRealmOrNull, JSAutoRealm};
|
||||
|
||||
pub struct AlreadyInCompartment(());
|
||||
|
||||
|
@ -17,9 +18,9 @@ impl AlreadyInCompartment {
|
|||
AlreadyInCompartment(())
|
||||
}
|
||||
|
||||
pub fn assert_for_cx(cx: *mut JSContext) -> AlreadyInCompartment {
|
||||
pub fn assert_for_cx(cx: JSContext) -> AlreadyInCompartment {
|
||||
unsafe {
|
||||
assert!(!GetCurrentRealmOrNull(cx).is_null());
|
||||
assert!(!GetCurrentRealmOrNull(*cx).is_null());
|
||||
}
|
||||
AlreadyInCompartment(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue