diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-01-01 12:20:31 +0100 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-01-01 20:36:43 +0100 |
commit | 1290c1879415c80b374bc3ff6378aec899850048 (patch) | |
tree | 0d89e9085b96ddf1b44d737d7207f33a98a29918 | |
parent | 95ec20bd976c5fe7b9c56e150cf7e909b27fe624 (diff) | |
download | servo-1290c1879415c80b374bc3ff6378aec899850048.tar.gz servo-1290c1879415c80b374bc3ff6378aec899850048.zip |
Remove the 'b lifetime from Root.
It does not add any safety, as the reference is constructed from a raw pointer
without limiting the lifetime in any way.
-rw-r--r-- | components/script/dom/bindings/codegen/Configuration.py | 2 | ||||
-rw-r--r-- | components/script/dom/bindings/conversions.rs | 2 | ||||
-rw-r--r-- | components/script/dom/bindings/global.rs | 8 | ||||
-rw-r--r-- | components/script/dom/bindings/js.rs | 42 |
4 files changed, 27 insertions, 27 deletions
diff --git a/components/script/dom/bindings/codegen/Configuration.py b/components/script/dom/bindings/codegen/Configuration.py index 6ebe6467e52..ac103c86378 100644 --- a/components/script/dom/bindings/codegen/Configuration.py +++ b/components/script/dom/bindings/codegen/Configuration.py @@ -156,7 +156,7 @@ class Descriptor(DescriptorProvider): self.needsRooting = True self.returnType = "Temporary<%s>" % ifaceName self.argumentType = "JSRef<%s>" % ifaceName - self.memberType = "Root<'b, %s>" % ifaceName + self.memberType = "Root<%s>" % ifaceName self.nativeType = "JS<%s>" % ifaceName self.concreteType = ifaceName diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs index 2931e7d700d..068f4287206 100644 --- a/components/script/dom/bindings/conversions.rs +++ b/components/script/dom/bindings/conversions.rs @@ -471,7 +471,7 @@ impl<T: Reflectable+IDLInterface> FromJSValConvertible<()> for JS<T> { } } -impl<'b, T: Reflectable> ToJSValConvertible for Root<'b, T> { +impl<T: Reflectable> ToJSValConvertible for Root<T> { fn to_jsval(&self, cx: *mut JSContext) -> JSVal { self.reflector().to_jsval(cx) } diff --git a/components/script/dom/bindings/global.rs b/components/script/dom/bindings/global.rs index 259d3f6b2b3..3640aabb88d 100644 --- a/components/script/dom/bindings/global.rs +++ b/components/script/dom/bindings/global.rs @@ -32,9 +32,9 @@ pub enum GlobalRef<'a> { } /// A stack-based rooted reference to a global object. -pub enum GlobalRoot<'b> { - Window(Root<'b, window::Window>), - Worker(Root<'b, WorkerGlobalScope>), +pub enum GlobalRoot { + Window(Root<window::Window>), + Worker(Root<WorkerGlobalScope>), } /// A traced reference to a global object, for use in fields of traced Rust @@ -98,7 +98,7 @@ impl<'a> Reflectable for GlobalRef<'a> { } } -impl<'b> GlobalRoot<'b> { +impl GlobalRoot { /// Obtain a safe reference to the global object that cannot outlive the /// lifetime of this root. pub fn root_ref<'c>(&'c self) -> GlobalRef<'c> { diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index 20029a45d9e..42ba52b6d34 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -91,7 +91,7 @@ impl<T: Reflectable> Temporary<T> { } /// Create a stack-bounded root for this value. - pub fn root<'b>(self) -> Root<'b, T> { + pub fn root(self) -> Root<T> { let collection = StackRoots.get().unwrap(); unsafe { Root::new(&**collection, &self.inner) @@ -150,7 +150,7 @@ impl<T: Reflectable> JS<T> { /// Root this JS-owned value to prevent its collection as garbage. - pub fn root<'b>(&self) -> Root<'b, T> { + pub fn root(&self) -> Root<T> { let collection = StackRoots.get().unwrap(); unsafe { Root::new(&**collection, self) @@ -310,7 +310,7 @@ pub trait RootedReference<T> { fn root_ref<'a>(&'a self) -> Option<JSRef<'a, T>>; } -impl<'b, T: Reflectable> RootedReference<T> for Option<Root<'b, T>> { +impl<T: Reflectable> RootedReference<T> for Option<Root<T>> { fn root_ref<'a>(&'a self) -> Option<JSRef<'a, T>> { self.as_ref().map(|root| root.root_ref()) } @@ -321,7 +321,7 @@ pub trait OptionalRootedReference<T> { fn root_ref<'a>(&'a self) -> Option<Option<JSRef<'a, T>>>; } -impl<'b, T: Reflectable> OptionalRootedReference<T> for Option<Option<Root<'b, T>>> { +impl<T: Reflectable> OptionalRootedReference<T> for Option<Option<Root<T>>> { fn root_ref<'a>(&'a self) -> Option<Option<JSRef<'a, T>>> { self.as_ref().map(|inner| inner.root_ref()) } @@ -367,11 +367,11 @@ impl<T: Assignable<U>, U: Reflectable> OptionalSettable<T> for Cell<Option<JS<U> /// Root a rootable `Option` type (used for `Option<Temporary<T>>`) pub trait OptionalRootable<T> { - fn root<'b>(self) -> Option<Root<'b, T>>; + fn root(self) -> Option<Root<T>>; } impl<T: Reflectable> OptionalRootable<T> for Option<Temporary<T>> { - fn root<'b>(self) -> Option<Root<'b, T>> { + fn root(self) -> Option<Root<T>> { self.map(|inner| inner.root()) } } @@ -389,22 +389,22 @@ impl<'a, T: Reflectable> OptionalUnrootable<T> for Option<JSRef<'a, T>> { /// Root a rootable `Option` type (used for `Option<JS<T>>`) pub trait OptionalRootedRootable<T> { - fn root<'b>(&self) -> Option<Root<'b, T>>; + fn root(&self) -> Option<Root<T>>; } impl<T: Reflectable> OptionalRootedRootable<T> for Option<JS<T>> { - fn root<'b>(&self) -> Option<Root<'b, T>> { + fn root(&self) -> Option<Root<T>> { self.as_ref().map(|inner| inner.root()) } } /// Root a rootable `Option<Option>` type (used for `Option<Option<JS<T>>>`) pub trait OptionalOptionalRootedRootable<T> { - fn root<'b>(&self) -> Option<Option<Root<'b, T>>>; + fn root(&self) -> Option<Option<Root<T>>>; } impl<T: Reflectable> OptionalOptionalRootedRootable<T> for Option<Option<JS<T>>> { - fn root<'b>(&self) -> Option<Option<Root<'b, T>>> { + fn root(&self) -> Option<Option<Root<T>>> { self.as_ref().map(|inner| inner.root()) } } @@ -412,17 +412,17 @@ impl<T: Reflectable> OptionalOptionalRootedRootable<T> for Option<Option<JS<T>>> /// Root a rootable `Result` type (any of `Temporary<T>` or `JS<T>`) pub trait ResultRootable<T,U> { - fn root<'b>(self) -> Result<Root<'b, T>, U>; + fn root(self) -> Result<Root<T>, U>; } impl<T: Reflectable, U> ResultRootable<T, U> for Result<Temporary<T>, U> { - fn root<'b>(self) -> Result<Root<'b, T>, U> { + fn root(self) -> Result<Root<T>, U> { self.map(|inner| inner.root()) } } impl<T: Reflectable, U> ResultRootable<T, U> for Result<JS<T>, U> { - fn root<'b>(self) -> Result<Root<'b, T>, U> { + fn root(self) -> Result<Root<T>, U> { self.map(|inner| inner.root()) } } @@ -459,7 +459,7 @@ impl RootCollection { } /// Track a stack-based root to ensure LIFO root ordering - fn root<'b, T: Reflectable>(&self, untracked: &Root<'b, T>) { + fn root<'b, T: Reflectable>(&self, untracked: &Root<T>) { unsafe { let roots = self.roots.get(); (*roots).push(untracked.js_ptr); @@ -468,7 +468,7 @@ impl RootCollection { } /// Stop tracking a stack-based root, asserting if LIFO root ordering has been violated - fn unroot<'b, T: Reflectable>(&self, rooted: &Root<'b, T>) { + fn unroot<'b, T: Reflectable>(&self, rooted: &Root<T>) { unsafe { let roots = self.roots.get(); debug!("unrooting {} (expecting {}", @@ -485,20 +485,20 @@ impl RootCollection { /// for the same JS value. `Root`s cannot outlive the associated `RootCollection` object. /// Attempts to transfer ownership of a `Root` via moving will trigger dynamic unrooting /// failures due to incorrect ordering. -pub struct Root<'b, T> { +pub struct Root<T> { /// List that ensures correct dynamic root ordering root_list: &'static RootCollection, /// Reference to rooted value that must not outlive this container - jsref: JSRef<'b, T>, + jsref: JSRef<'static, T>, /// On-stack JS pointer to assuage conservative stack scanner js_ptr: *mut JSObject, } -impl<'b, T: Reflectable> Root<'b, T> { +impl<T: Reflectable> Root<T> { /// Create a new stack-bounded root for the provided JS-owned value. /// It cannot not outlive its associated `RootCollection`, and it contains a `JSRef` /// which cannot outlive this new `Root`. - fn new(roots: &'static RootCollection, unrooted: &JS<T>) -> Root<'b, T> { + fn new(roots: &'static RootCollection, unrooted: &JS<T>) -> Root<T> { let root = Root { root_list: roots, jsref: JSRef { @@ -519,13 +519,13 @@ impl<'b, T: Reflectable> Root<'b, T> { } #[unsafe_destructor] -impl<'b, T: Reflectable> Drop for Root<'b, T> { +impl<T: Reflectable> Drop for Root<T> { fn drop(&mut self) { self.root_list.unroot(self); } } -impl<'b, T: Reflectable> Deref<JSRef<'b, T>> for Root<'b, T> { +impl<'b, T: Reflectable> Deref<JSRef<'b, T>> for Root<T> { fn deref<'c>(&'c self) -> &'c JSRef<'b, T> { &self.jsref } |