Move out YGValue

Summary:
@public

Creates a single header file for `YGValue`. This is in preparation of a more compact representation of `YGValue` within `YGStyle`.

Also fixes the incorrect definition of NAN.

Reviewed By: SidharthGuglani

Differential Revision: D13172444

fbshipit-source-id: 4250dbcf8fe15ec3ecdee3913360a73bab633ce3
This commit is contained in:
David Aurelio
2018-12-06 07:35:08 -08:00
committed by Facebook Github Bot
parent 0962c5220c
commit d19da9e528
4 changed files with 70 additions and 44 deletions

29
yoga/YGValue.cpp Normal file
View File

@@ -0,0 +1,29 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*/
#include "YGValue.h"
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 != rhs.unit) {
return false;
}
switch (lhs.unit) {
case YGUnitUndefined:
case YGUnitAuto:
return true;
default:
return lhs.value == rhs.value;
}
}
bool operator!=(const YGValue& lhs, const YGValue& rhs) {
return !(lhs == rhs);
}