From c878ceeabdb04685a714479921c7b83afb665246 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Thu, 27 Apr 2023 03:15:14 -0700 Subject: [PATCH] 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 --- enums.py | 8 ++++++-- yoga/YGEnums.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/enums.py b/enums.py index 146909ad..f2dfd04d 100644 --- a/enums.py +++ b/enums.py @@ -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): diff --git a/yoga/YGEnums.h b/yoga/YGEnums.h index 13840694..eb4fbe72 100644 --- a/yoga/YGEnums.h +++ b/yoga/YGEnums.h @@ -127,6 +127,7 @@ YG_ENUM_DECL( YGPrintOptionsLayout = 1, YGPrintOptionsStyle = 2, YGPrintOptionsChildren = 4) +YG_DEFINE_ENUM_FLAG_OPERATORS(YGPrintOptions) YG_ENUM_SEQ_DECL( YGUnit,