-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix prototypes of interface objects (fixes #2665) #8954
Conversation
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 |
☔ The latest upstream changes (presumably #8963) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #8991) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #8825) made this pull request unmergeable. Please resolve the merge conflicts. |
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 |
💔 Test failed - linux-rel |
|
JS_NewFunction doesn't allow us to set the prototype of the interface objects.
@bors-servo r+ |
📌 Commit d13da7d has been approved by |
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 -->
☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-ref-unit, mac-rel-css, mac-rel-wpt |
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.