Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upFix prototypes of interface objects (fixes #2665) #8954
Conversation
highfive
commented
Dec 13, 2015
|
r? @Ms2ger |
|
For Document, we end up with: fn CreateInterfaceObjects(cx: *mut JSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray, receiver: HandleObject) {
unsafe {
let mut prototype_proto = RootedObject::new(cx, ptr::null_mut());
NodeBinding::GetProtoObject(cx, global, receiver, prototype_proto.handle_mut());
assert!(!prototype_proto.ptr.is_null());
let mut prototype = RootedObject::new(cx, ptr::null_mut());
create_interface_prototype_object(cx,
prototype_proto.handle(),
&PrototypeClass,
Some(sMethods),
Some(sAttributes),
&[],
prototype.handle_mut());
assert!(!prototype.ptr.is_null());
(*cache)[PrototypeList::ID::Document as usize] = prototype.ptr;
if <*mut JSObject>::needs_post_barrier(prototype.ptr) {
<*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::Document as isize));
}
let mut interface_proto = RootedObject::new(cx, ptr::null_mut());
NodeBinding::GetConstructorObject(cx, global, receiver, interface_proto.handle_mut());
assert!(!interface_proto.ptr.is_null());
let mut interface = RootedObject::new(cx, ptr::null_mut());
create_noncallback_interface_object(cx,
receiver,
interface_proto.handle(),
&InterfaceObjectClass,
None,
None,
&[],
prototype.handle(),
b"Document\0",
0,
interface.handle_mut());
assert!(!interface.ptr.is_null());
(*cache)[PrototypeList::Constructor::Document as usize] = interface.ptr;
if <*mut JSObject>::needs_post_barrier(prototype.ptr) {
<*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::Constructor::Document as isize));
}
let mut unforgeable_holder = RootedObject::new(cx, ptr::null_mut());
unforgeable_holder.handle_mut().set(
JS_NewObjectWithoutMetadata(cx, ptr::null(), HandleObject::null()));
assert!(!unforgeable_holder.ptr.is_null());
define_properties(cx, unforgeable_holder.handle(), sUnforgeableAttributes).unwrap();
JS_SetReservedSlot(prototype.ptr, DOM_PROTO_UNFORGEABLE_HOLDER_SLOT,
ObjectValue(&*unforgeable_holder.ptr))
}
} |
|
Fails tidy |
|
|
|
|
|
|
|
I'd still like to try and get the hasInstance stuff into a separate commit. Will try to look tomorrow. Review status: 0 of 9 files reviewed at latest revision, 1 unresolved discussion. components/script/dom/bindings/interface.rs, line 173 [r2] (raw file): Comments from the review on Reviewable.io |
|
I've just rebuilt on d81fe2f with the
So this was actually already provided by the fact that |
|
|
|
|
@bors-servo r+ |
|
|
Fix prototypes of interface objects (fixes #2665) Callback interface objects' (i.e. NodeFilter's) prototype is now Object instead of Function and non-callback interface objects' their proper ancestor, starting with the Function prototype. The function do_create_interface_objects is removed in favour of 4 functions: create_callback_interface_object, create_interface_prototype_object, create_noncallback_interface_object and create_named_constructors. While this increases the amount of codegen'd code, this greatly improves the readability of the code involved in this part of DOM, instead of having one function doing 4 different things. We can always find a more adequate abstraction later. NativeProperties and everything related to the interface objects have been removed from the utils module. Fixes #2665. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8954) <!-- Reviewable:end -->
|
|
nox commentedDec 13, 2015
Callback interface objects' (i.e. NodeFilter's) prototype is now Object instead of
Function and non-callback interface objects' their proper ancestor, starting with
the Function prototype.
The function do_create_interface_objects is removed in favour of 4 functions:
create_callback_interface_object, create_interface_prototype_object,
create_noncallback_interface_object and create_named_constructors.
While this increases the amount of codegen'd code, this greatly improves the
readability of the code involved in this part of DOM, instead of having one function
doing 4 different things. We can always find a more adequate abstraction later.
NativeProperties and everything related to the interface objects have been removed
from the utils module.
Fixes #2665.