mirror of
https://github.com/servo/servo.git
synced 2025-08-02 04:00:32 +01:00
Make {get,ensure}_expando_object unsafe.
They trust the caller-provided raw pointers to be valid.
This commit is contained in:
parent
bd431039b9
commit
b57abc19da
1 changed files with 15 additions and 19 deletions
|
@ -159,8 +159,7 @@ pub unsafe extern "C" fn get_prototype_if_ordinary(_: *mut JSContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the expando object, or null if there is none.
|
/// Get the expando object, or null if there is none.
|
||||||
pub fn get_expando_object(obj: HandleObject, expando: MutableHandleObject) {
|
pub unsafe fn get_expando_object(obj: HandleObject, expando: MutableHandleObject) {
|
||||||
unsafe {
|
|
||||||
assert!(is_dom_proxy(obj.get()));
|
assert!(is_dom_proxy(obj.get()));
|
||||||
let val = GetProxyExtra(obj.get(), JSPROXYSLOT_EXPANDO);
|
let val = GetProxyExtra(obj.get(), JSPROXYSLOT_EXPANDO);
|
||||||
expando.set(if val.is_undefined() {
|
expando.set(if val.is_undefined() {
|
||||||
|
@ -168,13 +167,11 @@ pub fn get_expando_object(obj: HandleObject, expando: MutableHandleObject) {
|
||||||
} else {
|
} else {
|
||||||
val.to_object()
|
val.to_object()
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the expando object, or create it if it doesn't exist yet.
|
/// Get the expando object, or create it if it doesn't exist yet.
|
||||||
/// Fails on JSAPI failure.
|
/// Fails on JSAPI failure.
|
||||||
pub fn ensure_expando_object(cx: *mut JSContext, obj: HandleObject, expando: MutableHandleObject) {
|
pub unsafe fn ensure_expando_object(cx: *mut JSContext, obj: HandleObject, expando: MutableHandleObject) {
|
||||||
unsafe {
|
|
||||||
assert!(is_dom_proxy(obj.get()));
|
assert!(is_dom_proxy(obj.get()));
|
||||||
get_expando_object(obj, expando);
|
get_expando_object(obj, expando);
|
||||||
if expando.is_null() {
|
if expando.is_null() {
|
||||||
|
@ -183,7 +180,6 @@ pub fn ensure_expando_object(cx: *mut JSContext, obj: HandleObject, expando: Mut
|
||||||
|
|
||||||
SetProxyExtra(obj.get(), JSPROXYSLOT_EXPANDO, &ObjectValue(expando.get()));
|
SetProxyExtra(obj.get(), JSPROXYSLOT_EXPANDO, &ObjectValue(expando.get()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the property descriptor's object to `obj` and set it to enumerable,
|
/// Set the property descriptor's object to `obj` and set it to enumerable,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue