Convert MTScript input numbers and output objects #4291
Merged
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.
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
This change is