C++ style enums 2/N: NodeType (#1383)

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

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

This converts usages of YGNodeType to NodeType

Reviewed By: rozele

Differential Revision: D49269117

fbshipit-source-id: 27318279fe555c28c605625a160d5be781b662b8
This commit is contained in:
Nick Gerleman
2023-09-14 23:06:34 -07:00
committed by Facebook GitHub Bot
parent 4cd45ac5d5
commit 9129a0af87
4 changed files with 11 additions and 10 deletions

View File

@@ -14,6 +14,7 @@
#include <yoga/Yoga.h>
#include <yoga/config/Config.h>
#include <yoga/enums/NodeType.h>
#include <yoga/node/LayoutResults.h>
#include <yoga/style/CompactValue.h>
#include <yoga/style/Style.h>
@@ -29,7 +30,7 @@ struct NodeFlags {
bool hasNewLayout : 1;
bool isReferenceBaseline : 1;
bool isDirty : 1;
uint32_t nodeType : 1;
NodeType nodeType : bitCount<NodeType>();
};
#pragma pack(pop)
@@ -92,8 +93,8 @@ class YG_EXPORT Node : public ::YGNode {
return flags_.hasNewLayout;
}
YGNodeType getNodeType() const {
return static_cast<YGNodeType>(flags_.nodeType);
NodeType getNodeType() const {
return flags_.nodeType;
}
bool hasMeasureFunc() const noexcept {
@@ -250,8 +251,8 @@ class YG_EXPORT Node : public ::YGNode {
flags_.hasNewLayout = hasNewLayout;
}
void setNodeType(YGNodeType nodeType) {
flags_.nodeType = static_cast<uint32_t>(nodeType) & 0x01;
void setNodeType(NodeType nodeType) {
flags_.nodeType = nodeType;
}
void setMeasureFunc(YGMeasureFunc measureFunc);