Define Flag operators for YGPrintOptions (#37115)

Summary:
X-link: https://github.com/facebook/react-native/pull/37115

Pull Request resolved: https://github.com/facebook/yoga/pull/1267

This is an existing bitset enum in the API. Use the facility added in the last diff to add flag operators to it, to avoid the need for casting, and to make it clearer in the generated YGEnums.h that it is a bitset.

Reviewed By: rshest

Differential Revision: D45341504

fbshipit-source-id: 0b80588f3e2e167d4c1c722c6d6608408dd617ba
This commit is contained in:
Nick Gerleman
2023-04-27 03:15:14 -07:00
committed by Facebook GitHub Bot
parent 01c0c4ed3b
commit c878ceeabd
2 changed files with 7 additions and 2 deletions

View File

@@ -57,7 +57,11 @@ ENUMS = {
# Conformance fix: https://github.com/facebook/yoga/pull/1028
"FixAbsoluteTrailingColumnMargin",
],
"PrintOptions": [("Layout", 1), ("Style", 2), ("Children", 4)],
"PrintOptions": [
("Layout", 1 << 0),
("Style", 1 << 1),
("Children", 1 << 2),
],
"Gutter": ["Column", "Row", "All"],
# Known incorrect behavior which can be enabled for compatibility
"Errata": [
@@ -79,7 +83,7 @@ ENUMS = {
# well?
DO_NOT_STRIP = ["LogLevel"]
BITSET_ENUMS = ["Errata"]
BITSET_ENUMS = ["PrintOptions", "Errata"]
def get_license(ext):

View File

@@ -127,6 +127,7 @@ YG_ENUM_DECL(
YGPrintOptionsLayout = 1,
YGPrintOptionsStyle = 2,
YGPrintOptionsChildren = 4)
YG_DEFINE_ENUM_FLAG_OPERATORS(YGPrintOptions)
YG_ENUM_SEQ_DECL(
YGUnit,