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 upImplement maybe_wrap_object_value without OOL calls #301
Conversation
| #[inline] | ||
| pub unsafe fn maybe_wrap_value(cx: *mut JSContext, rval: MutableHandleValue) { | ||
| if rval.is_object_or_null() { | ||
| maybe_wrap_object_value(cx, rval); |
This comment has been minimized.
This comment has been minimized.
| #[inline] | ||
| unsafe fn get_object_group(obj: *mut JSObject) -> *mut ObjectGroup { | ||
| assert!(!obj.is_null()); | ||
| (*(obj as *mut Object)).group |
This comment has been minimized.
This comment has been minimized.
Ms2ger
Aug 31, 2016
Collaborator
I think this would be more readable if you added a separate let binding for obj as *mut Object.
|
|
||
| #[inline] | ||
| pub unsafe fn get_context_compartment(cx: *mut JSContext) -> *mut JSCompartment { | ||
| (*(cx as *mut ContextFriendFields)).compartment_ |
This comment has been minimized.
This comment has been minimized.
|
Amended all the things. |
|
Code looks okay to me; I'd like @jdm to agree we want to go this way, though. (Also, some documentation might be useful.) |
| } | ||
|
|
||
| #[inline] | ||
| pub unsafe fn maybe_wrap_value(cx: *mut JSContext, rval: MutableHandleValue) { |
This comment has been minimized.
This comment has been minimized.
jdm
Sep 14, 2016
Member
This is different than Gecko's, which special-cases strings and objects but otherwise avoids wrapping: https://dxr.mozilla.org/mozilla-central/rev/82d0a583a9a39bf0b0000bccbf6d5c9ec2596bcc/dom/bindings/BindingUtils.h#852
| return try_to_outerize(rval); | ||
| } | ||
| } | ||
| assert!(JS_WrapValue(cx, rval)); |
This comment has been minimized.
This comment has been minimized.
jdm
Sep 14, 2016
Member
We miss a fast path here where the compartment is the same and it's a non-WebIDL object.
|
|
|
Planning to finish this up, @nox? |
The only remaining OOL calls are ToWindowIfWindowProxy and JS_WrapValue, like in the equivalent Gecko function.
|
@bors-servo: r+ |
|
|
Implement maybe_wrap_object_value without OOL calls The only remaining OOL calls are ToWindowIfWindowProxy and JS_WrapValue, like in the equivalent Gecko function. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-mozjs/301) <!-- Reviewable:end -->
|
|
nox commentedAug 30, 2016
•
edited by larsbergstrom
The only remaining OOL calls are ToWindowIfWindowProxy and JS_WrapValue,
like in the equivalent Gecko function.
This change is