mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 22:50:10 +08:00
Remove cast from detail::Values to std::array<YGValue
Summary: @public When switching to `CompactValue`, casting edges or dimensions to `std::array<YGValue, ...>` will do actual work. In order to avoid that from happening implicitely, we remove the casting operator. Reviewed By: SidharthGuglani Differential Revision: D13464292 fbshipit-source-id: 217065b001a63cfa8adde715063682c583007a4d
This commit is contained in:
committed by
Facebook Github Bot
parent
dac59586ed
commit
0eeb94e948
@@ -583,12 +583,11 @@ inline std::string toString(const YGFloatOptional &value) {
|
||||
return folly::to<std::string>(floatFromYogaFloat(value.unwrap()));
|
||||
}
|
||||
|
||||
inline std::string toString(
|
||||
const std::array<YGValue, YGDimensionCount> &value) {
|
||||
inline std::string toString(const YGStyle::Dimensions &value) {
|
||||
return "{" + toString(value[0]) + ", " + toString(value[1]) + "}";
|
||||
}
|
||||
|
||||
inline std::string toString(const std::array<YGValue, YGEdgeCount> &value) {
|
||||
inline std::string toString(const YGStyle::Edges &value) {
|
||||
static std::array<std::string, YGEdgeCount> names = {{"left",
|
||||
"top",
|
||||
"right",
|
||||
|
||||
@@ -13,32 +13,32 @@
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
static inline std::array<YGValue, 2> convertRawProp(
|
||||
static inline YGStyle::Dimensions convertRawProp(
|
||||
const RawProps &rawProps,
|
||||
const std::string &widthName,
|
||||
const std::string &heightName,
|
||||
const std::array<YGValue, 2> &sourceValue,
|
||||
const std::array<YGValue, 2> &defaultValue) {
|
||||
auto dimentions = defaultValue;
|
||||
dimentions[YGDimensionWidth] = convertRawProp(
|
||||
const YGStyle::Dimensions &sourceValue,
|
||||
const YGStyle::Dimensions &defaultValue) {
|
||||
auto dimensions = defaultValue;
|
||||
dimensions[YGDimensionWidth] = convertRawProp(
|
||||
rawProps,
|
||||
widthName,
|
||||
sourceValue[YGDimensionWidth],
|
||||
defaultValue[YGDimensionWidth]);
|
||||
dimentions[YGDimensionHeight] = convertRawProp(
|
||||
dimensions[YGDimensionHeight] = convertRawProp(
|
||||
rawProps,
|
||||
heightName,
|
||||
sourceValue[YGDimensionHeight],
|
||||
defaultValue[YGDimensionWidth]);
|
||||
return dimentions;
|
||||
return dimensions;
|
||||
}
|
||||
|
||||
static inline std::array<YGValue, YGEdgeCount> convertRawProp(
|
||||
static inline YGStyle::Edges convertRawProp(
|
||||
const RawProps &rawProps,
|
||||
const std::string &prefix,
|
||||
const std::string &suffix,
|
||||
const std::array<YGValue, YGEdgeCount> &sourceValue,
|
||||
const std::array<YGValue, YGEdgeCount> &defaultValue) {
|
||||
const YGStyle::Edges &sourceValue,
|
||||
const YGStyle::Edges &defaultValue) {
|
||||
auto result = defaultValue;
|
||||
result[YGEdgeLeft] = convertRawProp(
|
||||
rawProps,
|
||||
@@ -88,10 +88,10 @@ static inline std::array<YGValue, YGEdgeCount> convertRawProp(
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline std::array<YGValue, YGEdgeCount> convertRawProp(
|
||||
static inline YGStyle::Edges convertRawProp(
|
||||
const RawProps &rawProps,
|
||||
const std::array<YGValue, YGEdgeCount> &sourceValue,
|
||||
const std::array<YGValue, YGEdgeCount> &defaultValue) {
|
||||
const YGStyle::Edges &sourceValue,
|
||||
const YGStyle::Edges &defaultValue) {
|
||||
auto result = defaultValue;
|
||||
result[YGEdgeLeft] = convertRawProp(
|
||||
rawProps, "left", sourceValue[YGEdgeLeft], defaultValue[YGEdgeLeft]);
|
||||
|
||||
@@ -20,7 +20,8 @@ static void indent(string& base, uint32_t level) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool areFourValuesEqual(const std::array<YGValue, YGEdgeCount>& four) {
|
||||
static bool areFourValuesEqual(
|
||||
const facebook::yoga::detail::Values<YGEdgeCount>& four) {
|
||||
return YGValueEqual(four[0], four[1]) && YGValueEqual(four[0], four[2]) &&
|
||||
YGValueEqual(four[0], four[3]);
|
||||
}
|
||||
@@ -81,7 +82,7 @@ appendNumberIfNotZero(string& base, const string& str, const YGValue number) {
|
||||
static void appendEdges(
|
||||
string& base,
|
||||
const string& key,
|
||||
const std::array<YGValue, YGEdgeCount>& edges) {
|
||||
const facebook::yoga::detail::Values<YGEdgeCount>& edges) {
|
||||
if (areFourValuesEqual(edges)) {
|
||||
appendNumberIfNotZero(base, key, edges[YGEdgeLeft]);
|
||||
} else {
|
||||
@@ -95,7 +96,7 @@ static void appendEdges(
|
||||
static void appendEdgeIfNotUndefined(
|
||||
string& base,
|
||||
const string& str,
|
||||
const std::array<YGValue, YGEdgeCount>& edges,
|
||||
const facebook::yoga::detail::Values<YGEdgeCount>& edges,
|
||||
const YGEdge edge) {
|
||||
appendNumberIfNotUndefined(
|
||||
base, str, *YGComputedEdgeValue(edges, edge, &YGValueUndefined));
|
||||
|
||||
@@ -103,12 +103,6 @@ class Values {
|
||||
values_.fill(defaultValue);
|
||||
}
|
||||
|
||||
operator const std::array<YGValue, Size>&() const noexcept {
|
||||
return values_;
|
||||
}
|
||||
operator std::array<YGValue, Size>&() noexcept {
|
||||
return values_;
|
||||
}
|
||||
const YGValue& operator[](size_t i) const noexcept {
|
||||
return values_[i];
|
||||
}
|
||||
@@ -136,10 +130,6 @@ class Values {
|
||||
}
|
||||
|
||||
Values& operator=(const Values& other) = default;
|
||||
Values& operator=(const std::array<YGValue, Size>& other) noexcept {
|
||||
values_ = other;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@@ -153,6 +143,6 @@ static const float kWebDefaultFlexShrink = 1.0f;
|
||||
extern bool YGFloatsEqual(const float a, const float b);
|
||||
extern bool YGValueEqual(const YGValue a, const YGValue b);
|
||||
extern const YGValue* YGComputedEdgeValue(
|
||||
const std::array<YGValue, YGEdgeCount>& edges,
|
||||
const facebook::yoga::detail::Values<YGEdgeCount>& edges,
|
||||
const YGEdge edge,
|
||||
const YGValue* const defaultValue);
|
||||
|
||||
@@ -103,7 +103,7 @@ bool YGFloatIsUndefined(const float value) {
|
||||
}
|
||||
|
||||
const YGValue* YGComputedEdgeValue(
|
||||
const std::array<YGValue, YGEdgeCount>& edges,
|
||||
const facebook::yoga::detail::Values<YGEdgeCount>& edges,
|
||||
const YGEdge edge,
|
||||
const YGValue* const defaultValue) {
|
||||
if (edges[edge].unit != YGUnitUndefined) {
|
||||
|
||||
Reference in New Issue
Block a user