Repository navigation
Hand JS functions to Pharo as QJSFunction and let Pharo call them - #9
Merged
Merged
Conversation
A JS function reaching Pharo, as the argument of an exposed method or as
the result of an evaluation, used to arrive as its source text. It is now
a QJSFunction, which understands value, value:, value:value:, cull: and
valueWithArguments: like a block, so a Pharo method that takes a block
takes a JS closure:
grid.rowsDo_(row => names.push(row.name()))
The shim gets qjs_value_dup, so Pharo can keep a function beyond the
callback that only lends its arguments, and qjs_call, which calls it with
the same stack and deadline handling as qjs_eval, now shared in
enter_js/leave_js. Arguments and results take along the exposure table of
the binding the function came through. A function handed back to JS is
the same function again. QJSFunction frees its box through finalization.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
A JS function reaching Pharo, as the argument of an exposed method or as the result of an evaluation, used to arrive as its source text. It is now a QJSFunction, which understands value, value:, value:value:, cull: and valueWithArguments: like a block, so a Pharo method that takes a block takes a JS closure:
The shim gets qjs_value_dup, so Pharo can keep a function beyond the callback that only lends its arguments, and qjs_call, which calls it with the same stack and deadline handling as qjs_eval, now shared in enter_js/leave_js. Arguments and results take along the exposure table of the binding the function came through. A function handed back to JS is the same function again. QJSFunction frees its box through finalization.