Add YGErrata Enum (#1256)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1256 X-link: https://github.com/facebook/react-native/pull/37076 This adds a `YGErrata` bitset enum matching the API and guarantees described in https://github.com/facebook/yoga/issues/1247. It is hooked up in later diffs. There are a couple of `YGExperimentalFeature` values that belong here, but keeping the current options means that the default `YGErrataNone` corresponds to existing default behavior, letting us stage the series of changes as: 1. Implement errata API 2. Update internal Yoga users we want to de-risk to `YGErrataClassic` or `YGErrataAll` (if setting `UseLegacyStretchBehaviour`) 3. Add new errata, changing Yoga defaults to be conformant, while letting internal apps opt into compatibility modes pending experimentation. I also added a macro to let C++ users of Yoga perform bitwise operations on the enum without casting (already available for C users). Reviewed By: rshest Differential Revision: D45254098 fbshipit-source-id: d4b61271a8018f548f2d9d8c953db4b121a502d1
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fc68765314
commit
01c0c4ed3b
17
enums.py
17
enums.py
@@ -59,6 +59,19 @@ ENUMS = {
|
||||
],
|
||||
"PrintOptions": [("Layout", 1), ("Style", 2), ("Children", 4)],
|
||||
"Gutter": ["Column", "Row", "All"],
|
||||
# Known incorrect behavior which can be enabled for compatibility
|
||||
"Errata": [
|
||||
# Default: Standards conformant mode
|
||||
("None", 0),
|
||||
# Allows main-axis flex basis to be stretched without flexGrow being
|
||||
# set (previously referred to as "UseLegacyStretchBehaviour")
|
||||
("StretchFlexBasis", 1 << 0),
|
||||
# Enable all incorrect behavior (preserve compatibility)
|
||||
("All", 0x7FFFFFFF),
|
||||
# Enable all errata except for "StretchFlexBasis" (Defaults behavior
|
||||
# before Yoga 2.0)
|
||||
("Classic", 0x7FFFFFFF & (~(1 << 0))),
|
||||
],
|
||||
}
|
||||
|
||||
# Generated Java enums used to emit @DoNotStrip, but D17519844 removed them
|
||||
@@ -66,6 +79,8 @@ ENUMS = {
|
||||
# well?
|
||||
DO_NOT_STRIP = ["LogLevel"]
|
||||
|
||||
BITSET_ENUMS = ["Errata"]
|
||||
|
||||
|
||||
def get_license(ext):
|
||||
prologue = "/**" if ext == "js" else "/*"
|
||||
@@ -132,6 +147,8 @@ with open(root + "/yoga/YGEnums.h", "w") as f:
|
||||
f.write(")\n")
|
||||
else:
|
||||
f.write(",\n")
|
||||
if name in BITSET_ENUMS:
|
||||
f.write("YG_DEFINE_ENUM_FLAG_OPERATORS(YG%s)\n" % name)
|
||||
f.write("\n")
|
||||
f.write("YG_EXTERN_C_END\n")
|
||||
|
||||
|
Reference in New Issue
Block a user