mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Convert CGTraitInterface to use safe JSContext instead of raw JSContext
This commit is contained in:
parent
808fa65aef
commit
2c5d0a6ebc
43 changed files with 443 additions and 528 deletions
|
@ -76,41 +76,41 @@ 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<NonNull<JSObject>> {
|
||||
pub fn Next(&self, cx: SafeJSContext) -> Fallible<NonNull<JSObject>> {
|
||||
let index = self.index.get();
|
||||
rooted!(in(cx) let mut value = UndefinedValue());
|
||||
rooted!(in(cx) let mut rval = ptr::null_mut::<JSObject>());
|
||||
rooted!(in(*cx) let mut value = UndefinedValue());
|
||||
rooted!(in(*cx) let mut rval = ptr::null_mut::<JSObject>());
|
||||
let result = if index >= self.iterable.get_iterable_length() {
|
||||
dict_return(cx, rval.handle_mut(), true, value.handle())
|
||||
dict_return(*cx, rval.handle_mut(), true, value.handle())
|
||||
} else {
|
||||
match self.type_ {
|
||||
IteratorType::Keys => {
|
||||
unsafe {
|
||||
self.iterable
|
||||
.get_key_at_index(index)
|
||||
.to_jsval(cx, value.handle_mut());
|
||||
.to_jsval(*cx, value.handle_mut());
|
||||
}
|
||||
dict_return(cx, rval.handle_mut(), false, value.handle())
|
||||
dict_return(*cx, rval.handle_mut(), false, value.handle())
|
||||
},
|
||||
IteratorType::Values => {
|
||||
unsafe {
|
||||
self.iterable
|
||||
.get_value_at_index(index)
|
||||
.to_jsval(cx, value.handle_mut());
|
||||
.to_jsval(*cx, value.handle_mut());
|
||||
}
|
||||
dict_return(cx, rval.handle_mut(), false, value.handle())
|
||||
dict_return(*cx, rval.handle_mut(), false, value.handle())
|
||||
},
|
||||
IteratorType::Entries => {
|
||||
rooted!(in(cx) let mut key = UndefinedValue());
|
||||
rooted!(in(*cx) let mut key = UndefinedValue());
|
||||
unsafe {
|
||||
self.iterable
|
||||
.get_key_at_index(index)
|
||||
.to_jsval(cx, key.handle_mut());
|
||||
.to_jsval(*cx, key.handle_mut());
|
||||
self.iterable
|
||||
.get_value_at_index(index)
|
||||
.to_jsval(cx, value.handle_mut());
|
||||
.to_jsval(*cx, value.handle_mut());
|
||||
}
|
||||
key_and_value_return(cx, rval.handle_mut(), key.handle(), value.handle())
|
||||
key_and_value_return(*cx, rval.handle_mut(), key.handle(), value.handle())
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue