mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Replace NonZero<*mut JSObject> with a wrapper to enable local trait impls.
This commit is contained in:
parent
115d859551
commit
e2fafd2dfc
22 changed files with 108 additions and 69 deletions
|
@ -6,17 +6,17 @@
|
|||
|
||||
//! Implementation of `iterable<...>` and `iterable<..., ...>` WebIDL declarations.
|
||||
|
||||
use core::nonzero::NonZero;
|
||||
use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyAndValueResult;
|
||||
use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyOrValueResult;
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::nonnull::NonNullJSObjectPtr;
|
||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||
use dom::bindings::root::{Dom, DomRoot};
|
||||
use dom::bindings::trace::JSTraceable;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use js::jsapi::{HandleValue, Heap, JSContext, JSObject, MutableHandleObject};
|
||||
use js::jsapi::{HandleValue, Heap, JSContext, MutableHandleObject};
|
||||
use js::jsval::UndefinedValue;
|
||||
use std::cell::Cell;
|
||||
use std::ptr;
|
||||
|
@ -73,7 +73,7 @@ impl<T: DomObject + JSTraceable + Iterable> IterableIterator<T> {
|
|||
|
||||
/// Return the next value from the iterable object.
|
||||
#[allow(non_snake_case)]
|
||||
pub fn Next(&self, cx: *mut JSContext) -> Fallible<NonZero<*mut JSObject>> {
|
||||
pub fn Next(&self, cx: *mut JSContext) -> Fallible<NonNullJSObjectPtr> {
|
||||
let index = self.index.get();
|
||||
rooted!(in(cx) let mut value = UndefinedValue());
|
||||
rooted!(in(cx) let mut rval = ptr::null_mut());
|
||||
|
@ -106,7 +106,7 @@ impl<T: DomObject + JSTraceable + Iterable> IterableIterator<T> {
|
|||
self.index.set(index + 1);
|
||||
result.map(|_| {
|
||||
assert!(!rval.is_null());
|
||||
unsafe { NonZero::new_unchecked(rval.get()) }
|
||||
unsafe { NonNullJSObjectPtr::new_unchecked(rval.get()) }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue