forked from mirrors/gecko-dev
Bug 1466128 part 2 - Rename AutoCompartment to AutoRealm. r=jdm
Differential Revision: https://phabricator.services.mozilla.com/D3325 --HG-- extra : rebase_source : 961707f473d4c6664736f5f2e266be949a9ac700 extra : source : a4262ccfec7a662f672138f856cd7779ebd8e824
This commit is contained in:
parent
e25a7d3dd1
commit
7a68d5cb68
8 changed files with 21 additions and 21 deletions
|
|
@ -3,19 +3,19 @@ use jsapi::root::*;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AutoCompartment(JSAutoRealmAllowCCW);
|
pub struct AutoRealm(JSAutoRealmAllowCCW);
|
||||||
|
|
||||||
impl AutoCompartment {
|
impl AutoRealm {
|
||||||
#[cfg(feature = "debugmozjs")]
|
#[cfg(feature = "debugmozjs")]
|
||||||
pub unsafe fn with_obj(cx: *mut JSContext,
|
pub unsafe fn with_obj(cx: *mut JSContext,
|
||||||
target: *mut JSObject)
|
target: *mut JSObject)
|
||||||
-> AutoCompartment
|
-> AutoRealm
|
||||||
{
|
{
|
||||||
let mut notifier = mozilla::detail::GuardObjectNotifier {
|
let mut notifier = mozilla::detail::GuardObjectNotifier {
|
||||||
mStatementDone: ptr::null_mut(),
|
mStatementDone: ptr::null_mut(),
|
||||||
};
|
};
|
||||||
|
|
||||||
AutoCompartment(
|
AutoRealm(
|
||||||
JSAutoRealmAllowCCW::new(
|
JSAutoRealmAllowCCW::new(
|
||||||
cx,
|
cx,
|
||||||
target,
|
target,
|
||||||
|
|
@ -25,21 +25,21 @@ impl AutoCompartment {
|
||||||
#[cfg(not(feature = "debugmozjs"))]
|
#[cfg(not(feature = "debugmozjs"))]
|
||||||
pub unsafe fn with_obj(cx: *mut JSContext,
|
pub unsafe fn with_obj(cx: *mut JSContext,
|
||||||
target: *mut JSObject)
|
target: *mut JSObject)
|
||||||
-> AutoCompartment
|
-> AutoRealm
|
||||||
{
|
{
|
||||||
AutoCompartment(JSAutoRealmAllowCCW::new(cx, target))
|
AutoRealm(JSAutoRealmAllowCCW::new(cx, target))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "debugmozjs")]
|
#[cfg(feature = "debugmozjs")]
|
||||||
pub unsafe fn with_script(cx: *mut JSContext,
|
pub unsafe fn with_script(cx: *mut JSContext,
|
||||||
target: *mut JSScript)
|
target: *mut JSScript)
|
||||||
-> AutoCompartment
|
-> AutoRealm
|
||||||
{
|
{
|
||||||
let mut notifier = mozilla::detail::GuardObjectNotifier {
|
let mut notifier = mozilla::detail::GuardObjectNotifier {
|
||||||
mStatementDone: ptr::null_mut(),
|
mStatementDone: ptr::null_mut(),
|
||||||
};
|
};
|
||||||
|
|
||||||
AutoCompartment(
|
AutoRealm(
|
||||||
JSAutoRealmAllowCCW::new1(
|
JSAutoRealmAllowCCW::new1(
|
||||||
cx,
|
cx,
|
||||||
target,
|
target,
|
||||||
|
|
@ -49,8 +49,8 @@ impl AutoCompartment {
|
||||||
#[cfg(not(feature = "debugmozjs"))]
|
#[cfg(not(feature = "debugmozjs"))]
|
||||||
pub unsafe fn with_script(cx: *mut JSContext,
|
pub unsafe fn with_script(cx: *mut JSContext,
|
||||||
target: *mut JSScript)
|
target: *mut JSScript)
|
||||||
-> AutoCompartment
|
-> AutoRealm
|
||||||
{
|
{
|
||||||
AutoCompartment(JSAutoRealmAllowCCW::new1(cx, target))
|
AutoRealm(JSAutoRealmAllowCCW::new1(cx, target))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
//! Rust wrappers around the raw JS apis
|
//! Rust wrappers around the raw JS apis
|
||||||
|
|
||||||
use ar::AutoCompartment;
|
use ar::AutoRealm;
|
||||||
use libc::c_uint;
|
use libc::c_uint;
|
||||||
use std::cell::{Cell, UnsafeCell};
|
use std::cell::{Cell, UnsafeCell};
|
||||||
use std::char;
|
use std::char;
|
||||||
|
|
@ -231,7 +231,7 @@ impl Runtime {
|
||||||
};
|
};
|
||||||
assert!(!ptr.is_null());
|
assert!(!ptr.is_null());
|
||||||
unsafe {
|
unsafe {
|
||||||
let _ac = AutoCompartment::with_obj(self.cx(), glob.get());
|
let _ar = AutoRealm::with_obj(self.cx(), glob.get());
|
||||||
let options = CompileOptionsWrapper::new(self.cx(), filename_cstr.as_ptr(), line_num);
|
let options = CompileOptionsWrapper::new(self.cx(), filename_cstr.as_ptr(), line_num);
|
||||||
|
|
||||||
let mut srcBuf = JS::SourceBufferHolder {
|
let mut srcBuf = JS::SourceBufferHolder {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
extern crate js;
|
extern crate js;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
use js::ar::AutoCompartment;
|
use js::ar::AutoRealm;
|
||||||
use js::jsapi::root::JS::CallArgs;
|
use js::jsapi::root::JS::CallArgs;
|
||||||
use js::jsapi::root::JS::RealmOptions;
|
use js::jsapi::root::JS::RealmOptions;
|
||||||
use js::jsapi::root::JSContext;
|
use js::jsapi::root::JSContext;
|
||||||
|
|
@ -34,7 +34,7 @@ fn callback() {
|
||||||
let global = JS_NewGlobalObject(context, &SIMPLE_GLOBAL_CLASS, ptr::null_mut(), h_option, &c_option);
|
let global = JS_NewGlobalObject(context, &SIMPLE_GLOBAL_CLASS, ptr::null_mut(), h_option, &c_option);
|
||||||
rooted!(in(context) let global_root = global);
|
rooted!(in(context) let global_root = global);
|
||||||
let global = global_root.handle();
|
let global = global_root.handle();
|
||||||
let _ac = AutoCompartment::with_obj(context, global.get());
|
let _ar = AutoRealm::with_obj(context, global.get());
|
||||||
let function = JS_DefineFunction(context, global, b"puts\0".as_ptr() as *const libc::c_char,
|
let function = JS_DefineFunction(context, global, b"puts\0".as_ptr() as *const libc::c_char,
|
||||||
Some(puts), 1, 0);
|
Some(puts), 1, 0);
|
||||||
assert!(!function.is_null());
|
assert!(!function.is_null());
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ fn panic() {
|
||||||
ptr::null_mut(), h_option, &c_option);
|
ptr::null_mut(), h_option, &c_option);
|
||||||
rooted!(in(context) let global_root = global);
|
rooted!(in(context) let global_root = global);
|
||||||
let global = global_root.handle();
|
let global = global_root.handle();
|
||||||
let _ac = js::ar::AutoCompartment::with_obj(context, global.get());
|
let _ar = js::ar::AutoRealm::with_obj(context, global.get());
|
||||||
let function = JS_DefineFunction(context, global,
|
let function = JS_DefineFunction(context, global,
|
||||||
b"test\0".as_ptr() as *const _,
|
b"test\0".as_ptr() as *const _,
|
||||||
Some(test), 0, 0);
|
Some(test), 0, 0);
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ fn rooting() {
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
h_option,
|
h_option,
|
||||||
&c_option));
|
&c_option));
|
||||||
let _ac = js::ar::AutoCompartment::with_obj(cx, global.get());
|
let _ar = js::ar::AutoRealm::with_obj(cx, global.get());
|
||||||
rooted!(in(cx) let prototype_proto = JS::GetRealmObjectPrototype(cx));
|
rooted!(in(cx) let prototype_proto = JS::GetRealmObjectPrototype(cx));
|
||||||
rooted!(in(cx) let proto = JS_NewObjectWithUniqueType(cx,
|
rooted!(in(cx) let proto = JS_NewObjectWithUniqueType(cx,
|
||||||
&CLASS as *const _,
|
&CLASS as *const _,
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ fn runtime() {
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
h_option,
|
h_option,
|
||||||
&c_option));
|
&c_option));
|
||||||
let _ac = js::ar::AutoCompartment::with_obj(cx, global.get());
|
let _ar = js::ar::AutoRealm::with_obj(cx, global.get());
|
||||||
rooted!(in(cx) let _object = JS_NewObject(cx, &CLASS as *const _));
|
rooted!(in(cx) let _object = JS_NewObject(cx, &CLASS as *const _));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ fn typedarray() {
|
||||||
&JS::RealmOptions::default())
|
&JS::RealmOptions::default())
|
||||||
);
|
);
|
||||||
|
|
||||||
let _ac = js::ar::AutoCompartment::with_obj(cx, global.get());
|
let _ar = js::ar::AutoRealm::with_obj(cx, global.get());
|
||||||
|
|
||||||
rooted!(in(cx) let mut rval = UndefinedValue());
|
rooted!(in(cx) let mut rval = UndefinedValue());
|
||||||
assert!(rt.evaluate_script(global.handle(), "new Uint8Array([0, 2, 4])",
|
assert!(rt.evaluate_script(global.handle(), "new Uint8Array([0, 2, 4])",
|
||||||
|
|
@ -82,7 +82,7 @@ fn typedarray_update_panic() {
|
||||||
&JS::RealmOptions::default())
|
&JS::RealmOptions::default())
|
||||||
);
|
);
|
||||||
|
|
||||||
let _ac = js::ar::AutoCompartment::with_obj(cx, global.get());
|
let _ar = js::ar::AutoRealm::with_obj(cx, global.get());
|
||||||
rooted!(in(cx) let mut rval = ptr::null_mut());
|
rooted!(in(cx) let mut rval = ptr::null_mut());
|
||||||
let _ = Uint32Array::create(cx, CreateWith::Slice(&[1, 2, 3, 4, 5]), rval.handle_mut());
|
let _ = Uint32Array::create(cx, CreateWith::Slice(&[1, 2, 3, 4, 5]), rval.handle_mut());
|
||||||
typedarray!(in(cx) let mut array: Uint32Array = rval.get());
|
typedarray!(in(cx) let mut array: Uint32Array = rval.get());
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate js;
|
extern crate js;
|
||||||
|
|
||||||
use js::ar::AutoCompartment;
|
use js::ar::AutoRealm;
|
||||||
use js::conversions::ConversionBehavior;
|
use js::conversions::ConversionBehavior;
|
||||||
use js::conversions::ConversionResult;
|
use js::conversions::ConversionResult;
|
||||||
use js::conversions::FromJSValConvertible;
|
use js::conversions::FromJSValConvertible;
|
||||||
|
|
@ -42,7 +42,7 @@ fn vec_conversion() {
|
||||||
rooted!(in(cx) let global_root = global);
|
rooted!(in(cx) let global_root = global);
|
||||||
let global = global_root.handle();
|
let global = global_root.handle();
|
||||||
|
|
||||||
let _ac = AutoCompartment::with_obj(cx, global.get());
|
let _ar = AutoRealm::with_obj(cx, global.get());
|
||||||
assert!(InitRealmStandardClasses(cx));
|
assert!(InitRealmStandardClasses(cx));
|
||||||
|
|
||||||
rooted!(in(cx) let mut rval = UndefinedValue());
|
rooted!(in(cx) let mut rval = UndefinedValue());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue