From aa068e05ced8f21839e9f14e124beef9b77f51b6 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Tue, 7 Jun 2022 07:42:49 -0700 Subject: [PATCH] Make all headers public and add #ifdef __cplusplus (#1150) Summary: This change is mostly needed to support the new react-native architecture with Swift. Some private yoga headers end up being included in the swift build and result in compilation failure since swift cannot compile c++ modules. See https://github.com/facebook/react-native/pull/33381. The most reliable fix is to include all headers as public headers, and add `#ifdef __cplusplus` to those that include c++. This is already what we do for other headers, this applies this to all headers. Tested in the YogaKitSample, and also in a react-native app. Changelog: [iOS] [Changed] - Make all Yoga headers public and add #ifdef __cplusplus X-link: https://github.com/facebook/yoga/pull/1150 Reviewed By: dmitryrykun Differential Revision: D36966687 Pulled By: cortinico fbshipit-source-id: a34a54d56df43ab4934715070bab8e790b9abd39 --- ReactCommon/yoga/yoga/BitUtils.h | 4 ++++ ReactCommon/yoga/yoga/CompactValue.h | 4 ++++ ReactCommon/yoga/yoga/Utils.h | 5 +++++ ReactCommon/yoga/yoga/YGConfig.h | 5 +++++ ReactCommon/yoga/yoga/YGFloatOptional.h | 4 ++++ ReactCommon/yoga/yoga/YGLayout.h | 5 +++++ ReactCommon/yoga/yoga/YGNodePrint.h | 7 +++++++ ReactCommon/yoga/yoga/Yoga-internal.h | 5 +++++ ReactCommon/yoga/yoga/log.h | 4 ++++ 9 files changed, 43 insertions(+) diff --git a/ReactCommon/yoga/yoga/BitUtils.h b/ReactCommon/yoga/yoga/BitUtils.h index b17751ad331..a60ea7609ca 100644 --- a/ReactCommon/yoga/yoga/BitUtils.h +++ b/ReactCommon/yoga/yoga/BitUtils.h @@ -7,6 +7,8 @@ #pragma once +#ifdef __cplusplus + #include #include #include "YGEnums.h" @@ -65,3 +67,5 @@ inline void setBooleanData(uint8_t& flags, size_t index, bool value) { } // namespace detail } // namespace yoga } // namespace facebook + +#endif diff --git a/ReactCommon/yoga/yoga/CompactValue.h b/ReactCommon/yoga/yoga/CompactValue.h index 6879ca146ff..1f03cf721aa 100644 --- a/ReactCommon/yoga/yoga/CompactValue.h +++ b/ReactCommon/yoga/yoga/CompactValue.h @@ -7,6 +7,8 @@ #pragma once +#ifdef __cplusplus + #include "YGValue.h" #include "YGMacros.h" #include @@ -182,3 +184,5 @@ constexpr bool operator!=(CompactValue a, CompactValue b) noexcept { } // namespace detail } // namespace yoga } // namespace facebook + +#endif diff --git a/ReactCommon/yoga/yoga/Utils.h b/ReactCommon/yoga/yoga/Utils.h index d21e8ecb32b..8588ecc5946 100644 --- a/ReactCommon/yoga/yoga/Utils.h +++ b/ReactCommon/yoga/yoga/Utils.h @@ -6,6 +6,9 @@ */ #pragma once + +#ifdef __cplusplus + #include "YGNode.h" #include "Yoga-internal.h" #include "CompactValue.h" @@ -145,3 +148,5 @@ inline YGFloatOptional YGResolveValueMargin( } void throwLogicalErrorWithMessage(const char* message); + +#endif diff --git a/ReactCommon/yoga/yoga/YGConfig.h b/ReactCommon/yoga/yoga/YGConfig.h index 607408ace4b..e15cc122533 100644 --- a/ReactCommon/yoga/yoga/YGConfig.h +++ b/ReactCommon/yoga/yoga/YGConfig.h @@ -6,6 +6,9 @@ */ #pragma once + +#ifdef __cplusplus + #include "Yoga-internal.h" #include "Yoga.h" @@ -74,3 +77,5 @@ public: setCloneNodeCallback(YGCloneNodeFunc{nullptr}); } }; + +#endif diff --git a/ReactCommon/yoga/yoga/YGFloatOptional.h b/ReactCommon/yoga/yoga/YGFloatOptional.h index 4aa9e76e299..6af7bbafbfb 100644 --- a/ReactCommon/yoga/yoga/YGFloatOptional.h +++ b/ReactCommon/yoga/yoga/YGFloatOptional.h @@ -7,6 +7,8 @@ #pragma once +#ifdef __cplusplus + #include #include #include "Yoga-internal.h" @@ -68,3 +70,5 @@ inline bool operator>=(YGFloatOptional lhs, YGFloatOptional rhs) { inline bool operator<=(YGFloatOptional lhs, YGFloatOptional rhs) { return lhs < rhs || lhs == rhs; } + +#endif diff --git a/ReactCommon/yoga/yoga/YGLayout.h b/ReactCommon/yoga/yoga/YGLayout.h index 6c23934207e..e3a4a1943b2 100644 --- a/ReactCommon/yoga/yoga/YGLayout.h +++ b/ReactCommon/yoga/yoga/YGLayout.h @@ -6,6 +6,9 @@ */ #pragma once + +#ifdef __cplusplus + #include "BitUtils.h" #include "YGFloatOptional.h" #include "Yoga-internal.h" @@ -85,3 +88,5 @@ public: bool operator==(YGLayout layout) const; bool operator!=(YGLayout layout) const { return !(*this == layout); } }; + +#endif diff --git a/ReactCommon/yoga/yoga/YGNodePrint.h b/ReactCommon/yoga/yoga/YGNodePrint.h index 0e25b9728b0..83b3f860e4b 100644 --- a/ReactCommon/yoga/yoga/YGNodePrint.h +++ b/ReactCommon/yoga/yoga/YGNodePrint.h @@ -6,7 +6,11 @@ */ #ifdef DEBUG + #pragma once + +#ifdef __cplusplus + #include #include "Yoga.h" @@ -22,4 +26,7 @@ void YGNodeToString( } // namespace yoga } // namespace facebook + +#endif + #endif diff --git a/ReactCommon/yoga/yoga/Yoga-internal.h b/ReactCommon/yoga/yoga/Yoga-internal.h index 08f9da171c0..492543ef1d6 100644 --- a/ReactCommon/yoga/yoga/Yoga-internal.h +++ b/ReactCommon/yoga/yoga/Yoga-internal.h @@ -6,6 +6,9 @@ */ #pragma once + +#ifdef __cplusplus + #include #include #include @@ -148,3 +151,5 @@ static const float kDefaultFlexShrink = 0.0f; static const float kWebDefaultFlexShrink = 1.0f; extern bool YGFloatsEqual(const float a, const float b); + +#endif diff --git a/ReactCommon/yoga/yoga/log.h b/ReactCommon/yoga/yoga/log.h index 1d270e82e40..b9bfea4f390 100644 --- a/ReactCommon/yoga/yoga/log.h +++ b/ReactCommon/yoga/yoga/log.h @@ -7,6 +7,8 @@ #pragma once +#ifdef __cplusplus + #include "YGEnums.h" struct YGNode; @@ -36,3 +38,5 @@ struct Log { } // namespace detail } // namespace yoga } // namespace facebook + +#endif