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

Implement [[HostDefined]] field on Realms #2952

Merged
merged 1 commit into from
Sep 27, 2023
Merged

Conversation

HalidOdat
Copy link
Member

It changes the following:

  • Add [[HostDefined]] field to Realms
  • Add example.
  • Make FunctionObjectBuilder take a Realm instead of Context

@HalidOdat HalidOdat added enhancement New feature or request API labels May 20, 2023
@HalidOdat HalidOdat added this to the v0.17.0 milestone May 20, 2023
@HalidOdat HalidOdat requested a review from a team May 20, 2023 16:54
@github-actions
Copy link

github-actions bot commented May 20, 2023

Test262 conformance changes

Test result main count PR count difference
Total 95,574 95,574 0
Passed 75,084 75,084 0
Ignored 19,494 19,494 0
Failed 996 996 0
Panics 0 0 0
Conformance 78.56% 78.56% 0.00%

@HalidOdat HalidOdat force-pushed the feature/realm-host-defined branch 2 times, most recently from a869f9b to e39bc58 Compare May 20, 2023 17:19
@codecov
Copy link

codecov bot commented May 20, 2023

Codecov Report

Patch coverage: 5.44% and project coverage change: -0.15% ⚠️

Comparison is base (8a78061) 50.31% compared to head (8595932) 50.17%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2952      +/-   ##
==========================================
- Coverage   50.31%   50.17%   -0.15%     
==========================================
  Files         436      438       +2     
  Lines       42604    42730     +126     
==========================================
  Hits        21438    21438              
- Misses      21166    21292     +126     
Files Changed Coverage Δ
boa_cli/src/debug/limits.rs 0.00% <0.00%> (ø)
boa_cli/src/debug/optimizer.rs 0.00% <0.00%> (ø)
boa_engine/src/builtins/async_generator/mod.rs 30.57% <0.00%> (ø)
boa_engine/src/builtins/intl/collator/mod.rs 5.55% <0.00%> (ø)
.../src/builtins/iterable/async_from_sync_iterator.rs 11.30% <0.00%> (ø)
boa_engine/src/builtins/proxy/mod.rs 11.76% <0.00%> (ø)
boa_engine/src/context/mod.rs 55.55% <0.00%> (ø)
boa_engine/src/host_defined.rs 0.00% <0.00%> (ø)
boa_engine/src/lib.rs 73.33% <ø> (ø)
boa_engine/src/module/mod.rs 3.20% <0.00%> (ø)
... and 18 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@nekevss nekevss left a comment

Choose a reason for hiding this comment

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

I still need to look at this a little deeper, but overall this looks pretty good. Just a couple questions/comments.

boa_cli/src/debug/optimizer.rs Show resolved Hide resolved
boa_engine/src/object/builtins/jsproxy.rs Show resolved Hide resolved
boa_engine/src/realm.rs Show resolved Hide resolved
Copy link
Member

@raskad raskad 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

@HalidOdat
Copy link
Member Author

HalidOdat commented Jun 8, 2023

I redesigned the [[HostDefined]] API, the reason being that, when I was looking through the fetch WebAPI spec and realized that they utilize storing custom state. This wouldn't be a problem if it was implemented in boa_engine (since we could add it to realm if we wanted), but since we have an external crate for some WebAPI stuff (boa_runtime). It would occupy the host defined field and the user would not be able to create their own state.

That's why It's been extended to work with as many type Ts that implement NativeObject in a registry, with the key being the TypeId

@jedel1043
Copy link
Member

Really liking the new API! And it's also pretty similar to the upcoming Provider API (rust-lang/rust#96024), so we could migrate to that in the future without changing the API

@Razican Razican modified the milestones: v0.17.0, v0.18.0 Jul 8, 2023
@HalidOdat HalidOdat requested a review from a team September 8, 2023 14:22
@HalidOdat HalidOdat force-pushed the feature/realm-host-defined branch 2 times, most recently from 00e2cf5 to a808420 Compare September 16, 2023 15:43
Copy link
Member

@raskad raskad left a comment

Choose a reason for hiding this comment

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

I also like the API. Just found a few typos in the example, otherwise I'm for merging this.

boa_examples/src/bin/host_defined.rs Outdated Show resolved Hide resolved
boa_examples/src/bin/host_defined.rs Outdated Show resolved Hide resolved
boa_examples/src/bin/host_defined.rs Outdated Show resolved Hide resolved
boa_examples/src/bin/host_defined.rs Outdated Show resolved Hide resolved
boa_examples/src/bin/host_defined.rs Outdated Show resolved Hide resolved
boa_examples/src/bin/host_defined.rs Outdated Show resolved Hide resolved
boa_examples/src/bin/host_defined.rs Outdated Show resolved Hide resolved
boa_examples/src/bin/host_defined.rs Outdated Show resolved Hide resolved
boa_examples/src/bin/host_defined.rs Outdated Show resolved Hide resolved
boa_examples/src/bin/host_defined.rs Outdated Show resolved Hide resolved
- Improve HostDefined field to allow multiple stored types
@HalidOdat HalidOdat requested a review from a team September 21, 2023 13:44
@jedel1043 jedel1043 mentioned this pull request Sep 27, 2023
7 tasks
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!

@jedel1043 jedel1043 added this pull request to the merge queue Sep 27, 2023
Merged via the queue into main with commit 822634c Sep 27, 2023
9 checks passed
@jedel1043 jedel1043 deleted the feature/realm-host-defined branch September 27, 2023 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants