feat: Add JSContext::global_object#12
Merged
Merged
Conversation
This patch adds the `global_object` method on the `JSContext` struct. The idea is to be able to retrive the global object. It uses `JSContextGetGlobalObject` behind the scene. Because a global object might not always be available, `global_object` returns an `Result<JSObject, JSException>`. This patch adds a basic doctest, and a simple unit test.
Contributor
|
Thanks! I like what I think you're using this for (based on your test). Might be worth a follow up to add a section to the doc for it that says why the global object might not be available. |
Contributor
|
There was a small issue here which I'm fixing in a follow up commit. |
Contributor
|
Fixed in 6051246 |
Contributor
Author
|
Oh sorry for the doctest! Thanks for the quick fix! |
32 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch adds the
global_objectmethod on theJSContextstruct. The idea is to be able to retrive the global object. It usesJSContextGetGlobalObjectbehind the scene.Because a global object might not always be available,
global_objectreturns anResult<JSObject, JSException>.This patch adds a basic doctest, and a simple unit test.