Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add YGErrata Enum #37076

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.
*/

// @generated by enums.py

package com.facebook.yoga;

public enum YogaErrata {
NONE(0),
STRETCH_FLEX_BASIS(1),
ALL(2147483647),
CLASSIC(2147483646);

private final int mIntValue;

YogaErrata(int intValue) {
mIntValue = intValue;
}

public int intValue() {
return mIntValue;
}

public static YogaErrata fromInt(int value) {
switch (value) {
case 0: return NONE;
case 1: return STRETCH_FLEX_BASIS;
case 2147483647: return ALL;
case 2147483646: return CLASSIC;
default: throw new IllegalArgumentException("Unknown enum value: " + value);
}
}
}
14 changes: 14 additions & 0 deletions packages/react-native/ReactCommon/yoga/yoga/YGEnums.cpp
Original file line number Diff line number Diff line change
@@ -87,6 +87,20 @@ const char* YGEdgeToString(const YGEdge value) {
return "unknown";
}

const char* YGErrataToString(const YGErrata value) {
switch (value) {
case YGErrataNone:
return "none";
case YGErrataStretchFlexBasis:
return "stretch-flex-basis";
case YGErrataAll:
return "all";
case YGErrataClassic:
return "classic";
}
return "unknown";
}

const char* YGExperimentalFeatureToString(const YGExperimentalFeature value) {
switch (value) {
case YGExperimentalFeatureWebFlexBasis:
8 changes: 8 additions & 0 deletions packages/react-native/ReactCommon/yoga/yoga/YGEnums.h
Original file line number Diff line number Diff line change
@@ -54,6 +54,14 @@ YG_ENUM_SEQ_DECL(
YGEdgeVertical,
YGEdgeAll)

YG_ENUM_DECL(
YGErrata,
YGErrataNone = 0,
YGErrataStretchFlexBasis = 1,
YGErrataAll = 2147483647,
YGErrataClassic = 2147483646)
YG_DEFINE_ENUM_FLAG_OPERATORS(YGErrata)

YG_ENUM_SEQ_DECL(
YGExperimentalFeature,
YGExperimentalFeatureWebFlexBasis,
46 changes: 46 additions & 0 deletions packages/react-native/ReactCommon/yoga/yoga/YGMacros.h
Original file line number Diff line number Diff line change
@@ -7,6 +7,10 @@

#pragma once

#ifdef __cplusplus
#include <type_traits>
#endif

#ifdef __cplusplus
#define YG_EXTERN_C_BEGIN extern "C" {
#define YG_EXTERN_C_END }
@@ -40,6 +44,48 @@
#define YG_ENUM_END(name) name
#endif

#ifdef __cplusplus
#define YG_DEFINE_ENUM_FLAG_OPERATORS(name) \
extern "C++" { \
constexpr inline name operator~(name a) { \
return static_cast<name>( \
~static_cast<std::underlying_type<name>::type>(a)); \
} \
constexpr inline name operator|(name a, name b) { \
return static_cast<name>( \
static_cast<std::underlying_type<name>::type>(a) | \
static_cast<std::underlying_type<name>::type>(b)); \
} \
constexpr inline name operator&(name a, name b) { \
return static_cast<name>( \
static_cast<std::underlying_type<name>::type>(a) & \
static_cast<std::underlying_type<name>::type>(b)); \
} \
constexpr inline name operator^(name a, name b) { \
return static_cast<name>( \
static_cast<std::underlying_type<name>::type>(a) ^ \
static_cast<std::underlying_type<name>::type>(b)); \
} \
inline name& operator|=(name& a, name b) { \
return reinterpret_cast<name&>( \
reinterpret_cast<std::underlying_type<name>::type&>(a) |= \
static_cast<std::underlying_type<name>::type>(b)); \
} \
inline name& operator&=(name& a, name b) { \
return reinterpret_cast<name&>( \
reinterpret_cast<std::underlying_type<name>::type&>(a) &= \
static_cast<std::underlying_type<name>::type>(b)); \
} \
inline name& operator^=(name& a, name b) { \
return reinterpret_cast<name&>( \
reinterpret_cast<std::underlying_type<name>::type&>(a) ^= \
static_cast<std::underlying_type<name>::type>(b)); \
} \
}
#else
#define YG_DEFINE_ENUM_FLAG_OPERATORS(name)
#endif

#ifdef __cplusplus
namespace facebook {
namespace yoga {