Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert MTScript input numbers and output objects #4291

Merged

Conversation

fishface60
Copy link
Contributor

@fishface60 fishface60 commented Sep 16, 2023

MTScript numbers are BigDecimals, so require conversion to a number type that graal Values can contain.

Objects returned from JavaScript functions are PolyglotMaps, which are Host Objects instead of subclasses of Value and get turned into a HashMap,
which needs to be serialized to JSON to be usable from MTScript.

This allows numbers to be passed to JavaScript macros without serializing them to Strings first and allows them to return objects without serializing to JSON first.

Identify the Bug or Feature request

fixes #4290

Description of the Change

This converts the BigDecimal values that are passed to JavaScript into Long or Double so that they become a JavaScript Number instead of an Object, and serializes returned Objects to JSON.

Possible Drawbacks

I am not sufficiently familiar with the codebase to know whether the changes should be elsewhere.

It may be desirable for returned objects to be left unmodified if they are going to be passed back into other JavaScript functions, but they appear to be translated into HashMaps already, so this would already not work.

Release Notes

  • Fixed numbers being passed to JavaScript macro functions.
  • Objects returned from JavaScript macro functions are serialized as JSON.

This change is Reviewable

MTScript numbers are BigDecimals, so require conversion to a number type
that graal Values can contain.

Objects returned from JavaScript functions are PolyglotMaps,
which are Host Objects instead of subclasses of Value
and get turned into a HashMap,
which needs to be serialized to JSON to be usable from MTScript.

This allows
@cwisniew cwisniew added this pull request to the merge queue Sep 21, 2023
Merged via the queue into RPTools:develop with commit e2f4aaf Sep 21, 2023
4 checks passed
@cwisniew cwisniew added the bug label Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

[Bug]: JavaScript Macro FFI does not support passing numbers or returning objects
2 participants