Skip to content

Add a clone_inner method to allow cloning of inner data#3968

Merged
nekevss merged 3 commits intoboa-dev:mainfrom
hansl:jsclass-clone-inner
Aug 27, 2024
Merged

Add a clone_inner method to allow cloning of inner data#3968
nekevss merged 3 commits intoboa-dev:mainfrom
hansl:jsclass-clone-inner

Conversation

@hansl
Copy link
Contributor

@hansl hansl commented Aug 21, 2024

The issue I'm looking to solve is that I'm passing back the same object into JavaScript (think callbacks). The object is reentrant safe, but I'm ending up doing a lot of this.borrow().clone(). This would make it a bit easier to manage.

The JS code looks like that:

const someValue = new ApiClass();
someValue.doSomethingAndCallback(() => {
  // Using a naive but straightforward borrow_mut(), Boa would fail here as
  // the `doSomethingElse` method would need to borrow_mut() again.
  someValue.doSomethingElse();
});

@codecov
Copy link

codecov bot commented Aug 21, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 51.86%. Comparing base (6ddc2b4) to head (43193de).
Report is 244 commits behind head on main.

Files Patch % Lines
core/interop/src/lib.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3968      +/-   ##
==========================================
+ Coverage   47.24%   51.86%   +4.61%     
==========================================
  Files         476      468       -8     
  Lines       46892    45295    -1597     
==========================================
+ Hits        22154    23490    +1336     
+ Misses      24738    21805    -2933     

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

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! I Just have a small doc nitpick.

@jedel1043 jedel1043 added A-Enhancement New feature or request A-API Changes related to public APIs labels Aug 23, 2024
@hansl hansl requested a review from jedel1043 August 26, 2024 17:02
@jedel1043 jedel1043 added this to the next-release milestone Aug 26, 2024
@jedel1043 jedel1043 requested a review from a team August 26, 2024 17:39
@nekevss nekevss added this pull request to the merge queue Aug 27, 2024
Merged via the queue into boa-dev:main with commit c57f231 Aug 27, 2024
hansl added a commit to hansl/boa that referenced this pull request Sep 12, 2024
* Add a clone_inner method to allow cloning of inner data

* oops

* Address comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-API Changes related to public APIs A-Enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants