diff --git a/packages/react-native/React/CxxBridge/NSDataBigString.h b/packages/react-native/React/CxxBridge/NSDataBigString.h index b8c571f81826..4162b756ba37 100644 --- a/packages/react-native/React/CxxBridge/NSDataBigString.h +++ b/packages/react-native/React/CxxBridge/NSDataBigString.h @@ -7,6 +7,8 @@ #import +#ifdef __cplusplus + #include namespace facebook::react { @@ -38,3 +40,5 @@ class NSDataBigString : public JSBigString { }; } // namespace facebook::react + +#endif // __cplusplus diff --git a/packages/react-native/React/CxxBridge/RCTCxxBridgeDelegate.h b/packages/react-native/React/CxxBridge/RCTCxxBridgeDelegate.h index e2d48db4548d..c17fe43aa088 100644 --- a/packages/react-native/React/CxxBridge/RCTCxxBridgeDelegate.h +++ b/packages/react-native/React/CxxBridge/RCTCxxBridgeDelegate.h @@ -5,9 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -#include +#ifdef __cplusplus -#import +#include namespace facebook::react { @@ -15,11 +15,16 @@ class JSExecutorFactory; } // namespace facebook::react +#endif // __cplusplus + +#import + // This is a separate class so non-C++ implementations don't need to // take a C++ dependency. @protocol RCTCxxBridgeDelegate +#ifdef __cplusplus /** * In the RCTCxxBridge, if this method is implemented, return a * ExecutorFactory instance which can be used to create the executor. @@ -27,5 +32,6 @@ class JSExecutorFactory; * will be used with a JSCRuntime. */ - (std::unique_ptr)jsExecutorFactoryForBridge:(RCTBridge *)bridge; +#endif // __cplusplus @end diff --git a/packages/react-native/React/CxxBridge/RCTJSIExecutorRuntimeInstaller.h b/packages/react-native/React/CxxBridge/RCTJSIExecutorRuntimeInstaller.h index a258102a21ff..9508d5e458d5 100644 --- a/packages/react-native/React/CxxBridge/RCTJSIExecutorRuntimeInstaller.h +++ b/packages/react-native/React/CxxBridge/RCTJSIExecutorRuntimeInstaller.h @@ -6,6 +6,7 @@ */ #pragma once +#ifdef __cplusplus #include @@ -19,3 +20,5 @@ JSIExecutor::RuntimeInstaller RCTJSIExecutorRuntimeInstaller( JSIExecutor::RuntimeInstaller runtimeInstallerToWrap); } // namespace facebook::react + +#endif // __cplusplus diff --git a/packages/react-native/React/CxxBridge/RCTMessageThread.h b/packages/react-native/React/CxxBridge/RCTMessageThread.h index 1232a9e6bc2b..a0c2b95d401d 100644 --- a/packages/react-native/React/CxxBridge/RCTMessageThread.h +++ b/packages/react-native/React/CxxBridge/RCTMessageThread.h @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#ifdef __cplusplus + #import #import @@ -37,3 +39,5 @@ class RCTMessageThread : public MessageQueueThread, }; } // namespace facebook::react + +#endif // __cplusplus diff --git a/packages/react-native/React/CxxBridge/RCTObjcExecutor.h b/packages/react-native/React/CxxBridge/RCTObjcExecutor.h index 87ad0858f505..fe149f95f1ae 100644 --- a/packages/react-native/React/CxxBridge/RCTObjcExecutor.h +++ b/packages/react-native/React/CxxBridge/RCTObjcExecutor.h @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#ifdef __cplusplus + #include #include @@ -29,3 +31,5 @@ class RCTObjcExecutorFactory : public JSExecutorFactory { }; } // namespace facebook::react + +#endif // __cplusplus diff --git a/packages/react-native/React/CxxModule/DispatchMessageQueueThread.h b/packages/react-native/React/CxxModule/DispatchMessageQueueThread.h index a8b755bd52c5..4a581d0cbf84 100644 --- a/packages/react-native/React/CxxModule/DispatchMessageQueueThread.h +++ b/packages/react-native/React/CxxModule/DispatchMessageQueueThread.h @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#ifdef __cplusplus + #include #include @@ -43,3 +45,5 @@ class DispatchMessageQueueThread : public MessageQueueThread { }; } // namespace facebook::react + +#endif // __cplusplus diff --git a/packages/react-native/React/CxxModule/RCTCxxMethod.h b/packages/react-native/React/CxxModule/RCTCxxMethod.h index f126032dca48..f409091ca8be 100644 --- a/packages/react-native/React/CxxModule/RCTCxxMethod.h +++ b/packages/react-native/React/CxxModule/RCTCxxMethod.h @@ -8,10 +8,15 @@ #import #import + +#ifdef __cplusplus #import +#endif // __cplusplus @interface RCTCxxMethod : NSObject +#ifdef __cplusplus - (instancetype)initWithCxxMethod:(const facebook::xplat::module::CxxModule::Method &)cxxMethod; +#endif // __cplusplus @end diff --git a/packages/react-native/React/CxxModule/RCTCxxModule.h b/packages/react-native/React/CxxModule/RCTCxxModule.h index 093aafee890b..304149025f77 100644 --- a/packages/react-native/React/CxxModule/RCTCxxModule.h +++ b/packages/react-native/React/CxxModule/RCTCxxModule.h @@ -5,16 +5,20 @@ * LICENSE file in the root directory of this source tree. */ -#import - #import #import +#ifdef __cplusplus + +#import + namespace facebook::xplat::module { class CxxModule; } // namespace facebook::react::module +#endif // __cplusplus + /** * Subclass RCTCxxModule to use cross-platform CxxModule on iOS. * @@ -23,7 +27,9 @@ class CxxModule; */ @interface RCTCxxModule : NSObject +#ifdef __cplusplus // To be implemented by subclasses - (std::unique_ptr)createModule; +#endif // __cplusplus @end diff --git a/packages/react-native/React/CxxModule/RCTCxxUtils.h b/packages/react-native/React/CxxModule/RCTCxxUtils.h index b4411088e19f..402cdc06625b 100644 --- a/packages/react-native/React/CxxModule/RCTCxxUtils.h +++ b/packages/react-native/React/CxxModule/RCTCxxUtils.h @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#ifdef __cplusplus + #include #include @@ -25,3 +27,5 @@ NSError *tryAndReturnError(const std::function &func); NSString *deriveSourceURL(NSURL *url); } // namespace facebook::react + +#endif // __cplusplus diff --git a/packages/react-native/React/CxxModule/RCTNativeModule.h b/packages/react-native/React/CxxModule/RCTNativeModule.h index 730839a9b52e..6f18be87524f 100644 --- a/packages/react-native/React/CxxModule/RCTNativeModule.h +++ b/packages/react-native/React/CxxModule/RCTNativeModule.h @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#ifdef __cplusplus + #import #import @@ -30,3 +32,5 @@ class RCTNativeModule : public NativeModule { }; } // namespace facebook::react + +#endif // __cplusplus diff --git a/packages/react-native/React/CxxUtils/RCTFollyConvert.h b/packages/react-native/React/CxxUtils/RCTFollyConvert.h index 7da61aa9bd55..95ba5b06cf72 100644 --- a/packages/react-native/React/CxxUtils/RCTFollyConvert.h +++ b/packages/react-native/React/CxxUtils/RCTFollyConvert.h @@ -7,6 +7,8 @@ #import +#ifdef __cplusplus + #include namespace facebook::react { @@ -15,3 +17,5 @@ folly::dynamic convertIdToFollyDynamic(id json); id convertFollyDynamicToId(const folly::dynamic &dyn); } // namespace facebook::react + +#endif // __cplusplus