Use fbsource clang-format config
Summary: This mirrors the clang-format config used by fbsource to Yoga. They are pretty similar, except for an annoying habit where Yoga's previous forced small functions in headers to be a a single line, so you would get a combination of multiline and single line functions next to each other which are hard to read. That is what motivated this change. It also enforces header ordering (yay). I don't think we have any side-effect causing headers, so this should be safe. Reviewed By: yungsters Differential Revision: D49248994 fbshipit-source-id: 66998395e7c0158ff9d9fb1bee44e8401bdd8f21
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9d21e3e300
commit
f9c2c27d33
@@ -24,7 +24,7 @@ class YG_EXPORT Style {
|
||||
template <typename Enum>
|
||||
using Values = std::array<CompactValue, enums::count<Enum>()>;
|
||||
|
||||
public:
|
||||
public:
|
||||
using Dimensions = Values<YGDimension>;
|
||||
using Edges = Values<YGEdge>;
|
||||
using Gutters = Values<YGGutter>;
|
||||
@@ -37,7 +37,9 @@ public:
|
||||
struct BitfieldRef {
|
||||
Style& style;
|
||||
uint8_t offset;
|
||||
operator T() const { return getEnumData<T>(style.flags, offset); }
|
||||
operator T() const {
|
||||
return getEnumData<T>(style.flags, offset);
|
||||
}
|
||||
BitfieldRef<T>& operator=(T x) {
|
||||
setEnumData<T>(style.flags, offset, x);
|
||||
return *this;
|
||||
@@ -47,7 +49,9 @@ public:
|
||||
template <typename T, T Style::*Prop>
|
||||
struct Ref {
|
||||
Style& style;
|
||||
operator T() const { return style.*Prop; }
|
||||
operator T() const {
|
||||
return style.*Prop;
|
||||
}
|
||||
Ref<T, Prop>& operator=(T value) {
|
||||
style.*Prop = value;
|
||||
return *this;
|
||||
@@ -59,8 +63,12 @@ public:
|
||||
struct Ref {
|
||||
Style& style;
|
||||
Idx idx;
|
||||
operator CompactValue() const { return (style.*Prop)[idx]; }
|
||||
operator YGValue() const { return (style.*Prop)[idx]; }
|
||||
operator CompactValue() const {
|
||||
return (style.*Prop)[idx];
|
||||
}
|
||||
operator YGValue() const {
|
||||
return (style.*Prop)[idx];
|
||||
}
|
||||
Ref& operator=(CompactValue value) {
|
||||
(style.*Prop)[idx] = value;
|
||||
return *this;
|
||||
@@ -72,9 +80,15 @@ public:
|
||||
style.*Prop = values;
|
||||
return *this;
|
||||
}
|
||||
operator const Values<Idx>&() const { return style.*Prop; }
|
||||
Ref operator[](Idx idx) { return {style, idx}; }
|
||||
CompactValue operator[](Idx idx) const { return (style.*Prop)[idx]; }
|
||||
operator const Values<Idx>&() const {
|
||||
return style.*Prop;
|
||||
}
|
||||
Ref operator[](Idx idx) {
|
||||
return {style, idx};
|
||||
}
|
||||
CompactValue operator[](Idx idx) const {
|
||||
return (style.*Prop)[idx];
|
||||
}
|
||||
};
|
||||
|
||||
Style() {
|
||||
@@ -83,7 +97,7 @@ public:
|
||||
}
|
||||
~Style() = default;
|
||||
|
||||
private:
|
||||
private:
|
||||
static constexpr uint8_t directionOffset = 0;
|
||||
static constexpr uint8_t flexdirectionOffset =
|
||||
directionOffset + minimumBitCount<YGDirection>();
|
||||
@@ -121,14 +135,16 @@ private:
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
FloatOptional aspectRatio_ = {};
|
||||
|
||||
public:
|
||||
public:
|
||||
// for library users needing a type
|
||||
using ValueRepr = std::remove_reference<decltype(margin_[0])>::type;
|
||||
|
||||
YGDirection direction() const {
|
||||
return getEnumData<YGDirection>(flags, directionOffset);
|
||||
}
|
||||
BitfieldRef<YGDirection> direction() { return {*this, directionOffset}; }
|
||||
BitfieldRef<YGDirection> direction() {
|
||||
return {*this, directionOffset};
|
||||
}
|
||||
|
||||
YGFlexDirection flexDirection() const {
|
||||
return getEnumData<YGFlexDirection>(flags, flexdirectionOffset);
|
||||
@@ -147,17 +163,23 @@ public:
|
||||
YGAlign alignContent() const {
|
||||
return getEnumData<YGAlign>(flags, alignContentOffset);
|
||||
}
|
||||
BitfieldRef<YGAlign> alignContent() { return {*this, alignContentOffset}; }
|
||||
BitfieldRef<YGAlign> alignContent() {
|
||||
return {*this, alignContentOffset};
|
||||
}
|
||||
|
||||
YGAlign alignItems() const {
|
||||
return getEnumData<YGAlign>(flags, alignItemsOffset);
|
||||
}
|
||||
BitfieldRef<YGAlign> alignItems() { return {*this, alignItemsOffset}; }
|
||||
BitfieldRef<YGAlign> alignItems() {
|
||||
return {*this, alignItemsOffset};
|
||||
}
|
||||
|
||||
YGAlign alignSelf() const {
|
||||
return getEnumData<YGAlign>(flags, alignSelfOffset);
|
||||
}
|
||||
BitfieldRef<YGAlign> alignSelf() { return {*this, alignSelfOffset}; }
|
||||
BitfieldRef<YGAlign> alignSelf() {
|
||||
return {*this, alignSelfOffset};
|
||||
}
|
||||
|
||||
YGPositionType positionType() const {
|
||||
return getEnumData<YGPositionType>(flags, positionTypeOffset);
|
||||
@@ -166,62 +188,118 @@ public:
|
||||
return {*this, positionTypeOffset};
|
||||
}
|
||||
|
||||
YGWrap flexWrap() const { return getEnumData<YGWrap>(flags, flexWrapOffset); }
|
||||
BitfieldRef<YGWrap> flexWrap() { return {*this, flexWrapOffset}; }
|
||||
YGWrap flexWrap() const {
|
||||
return getEnumData<YGWrap>(flags, flexWrapOffset);
|
||||
}
|
||||
BitfieldRef<YGWrap> flexWrap() {
|
||||
return {*this, flexWrapOffset};
|
||||
}
|
||||
|
||||
YGOverflow overflow() const {
|
||||
return getEnumData<YGOverflow>(flags, overflowOffset);
|
||||
}
|
||||
BitfieldRef<YGOverflow> overflow() { return {*this, overflowOffset}; }
|
||||
BitfieldRef<YGOverflow> overflow() {
|
||||
return {*this, overflowOffset};
|
||||
}
|
||||
|
||||
YGDisplay display() const {
|
||||
return getEnumData<YGDisplay>(flags, displayOffset);
|
||||
}
|
||||
BitfieldRef<YGDisplay> display() { return {*this, displayOffset}; }
|
||||
BitfieldRef<YGDisplay> display() {
|
||||
return {*this, displayOffset};
|
||||
}
|
||||
|
||||
FloatOptional flex() const { return flex_; }
|
||||
Ref<FloatOptional, &Style::flex_> flex() { return {*this}; }
|
||||
FloatOptional flex() const {
|
||||
return flex_;
|
||||
}
|
||||
Ref<FloatOptional, &Style::flex_> flex() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
FloatOptional flexGrow() const { return flexGrow_; }
|
||||
Ref<FloatOptional, &Style::flexGrow_> flexGrow() { return {*this}; }
|
||||
FloatOptional flexGrow() const {
|
||||
return flexGrow_;
|
||||
}
|
||||
Ref<FloatOptional, &Style::flexGrow_> flexGrow() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
FloatOptional flexShrink() const { return flexShrink_; }
|
||||
Ref<FloatOptional, &Style::flexShrink_> flexShrink() { return {*this}; }
|
||||
FloatOptional flexShrink() const {
|
||||
return flexShrink_;
|
||||
}
|
||||
Ref<FloatOptional, &Style::flexShrink_> flexShrink() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
CompactValue flexBasis() const { return flexBasis_; }
|
||||
Ref<CompactValue, &Style::flexBasis_> flexBasis() { return {*this}; }
|
||||
CompactValue flexBasis() const {
|
||||
return flexBasis_;
|
||||
}
|
||||
Ref<CompactValue, &Style::flexBasis_> flexBasis() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
const Edges& margin() const { return margin_; }
|
||||
IdxRef<YGEdge, &Style::margin_> margin() { return {*this}; }
|
||||
const Edges& margin() const {
|
||||
return margin_;
|
||||
}
|
||||
IdxRef<YGEdge, &Style::margin_> margin() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
const Edges& position() const { return position_; }
|
||||
IdxRef<YGEdge, &Style::position_> position() { return {*this}; }
|
||||
const Edges& position() const {
|
||||
return position_;
|
||||
}
|
||||
IdxRef<YGEdge, &Style::position_> position() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
const Edges& padding() const { return padding_; }
|
||||
IdxRef<YGEdge, &Style::padding_> padding() { return {*this}; }
|
||||
const Edges& padding() const {
|
||||
return padding_;
|
||||
}
|
||||
IdxRef<YGEdge, &Style::padding_> padding() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
const Edges& border() const { return border_; }
|
||||
IdxRef<YGEdge, &Style::border_> border() { return {*this}; }
|
||||
const Edges& border() const {
|
||||
return border_;
|
||||
}
|
||||
IdxRef<YGEdge, &Style::border_> border() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
const Gutters& gap() const { return gap_; }
|
||||
IdxRef<YGGutter, &Style::gap_> gap() { return {*this}; }
|
||||
const Gutters& gap() const {
|
||||
return gap_;
|
||||
}
|
||||
IdxRef<YGGutter, &Style::gap_> gap() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
const Dimensions& dimensions() const { return dimensions_; }
|
||||
IdxRef<YGDimension, &Style::dimensions_> dimensions() { return {*this}; }
|
||||
const Dimensions& dimensions() const {
|
||||
return dimensions_;
|
||||
}
|
||||
IdxRef<YGDimension, &Style::dimensions_> dimensions() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
const Dimensions& minDimensions() const { return minDimensions_; }
|
||||
const Dimensions& minDimensions() const {
|
||||
return minDimensions_;
|
||||
}
|
||||
IdxRef<YGDimension, &Style::minDimensions_> minDimensions() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
const Dimensions& maxDimensions() const { return maxDimensions_; }
|
||||
const Dimensions& maxDimensions() const {
|
||||
return maxDimensions_;
|
||||
}
|
||||
IdxRef<YGDimension, &Style::maxDimensions_> maxDimensions() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
FloatOptional aspectRatio() const { return aspectRatio_; }
|
||||
Ref<FloatOptional, &Style::aspectRatio_> aspectRatio() { return {*this}; }
|
||||
FloatOptional aspectRatio() const {
|
||||
return aspectRatio_;
|
||||
}
|
||||
Ref<FloatOptional, &Style::aspectRatio_> aspectRatio() {
|
||||
return {*this};
|
||||
}
|
||||
};
|
||||
|
||||
YG_EXPORT bool operator==(const Style& lhs, const Style& rhs);
|
||||
|
Reference in New Issue
Block a user