C++ 17 style nested namespaces (#1326)
Summary: X-link: https://github.com/facebook/react-native/pull/38304 Pull Request resolved: https://github.com/facebook/yoga/pull/1326 For better readability Reviewed By: christophpurrer Differential Revision: D47384926 fbshipit-source-id: 2f60d50a185331b3624d45d1fc45f98d504b3034
This commit is contained in:
committed by
Facebook GitHub Bot
parent
423dc155d8
commit
660edcec20
@@ -13,10 +13,7 @@
|
||||
|
||||
#include <yoga/YGEnums.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
|
||||
namespace detail {
|
||||
namespace facebook::yoga::detail {
|
||||
|
||||
// std::bitset with one bit for each option defined in YG_ENUM_SEQ_DECL
|
||||
template <typename Enum>
|
||||
@@ -68,6 +65,4 @@ inline void setBooleanData(uint8_t& flags, size_t index, bool value) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
} // namespace facebook::yoga::detail
|
||||
|
@@ -38,9 +38,7 @@ static_assert(
|
||||
#define VISIBLE_FOR_TESTING private:
|
||||
#endif
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace detail {
|
||||
namespace facebook::yoga::detail {
|
||||
|
||||
// This class stores YGValue in 32 bits.
|
||||
// - The value does not matter for Undefined and Auto. NaNs are used for their
|
||||
@@ -209,6 +207,4 @@ constexpr bool operator!=(CompactValue a, CompactValue b) noexcept {
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
} // namespace facebook::yoga::detail
|
||||
|
@@ -9,16 +9,14 @@
|
||||
|
||||
using namespace facebook::yoga;
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace facebook::yoga {
|
||||
bool configUpdateInvalidatesLayout(YGConfigRef a, YGConfigRef b) {
|
||||
return a->getErrata() != b->getErrata() ||
|
||||
a->getEnabledExperiments() != b->getEnabledExperiments() ||
|
||||
a->getPointScaleFactor() != b->getPointScaleFactor() ||
|
||||
a->useWebDefaults() != b->useWebDefaults();
|
||||
}
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
} // namespace facebook::yoga
|
||||
|
||||
YGConfig::YGConfig(YGLogger logger) : cloneNodeCallback_{nullptr} {
|
||||
setLogger(logger);
|
||||
|
@@ -12,8 +12,7 @@
|
||||
#include "BitUtils.h"
|
||||
#include "Yoga-internal.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace facebook::yoga {
|
||||
|
||||
// Whether moving a node from config "a" to config "b" should dirty previously
|
||||
// calculated layout results.
|
||||
@@ -48,8 +47,7 @@ struct YGConfigFlags {
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
} // namespace facebook::yoga
|
||||
|
||||
struct YOGA_EXPORT YGConfig {
|
||||
YGConfig(YGLogger logger);
|
||||
|
@@ -95,9 +95,8 @@
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace enums {
|
||||
|
||||
namespace facebook::yoga::enums {
|
||||
|
||||
template <typename T>
|
||||
constexpr int count(); // can't use `= delete` due to a defect in clang < 3.9
|
||||
@@ -109,9 +108,7 @@ constexpr int n() {
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
} // namespace enums
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
} // namespace facebook::yoga::enums
|
||||
#endif
|
||||
|
||||
#define YG_ENUM_DECL(NAME, ...) \
|
||||
@@ -122,16 +119,13 @@ constexpr int n() {
|
||||
#define YG_ENUM_SEQ_DECL(NAME, ...) \
|
||||
YG_ENUM_DECL(NAME, __VA_ARGS__) \
|
||||
YG_EXTERN_C_END \
|
||||
namespace facebook { \
|
||||
namespace yoga { \
|
||||
namespace enums { \
|
||||
\
|
||||
namespace facebook::yoga::enums { \
|
||||
template <> \
|
||||
constexpr int count<NAME>() { \
|
||||
return detail::n<__VA_ARGS__>(); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
YG_EXTERN_C_BEGIN
|
||||
#else
|
||||
#define YG_ENUM_SEQ_DECL YG_ENUM_DECL
|
||||
|
@@ -16,8 +16,7 @@
|
||||
#include "Yoga-internal.h"
|
||||
#include "Utils.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace facebook::yoga {
|
||||
typedef std::string string;
|
||||
|
||||
static void indent(string& base, uint32_t level) {
|
||||
@@ -242,6 +241,6 @@ void YGNodeToString(
|
||||
}
|
||||
appendFormattedString(str, "</div>");
|
||||
}
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
|
||||
} // namespace facebook::yoga
|
||||
#endif
|
||||
|
@@ -13,8 +13,7 @@
|
||||
|
||||
#include <yoga/Yoga.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace facebook::yoga {
|
||||
|
||||
void YGNodeToString(
|
||||
std::string& str,
|
||||
@@ -22,7 +21,6 @@ void YGNodeToString(
|
||||
YGPrintOptions options,
|
||||
uint32_t level);
|
||||
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
} // namespace facebook::yoga
|
||||
|
||||
#endif
|
||||
|
@@ -33,8 +33,7 @@ void YGNodeDeallocate(YGNodeRef node);
|
||||
|
||||
YG_EXTERN_C_END
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace facebook::yoga {
|
||||
|
||||
inline bool isUndefined(float value) {
|
||||
return std::isnan(value);
|
||||
@@ -46,8 +45,7 @@ inline bool isUndefined(double value) {
|
||||
|
||||
void throwLogicalErrorWithMessage(const char* message);
|
||||
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
} // namespace facebook::yoga
|
||||
|
||||
extern const std::array<YGEdge, 4> trailing;
|
||||
extern const std::array<YGEdge, 4> leading;
|
||||
@@ -103,9 +101,7 @@ struct YGCachedMeasurement {
|
||||
// 98% of analyzed layouts require less than 8 entries.
|
||||
#define YG_MAX_CACHED_RESULT_COUNT 8
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace detail {
|
||||
namespace facebook::yoga::detail {
|
||||
|
||||
template <size_t Size>
|
||||
class Values {
|
||||
@@ -149,9 +145,8 @@ public:
|
||||
|
||||
Values& operator=(const Values& other) = default;
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
|
||||
} // namespace facebook::yoga::detail
|
||||
|
||||
static const float kDefaultFlexGrow = 0.0f;
|
||||
static const float kDefaultFlexShrink = 0.0f;
|
||||
|
@@ -9,8 +9,7 @@
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace facebook::yoga {
|
||||
|
||||
const char* LayoutPassReasonToString(const LayoutPassReason value) {
|
||||
switch (value) {
|
||||
@@ -82,5 +81,4 @@ void Event::publish(const YGNode& node, Type eventType, const Data& eventData) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
} // namespace facebook::yoga
|
||||
|
@@ -16,8 +16,7 @@
|
||||
struct YGConfig;
|
||||
struct YGNode;
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace facebook::yoga {
|
||||
|
||||
enum struct LayoutType : int {
|
||||
kLayout = 0,
|
||||
@@ -140,5 +139,4 @@ struct Event::TypedData<Event::NodeLayout> {
|
||||
void* layoutContext;
|
||||
};
|
||||
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
} // namespace facebook::yoga
|
||||
|
@@ -11,9 +11,7 @@
|
||||
#include "YGConfig.h"
|
||||
#include "YGNode.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace detail {
|
||||
namespace facebook::yoga::detail {
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -59,6 +57,4 @@ void Log::log(
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
} // namespace facebook::yoga::detail
|
||||
|
@@ -12,10 +12,7 @@
|
||||
struct YGNode;
|
||||
struct YGConfig;
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
|
||||
namespace detail {
|
||||
namespace facebook::yoga::detail {
|
||||
|
||||
struct Log {
|
||||
static void log(
|
||||
@@ -33,6 +30,4 @@ struct Log {
|
||||
...) noexcept;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
} // namespace facebook::yoga::detail
|
||||
|
Reference in New Issue
Block a user