Inline simple YGNode getters/setters

Summary: Simple getters/setters are usually inlined like this.

Reviewed By: priteshrnandgaonkar, davidaurelio

Differential Revision: D8793588

fbshipit-source-id: 436bd54880e41a5e403e3f4ae0d9dd4a413df79c
This commit is contained in:
Scott Wolchok
2018-07-11 08:51:33 -07:00
committed by Facebook Github Bot
parent 9ceed4b601
commit e384002878
2 changed files with 142 additions and 163 deletions

View File

@@ -9,82 +9,6 @@
#include <iostream> #include <iostream>
#include "Utils.h" #include "Utils.h"
void* YGNode::getContext() const {
return context_;
}
YGPrintFunc YGNode::getPrintFunc() const {
return print_;
}
bool YGNode::getHasNewLayout() const {
return hasNewLayout_;
}
YGNodeType YGNode::getNodeType() const {
return nodeType_;
}
YGMeasureFunc YGNode::getMeasure() const {
return measure_;
}
YGBaselineFunc YGNode::getBaseline() const {
return baseline_;
}
YGDirtiedFunc YGNode::getDirtied() const {
return dirtied_;
}
YGStyle& YGNode::getStyle() {
return style_;
}
YGLayout& YGNode::getLayout() {
return layout_;
}
uint32_t YGNode::getLineIndex() const {
return lineIndex_;
}
YGNodeRef YGNode::getOwner() const {
return owner_;
}
YGNodeRef YGNode::getParent() const {
return getOwner();
}
YGVector YGNode::getChildren() const {
return children_;
}
uint32_t YGNode::getChildrenCount() const {
return static_cast<uint32_t>(children_.size());
}
YGNodeRef YGNode::getChild(uint32_t index) const {
return children_.at(index);
}
YGConfigRef YGNode::getConfig() const {
return config_;
}
bool YGNode::isDirty() const {
return isDirty_;
}
YGValue YGNode::getResolvedDimension(int index) {
return resolvedDimensions_[index];
}
std::array<YGValue, 2> YGNode::getResolvedDimensions() const {
return resolvedDimensions_;
}
YGFloatOptional YGNode::getLeadingPosition( YGFloatOptional YGNode::getLeadingPosition(
const YGFlexDirection& axis, const YGFlexDirection& axis,
const float& axisSize) const { const float& axisSize) const {
@@ -173,29 +97,7 @@ YGFloatOptional YGNode::getMarginForAxis(
// Setters // Setters
void YGNode::setContext(void* context) {
context_ = context;
}
void YGNode::setPrintFunc(YGPrintFunc printFunc) {
print_ = printFunc;
}
void YGNode::setHasNewLayout(bool hasNewLayout) {
hasNewLayout_ = hasNewLayout;
}
void YGNode::setNodeType(YGNodeType nodeType) {
nodeType_ = nodeType;
}
void YGNode::setStyleFlexDirection(YGFlexDirection direction) {
style_.flexDirection = direction;
}
void YGNode::setStyleAlignContent(YGAlign alignContent) {
style_.alignContent = alignContent;
}
void YGNode::setMeasureFunc(YGMeasureFunc measureFunc) { void YGNode::setMeasureFunc(YGMeasureFunc measureFunc) {
if (measureFunc == nullptr) { if (measureFunc == nullptr) {
@@ -217,34 +119,6 @@ void YGNode::setMeasureFunc(YGMeasureFunc measureFunc) {
measure_ = measureFunc; measure_ = measureFunc;
} }
void YGNode::setBaseLineFunc(YGBaselineFunc baseLineFunc) {
baseline_ = baseLineFunc;
}
void YGNode::setDirtiedFunc(YGDirtiedFunc dirtiedFunc) {
dirtied_ = dirtiedFunc;
}
void YGNode::setStyle(const YGStyle& style) {
style_ = style;
}
void YGNode::setLayout(const YGLayout& layout) {
layout_ = layout;
}
void YGNode::setLineIndex(uint32_t lineIndex) {
lineIndex_ = lineIndex;
}
void YGNode::setOwner(YGNodeRef owner) {
owner_ = owner;
}
void YGNode::setChildren(const YGVector& children) {
children_ = children;
}
void YGNode::replaceChild(YGNodeRef child, uint32_t index) { void YGNode::replaceChild(YGNodeRef child, uint32_t index) {
children_[index] = child; children_[index] = child;
} }
@@ -257,10 +131,6 @@ void YGNode::insertChild(YGNodeRef child, uint32_t index) {
children_.insert(children_.begin() + index, child); children_.insert(children_.begin() + index, child);
} }
void YGNode::setConfig(YGConfigRef config) {
config_ = config;
}
void YGNode::setDirty(bool isDirty) { void YGNode::setDirty(bool isDirty) {
if (isDirty == isDirty_) { if (isDirty == isDirty_) {
return; return;

View File

@@ -58,33 +58,97 @@ struct YGNode {
std::array<YGValue, 2> resolvedDimensions); std::array<YGValue, 2> resolvedDimensions);
// Getters // Getters
void* getContext() const; void* getContext() const {
YGPrintFunc getPrintFunc() const; return context_;
bool getHasNewLayout() const; }
YGNodeType getNodeType() const;
YGMeasureFunc getMeasure() const; YGPrintFunc getPrintFunc() const {
YGBaselineFunc getBaseline() const; return print_;
YGDirtiedFunc getDirtied() const; }
bool getHasNewLayout() const {
return hasNewLayout_;
}
YGNodeType getNodeType() const {
return nodeType_;
}
YGMeasureFunc getMeasure() const {
return measure_;
}
YGBaselineFunc getBaseline() const {
return baseline_;
}
YGDirtiedFunc getDirtied() const {
return dirtied_;
}
// For Performance reasons passing as reference. // For Performance reasons passing as reference.
YGStyle& getStyle(); YGStyle& getStyle() {
return style_;
}
const YGStyle& getStyle() const {
return style_;
}
// For Performance reasons passing as reference. // For Performance reasons passing as reference.
YGLayout& getLayout(); YGLayout& getLayout() {
uint32_t getLineIndex() const; return layout_;
}
const YGLayout& getLayout() const {
return layout_;
}
uint32_t getLineIndex() const {
return lineIndex_;
}
// returns the YGNodeRef that owns this YGNode. An owner is used to identify // returns the YGNodeRef that owns this YGNode. An owner is used to identify
// the YogaTree that a YGNode belongs to. // the YogaTree that a YGNode belongs to.
// This method will return the parent of the YGNode when a YGNode only belongs // This method will return the parent of the YGNode when a YGNode only belongs
// to one YogaTree or nullptr when the YGNode is shared between two or more // to one YogaTree or nullptr when the YGNode is shared between two or more
// YogaTrees. // YogaTrees.
YGNodeRef getOwner() const; YGNodeRef getOwner() const {
return owner_;
}
// Deprecated, use getOwner() instead. // Deprecated, use getOwner() instead.
YGNodeRef getParent() const; YGNodeRef getParent() const {
YGVector getChildren() const; return getOwner();
uint32_t getChildrenCount() const; }
YGNodeRef getChild(uint32_t index) const;
YGConfigRef getConfig() const; YGVector getChildren() const {
bool isDirty() const; return children_;
std::array<YGValue, 2> getResolvedDimensions() const; }
YGValue getResolvedDimension(int index);
uint32_t getChildrenCount() const {
return static_cast<uint32_t>(children_.size());
}
YGNodeRef getChild(uint32_t index) const {
return children_.at(index);
}
YGConfigRef getConfig() const {
return config_;
}
bool isDirty() const {
return isDirty_;
}
std::array<YGValue, 2> getResolvedDimensions() const {
return resolvedDimensions_;
}
YGValue getResolvedDimension(int index) const {
return resolvedDimensions_[index];
}
// Methods related to positions, margin, padding and border // Methods related to positions, margin, padding and border
YGFloatOptional getLeadingPosition(const YGFlexDirection& axis, YGFloatOptional getLeadingPosition(const YGFlexDirection& axis,
@@ -119,21 +183,66 @@ struct YGNode {
const float& widthSize) const; const float& widthSize) const;
// Setters // Setters
void setContext(void* context); void setContext(void* context) {
void setPrintFunc(YGPrintFunc printFunc); context_ = context;
void setHasNewLayout(bool hasNewLayout); }
void setNodeType(YGNodeType nodeTye);
void setPrintFunc(YGPrintFunc printFunc) {
print_ = printFunc;
}
void setHasNewLayout(bool hasNewLayout) {
hasNewLayout_ = hasNewLayout;
}
void setNodeType(YGNodeType nodeType) {
nodeType_ = nodeType;
}
void setStyleFlexDirection(YGFlexDirection direction) {
style_.flexDirection = direction;
}
void setStyleAlignContent(YGAlign alignContent) {
style_.alignContent = alignContent;
}
void setMeasureFunc(YGMeasureFunc measureFunc); void setMeasureFunc(YGMeasureFunc measureFunc);
void setBaseLineFunc(YGBaselineFunc baseLineFunc);
void setDirtiedFunc(YGDirtiedFunc dirtiedFunc); void setBaseLineFunc(YGBaselineFunc baseLineFunc) {
void setStyle(const YGStyle& style); baseline_ = baseLineFunc;
void setStyleFlexDirection(YGFlexDirection direction); }
void setStyleAlignContent(YGAlign alignContent);
void setLayout(const YGLayout& layout); void setDirtiedFunc(YGDirtiedFunc dirtiedFunc) {
void setLineIndex(uint32_t lineIndex); dirtied_ = dirtiedFunc;
void setOwner(YGNodeRef owner); }
void setChildren(const YGVector& children);
void setConfig(YGConfigRef config); void setStyle(const YGStyle& style) {
style_ = style;
}
void setLayout(const YGLayout& layout) {
layout_ = layout;
}
void setLineIndex(uint32_t lineIndex) {
lineIndex_ = lineIndex;
}
void setOwner(YGNodeRef owner) {
owner_ = owner;
}
void setChildren(const YGVector& children) {
children_ = children;
}
// TODO: rvalue override for setChildren
void setConfig(YGConfigRef config) {
config_ = config;
}
void setDirty(bool isDirty); void setDirty(bool isDirty);
void setLayoutLastOwnerDirection(YGDirection direction); void setLayoutLastOwnerDirection(YGDirection direction);
void setLayoutComputedFlexBasis(const YGFloatOptional& computedFlexBasis); void setLayoutComputedFlexBasis(const YGFloatOptional& computedFlexBasis);