diff options
Diffstat (limited to 'components/script/dom/bindings/utils.rs')
-rw-r--r-- | components/script/dom/bindings/utils.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index e7db5ce70ee..bee42bbe2d3 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -156,10 +156,10 @@ unsafe impl Sync for DOMJSClass {} /// Returns the ProtoOrIfaceArray for the given global object. /// Fails if `global` is not a DOM global object. -pub fn get_proto_or_iface_array(global: *mut JSObject) -> *mut *mut JSObject { +pub fn get_proto_or_iface_array(global: *mut JSObject) -> *mut ProtoOrIfaceArray { unsafe { assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0); - JS_GetReservedSlot(global, DOM_PROTOTYPE_SLOT).to_private() as *mut *mut JSObject + JS_GetReservedSlot(global, DOM_PROTOTYPE_SLOT).to_private() as *mut ProtoOrIfaceArray } } @@ -330,7 +330,8 @@ pub unsafe extern fn throwing_constructor(cx: *mut JSContext, _argc: c_uint, return 0; } -type ProtoOrIfaceArray = [*mut JSObject; PrototypeList::ID::Count as usize]; +/// An array of *mut JSObject of size PrototypeList::ID::Count +pub type ProtoOrIfaceArray = [*mut JSObject; PrototypeList::ID::Count as usize]; /// Construct and cache the ProtoOrIfaceArray for the given global. /// Fails if the argument is not a DOM global. @@ -594,12 +595,12 @@ pub fn create_dom_global(cx: *mut JSContext, class: *const JSClass) /// Drop the resources held by reserved slots of a global object pub unsafe fn finalize_global(obj: *mut JSObject) { let _: Box<ProtoOrIfaceArray> = - Box::from_raw(get_proto_or_iface_array(obj) as *mut ProtoOrIfaceArray); + Box::from_raw(get_proto_or_iface_array(obj)); } /// Trace the resources held by reserved slots of a global object pub unsafe fn trace_global(tracer: *mut JSTracer, obj: *mut JSObject) { - let array = get_proto_or_iface_array(obj) as *mut ProtoOrIfaceArray; + let array = get_proto_or_iface_array(obj); for &proto in (*array).iter() { if !proto.is_null() { trace_object(tracer, "prototype", proto); |