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

Add C++20 std::span-based APIs for function arguments #43489

Closed
wants to merge 1 commit into from

Conversation

motiz88
Copy link
Contributor

@motiz88 motiz88 commented Mar 14, 2024

Differential Revision: D54901847

Changelog: [General][Changed] - Add std::span methods to jsi::Function when compiled as C++20

Adds std::span<const jsi::Value> overloads to public JSI methods that currently accept (or are designed to emit) const jsi::Value* args, size_t count for a dynamically-sized span of function arguments.

These are:

  • Function::call
  • Function::callWithThis
  • Function::callAsConstructor
  • Function::createFromHostFunction

We also add a HostFunctionTypeWithSpanArgs typedef (naming feedback welcome!) to serve a similar purpose to the existing HostFunctionType.

Backwards compatibility

  • The new APIs are compiled conditionally to support pre-C++20 compilers.
  • No overloads are removed.
  • The new overloads are implemented as inline wrappers over the pointer+size versions. No change is made to the JSI contract for implementers (i.e. no new overloads, virtual or otherwise, are added to Runtime).

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 14, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D54901847

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D54901847

motiz88 added a commit to motiz88/react-native that referenced this pull request Mar 14, 2024
Summary:

Changelog: [General][Changed] - Add `std::span` methods to `jsi::Function` when compiled as C++20

Adds `std::span<const jsi::Value>` overloads to public JSI methods that currently accept (or are designed to emit) `const jsi::Value* args, size_t count` for a dynamically-sized span of function arguments.

These are:
* `Function::call`
* `Function::callWithThis`
* `Function::callAsConstructor`
* `Function::createFromHostFunction`

We also add a `HostFunctionTypeWithSpanArgs` typedef (naming feedback welcome!) to serve a similar purpose to the existing `HostFunctionType`.

## Backwards compatibility

* The new APIs are compiled conditionally to support pre-C++20 compilers.
* No overloads are removed.
* The new overloads are implemented as `inline` wrappers over the pointer+size versions. No change is made to the JSI contract for implementers (i.e. no new overloads, virtual or otherwise, are added to `Runtime`).

Differential Revision: D54901847
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D54901847

motiz88 added a commit to motiz88/react-native that referenced this pull request Mar 15, 2024
Summary:

Changelog: [General][Changed] - Add `std::span` methods to `jsi::Function` when compiled as C++20

Adds `std::span<const jsi::Value>` overloads to public JSI methods that currently accept (or are designed to emit) `const jsi::Value* args, size_t count` for a dynamically-sized span of function arguments.

These are:
* `Function::call`
* `Function::callWithThis`
* `Function::callAsConstructor`
* `Function::createFromHostFunction`

## Backwards compatibility

* The new APIs are compiled conditionally to support pre-C++20 compilers.
* No overloads are removed.
* The new overloads are implemented as `inline` wrappers over the pointer+size versions.
* No change is made to the JSI contract for implementers (i.e. no new overloads, virtual or otherwise, are added to `Runtime`).

Differential Revision: D54901847
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D54901847

motiz88 added a commit to motiz88/react-native that referenced this pull request Mar 15, 2024
Summary:

Changelog: [General][Changed] - Add `std::span` methods to `jsi::Function` when compiled as C++20

Adds `std::span<const jsi::Value>` overloads to public JSI methods that currently accept (or are designed to emit) `const jsi::Value* args, size_t count` for a dynamically-sized span of function arguments.

These are:
* `Function::call`
* `Function::callWithThis`
* `Function::callAsConstructor`
* `Function::createFromHostFunction`

## Backwards compatibility

* The new APIs are compiled conditionally to support pre-C++20 compilers.
* No overloads are removed.
* The new overloads are implemented as `inline` wrappers over the pointer+size versions.
* No change is made to the JSI contract for implementers (i.e. no new overloads, virtual or otherwise, are added to `Runtime`).

Differential Revision: D54901847
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D54901847

Summary:

Changelog: [General][Changed] - Add `std::span` methods to `jsi::Function` when compiled as C++20

Adds `std::span<const jsi::Value>` overloads to public JSI methods that currently accept (or are designed to emit) `const jsi::Value* args, size_t count` for a dynamically-sized span of function arguments.

These are:
* `Function::call`
* `Function::callWithThis`
* `Function::callAsConstructor`
* `Function::createFromHostFunction`

## Backwards compatibility

* The new APIs are compiled conditionally to support pre-C++20 compilers.
* No overloads are removed, except for `createFromHostFunction` (which has been folded into the template implementation).
* The new overloads are implemented as `inline` wrappers over the pointer+size versions.
* No change is made to the JSI contract for implementers (i.e. no new overloads, virtual or otherwise, are added to `Runtime`).

Differential Revision: D54901847
@motiz88 motiz88 force-pushed the export-D54901847 branch from 3757f82 to 6513db1 Compare April 5, 2024 12:46
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D54901847

@react-native-bot
Copy link
Collaborator

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@react-native-bot react-native-bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 3, 2024
@react-native-bot
Copy link
Collaborator

This PR was closed because it has been stalled for 7 days with no activity.

@react-native-bot react-native-bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants