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 735352de50f..4555e46f4db 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 @@ -28,6 +28,10 @@ namespace facebook::react { class CallbackWrapper; class Instance; +namespace TurboModuleConvertUtils { +jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value); +} + /** * ObjC++ specific TurboModule base class. */ 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 8656fe03622..594e2fb8c9f 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 @@ -29,6 +29,7 @@ using namespace facebook; using namespace facebook::react; +using namespace facebook::react::TurboModuleConvertUtils; static int32_t getUniqueId() { @@ -36,6 +37,10 @@ static int32_t getUniqueId() return counter++; } +namespace facebook { +namespace react { + +namespace TurboModuleConvertUtils { /** * All static helper functions are ObjC++ specific. */ @@ -54,7 +59,7 @@ static jsi::String convertNSStringToJSIString(jsi::Runtime &runtime, NSString *v return jsi::String::createFromUtf8(runtime, [value UTF8String] ?: ""); } -static jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value); +jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value); static jsi::Object convertNSDictionaryToJSIObject(jsi::Runtime &runtime, NSDictionary *value) { jsi::Object result = jsi::Object(runtime); @@ -82,7 +87,7 @@ static std::vector convertNSArrayToStdVector(jsi::Runtime &runtime, return result; } -static jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value) +jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value) { if ([value isKindOfClass:[NSString class]]) { return convertNSStringToJSIString(runtime, (NSString *)value); @@ -211,8 +216,6 @@ convertJSIFunctionToCallback(jsi::Runtime &runtime, const jsi::Function &value, return [callback copy]; } -namespace facebook::react { - static jsi::Value createJSRuntimeError(jsi::Runtime &runtime, const std::string &message) { return runtime.global().getPropertyAsFunction(runtime, "Error").call(runtime, message); @@ -237,6 +240,8 @@ static jsi::JSError convertNSExceptionToJSError(jsi::Runtime &runtime, NSExcepti return {runtime, std::move(error)}; } +} + jsi::Value ObjCTurboModule::createPromise(jsi::Runtime &runtime, std::string methodName, PromiseInvocationBlock invoke) { if (!invoke) { @@ -771,4 +776,5 @@ void ObjCTurboModule::setMethodArgConversionSelector(NSString *methodName, int a methodArgConversionSelectors_[methodName][argIndex] = selectorValue; } +} } // namespace facebook::react