Code formatting: allow short inline methods on one line
Summary: @public This allows short methods defined in class declarations to occupy a single line. The change makes class declarations more readable. Reviewed By: SidharthGuglani Differential Revision: D14950012 fbshipit-source-id: 1321949475184181c6cceb86613f730e430763e2
This commit is contained in:
committed by
Facebook Github Bot
parent
3f7d03b443
commit
e9bb1efb03
@@ -9,7 +9,7 @@ AlignTrailingComments: false
|
|||||||
AllowAllParametersOfDeclarationOnNextLine: false
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
AllowShortBlocksOnASingleLine: false
|
AllowShortBlocksOnASingleLine: false
|
||||||
AllowShortCaseLabelsOnASingleLine: false
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
AllowShortFunctionsOnASingleLine: Empty
|
AllowShortFunctionsOnASingleLine: Inline
|
||||||
AllowShortIfStatementsOnASingleLine: false
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
AllowShortLoopsOnASingleLine: true
|
AllowShortLoopsOnASingleLine: true
|
||||||
AlwaysBreakAfterReturnType: None
|
AlwaysBreakAfterReturnType: None
|
||||||
|
@@ -135,18 +135,14 @@ public:
|
|||||||
node->setContext(context.asVoidPtr);
|
node->setContext(context.asVoidPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has(Edge edge) {
|
bool has(Edge edge) { return (edges_ & edge) == edge; }
|
||||||
return (edges_ & edge) == edge;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGNodeEdges& add(Edge edge) {
|
YGNodeEdges& add(Edge edge) {
|
||||||
edges_ |= edge;
|
edges_ |= edge;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get() {
|
int get() { return edges_; }
|
||||||
return edges_;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct YogaValue {
|
struct YogaValue {
|
||||||
|
@@ -20,12 +20,8 @@ struct ConfigCloningTest : public ::testing::Test {
|
|||||||
void TearDown() override;
|
void TearDown() override;
|
||||||
|
|
||||||
static YGNode clonedNode;
|
static YGNode clonedNode;
|
||||||
static YGNodeRef cloneNode(YGNodeRef, YGNodeRef, int) {
|
static YGNodeRef cloneNode(YGNodeRef, YGNodeRef, int) { return &clonedNode; }
|
||||||
return &clonedNode;
|
static YGNodeRef doNotClone(YGNodeRef, YGNodeRef, int) { return nullptr; }
|
||||||
}
|
|
||||||
static YGNodeRef doNotClone(YGNodeRef, YGNodeRef, int) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(ConfigCloningTest, uses_values_provided_by_cloning_callback) {
|
TEST_F(ConfigCloningTest, uses_values_provided_by_cloning_callback) {
|
||||||
|
@@ -134,9 +134,7 @@ public:
|
|||||||
payload_.repr != ZERO_BITS_PERCENT && std::isnan(payload_.value));
|
payload_.repr != ZERO_BITS_PERCENT && std::isnan(payload_.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAuto() const noexcept {
|
bool isAuto() const noexcept { return payload_.repr == AUTO_BITS; }
|
||||||
return payload_.repr == AUTO_BITS;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
union Payload {
|
union Payload {
|
||||||
@@ -160,9 +158,7 @@ private:
|
|||||||
|
|
||||||
Payload payload_;
|
Payload payload_;
|
||||||
|
|
||||||
VISIBLE_FOR_TESTING uint32_t repr() {
|
VISIBLE_FOR_TESTING uint32_t repr() { return payload_.repr; }
|
||||||
return payload_.repr;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
@@ -56,9 +56,7 @@ public:
|
|||||||
logger_.withContext = logger;
|
logger_.withContext = logger;
|
||||||
loggerUsesContext_ = true;
|
loggerUsesContext_ = true;
|
||||||
}
|
}
|
||||||
void setLogger(std::nullptr_t) {
|
void setLogger(std::nullptr_t) { setLogger(YGLogger{nullptr}); }
|
||||||
setLogger(YGLogger{nullptr});
|
|
||||||
}
|
|
||||||
|
|
||||||
YGNodeRef cloneNode(
|
YGNodeRef cloneNode(
|
||||||
YGNodeRef node,
|
YGNodeRef node,
|
||||||
|
@@ -19,23 +19,15 @@ public:
|
|||||||
constexpr YGFloatOptional() = default;
|
constexpr YGFloatOptional() = default;
|
||||||
|
|
||||||
// returns the wrapped value, or a value x with YGIsUndefined(x) == true
|
// returns the wrapped value, or a value x with YGIsUndefined(x) == true
|
||||||
constexpr float unwrap() const {
|
constexpr float unwrap() const { return value_; }
|
||||||
return value_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isUndefined() const {
|
bool isUndefined() const { return std::isnan(value_); }
|
||||||
return std::isnan(value_);
|
|
||||||
}
|
|
||||||
|
|
||||||
YGFloatOptional operator+(YGFloatOptional op) const {
|
YGFloatOptional operator+(YGFloatOptional op) const {
|
||||||
return YGFloatOptional{value_ + op.value_};
|
return YGFloatOptional{value_ + op.value_};
|
||||||
}
|
}
|
||||||
bool operator>(YGFloatOptional op) const {
|
bool operator>(YGFloatOptional op) const { return value_ > op.value_; }
|
||||||
return value_ > op.value_;
|
bool operator<(YGFloatOptional op) const { return value_ < op.value_; }
|
||||||
}
|
|
||||||
bool operator<(YGFloatOptional op) const {
|
|
||||||
return value_ < op.value_;
|
|
||||||
}
|
|
||||||
bool operator>=(YGFloatOptional op) const {
|
bool operator>=(YGFloatOptional op) const {
|
||||||
return *this > op || *this == op;
|
return *this > op || *this == op;
|
||||||
}
|
}
|
||||||
@@ -45,14 +37,10 @@ public:
|
|||||||
bool operator==(YGFloatOptional op) const {
|
bool operator==(YGFloatOptional op) const {
|
||||||
return value_ == op.value_ || (isUndefined() && op.isUndefined());
|
return value_ == op.value_ || (isUndefined() && op.isUndefined());
|
||||||
}
|
}
|
||||||
bool operator!=(YGFloatOptional op) const {
|
bool operator!=(YGFloatOptional op) const { return !(*this == op); }
|
||||||
return !(*this == op);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(float val) const {
|
bool operator==(float val) const {
|
||||||
return value_ == val || (isUndefined() && yoga::isUndefined(val));
|
return value_ == val || (isUndefined() && yoga::isUndefined(val));
|
||||||
}
|
}
|
||||||
bool operator!=(float val) const {
|
bool operator!=(float val) const { return !(*this == val); }
|
||||||
return !(*this == val);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@@ -44,7 +44,5 @@ struct YGLayout {
|
|||||||
hadOverflow(false) {}
|
hadOverflow(false) {}
|
||||||
|
|
||||||
bool operator==(YGLayout layout) const;
|
bool operator==(YGLayout layout) const;
|
||||||
bool operator!=(YGLayout layout) const {
|
bool operator!=(YGLayout layout) const { return !(*this == layout); }
|
||||||
return !(*this == layout);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@@ -62,16 +62,12 @@ struct MarkerData;
|
|||||||
template <>
|
template <>
|
||||||
struct MarkerData<YGMarkerLayout> {
|
struct MarkerData<YGMarkerLayout> {
|
||||||
using type = YGMarkerLayoutData;
|
using type = YGMarkerLayoutData;
|
||||||
static type*& get(YGMarkerData& d) {
|
static type*& get(YGMarkerData& d) { return d.layout; }
|
||||||
return d.layout;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NoMarkerData {
|
struct NoMarkerData {
|
||||||
using type = YGMarkerNoData;
|
using type = YGMarkerNoData;
|
||||||
static type*& get(YGMarkerData& d) {
|
static type*& get(YGMarkerData& d) { return d.noData; }
|
||||||
return d.noData;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
112
yoga/YGNode.h
112
yoga/YGNode.h
@@ -85,23 +85,15 @@ public:
|
|||||||
YGNode& operator=(const YGNode&) = delete;
|
YGNode& operator=(const YGNode&) = delete;
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
void* getContext() const {
|
void* getContext() const { return context_; }
|
||||||
return context_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void print(void*);
|
void print(void*);
|
||||||
|
|
||||||
bool getHasNewLayout() const {
|
bool getHasNewLayout() const { return hasNewLayout_; }
|
||||||
return hasNewLayout_;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGNodeType getNodeType() const {
|
YGNodeType getNodeType() const { return nodeType_; }
|
||||||
return nodeType_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hasMeasureFunc() const noexcept {
|
bool hasMeasureFunc() const noexcept { return measure_.noContext != nullptr; }
|
||||||
return measure_.noContext != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGSize measure(float, YGMeasureMode, float, YGMeasureMode, void*);
|
YGSize measure(float, YGMeasureMode, float, YGMeasureMode, void*);
|
||||||
|
|
||||||
@@ -111,52 +103,32 @@ public:
|
|||||||
|
|
||||||
float baseline(float width, float height, void* layoutContext);
|
float baseline(float width, float height, void* layoutContext);
|
||||||
|
|
||||||
YGDirtiedFunc getDirtied() const {
|
YGDirtiedFunc getDirtied() const { return dirtied_; }
|
||||||
return dirtied_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For Performance reasons passing as reference.
|
// For Performance reasons passing as reference.
|
||||||
YGStyle& getStyle() {
|
YGStyle& getStyle() { return style_; }
|
||||||
return style_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const YGStyle& getStyle() const {
|
const YGStyle& getStyle() const { return style_; }
|
||||||
return style_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For Performance reasons passing as reference.
|
// For Performance reasons passing as reference.
|
||||||
YGLayout& getLayout() {
|
YGLayout& getLayout() { return layout_; }
|
||||||
return layout_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const YGLayout& getLayout() const {
|
const YGLayout& getLayout() const { return layout_; }
|
||||||
return layout_;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t getLineIndex() const {
|
uint32_t getLineIndex() const { return lineIndex_; }
|
||||||
return lineIndex_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isReferenceBaseline() {
|
bool isReferenceBaseline() { return isReferenceBaseline_; }
|
||||||
return isReferenceBaseline_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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. This method will return the parent
|
// the YogaTree that a YGNode belongs to. This method will return the parent
|
||||||
// of the YGNode when a YGNode only belongs to one YogaTree or nullptr when
|
// of the YGNode when a YGNode only belongs to one YogaTree or nullptr when
|
||||||
// the YGNode is shared between two or more YogaTrees.
|
// the YGNode is shared between two or more YogaTrees.
|
||||||
YGNodeRef getOwner() const {
|
YGNodeRef getOwner() const { return owner_; }
|
||||||
return owner_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated, use getOwner() instead.
|
// Deprecated, use getOwner() instead.
|
||||||
YGNodeRef getParent() const {
|
YGNodeRef getParent() const { return getOwner(); }
|
||||||
return getOwner();
|
|
||||||
}
|
|
||||||
|
|
||||||
const YGVector& getChildren() const {
|
const YGVector& getChildren() const { return children_; }
|
||||||
return children_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Applies a callback to all children, after cloning them if they are not
|
// Applies a callback to all children, after cloning them if they are not
|
||||||
// owned.
|
// owned.
|
||||||
@@ -174,17 +146,11 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
YGNodeRef getChild(uint32_t index) const {
|
YGNodeRef getChild(uint32_t index) const { return children_.at(index); }
|
||||||
return children_.at(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
YGConfigRef getConfig() const {
|
YGConfigRef getConfig() const { return config_; }
|
||||||
return config_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isDirty() const {
|
bool isDirty() const { return isDirty_; }
|
||||||
return isDirty_;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::array<YGValue, 2> getResolvedDimensions() const {
|
std::array<YGValue, 2> getResolvedDimensions() const {
|
||||||
return resolvedDimensions_;
|
return resolvedDimensions_;
|
||||||
@@ -228,9 +194,7 @@ public:
|
|||||||
const float widthSize) const;
|
const float widthSize) const;
|
||||||
// Setters
|
// Setters
|
||||||
|
|
||||||
void setContext(void* context) {
|
void setContext(void* context) { context_ = context; }
|
||||||
context_ = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPrintFunc(YGPrintFunc printFunc) {
|
void setPrintFunc(YGPrintFunc printFunc) {
|
||||||
print_.noContext = printFunc;
|
print_.noContext = printFunc;
|
||||||
@@ -240,17 +204,11 @@ public:
|
|||||||
print_.withContext = printFunc;
|
print_.withContext = printFunc;
|
||||||
printUsesContext_ = true;
|
printUsesContext_ = true;
|
||||||
}
|
}
|
||||||
void setPrintFunc(std::nullptr_t) {
|
void setPrintFunc(std::nullptr_t) { setPrintFunc(YGPrintFunc{nullptr}); }
|
||||||
setPrintFunc(YGPrintFunc{nullptr});
|
|
||||||
}
|
|
||||||
|
|
||||||
void setHasNewLayout(bool hasNewLayout) {
|
void setHasNewLayout(bool hasNewLayout) { hasNewLayout_ = hasNewLayout; }
|
||||||
hasNewLayout_ = hasNewLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setNodeType(YGNodeType nodeType) {
|
void setNodeType(YGNodeType nodeType) { nodeType_ = nodeType; }
|
||||||
nodeType_ = nodeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setStyleFlexDirection(YGFlexDirection direction) {
|
void setStyleFlexDirection(YGFlexDirection direction) {
|
||||||
style_.flexDirection = direction;
|
style_.flexDirection = direction;
|
||||||
@@ -278,39 +236,25 @@ public:
|
|||||||
return setBaselineFunc(YGBaselineFunc{nullptr});
|
return setBaselineFunc(YGBaselineFunc{nullptr});
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDirtiedFunc(YGDirtiedFunc dirtiedFunc) {
|
void setDirtiedFunc(YGDirtiedFunc dirtiedFunc) { dirtied_ = dirtiedFunc; }
|
||||||
dirtied_ = dirtiedFunc;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setStyle(const YGStyle& style) {
|
void setStyle(const YGStyle& style) { style_ = style; }
|
||||||
style_ = style;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLayout(const YGLayout& layout) {
|
void setLayout(const YGLayout& layout) { layout_ = layout; }
|
||||||
layout_ = layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLineIndex(uint32_t lineIndex) {
|
void setLineIndex(uint32_t lineIndex) { lineIndex_ = lineIndex; }
|
||||||
lineIndex_ = lineIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIsReferenceBaseline(bool isReferenceBaseline) {
|
void setIsReferenceBaseline(bool isReferenceBaseline) {
|
||||||
isReferenceBaseline_ = isReferenceBaseline;
|
isReferenceBaseline_ = isReferenceBaseline;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setOwner(YGNodeRef owner) {
|
void setOwner(YGNodeRef owner) { owner_ = owner; }
|
||||||
owner_ = owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setChildren(const YGVector& children) {
|
void setChildren(const YGVector& children) { children_ = children; }
|
||||||
children_ = children;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: rvalue override for setChildren
|
// TODO: rvalue override for setChildren
|
||||||
|
|
||||||
void setConfig(YGConfigRef config) {
|
void setConfig(YGConfigRef config) { config_ = config; }
|
||||||
config_ = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDirty(bool isDirty);
|
void setDirty(bool isDirty);
|
||||||
void setLayoutLastOwnerDirection(YGDirection direction);
|
void setLayoutLastOwnerDirection(YGDirection direction);
|
||||||
|
@@ -112,12 +112,8 @@ public:
|
|||||||
values_.fill(defaultValue);
|
values_.fill(defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CompactValue& operator[](size_t i) const noexcept {
|
const CompactValue& operator[](size_t i) const noexcept { return values_[i]; }
|
||||||
return values_[i];
|
CompactValue& operator[](size_t i) noexcept { return values_[i]; }
|
||||||
}
|
|
||||||
CompactValue& operator[](size_t i) noexcept {
|
|
||||||
return values_[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t I>
|
template <size_t I>
|
||||||
YGValue get() const noexcept {
|
YGValue get() const noexcept {
|
||||||
|
Reference in New Issue
Block a user