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 PR adds module support (not binary modules, just other files imported via the ES6 module syntax) and the js timer API (setTimeout, clearTimeout).
I wasn't really happy with bindings.rs being that one big huge file and refactored. This led to a big PR diff, but I'm willing to split this into smaller change-sets if the overall structure is something that this project want to go forward with.
The changes in detail. First commit:
Second commit:
The bindings.rs file grew to one huge file with many different aspects covered. It is now split into value/marshal for ser/deserializing of JsValues and owned_value_ref for the OwnedValueRef type and utils for general utility methods.
DroppableValue was used in two ways: Either as a OwnedValueRef with a context pointer (instead of a ContextWrapper like OwnedValueRef uses it) or for the Properties enumeration. DroppableValue has been completely removed instead and OwnedValueRef takes a context pointer now. For properties enumeration a new type has been introduced (see value/marshal.rs).
impl ContextWrapper has been split into multiple impl ContextWrapper's, so that the callback API, timer API, module support each stay in their own rust-modules. bindings.rs is now purely for state keeping and the eval related API with about 500 LOC instead of 2k LOC.
Compiling to bytecode and running from bytecode has been added.
The timer API setTimeout/clearTimeout has been added. resolve_value required a few changes to "wait" for all timers to expire before returning.
Allow callback function arguments for
add_callback
andcreate_callback
APIs. A new OpaqueJsFunction type (a simple-type wrapper around OwnedValueRef) is introduced for this. Usage example:add_callback
andcreate_callback
APIs. This is useful if a js-api consumer is allowed to hand in a number, a string, a boolean. Usage example: