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

[Merged by Bors] - Implementation of JsMap Wrapper #2115

Closed
wants to merge 43 commits into from

Conversation

nekevss
Copy link
Member

@nekevss nekevss commented Jun 11, 2022

This Pull Request related to JsMap for #2098.

Any feedback on implementing JsMapIterator would be welcome. I wasn't entirely sure if it was the right approach, but as I worked on the example file, it felt like something at least similar would be needed to use Map's .entries(), .keys(), and .values() methods.

It changes the following:

  • Implements JsMap Wrapper
  • Implements JsMapIterator Wrapper
  • Creates JsMap example in boa_examples

@codecov
Copy link

codecov bot commented Jun 11, 2022

Codecov Report

Merging #2115 (18bd5f6) into main (ce8c6e2) will decrease coverage by 1.07%.
The diff coverage is 1.66%.

@@            Coverage Diff             @@
##             main    #2115      +/-   ##
==========================================
- Coverage   43.40%   42.32%   -1.08%     
==========================================
  Files         220      228       +8     
  Lines       20079    21047     +968     
==========================================
+ Hits         8715     8909     +194     
- Misses      11364    12138     +774     
Impacted Files Coverage Δ
boa_engine/src/object/jsmap.rs 0.00% <0.00%> (ø)
boa_engine/src/object/jsmap_iterator.rs 0.00% <0.00%> (ø)
boa_engine/src/object/mod.rs 20.78% <ø> (+0.28%) ⬆️
boa_engine/src/object/jsobject.rs 52.46% <50.00%> (-0.17%) ⬇️
...ax/ast/node/declaration/async_function_decl/mod.rs 52.63% <0.00%> (-14.04%) ⬇️
.../syntax/parser/expression/left_hand_side/member.rs 26.92% <0.00%> (-12.21%) ⬇️
...src/syntax/parser/expression/left_hand_side/mod.rs 45.45% <0.00%> (-11.69%) ⬇️
boa_engine/src/syntax/parser/mod.rs 26.78% <0.00%> (-9.98%) ⬇️
boa_engine/src/builtins/promise/mod.rs 18.97% <0.00%> (-9.71%) ⬇️
boa_engine/src/syntax/ast/node/identifier/mod.rs 18.18% <0.00%> (-9.10%) ⬇️
... and 67 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce8c6e2...18bd5f6. Read the comment docs.

@Razican Razican added enhancement New feature or request builtins PRs and Issues related to builtins/intrinsics API labels Jun 12, 2022
@Razican Razican added this to the v0.16.0 milestone Jun 12, 2022
@raskad
Copy link
Member

raskad commented Jun 15, 2022

I think this looks really good. The implementation of JsMapIterator looks totally logical to me. Is there a reason forEach is missing?

One little nitpick; there are some comments that don't start uppercase and end with a dot. Just for consistency and style ;)

And we probably need a rebase, because the 262 submodule seems to be outdated here.

@nekevss
Copy link
Member Author

nekevss commented Jun 15, 2022

I can clean up the comments real quick. They were mostly guideposts I was using while going.

There isn't much of a reason that forEach was left off. To be honest, I wasn't entirely certain about adding it as it seemed to be omitted from JsArray, which mostly made me pause and leave it off. I can definitely add forEach.

The 262 submodule is probably totally my bad. Any guidance on how I can fix it on my end would be really appreciated!

@raskad
Copy link
Member

raskad commented Jun 22, 2022

The 262 submodule is probably totally my bad. Any guidance on how I can fix it on my end would be really appreciated!

You can update the 262 submodule with git submodule update --init. You probably have to checkout main, pull the current changes, update the submodule there. Then you can rebase your branch on main and update the submodule there too. If I'm not mistaken that should do it.

@nekevss
Copy link
Member Author

nekevss commented Jun 23, 2022

@raskad I updated the comments and the submodule in main and ran the rebase. There were also some changes that needed to be made to .keys(), .entries(), and .values() since IteratorRecord had changed in one of the recent pull requests.

The submodule still didn't want to update on the branch with the git submodule update --init command, which was one of the issues I was having. I basically ended up going into test262 and pulling from main there. So hopefully that should be fixed too.

@nekevss nekevss requested a review from jedel1043 July 2, 2022 04:09
@nekevss
Copy link
Member Author

nekevss commented Jul 2, 2022

I made some pretty big changes to the comments and documentation for JsMap, building out some of the comments and documentation/examples where possible. The documentation do vary between shorthand code snippets and longer examples, but they may have caused the continuous integration check fails. Do code snippets in comments typically cause these tests to fail or should the shorthand examples be lengthened?

Also, I did shy away from going too deep into the documentation surrounding JsMapIterator as I believe the next method returns an IteratorResult. I wasn't certain what the discussion was around IteratorResult and whether that should be exposed or handled within the next method of JsMapIterator, so I thought it best to leave it open for now

@jedel1043
Copy link
Member

@nekevss Very nice work!

The thing about Rust examples in docs is that cargo's test framework will try to compile and test them to verify that they're valid.
This means you need to create a context for each example, just like the examples inside the struct doc.
Also, if you want to hide the initialization code, check https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#hiding-portions-of-the-example for code snippets on how to do that :D

Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very very great work! I'm very impressed with the addition of so many example usages. I just have a single nit. After that, it's ready to merge.

boa_engine/src/object/jsmap.rs Outdated Show resolved Hide resolved
Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@jedel1043
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Jul 6, 2022
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel neccessary.
--->

This Pull Request related to JsMap for #2098.

Any feedback on implementing JsMapIterator would be welcome. I wasn't entirely sure if it was the right approach, but as I worked on the example file, it felt like something at least similar would be needed to use Map's .entries(), .keys(), and .values() methods.

It changes the following:

- Implements JsMap Wrapper
- Implements JsMapIterator Wrapper
- Creates JsMap example in boa_examples
@bors
Copy link

bors bot commented Jul 6, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Implementation of JsMap Wrapper [Merged by Bors] - Implementation of JsMap Wrapper Jul 6, 2022
@bors bors bot closed this Jul 6, 2022
lameferret pushed a commit to lameferret/boa that referenced this pull request Jul 6, 2022
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel neccessary.
--->

This Pull Request related to JsMap for boa-dev#2098.

Any feedback on implementing JsMapIterator would be welcome. I wasn't entirely sure if it was the right approach, but as I worked on the example file, it felt like something at least similar would be needed to use Map's .entries(), .keys(), and .values() methods.

It changes the following:

- Implements JsMap Wrapper
- Implements JsMapIterator Wrapper
- Creates JsMap example in boa_examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API builtins PRs and Issues related to builtins/intrinsics enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants