Skip to content

feat: Add JSContext::global_object#12

Merged
waywardmonkeys merged 1 commit into
endoli:mainfrom
Hywan:feat-context-global-object
Oct 4, 2023
Merged

feat: Add JSContext::global_object#12
waywardmonkeys merged 1 commit into
endoli:mainfrom
Hywan:feat-context-global-object

Conversation

@Hywan
Copy link
Copy Markdown
Contributor

@Hywan Hywan commented Oct 4, 2023

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.

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.
@waywardmonkeys waywardmonkeys merged commit 63613b6 into endoli:main Oct 4, 2023
@waywardmonkeys
Copy link
Copy Markdown
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.

@waywardmonkeys
Copy link
Copy Markdown
Contributor

There was a small issue here which I'm fixing in a follow up commit.

@waywardmonkeys
Copy link
Copy Markdown
Contributor

Fixed in 6051246

@Hywan
Copy link
Copy Markdown
Contributor Author

Hywan commented Oct 4, 2023

Oh sorry for the doctest! Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants