Bug 1466128 part 2 - Rename AutoCompartment to AutoRealm. r=jdm
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 14 Aug 2018 14:25:48 +0200
changeset 487911 9cf35b96d52478037f6b0da91a6df7f8476b736e
parent 487910 d814396399b3dc90603e72b01d4c610228ec299e
child 487912 4c42ea4583b250aa78c491f30716a99d0629ebde
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
bugs1466128
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1466128 part 2 - Rename AutoCompartment to AutoRealm. r=jdm Differential Revision: https://phabricator.services.mozilla.com/D3325
js/rust/src/ar.rs
js/rust/src/rust.rs
js/rust/tests/callback.rs
js/rust/tests/panic.rs
js/rust/tests/rooting.rs
js/rust/tests/runtime.rs
js/rust/tests/typedarray.rs
js/rust/tests/vec_conversion.rs
--- a/js/rust/src/ar.rs
+++ b/js/rust/src/ar.rs
@@ -1,56 +1,56 @@
 use jsapi::root::*;
 #[cfg(feature = "debugmozjs")]
 use std::ptr;
 
 #[derive(Debug)]
-pub struct AutoCompartment(JSAutoRealmAllowCCW);
+pub struct AutoRealm(JSAutoRealmAllowCCW);
 
-impl AutoCompartment {
+impl AutoRealm {
     #[cfg(feature = "debugmozjs")]
     pub unsafe fn with_obj(cx: *mut JSContext,
                            target: *mut JSObject)
-                           -> AutoCompartment
+                           -> AutoRealm
     {
         let mut notifier = mozilla::detail::GuardObjectNotifier {
             mStatementDone: ptr::null_mut(),
         };
 
-        AutoCompartment(
+        AutoRealm(
             JSAutoRealmAllowCCW::new(
                 cx,
                 target,
                 &mut notifier as *mut _))
     }
 
     #[cfg(not(feature = "debugmozjs"))]
     pub unsafe fn with_obj(cx: *mut JSContext,
                            target: *mut JSObject)
-                           -> AutoCompartment
+                           -> AutoRealm
     {
-        AutoCompartment(JSAutoRealmAllowCCW::new(cx, target))
+        AutoRealm(JSAutoRealmAllowCCW::new(cx, target))
     }
 
     #[cfg(feature = "debugmozjs")]
     pub unsafe fn with_script(cx: *mut JSContext,
                               target: *mut JSScript)
-                              -> AutoCompartment
+                              -> AutoRealm
     {
         let mut notifier = mozilla::detail::GuardObjectNotifier {
             mStatementDone: ptr::null_mut(),
         };
 
-        AutoCompartment(
+        AutoRealm(
             JSAutoRealmAllowCCW::new1(
                 cx,
                 target,
                 &mut notifier as *mut _))
     }
 
     #[cfg(not(feature = "debugmozjs"))]
     pub unsafe fn with_script(cx: *mut JSContext,
                               target: *mut JSScript)
-                              -> AutoCompartment
+                              -> AutoRealm
     {
-        AutoCompartment(JSAutoRealmAllowCCW::new1(cx, target))
+        AutoRealm(JSAutoRealmAllowCCW::new1(cx, target))
     }
 }
--- a/js/rust/src/rust.rs
+++ b/js/rust/src/rust.rs
@@ -1,15 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 //! Rust wrappers around the raw JS apis
 
-use ar::AutoCompartment;
+use ar::AutoRealm;
 use libc::c_uint;
 use std::cell::{Cell, UnsafeCell};
 use std::char;
 use std::ffi;
 use std::ptr;
 use std::slice;
 use std::mem;
 use std::u32;
@@ -226,17 +226,17 @@ impl Runtime {
         let (ptr, len) = if script_utf16.len() == 0 {
             static empty: &'static [u16] = &[];
             (empty.as_ptr(), 0)
         } else {
             (script_utf16.as_ptr(), script_utf16.len() as c_uint)
         };
         assert!(!ptr.is_null());
         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 mut srcBuf = JS::SourceBufferHolder {
                 data_: ptr,
                 length_: len as _,
                 ownsChars_: false
             };
             if !JS::Evaluate(self.cx(), options.ptr, &mut srcBuf, rval) {
--- a/js/rust/tests/callback.rs
+++ b/js/rust/tests/callback.rs
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #[macro_use]
 extern crate js;
 extern crate libc;
 
-use js::ar::AutoCompartment;
+use js::ar::AutoRealm;
 use js::jsapi::root::JS::CallArgs;
 use js::jsapi::root::JS::RealmOptions;
 use js::jsapi::root::JSContext;
 use js::jsapi::root::JS_DefineFunction;
 use js::jsapi::root::JS_EncodeStringToUTF8;
 use js::jsapi::root::JS_NewGlobalObject;
 use js::jsapi::root::JS_ReportErrorASCII;
 use js::jsapi::root::JS::OnNewGlobalHookOption;
@@ -29,17 +29,17 @@ fn callback() {
     let context = runtime.cx();
     let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook;
     let c_option = RealmOptions::default();
 
     unsafe {
         let global = JS_NewGlobalObject(context, &SIMPLE_GLOBAL_CLASS, ptr::null_mut(), h_option, &c_option);
         rooted!(in(context) let global_root = global);
         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,
                                          Some(puts), 1, 0);
         assert!(!function.is_null());
         let javascript = "puts('Test Iñtërnâtiônàlizætiøn ┬─┬ノ( º _ ºノ) ');";
         rooted!(in(context) let mut rval = UndefinedValue());
         let _ = runtime.evaluate_script(global, javascript, "test.js", 0, rval.handle_mut());
     }
 }
--- a/js/rust/tests/panic.rs
+++ b/js/rust/tests/panic.rs
@@ -20,17 +20,17 @@ fn panic() {
     let h_option = JS::OnNewGlobalHookOption::FireOnNewGlobalHook;
     let c_option = JS::RealmOptions::default();
 
     unsafe {
         let global = JS_NewGlobalObject(context, &SIMPLE_GLOBAL_CLASS,
                                         ptr::null_mut(), h_option, &c_option);
         rooted!(in(context) let global_root = global);
         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,
                                          b"test\0".as_ptr() as *const _,
                                          Some(test), 0, 0);
         assert!(!function.is_null());
         rooted!(in(context) let mut rval = UndefinedValue());
         let _ = runtime.evaluate_script(global, "test();", "test.js", 0,
                                         rval.handle_mut());
     }
--- a/js/rust/tests/rooting.rs
+++ b/js/rust/tests/rooting.rs
@@ -24,17 +24,17 @@ fn rooting() {
         let h_option = JS::OnNewGlobalHookOption::FireOnNewGlobalHook;
         let c_option = JS::RealmOptions::default();
 
         rooted!(in(cx) let global = JS_NewGlobalObject(cx,
                                                        &SIMPLE_GLOBAL_CLASS,
                                                        ptr::null_mut(),
                                                        h_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 proto = JS_NewObjectWithUniqueType(cx,
                                                               &CLASS as *const _,
                                                               prototype_proto.handle()));
         define_methods(cx, proto.handle(), &METHODS[..]).unwrap();
     }
 }
 
--- a/js/rust/tests/runtime.rs
+++ b/js/rust/tests/runtime.rs
@@ -19,17 +19,17 @@ fn runtime() {
         let h_option = JS::OnNewGlobalHookOption::FireOnNewGlobalHook;
         let c_option = JS::RealmOptions::default();
 
         rooted!(in(cx) let global = JS_NewGlobalObject(cx,
                                                        &SIMPLE_GLOBAL_CLASS,
                                                        ptr::null_mut(),
                                                        h_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 _));
     }
 
     assert!(Runtime::new(false).is_err());
 }
 
 unsafe extern fn finalize(_fop: *mut JSFreeOp, _object: *mut JSObject) {
     assert!(!Runtime::get().is_null());
--- a/js/rust/tests/typedarray.rs
+++ b/js/rust/tests/typedarray.rs
@@ -19,17 +19,17 @@ fn typedarray() {
 
     unsafe {
         rooted!(in(cx) let global =
             JS_NewGlobalObject(cx, &SIMPLE_GLOBAL_CLASS, ptr::null_mut(),
                                JS::OnNewGlobalHookOption::FireOnNewGlobalHook,
                                &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());
         assert!(rt.evaluate_script(global.handle(), "new Uint8Array([0, 2, 4])",
                                    "test", 1, rval.handle_mut()).is_ok());
         assert!(rval.is_object());
 
         typedarray!(in(cx) let array: Uint8Array = rval.to_object());
         assert_eq!(array.unwrap().as_slice(), &[0, 2, 4][..]);
@@ -77,15 +77,15 @@ fn typedarray_update_panic() {
 
     unsafe {
         rooted!(in(cx) let global =
             JS_NewGlobalObject(cx, &SIMPLE_GLOBAL_CLASS, ptr::null_mut(),
                                JS::OnNewGlobalHookOption::FireOnNewGlobalHook,
                                &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());
         let _ = Uint32Array::create(cx, CreateWith::Slice(&[1, 2, 3, 4, 5]), rval.handle_mut());
         typedarray!(in(cx) let mut array: Uint32Array = rval.get());
         array.as_mut().unwrap().update(&[0, 2, 4, 6, 8, 10]);
     }
 }
--- a/js/rust/tests/vec_conversion.rs
+++ b/js/rust/tests/vec_conversion.rs
@@ -1,16 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #[macro_use]
 extern crate js;
 
-use js::ar::AutoCompartment;
+use js::ar::AutoRealm;
 use js::conversions::ConversionBehavior;
 use js::conversions::ConversionResult;
 use js::conversions::FromJSValConvertible;
 use js::conversions::ToJSValConvertible;
 use js::jsapi::root::JS::RealmOptions;
 use js::jsapi::root::JS::InitRealmStandardClasses;
 use js::jsapi::root::JS_NewGlobalObject;
 use js::jsapi::root::JS::OnNewGlobalHookOption;
@@ -37,17 +37,17 @@ fn vec_conversion() {
     let c_option = RealmOptions::default();
 
     unsafe {
         let global = JS_NewGlobalObject(cx, &SIMPLE_GLOBAL_CLASS,
                                         ptr::null_mut(), h_option, &c_option);
         rooted!(in(cx) let global_root = global);
         let global = global_root.handle();
 
-        let _ac = AutoCompartment::with_obj(cx, global.get());
+        let _ar = AutoRealm::with_obj(cx, global.get());
         assert!(InitRealmStandardClasses(cx));
 
         rooted!(in(cx) let mut rval = UndefinedValue());
 
         let orig_vec: Vec<f32> = vec![1.0, 2.9, 3.0];
         orig_vec.to_jsval(cx, rval.handle_mut());
         assert_is_array(cx, rval.handle());
         let converted = Vec::<f32>::from_jsval(cx, rval.handle(), ()).unwrap();