From a320dce2fd654d477de114be5fc87ce0b182fb45 Mon Sep 17 00:00:00 2001 From: Phillip Pan Date: Thu, 11 May 2023 21:45:50 -0700 Subject: [PATCH] introduce RCTHostCreationHelpers (#37328) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37328 Changelog: [Internal] in this diff, i introduced a C function to be used to create RCTHost that obfuscates away all the C++ arguments. i expect this to be the API that the vast majority of the community will use to create `RCTHost`. Reviewed By: cipolleschi Differential Revision: D45678970 fbshipit-source-id: e3479db1bb68d93b3ee2f02598413d2080bb5ea9 --- .../ios/Core/RCTHostCreationHelpers.h | 29 +++++++++++++++++++ .../ios/Core/RCTHostCreationHelpers.mm | 19 ++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.h create mode 100644 packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.mm diff --git a/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.h b/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.h new file mode 100644 index 00000000000000..5006e14ef0c63a --- /dev/null +++ b/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import +#import + +#import "RCTHost.h" + +@class RCTHost; + +@protocol RCTHostDelegate; +@protocol RCTTurboModuleManagerDelegate; + +NS_ASSUME_NONNULL_BEGIN + +RCT_EXTERN_C_BEGIN + +RCTHost *RCTHostCreateDefault( + id hostDelegate, + id turboModuleManagerDelegate, + RCTHostJSEngineProvider jsEngineProvider); + +RCT_EXTERN_C_END + +NS_ASSUME_NONNULL_END diff --git a/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.mm b/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.mm new file mode 100644 index 00000000000000..31d1af728d2691 --- /dev/null +++ b/packages/react-native/ReactCommon/react/bridgeless/platform/ios/Core/RCTHostCreationHelpers.mm @@ -0,0 +1,19 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import "RCTHostCreationHelpers.h" + +RCTHost *RCTHostCreateDefault( + id hostDelegate, + id turboModuleManagerDelegate, + RCTHostJSEngineProvider jsEngineProvider) +{ + return [[RCTHost alloc] initWithHostDelegate:hostDelegate + turboModuleManagerDelegate:turboModuleManagerDelegate + bindingsInstallFunc:nullptr + jsEngineProvider:jsEngineProvider]; +}