diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index c9799c3c..b9a5f781 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -48,6 +48,19 @@ const YGValue YGValueZero = {0, YGUnitPoint}; const YGValue YGValueUndefined = {YGUndefined, YGUnitUndefined}; const YGValue YGValueAuto = {YGUndefined, YGUnitAuto}; +bool operator==(const YGValue& lhs, const YGValue& rhs) { + if ((lhs.unit == YGUnitUndefined && rhs.unit == YGUnitUndefined) || + (lhs.unit == YGUnitAuto && rhs.unit == YGUnitAuto)) { + return true; + } + + return lhs.unit == rhs.unit && lhs.value == rhs.value; +} + +bool operator!=(const YGValue& lhs, const YGValue& rhs) { + return !(lhs == rhs); +} + #ifdef ANDROID #include static int YGAndroidLog( diff --git a/yoga/Yoga.h b/yoga/Yoga.h index d6b12d29..5bcbe2ab 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -45,6 +45,13 @@ typedef struct YGValue { extern const YGValue YGValueUndefined; extern const YGValue YGValueAuto; +#ifdef __cplusplus + +extern bool operator==(const YGValue& lhs, const YGValue& rhs); +extern bool operator!=(const YGValue& lhs, const YGValue& rhs); + +#endif + typedef struct YGConfig* YGConfigRef; typedef struct YGNode* YGNodeRef;