Skip to content

[0.64] Enable support for C++ TurboModules (#6804) - #6814

Merged
Vladimir Morozov (vmoroz) merged 2 commits into
microsoft:0.64-stablefrom
vmoroz:PR/0.64-SupportTurboModules
Jan 5, 2021
Merged

[0.64] Enable support for C++ TurboModules (#6804)#6814
Vladimir Morozov (vmoroz) merged 2 commits into
microsoft:0.64-stablefrom
vmoroz:PR/0.64-SupportTurboModules

Conversation

@vmoroz

@vmorozVladimir Morozov (vmoroz) commented Jan 4, 2021

Copy link
Copy Markdown
Member

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:

structMySimpleTurboModulePackageProvider
: winrt::implements<MySimpleTurboModulePackageProvider, IReactPackageProvider> {
voidCreatePackage(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
@vmorozVladimir Morozov (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
Copy Markdown

Hello Vladimir Morozov (@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.

Comment threadvnext/Microsoft.ReactNative.Cxx/TurboModuleProvider.h
Comment threadvnext/Microsoft.ReactNative.Cxx/JSI/JsiApiContext.h
Comment threadvnext/Microsoft.ReactNative.Cxx/JSI/JsiApiContext.h

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

:shipit:

@vmorozVladimir Morozov (vmoroz) removed the AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) label Jan 5, 2021
@vmorozVladimir Morozov (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
Vladimir Morozov (vmoroz) merged commit 54b8873 into microsoft:0.64-stableJan 5, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AutoMergeCauses 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

@vmoroz@NikoAri