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 upWrapping unsafe raw JSContext pointers in a safe struct. Part 1. #23816
Conversation
highfive
commented
Jul 20, 2019
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @emilio (or someone else) soon. |
highfive
commented
Jul 20, 2019
|
Heads up! This PR modifies the following files:
|
highfive
commented
Jul 20, 2019
|
@jdm i updated the code according to your comments. I am heading toward the right direction here? |
|
Yes! This looks like what I expected to see :D |
|
I am having trouble modifying
which i don't know how to solve. |
|
Ah, indeed. Those will need to continue to have the raw pointer argument because the C function pointers can't be changed. We will want to declare a |
|
Looking good so far! |
8c5ec29
to
c70cd71
|
@jdm i've followed the steps you described in the other PR #23657 (comment) Also |
|
The failure does come from your changes. If you run |
|
I think the next big step would be modifying GlobalScope::get_cx to return a SafeJSContext and store one internally as well. That should remove a bunch of uses of from_ptr uses right now. At that point it would probably make sense to merge the changes and file follow-ups for increasing the usage in hand-written Rust code. |
Ok it should be fixed now.
I'll look into it then |
|
@jdm I made all methods |
|
Great work! Let's fix these two nits and merge it! |
|
|
|
@jdm i rebased and fixed the conflicts but appveyor failed and i don't really understand what is the problem. I don't know what to look for in the build log. |
|
It hit the time limit for the build and it's very bad at making that clear. We can ignore it. |
|
@bors-servo r+ |
|
|
Wrapping unsafe raw JSContext pointers in a safe struct. Part 1. Wrapping unsafe raw JSContext pointers in a safe struct. Issue #20377. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] create a struct JSContext(*mut jsapi::JSContext) type - [x] implement Deref for this new type so it's easy to obtain the inner context pointer - [x] add an unsafe from_ptr static method that returns a new instance of the type - [x] start by changing various Argument uses in CodegenRust.py for python classes that inherit from CGAbstractMethod - [x] convert the python code that interacts with CGClass (CGCallback, CGCallbackFunction, CGCallbackFunctionImpl, CGCallbackInterface) and any rust code that interacts with it - [x] update CGDictionary and any rust code that interacts with it - [x] make the code generator declare trait methods that accept the new type instead of *mut JSContext (CGInterfaceTrait) - [x] modify GlobalScope::get_cx to return a SafeJSContext <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23816) <!-- Reviewable:end -->
|
|
marmeladema commentedJul 20, 2019
•
edited
Wrapping unsafe raw JSContext pointers in a safe struct. Issue #20377.
This change is