mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Avoid casting in the callers
get_proto_or_iface_array now returns *mut ProtoOrIfaceArray Fix #6271
This commit is contained in:
parent
458a532461
commit
15c4f7fe2d
2 changed files with 8 additions and 7 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue