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 up[WIP] Make DOM bindings methods not take raw JSContext pointers #20424
Conversation
highfive
commented
Mar 25, 2018
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @asajeffrey (or someone else) soon. |
highfive
commented
Mar 25, 2018
|
Heads up! This PR modifies the following files:
|
highfive
commented
Mar 25, 2018
| pub struct JSContext(*mut JSContext); | ||
|
|
||
| impl Deref for JSContext { | ||
| type Target = JSContext; |
This comment has been minimized.
This comment has been minimized.
KiChjang
Mar 26, 2018
Member
This looks like it would not compile, since there's a naming collision.
| @@ -473,3 +473,13 @@ unsafe fn set_gc_zeal_options(rt: *mut JSRuntime) { | |||
| #[allow(unsafe_code)] | |||
| #[cfg(not(feature = "debugmozjs"))] | |||
| unsafe fn set_gc_zeal_options(_: *mut JSRuntime) {} | |||
|
|
|||
| pub struct RawJSContext(*mut JSContext); | |||
This comment has been minimized.
This comment has been minimized.
KiChjang
Mar 28, 2018
Member
I believe this is a misnomer -- the struct that wraps the *mut JSContext is actually the safe JSContext, since we make sure that we don't have a null pointer reference when creating the struct. I would instead rename the JSContext import to RawJSContext.
This comment has been minimized.
This comment has been minimized.
7c15665
to
95d76b1
|
there are lots of raw JSContext waiting to be wrapped in |
|
Yes, that is definitely something we can do incrementally over time. |
|
|
|
There are some methods defined locally but declared from outside servo/components/script/dom/bindings/conversions.rs Lines 75 to 81 in a69ecee the to_jsval method is declared in mozjs crate:
pub trait ToJSValConvertible {
/// Convert `self` to a `JSVal`. JSAPI failure causes a panic.
#[inline]
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue);
}this prevents me to introduce safe |
|
Yes. We can migrate this type into the upstream rust-mozjs crate at a later time if we decide it's worthwhile. |
|
I'm not sure if the migration is possible, since I believe that these |
|
I meant migrating the new wrapper struct. |
|
I suspect that it'll be better if the safe If it's ok, I'll volunteer to create a PR for |
|
@csmoe Are you still planning to continue working on this? |
|
@jdm I'll restart this |
|
|
csmoe commentedMar 25, 2018
•
edited
address #20377
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is