mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
ObjCTurboModule: Migrate over to id<RCTBridgeModule>
Summary: ## Definitions - **id<RCTBridgeModule>**: A native module object. - **id<RCTTurboModule>**: A turbo module object. ## Changes This diff refactors the ObjCTurboModule, so that it can create perform method dispatch for legacy native module objects. This change shouldn't impact any existing behaviour of the TurboModule system, because all turbo modules are also native modules. ## Rationale In Bridgeless mode, the TurboModule system will now have to manage legacy native modules. Changelog: [Internal] Reviewed By: philIip Differential Revision: D44646371 fbshipit-source-id: 946dcb82bdfced60f5c29fda8e3b4a92cda8acb0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
97c0fc0774
commit
80ecbdf2b2
+2
-2
@@ -40,7 +40,7 @@ class JSI_EXPORT ObjCTurboModule : public TurboModule {
|
||||
// TODO(T65603471): Should we unify this with a Fabric abstraction?
|
||||
struct InitParams {
|
||||
std::string moduleName;
|
||||
id<RCTTurboModule> instance;
|
||||
id<RCTBridgeModule> instance;
|
||||
std::shared_ptr<CallInvoker> jsInvoker;
|
||||
std::shared_ptr<CallInvoker> nativeInvoker;
|
||||
bool isSyncModule;
|
||||
@@ -56,7 +56,7 @@ class JSI_EXPORT ObjCTurboModule : public TurboModule {
|
||||
const jsi::Value *args,
|
||||
size_t count);
|
||||
|
||||
id<RCTTurboModule> instance_;
|
||||
id<RCTBridgeModule> instance_;
|
||||
std::shared_ptr<CallInvoker> nativeInvoker_;
|
||||
|
||||
protected:
|
||||
|
||||
+3
-3
@@ -385,13 +385,13 @@ id ObjCTurboModule::performMethodInvocation(
|
||||
NSMutableArray *retainedObjectsForInvocation)
|
||||
{
|
||||
__block id result;
|
||||
__weak id<RCTTurboModule> weakModule = instance_;
|
||||
__weak id<RCTBridgeModule> weakModule = instance_;
|
||||
const char *moduleName = name_.c_str();
|
||||
std::string methodNameStr{methodName};
|
||||
__block int32_t asyncCallCounter = 0;
|
||||
|
||||
void (^block)() = ^{
|
||||
id<RCTTurboModule> strongModule = weakModule;
|
||||
id<RCTBridgeModule> strongModule = weakModule;
|
||||
if (!strongModule) {
|
||||
return;
|
||||
}
|
||||
@@ -650,7 +650,7 @@ NSInvocation *ObjCTurboModule::createMethodInvocation(
|
||||
NSMutableArray *retainedObjectsForInvocation)
|
||||
{
|
||||
const char *moduleName = name_.c_str();
|
||||
const id<RCTTurboModule> module = instance_;
|
||||
const id<RCTBridgeModule> module = instance_;
|
||||
|
||||
if (isSync) {
|
||||
TurboModulePerfLogger::syncMethodCallArgConversionStart(moduleName, methodName);
|
||||
|
||||
+1
-1
@@ -307,7 +307,7 @@ static Class getFallbackClassFromName(const char *name)
|
||||
if ([module respondsToSelector:@selector(getTurboModule:)]) {
|
||||
ObjCTurboModule::InitParams params = {
|
||||
.moduleName = moduleName,
|
||||
.instance = (id<RCTTurboModule>)module,
|
||||
.instance = module,
|
||||
.jsInvoker = _jsInvoker,
|
||||
.nativeInvoker = nativeInvoker,
|
||||
.isSyncModule = methodQueue == RCTJSThread,
|
||||
|
||||
Reference in New Issue
Block a user