Move utility functions to utils file
Reviewed By: emilsjolander Differential Revision: D6682933 fbshipit-source-id: 0fd90fdaf5ca4f9b7a11cbd15d8c54c7d0ce8a03
This commit is contained in:
parent
ab972708a8
commit
b41d41fd40
|
@ -954,6 +954,10 @@
|
|||
3DFE0D1C1DF8575800459392 /* Yoga.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77081DF767AF001F9587 /* Yoga.h */; };
|
||||
3EDCA8A51D3591E700450C31 /* RCTErrorInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EDCA8A41D3591E700450C31 /* RCTErrorInfo.m */; };
|
||||
5335D5411FE81A4700883D58 /* RCTShadowView.m in Sources */ = {isa = PBXBuildFile; fileRef = 5335D5401FE81A4700883D58 /* RCTShadowView.m */; };
|
||||
53756E3B2004FFFA00FBBD99 /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53756E372004FFF700FBBD99 /* Utils.cpp */; };
|
||||
53756E3C2004FFFC00FBBD99 /* Utils.h in Headers */ = {isa = PBXBuildFile; fileRef = 53756E382004FFF700FBBD99 /* Utils.h */; };
|
||||
53756E3D2004FFFE00FBBD99 /* Utils.h in Headers */ = {isa = PBXBuildFile; fileRef = 53756E382004FFF700FBBD99 /* Utils.h */; };
|
||||
53756E3E2005000300FBBD99 /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53756E372004FFF700FBBD99 /* Utils.cpp */; };
|
||||
5376C5E41FC6DDBC0083513D /* YGNodePrint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5376C5E11FC6DDB20083513D /* YGNodePrint.cpp */; };
|
||||
5376C5E51FC6DDBD0083513D /* YGNodePrint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5376C5E11FC6DDB20083513D /* YGNodePrint.cpp */; };
|
||||
5376C5E61FC6DDC10083513D /* YGNodePrint.h in Headers */ = {isa = PBXBuildFile; fileRef = 5376C5E01FC6DDB20083513D /* YGNodePrint.h */; };
|
||||
|
@ -2133,6 +2137,8 @@
|
|||
3EDCA8A31D3591E700450C31 /* RCTErrorInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTErrorInfo.h; sourceTree = "<group>"; };
|
||||
3EDCA8A41D3591E700450C31 /* RCTErrorInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTErrorInfo.m; sourceTree = "<group>"; };
|
||||
5335D5401FE81A4700883D58 /* RCTShadowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTShadowView.m; sourceTree = "<group>"; };
|
||||
53756E372004FFF700FBBD99 /* Utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Utils.cpp; sourceTree = "<group>"; };
|
||||
53756E382004FFF700FBBD99 /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utils.h; sourceTree = "<group>"; };
|
||||
5376C5E01FC6DDB20083513D /* YGNodePrint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGNodePrint.h; sourceTree = "<group>"; };
|
||||
5376C5E11FC6DDB20083513D /* YGNodePrint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGNodePrint.cpp; sourceTree = "<group>"; };
|
||||
53CBF1851FB4FE80002CBB31 /* Yoga-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Yoga-internal.h"; sourceTree = "<group>"; };
|
||||
|
@ -2315,6 +2321,8 @@
|
|||
130A77021DF767AF001F9587 /* yoga */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
53756E372004FFF700FBBD99 /* Utils.cpp */,
|
||||
53756E382004FFF700FBBD99 /* Utils.h */,
|
||||
53EC85DF1FDEC75A0051B2B5 /* YGNode.cpp */,
|
||||
53EC85DE1FDEC75A0051B2B5 /* YGNode.h */,
|
||||
5376C5E11FC6DDB20083513D /* YGNodePrint.cpp */,
|
||||
|
@ -3240,6 +3248,7 @@
|
|||
53D1239F1FBF1EFB001B8A10 /* Yoga-internal.h in Headers */,
|
||||
3DFE0D161DF8574D00459392 /* YGEnums.h in Headers */,
|
||||
3DFE0D171DF8574D00459392 /* YGMacros.h in Headers */,
|
||||
53756E3D2004FFFE00FBBD99 /* Utils.h in Headers */,
|
||||
5376C5E71FC6DDC20083513D /* YGNodePrint.h in Headers */,
|
||||
3DFE0D191DF8574D00459392 /* Yoga.h in Headers */,
|
||||
);
|
||||
|
@ -3318,6 +3327,7 @@
|
|||
53D1239E1FBF1EFB001B8A10 /* Yoga-internal.h in Headers */,
|
||||
133957881DF76D3500EC27BE /* YGEnums.h in Headers */,
|
||||
1339578B1DF76D3500EC27BE /* Yoga.h in Headers */,
|
||||
53756E3C2004FFFC00FBBD99 /* Utils.h in Headers */,
|
||||
5376C5E61FC6DDC10083513D /* YGNodePrint.h in Headers */,
|
||||
133957891DF76D3500EC27BE /* YGMacros.h in Headers */,
|
||||
);
|
||||
|
@ -4257,6 +4267,7 @@
|
|||
53D123A01FBF1EFF001B8A10 /* Yoga.cpp in Sources */,
|
||||
53EC85E21FDEC75F0051B2B5 /* YGNode.cpp in Sources */,
|
||||
53D1239A1FBF1EF2001B8A10 /* YGEnums.cpp in Sources */,
|
||||
53756E3B2004FFFA00FBBD99 /* Utils.cpp in Sources */,
|
||||
5376C5E41FC6DDBC0083513D /* YGNodePrint.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -4268,6 +4279,7 @@
|
|||
53D123A11FBF1EFF001B8A10 /* Yoga.cpp in Sources */,
|
||||
53EC85E31FDEC75F0051B2B5 /* YGNode.cpp in Sources */,
|
||||
53D1239B1FBF1EF4001B8A10 /* YGEnums.cpp in Sources */,
|
||||
53756E3E2005000300FBBD99 /* Utils.cpp in Sources */,
|
||||
5376C5E51FC6DDBD0083513D /* YGNodePrint.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#include "Utils.h"
|
||||
|
||||
bool YGValueEqual(const YGValue a, const YGValue b) {
|
||||
if (a.unit != b.unit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (a.unit == YGUnitUndefined ||
|
||||
(std::isnan(a.value) && std::isnan(b.value))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return fabs(a.value - b.value) < 0.0001f;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#include "Yoga-internal.h"
|
||||
|
||||
inline bool YGFlexDirectionIsRow(const YGFlexDirection flexDirection) {
|
||||
return flexDirection == YGFlexDirectionRow ||
|
||||
flexDirection == YGFlexDirectionRowReverse;
|
||||
}
|
||||
|
||||
bool YGValueEqual(const YGValue a, const YGValue b);
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "YGNode.h"
|
||||
#include <iostream>
|
||||
#include "Utils.h"
|
||||
|
||||
void* YGNode::getContext() const {
|
||||
return context_;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "Yoga.h"
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include "Utils.h"
|
||||
#include "YGNode.h"
|
||||
#include "YGNodePrint.h"
|
||||
#include "Yoga-internal.h"
|
||||
|
@ -749,19 +750,6 @@ bool YGLayoutNodeInternal(const YGNodeRef node,
|
|||
const char *reason,
|
||||
const YGConfigRef config);
|
||||
|
||||
bool YGValueEqual(const YGValue a, const YGValue b) {
|
||||
if (a.unit != b.unit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (a.unit == YGUnitUndefined ||
|
||||
(std::isnan(a.value) && std::isnan(b.value))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return fabs(a.value - b.value) < 0.0001f;
|
||||
}
|
||||
|
||||
bool YGFloatsEqual(const float a, const float b) {
|
||||
if (YGFloatIsUndefined(a)) {
|
||||
return YGFloatIsUndefined(b);
|
||||
|
@ -794,10 +782,6 @@ static const std::array<YGEdge, 4> pos = {{
|
|||
static const std::array<YGDimension, 4> dim = {
|
||||
{YGDimensionHeight, YGDimensionHeight, YGDimensionWidth, YGDimensionWidth}};
|
||||
|
||||
bool YGFlexDirectionIsRow(const YGFlexDirection flexDirection) {
|
||||
return flexDirection == YGFlexDirectionRow || flexDirection == YGFlexDirectionRowReverse;
|
||||
}
|
||||
|
||||
static inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) {
|
||||
return flexDirection == YGFlexDirectionColumn || flexDirection == YGFlexDirectionColumnReverse;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue