-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
[Merged by Bors] - Feature JsArray
#1746
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1746 +/- ##
==========================================
- Coverage 55.57% 55.30% -0.28%
==========================================
Files 199 200 +1
Lines 17760 17848 +88
==========================================
Hits 9871 9871
- Misses 7889 7977 +88
Continue to review full report at Codecov.
|
Test262 conformance changesVM implementation
|
Sounds good to me, the exposed API could work quite well. I'm assuming src/object will eventually have all the APIs we plan to expose? |
ab0a708
to
6d95db1
Compare
Yeah, plan to add others like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this :) It just needs a re-base, and maybe fixing that TODO, but all in all, I like this approach to improve the API, it should be much easier to use from Rust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just some API suggestions that I would like to see implemented :)
af59c00
to
8a7670e
Compare
Benchmark for 7676a2bClick to view benchmark
|
Benchmark for 3b831ddClick to view benchmark
|
8a7670e
to
06bfad5
Compare
Benchmark for 07e4868Click to view benchmark
|
06bfad5
to
3c667fb
Compare
3c667fb
to
e1c4fec
Compare
Benchmark for ff3f778Click to view benchmark
|
Benchmark for bd05fd5Click to view benchmark
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
LGTM! bors r+ |
This PR introduces a new API for JavaScript builtin objects in Rust (such as `Array`, `Map`, `Proxy`, etc). Rather than just expose the raw builtin functions as discussed here #1692 (though having raw API exposed may be nice as well), In this PR we introduce a very light wrapper around the raw API, for a more pleasant user experience. The wrapper implements functions that are specific to the wrapper type (for `Array` this would be methods like `pop`, `push`, etc) as well as implementing `Deref<Target = JsObject>` so we can call `JsObject` functions without converting to `JsObject` and `Into<JsValue>` for easy to `JsValue` conversions. Please check `jsarray.rs` in the `examples`
Pull request successfully merged into main. Build succeeded: |
This PR introduces a new API for JavaScript builtin objects in Rust (such as `Array`, `Map`, `Proxy`, etc). Rather than just expose the raw builtin functions as discussed here #1692 (though having raw API exposed may be nice as well), In this PR we introduce a very light wrapper around the raw API, for a more pleasant user experience. The wrapper implements functions that are specific to the wrapper type (for `Array` this would be methods like `pop`, `push`, etc) as well as implementing `Deref<Target = JsObject>` so we can call `JsObject` functions without converting to `JsObject` and `Into<JsValue>` for easy to `JsValue` conversions. Please check `jsarray.rs` in the `examples`
This PR adds `JsFunction` wrapper around JavaScript `Function` object, like #1746 With this PR we can distinguish between regular object and function object when we need, such as accessors (because they always need to be functions), predicates in `JsArray` methods like `map`, `find`, etc. With this abstraction we leverage the type system of rust which cleans the API making intentions clear. It changes the following: - Make methods that take predicate/callback function take `JsFunction`s - Make `.accessor()` and `.static_accessor()` take `Option<JsFunction>` - Make `FunctionBuilder` return `JsFunction` - Make `ConstructorBuilder` return `JsFunction` - Make `ClassBuilder` return `JsFunction`
This PR adds `JsFunction` wrapper around JavaScript `Function` object, like #1746 With this PR we can distinguish between regular object and function object when we need, such as accessors (because they always need to be functions), predicates in `JsArray` methods like `map`, `find`, etc. With this abstraction we leverage the type system of rust which cleans the API making intentions clear. It changes the following: - Make methods that take predicate/callback function take `JsFunction`s - Make `.accessor()` and `.static_accessor()` take `Option<JsFunction>` - Make `FunctionBuilder` return `JsFunction` - Make `ConstructorBuilder` return `JsFunction` - Make `ClassBuilder` return `JsFunction`
This PR introduces a new API for JavaScript builtin objects in Rust (such as
Array
,Map
,Proxy
, etc). Rather than just expose the raw builtin functions as discussed here #1692 (though having raw API exposed may be nice as well), In this PR we introduce a very light wrapper around the raw API, for a more pleasant user experience. The wrapper implements functions that are specific to the wrapper type (forArray
this would be methods likepop
,push
, etc) as well as implementingDeref<Target = JsObject>
so we can callJsObject
functions without converting toJsObject
andInto<JsValue>
for easy toJsValue
conversions.Please check
jsarray.rs
in theexamples