From 34caa8d552c2fef0b10cdf07135b632cdc1b9984 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sun, 30 Apr 2023 03:28:33 -0700 Subject: [PATCH] Refactor: Pass jsi::Runtime to getArgumentTypeName Summary: ObjCTurboModule::getArgumentTypeName: 1. Only called from JavaScript. 2. Can raise exceptions. Thread the jsi::Runtime through this method: 1. So that it can throw jsi::JSErrors. 2. To enfore that it be called from JavaScript. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D44887177 fbshipit-source-id: 170399c2919f56d4c15593adf76ec50c061cce69 --- .../core/platform/ios/ReactCommon/RCTTurboModule.h | 2 +- .../core/platform/ios/ReactCommon/RCTTurboModule.mm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.h b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.h index b627bde2b08..1021b3adce6 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.h +++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.h @@ -81,7 +81,7 @@ class JSI_EXPORT ObjCTurboModule : public TurboModule { bool isMethodSync(TurboModuleMethodValueKind returnType); BOOL hasMethodArgConversionSelector(NSString *methodName, int argIndex); SEL getMethodArgConversionSelector(NSString *methodName, int argIndex); - NSString *getArgumentTypeName(NSString *methodName, int argIndex); + NSString *getArgumentTypeName(jsi::Runtime &runtime, NSString *methodName, int argIndex); NSInvocation *createMethodInvocation( jsi::Runtime &runtime, bool isSync, diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm index 36e781962cd..359747b02c5 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm +++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm @@ -494,7 +494,7 @@ jsi::Value ObjCTurboModule::convertReturnIdToJSIValue( * Note: This is only being introduced for backward compatibility. It will be removed * in the future. */ -NSString *ObjCTurboModule::getArgumentTypeName(NSString *methodName, int argIndex) +NSString *ObjCTurboModule::getArgumentTypeName(jsi::Runtime &runtime, NSString *methodName, int argIndex) { if (!methodArgumentTypeNames_) { NSMutableDictionary *> *methodArgumentTypeNames = [NSMutableDictionary new]; @@ -595,7 +595,7 @@ void ObjCTurboModule::setInvocationArg( * Convert objects using RCTConvert. */ if (objCArgType == @encode(id)) { - NSString *argumentType = getArgumentTypeName(methodNameNSString, i); + NSString *argumentType = getArgumentTypeName(runtime, methodNameNSString, i); if (argumentType != nil) { NSString *rctConvertMethodName = [NSString stringWithFormat:@"%@:", argumentType]; SEL rctConvertSelector = NSSelectorFromString(rctConvertMethodName);