CompactValue
overrides of YGResolveValue
/YGValueEqual
Summary: @public I would like to get rid of implicit conversions between `YGValue` and `CompactValue`, because they don’t come for free. That’s why I am adding `CompactValue` specific overrides for `YGResolveValue` and `YGValueEqual`, that do explicit casts. Up the commit stack, we will be able mark both `CompactValue(const YGValue&)` and `CompactValue::operator YGValue()` as `explicit`. Reviewed By: SidharthGuglani Differential Revision: D14598447 fbshipit-source-id: 75dc15cefb2dddcf8def891c5fb37893cacd9d46
This commit is contained in:
committed by
Facebook Github Bot
parent
e4856a2264
commit
3d2836a947
@@ -31,7 +31,7 @@ float YGFloatMin(const float a, const float b) {
|
|||||||
return yoga::isUndefined(a) ? b : a;
|
return yoga::isUndefined(a) ? b : a;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YGValueEqual(const YGValue a, const YGValue b) {
|
bool YGValueEqual(const YGValue& a, const YGValue& b) {
|
||||||
if (a.unit != b.unit) {
|
if (a.unit != b.unit) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
13
yoga/Utils.h
13
yoga/Utils.h
@@ -52,7 +52,12 @@ struct YGCollectFlexItemsRowValues {
|
|||||||
float crossDim;
|
float crossDim;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool YGValueEqual(const YGValue a, const YGValue b);
|
bool YGValueEqual(const YGValue& a, const YGValue& b);
|
||||||
|
inline bool YGValueEqual(
|
||||||
|
facebook::yoga::detail::CompactValue a,
|
||||||
|
facebook::yoga::detail::CompactValue b) {
|
||||||
|
return YGValueEqual((YGValue) a, (YGValue) b);
|
||||||
|
}
|
||||||
|
|
||||||
// This custom float equality function returns true if either absolute
|
// This custom float equality function returns true if either absolute
|
||||||
// difference between two floats is less than 0.0001f or both are undefined.
|
// difference between two floats is less than 0.0001f or both are undefined.
|
||||||
@@ -105,6 +110,12 @@ inline YGFloatOptional YGResolveValue(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline YGFloatOptional YGResolveValue(
|
||||||
|
yoga::detail::CompactValue value,
|
||||||
|
float ownerSize) {
|
||||||
|
return YGResolveValue((YGValue) value, ownerSize);
|
||||||
|
}
|
||||||
|
|
||||||
inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) {
|
inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) {
|
||||||
return flexDirection == YGFlexDirectionColumn ||
|
return flexDirection == YGFlexDirectionColumn ||
|
||||||
flexDirection == YGFlexDirectionColumnReverse;
|
flexDirection == YGFlexDirectionColumnReverse;
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#include "YGEnums.h"
|
#include "YGEnums.h"
|
||||||
#include "YGNode.h"
|
#include "YGNode.h"
|
||||||
#include "Yoga-internal.h"
|
#include "Yoga-internal.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
namespace facebook {
|
namespace facebook {
|
||||||
namespace yoga {
|
namespace yoga {
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
* file in the root directory of this source tree.
|
* file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
#include "YGStyle.h"
|
#include "YGStyle.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
// Yoga specific properties, not compatible with flexbox specification
|
// Yoga specific properties, not compatible with flexbox specification
|
||||||
bool operator==(const YGStyle& lhs, const YGStyle& rhs) {
|
bool operator==(const YGStyle& lhs, const YGStyle& rhs) {
|
||||||
|
@@ -45,7 +45,6 @@ using namespace facebook;
|
|||||||
|
|
||||||
extern const std::array<YGEdge, 4> trailing;
|
extern const std::array<YGEdge, 4> trailing;
|
||||||
extern const std::array<YGEdge, 4> leading;
|
extern const std::array<YGEdge, 4> leading;
|
||||||
extern bool YGValueEqual(const YGValue a, const YGValue b);
|
|
||||||
extern const YGValue YGValueUndefined;
|
extern const YGValue YGValueUndefined;
|
||||||
extern const YGValue YGValueAuto;
|
extern const YGValue YGValueAuto;
|
||||||
extern const YGValue YGValueZero;
|
extern const YGValue YGValueZero;
|
||||||
|
Reference in New Issue
Block a user