Skip to content

Conversation

vmoroz
Copy link
Member

@vmoroz vmoroz commented Jan 4, 2021

Cherry pick the #6804 from master branch: Enable support for C++ TurboModules
The #6804 description:

In this PR we enable support for C++ TurboModules as they defined in react-native package.
The C++ TurboModules use JSI and we can enable their support based on our ABI-safe JSI implementation.
The only additional code that we needed to add is the ABI-safe wrapper for CallInvoker and ABI-safe registration of TurboModules.
The TurboModules can use the same base types as in the react-native package.
Though we had to do a small fix to the TurboModuleUtils.h to avoid unnecessary dependency on Folly.

We have added new JsiTurboModuleTests to test the use of the TurboModules.
It shows that the TurboModule must be inherited from the facebook::jsi::TurboModule and registered using the Package provider that might look as in the test:

struct MySimpleTurboModulePackageProvider
    : winrt::implements<MySimpleTurboModulePackageProvider, IReactPackageProvider> {
  void CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept {
    AddTurboModuleProvider<MySimpleTurboModule>(packageBuilder, L"MySimpleTurboModule");
  }
};

This code uses the new AddTurboModuleProvider method to create an ABI safe provider for the TurboModule.

Note that C++ TurboModule use code generation. In this PR we do not implement the code generation. We just provide a foundation for it. The code generation will be added in the follow up PRs.

Microsoft Reviewers: Open in CodeFlow

* Enable support for C++ TurboModules

* Change files

* Fix compilation issues

* Attempt to fix the CLI test for Nuget with binaries

* Address PR feedback

* Format code

* Address PR feedback

* Throw an exception in AbiCallInvoker::invokeSync as in Instance::JSCallInvoker::invokeSync

* Format code
# Conflicts:
#	vnext/JSI/Universal/ChakraJsiRuntime_edgemode.cpp
@vmoroz vmoroz requested a review from a team as a code owner January 4, 2021 22:21
@vmoroz vmoroz added the AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) label Jan 4, 2021
@ghost
Copy link

ghost commented Jan 4, 2021

Hello @vmoroz!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 10 hours, a condition that will be fulfilled in about 9 hours 55 minutes. No worries though, I will be back when the time is right! 😉

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

Copy link

@NikoAri NikoAri left a comment

Choose a reason for hiding this comment

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

:shipit:

@vmoroz vmoroz removed the AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) label Jan 5, 2021
@vmoroz vmoroz added the AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) label Jan 5, 2021
@vmoroz vmoroz merged commit 54b8873 into microsoft:0.64-stable Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants