Skip to content

Conversation

@brendandahl
Copy link
Collaborator

This change adds support for using argument policies with val::set, val::operator(), val::call, val::new_, and the val constructor.

Previously, these methods used default behavior (usually copy) or required manual handling. Now policies like policy::take_ownership or policy::reference can be used directly to control how values are passed between C++ and JS.

See test/embind/test_val.cpp for usage examples.

Fixes #25412

This change adds support for using argument policies with val::set,
val::operator(), val::call, val::new_, and the val constructor.

Previously, these methods used default behavior (usually copy) or required
manual handling. Now policies like policy::take_ownership or
policy::reference can be used directly to control how values are passed
between C++ and JS.

See test/embind/test_val.cpp for usage examples.

Fixes emscripten-core#25412
@brendandahl
Copy link
Collaborator Author

Another idea I've been toying with is to rely more on the C++ semantics. i.e. values are moved if possible, otherwise they're copied. Pointers would be how you reference an object. The downside of that approach is it doesn't really signal whether JS should delete the object or it's managed by C++.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid copying rvalue object passed to Embind

1 participant