Skip to content

docs: add NativeObject design document#5061

Merged
jedel1043 merged 4 commits intoboa-dev:mainfrom
yush-1018:docs/native-object-design
Mar 17, 2026
Merged

docs: add NativeObject design document#5061
jedel1043 merged 4 commits intoboa-dev:mainfrom
yush-1018:docs/native-object-design

Conversation

@yush-1018
Copy link
Contributor

Resolves #3938

Added a design doc for NativeObject. It covers how Rust types are wrapped using JsData and ObjectData, and how they interact safely with the garbage collector.

@yush-1018 yush-1018 requested a review from a team as a code owner March 14, 2026 10:52
@github-actions
Copy link

github-actions bot commented Mar 14, 2026

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 50,070 50,070 0
Ignored 2,072 2,072 0
Failed 821 821 0
Panics 0 0 0
Conformance 94.54% 94.54% 0.00%

Tested main commit: 3016f492d02a06033e11269fdcef603d293222c4
Tested PR commit: 4e339feb9d549d70879c8dec2ecf89fb11ca4293
Compare commits: 3016f49...4e339fe

@codecov
Copy link

codecov bot commented Mar 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.11%. Comparing base (6ddc2b4) to head (4e339fe).
⚠️ Report is 872 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5061       +/-   ##
===========================================
+ Coverage   47.24%   59.11%   +11.86%     
===========================================
  Files         476      563       +87     
  Lines       46892    62665    +15773     
===========================================
+ Hits        22154    37042    +14888     
- Misses      24738    25623      +885     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +51 to +53
1. `object.downcast_ref::<T>()` -> Returns `Option<&T>` representing an immutable reference to the native object data if the types match.
2. `object.downcast_mut::<T>()` -> Returns `Option<&mut T>` representing a mutable reference to the native object data.
3. `object.borrow_mut()` -> Often used when working closely with garbage collected `NativeObject`s that need interior mutability inside contexts.
Copy link
Member

Choose a reason for hiding this comment

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

You might also wanna mention downcast, which returns a typed JsObject<T> that can be borrowed later without losing the type information.

@jedel1043 jedel1043 added Waiting On Review Waiting on reviews from the maintainers and removed waiting-for-review labels Mar 15, 2026
@github-actions github-actions bot added C-Documentation update documentation C-Builtins PRs and Issues related to builtins/intrinsics labels Mar 15, 2026
@jedel1043 jedel1043 added this to the v1.0.0 milestone Mar 16, 2026
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 great!

@jedel1043 jedel1043 added this pull request to the merge queue Mar 16, 2026
Merged via the queue into boa-dev:main with commit 3f04847 Mar 17, 2026
21 checks passed
@github-actions github-actions bot removed the Waiting On Review Waiting on reviews from the maintainers label Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Builtins PRs and Issues related to builtins/intrinsics C-Documentation update documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create design notes for documentation purposes

2 participants