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:
David Aurelio
2019-04-16 07:09:36 -07:00
committed by Facebook Github Bot
parent 3f7d03b443
commit e9bb1efb03
10 changed files with 47 additions and 139 deletions

View File

@@ -9,7 +9,7 @@ AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None

View File

@@ -135,18 +135,14 @@ public:
node->setContext(context.asVoidPtr);
}
bool has(Edge edge) {
return (edges_ & edge) == edge;
}
bool has(Edge edge) { return (edges_ & edge) == edge; }
YGNodeEdges& add(Edge edge) {
edges_ |= edge;
return *this;
}
int get() {
return edges_;
}
int get() { return edges_; }
};
struct YogaValue {

View File

@@ -20,12 +20,8 @@ struct ConfigCloningTest : public ::testing::Test {
void TearDown() override;
static YGNode clonedNode;
static YGNodeRef cloneNode(YGNodeRef, YGNodeRef, int) {
return &clonedNode;
}
static YGNodeRef doNotClone(YGNodeRef, YGNodeRef, int) {
return nullptr;
}
static YGNodeRef cloneNode(YGNodeRef, YGNodeRef, int) { return &clonedNode; }
static YGNodeRef doNotClone(YGNodeRef, YGNodeRef, int) { return nullptr; }
};
TEST_F(ConfigCloningTest, uses_values_provided_by_cloning_callback) {

View File

@@ -134,9 +134,7 @@ public:
payload_.repr != ZERO_BITS_PERCENT && std::isnan(payload_.value));
}
bool isAuto() const noexcept {
return payload_.repr == AUTO_BITS;
}
bool isAuto() const noexcept { return payload_.repr == AUTO_BITS; }
private:
union Payload {
@@ -160,9 +158,7 @@ private:
Payload payload_;
VISIBLE_FOR_TESTING uint32_t repr() {
return payload_.repr;
}
VISIBLE_FOR_TESTING uint32_t repr() { return payload_.repr; }
};
template <>

View File

@@ -56,9 +56,7 @@ public:
logger_.withContext = logger;
loggerUsesContext_ = true;
}
void setLogger(std::nullptr_t) {
setLogger(YGLogger{nullptr});
}
void setLogger(std::nullptr_t) { setLogger(YGLogger{nullptr}); }
YGNodeRef cloneNode(
YGNodeRef node,

View File

@@ -19,23 +19,15 @@ public:
constexpr YGFloatOptional() = default;
// returns the wrapped value, or a value x with YGIsUndefined(x) == true
constexpr float unwrap() const {
return value_;
}
constexpr float unwrap() const { return value_; }
bool isUndefined() const {
return std::isnan(value_);
}
bool isUndefined() const { return std::isnan(value_); }
YGFloatOptional operator+(YGFloatOptional op) const {
return YGFloatOptional{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 { return value_ > op.value_; }
bool operator<(YGFloatOptional op) const { return value_ < op.value_; }
bool operator>=(YGFloatOptional op) const {
return *this > op || *this == op;
}
@@ -45,14 +37,10 @@ public:
bool operator==(YGFloatOptional op) const {
return value_ == op.value_ || (isUndefined() && op.isUndefined());
}
bool operator!=(YGFloatOptional op) const {
return !(*this == op);
}
bool operator!=(YGFloatOptional op) const { return !(*this == op); }
bool operator==(float val) const {
return value_ == val || (isUndefined() && yoga::isUndefined(val));
}
bool operator!=(float val) const {
return !(*this == val);
}
bool operator!=(float val) const { return !(*this == val); }
};

View File

@@ -44,7 +44,5 @@ struct YGLayout {
hadOverflow(false) {}
bool operator==(YGLayout layout) const;
bool operator!=(YGLayout layout) const {
return !(*this == layout);
}
bool operator!=(YGLayout layout) const { return !(*this == layout); }
};

View File

@@ -62,16 +62,12 @@ struct MarkerData;
template <>
struct MarkerData<YGMarkerLayout> {
using type = YGMarkerLayoutData;
static type*& get(YGMarkerData& d) {
return d.layout;
}
static type*& get(YGMarkerData& d) { return d.layout; }
};
struct NoMarkerData {
using type = YGMarkerNoData;
static type*& get(YGMarkerData& d) {
return d.noData;
}
static type*& get(YGMarkerData& d) { return d.noData; }
};
template <>

View File

@@ -85,23 +85,15 @@ public:
YGNode& operator=(const YGNode&) = delete;
// Getters
void* getContext() const {
return context_;
}
void* getContext() const { return context_; }
void print(void*);
bool getHasNewLayout() const {
return hasNewLayout_;
}
bool getHasNewLayout() const { return hasNewLayout_; }
YGNodeType getNodeType() const {
return nodeType_;
}
YGNodeType getNodeType() const { return nodeType_; }
bool hasMeasureFunc() const noexcept {
return measure_.noContext != nullptr;
}
bool hasMeasureFunc() const noexcept { return measure_.noContext != nullptr; }
YGSize measure(float, YGMeasureMode, float, YGMeasureMode, void*);
@@ -111,52 +103,32 @@ public:
float baseline(float width, float height, void* layoutContext);
YGDirtiedFunc getDirtied() const {
return dirtied_;
}
YGDirtiedFunc getDirtied() const { return dirtied_; }
// For Performance reasons passing as reference.
YGStyle& getStyle() {
return style_;
}
YGStyle& getStyle() { return style_; }
const YGStyle& getStyle() const {
return style_;
}
const YGStyle& getStyle() const { return style_; }
// For Performance reasons passing as reference.
YGLayout& getLayout() {
return layout_;
}
YGLayout& getLayout() { return layout_; }
const YGLayout& getLayout() const {
return layout_;
}
const YGLayout& getLayout() const { return layout_; }
uint32_t getLineIndex() const {
return lineIndex_;
}
uint32_t getLineIndex() const { return lineIndex_; }
bool isReferenceBaseline() {
return isReferenceBaseline_;
}
bool isReferenceBaseline() { return isReferenceBaseline_; }
// 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
// of the YGNode when a YGNode only belongs to one YogaTree or nullptr when
// the YGNode is shared between two or more YogaTrees.
YGNodeRef getOwner() const {
return owner_;
}
YGNodeRef getOwner() const { return owner_; }
// Deprecated, use getOwner() instead.
YGNodeRef getParent() const {
return getOwner();
}
YGNodeRef getParent() const { return getOwner(); }
const YGVector& getChildren() const {
return children_;
}
const YGVector& getChildren() const { return children_; }
// Applies a callback to all children, after cloning them if they are not
// owned.
@@ -174,17 +146,11 @@ public:
}
}
YGNodeRef getChild(uint32_t index) const {
return children_.at(index);
}
YGNodeRef getChild(uint32_t index) const { return children_.at(index); }
YGConfigRef getConfig() const {
return config_;
}
YGConfigRef getConfig() const { return config_; }
bool isDirty() const {
return isDirty_;
}
bool isDirty() const { return isDirty_; }
std::array<YGValue, 2> getResolvedDimensions() const {
return resolvedDimensions_;
@@ -228,9 +194,7 @@ public:
const float widthSize) const;
// Setters
void setContext(void* context) {
context_ = context;
}
void setContext(void* context) { context_ = context; }
void setPrintFunc(YGPrintFunc printFunc) {
print_.noContext = printFunc;
@@ -240,17 +204,11 @@ public:
print_.withContext = printFunc;
printUsesContext_ = true;
}
void setPrintFunc(std::nullptr_t) {
setPrintFunc(YGPrintFunc{nullptr});
}
void setPrintFunc(std::nullptr_t) { setPrintFunc(YGPrintFunc{nullptr}); }
void setHasNewLayout(bool hasNewLayout) {
hasNewLayout_ = hasNewLayout;
}
void setHasNewLayout(bool hasNewLayout) { hasNewLayout_ = hasNewLayout; }
void setNodeType(YGNodeType nodeType) {
nodeType_ = nodeType;
}
void setNodeType(YGNodeType nodeType) { nodeType_ = nodeType; }
void setStyleFlexDirection(YGFlexDirection direction) {
style_.flexDirection = direction;
@@ -278,39 +236,25 @@ public:
return setBaselineFunc(YGBaselineFunc{nullptr});
}
void setDirtiedFunc(YGDirtiedFunc dirtiedFunc) {
dirtied_ = dirtiedFunc;
}
void setDirtiedFunc(YGDirtiedFunc dirtiedFunc) { dirtied_ = dirtiedFunc; }
void setStyle(const YGStyle& style) {
style_ = style;
}
void setStyle(const YGStyle& style) { style_ = style; }
void setLayout(const YGLayout& layout) {
layout_ = layout;
}
void setLayout(const YGLayout& layout) { layout_ = layout; }
void setLineIndex(uint32_t lineIndex) {
lineIndex_ = lineIndex;
}
void setLineIndex(uint32_t lineIndex) { lineIndex_ = lineIndex; }
void setIsReferenceBaseline(bool isReferenceBaseline) {
isReferenceBaseline_ = isReferenceBaseline;
}
void setOwner(YGNodeRef owner) {
owner_ = owner;
}
void setOwner(YGNodeRef owner) { owner_ = owner; }
void setChildren(const YGVector& children) {
children_ = children;
}
void setChildren(const YGVector& children) { children_ = children; }
// TODO: rvalue override for setChildren
void setConfig(YGConfigRef config) {
config_ = config;
}
void setConfig(YGConfigRef config) { config_ = config; }
void setDirty(bool isDirty);
void setLayoutLastOwnerDirection(YGDirection direction);

View File

@@ -112,12 +112,8 @@ public:
values_.fill(defaultValue);
}
const CompactValue& operator[](size_t i) const noexcept {
return values_[i];
}
CompactValue& operator[](size_t i) noexcept {
return values_[i];
}
const CompactValue& operator[](size_t i) const noexcept { return values_[i]; }
CompactValue& operator[](size_t i) noexcept { return values_[i]; }
template <size_t I>
YGValue get() const noexcept {