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: D13439602

fbshipit-source-id: 68eef2c391b6c9810f3c995b86fff7204ebe6511
This commit is contained in:
David Aurelio 2018-12-13 07:09:28 -08:00 коммит произвёл Facebook Github Bot
Родитель 6f70d4c0ac
Коммит b5c66a3fbe
6 изменённых файлов: 91 добавлений и 45 удалений

Просмотреть файл

@ -1069,6 +1069,14 @@
A2440AA21DF8D854006E7BFC /* RCTReloadCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = A2440AA01DF8D854006E7BFC /* RCTReloadCommand.h */; };
A2440AA31DF8D854006E7BFC /* RCTReloadCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = A2440AA11DF8D854006E7BFC /* RCTReloadCommand.m */; };
A2440AA41DF8D865006E7BFC /* RCTReloadCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = A2440AA01DF8D854006E7BFC /* RCTReloadCommand.h */; };
AC6B69E321B1467C00B2B68A /* YGValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AC6B69E121B1467C00B2B68A /* YGValue.cpp */; };
AC6B69E421B1467C00B2B68A /* YGValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AC6B69E221B1467C00B2B68A /* YGValue.h */; };
AC6B69E521B1469A00B2B68A /* YGValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AC6B69E221B1467C00B2B68A /* YGValue.h */; };
AC6B69E621B146A500B2B68A /* YGValue.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = AC6B69E221B1467C00B2B68A /* YGValue.h */; };
AC6B69E721B146B400B2B68A /* YGValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AC6B69E121B1467C00B2B68A /* YGValue.cpp */; };
AC6B69E821B146C500B2B68A /* YGValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AC6B69E221B1467C00B2B68A /* YGValue.h */; };
AC6B69E921B146DB00B2B68A /* YGValue.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = AC6B69E221B1467C00B2B68A /* YGValue.h */; };
AC6B69EA21B146E700B2B68A /* YGValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AC6B69E121B1467C00B2B68A /* YGValue.cpp */; };
AC70D2E91DE489E4002E6351 /* RCTJavaScriptLoader.mm in Sources */ = {isa = PBXBuildFile; fileRef = AC70D2E81DE489E4002E6351 /* RCTJavaScriptLoader.mm */; };
AC71763521B0274000C06877 /* YGConfig.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 5CE2080120772F7C009A43B3 /* YGConfig.h */; };
AC71763621B0274A00C06877 /* YGMarker.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = AC8360CC21B0256A00FC46B9 /* YGMarker.h */; };
@ -1493,6 +1501,7 @@
dstPath = include/yoga;
dstSubfolderSpec = 16;
files = (
AC6B69E921B146DB00B2B68A /* YGValue.h in Copy Headers */,
AC71763621B0274A00C06877 /* YGMarker.h in Copy Headers */,
AC71763521B0274000C06877 /* YGConfig.h in Copy Headers */,
3DFE0D1A1DF8575800459392 /* YGEnums.h in Copy Headers */,
@ -1693,6 +1702,7 @@
dstPath = include/yoga;
dstSubfolderSpec = 16;
files = (
AC6B69E621B146A500B2B68A /* YGValue.h in Copy Headers */,
AC8360D321B0263000FC46B9 /* YGMarker.h in Copy Headers */,
3DE4F8681DF85D8E00B9E5A0 /* YGEnums.h in Copy Headers */,
3DE4F8691DF85D8E00B9E5A0 /* YGMacros.h in Copy Headers */,
@ -2214,6 +2224,8 @@
91076A881F743AB00081B4FA /* RCTModalManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTModalManager.h; sourceTree = "<group>"; };
A2440AA01DF8D854006E7BFC /* RCTReloadCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTReloadCommand.h; sourceTree = "<group>"; };
A2440AA11DF8D854006E7BFC /* RCTReloadCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTReloadCommand.m; sourceTree = "<group>"; };
AC6B69E121B1467C00B2B68A /* YGValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGValue.cpp; sourceTree = "<group>"; };
AC6B69E221B1467C00B2B68A /* YGValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGValue.h; sourceTree = "<group>"; };
AC70D2E81DE489E4002E6351 /* RCTJavaScriptLoader.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RCTJavaScriptLoader.mm; sourceTree = "<group>"; };
AC70D2EB1DE48A22002E6351 /* JSBundleType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBundleType.cpp; sourceTree = "<group>"; };
AC8360CC21B0256A00FC46B9 /* YGMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGMarker.h; sourceTree = "<group>"; };
@ -2339,6 +2351,8 @@
130A77021DF767AF001F9587 /* yoga */ = {
isa = PBXGroup;
children = (
AC6B69E121B1467C00B2B68A /* YGValue.cpp */,
AC6B69E221B1467C00B2B68A /* YGValue.h */,
AC8360CC21B0256A00FC46B9 /* YGMarker.h */,
5CE2080020772F7C009A43B3 /* YGConfig.cpp */,
5CE2080120772F7C009A43B3 /* YGConfig.h */,
@ -3266,6 +3280,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
AC6B69E821B146C500B2B68A /* YGValue.h in Headers */,
AC8360D221B025EF00FC46B9 /* YGConfig.h in Headers */,
AC8360CE21B0256A00FC46B9 /* YGMarker.h in Headers */,
5352C5782038FF9B00A3B97E /* YGStyle.h in Headers */,
@ -3329,6 +3344,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
AC6B69E521B1469A00B2B68A /* YGValue.h in Headers */,
AC8360CF21B0258B00FC46B9 /* YGConfig.h in Headers */,
AC8360CD21B0256A00FC46B9 /* YGMarker.h in Headers */,
5352C5772038FF9A00A3B97E /* YGStyle.h in Headers */,
@ -3467,6 +3483,7 @@
3D80DA541DF820620028D040 /* RCTI18nUtil.h in Headers */,
3D80DA551DF820620028D040 /* RCTKeyboardObserver.h in Headers */,
3D80DA561DF820620028D040 /* RCTRedBox.h in Headers */,
AC6B69E421B1467C00B2B68A /* YGValue.h in Headers */,
3D80DA571DF820620028D040 /* RCTSourceCode.h in Headers */,
EBF21BBC1FC498270052F4D5 /* InspectorInterfaces.h in Headers */,
3D80DA581DF820620028D040 /* RCTStatusBarManager.h in Headers */,
@ -4357,6 +4374,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AC6B69E721B146B400B2B68A /* YGValue.cpp in Sources */,
AC8360D121B025BC00FC46B9 /* YGConfig.cpp in Sources */,
53DEF6EA205AE5A0006A3890 /* YGFloatOptional.cpp in Sources */,
53D123A01FBF1EFF001B8A10 /* Yoga.cpp in Sources */,
@ -4373,6 +4391,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AC6B69EA21B146E700B2B68A /* YGValue.cpp in Sources */,
BA0501B02109DD1800A6BBC4 /* YGConfig.cpp in Sources */,
53DEF6EB205AE5A1006A3890 /* YGFloatOptional.cpp in Sources */,
53D123A11FBF1EFF001B8A10 /* Yoga.cpp in Sources */,
@ -4471,6 +4490,7 @@
13134C8E1E296B2A00B9F3CB /* RCTMessageThread.mm in Sources */,
599FAA381FB274980058CCF6 /* RCTSurface.mm in Sources */,
59D031EF1F8353D3008361F0 /* RCTSafeAreaShadowView.m in Sources */,
AC6B69E321B1467C00B2B68A /* YGValue.cpp in Sources */,
3D1E68DB1CABD13900DD7465 /* RCTDisplayLink.m in Sources */,
14F3620E1AABD06A001CE568 /* RCTSwitchManager.m in Sources */,
13B080201A69489C00A75B9A /* RCTActivityIndicatorViewManager.m in Sources */,

Просмотреть файл

@ -47,7 +47,7 @@ Pod::Spec.new do |spec|
source_files = File.join('ReactCommon/yoga', source_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION']
spec.source_files = source_files
header_files = 'yoga/{Yoga,YGEnums,YGMacros}.h'
header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGValue}.h'
header_files = File.join('ReactCommon/yoga', header_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION']
spec.public_header_files = header_files
end

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -0,0 +1,40 @@
/**
* 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.
*/
#pragma once
#include <math.h>
#include "YGEnums.h"
#include "YGMacros.h"
YG_EXTERN_C_BEGIN
// Not defined in MSVC++
#ifndef NAN
static const uint32_t __nan = 0x7fc00000;
#define NAN (*(const float*)__nan)
#endif
#define YGUndefined NAN
typedef struct YGValue {
float value;
YGUnit unit;
} YGValue;
extern const YGValue YGValueAuto;
extern const YGValue YGValueUndefined;
extern const YGValue YGValueZero;
YG_EXTERN_C_END
#ifdef __cplusplus
bool operator==(const YGValue& lhs, const YGValue& rhs);
bool operator!=(const YGValue& lhs, const YGValue& rhs);
#endif

Просмотреть файл

@ -39,23 +39,6 @@ static int YGDefaultLog(
va_list args);
#endif
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 <android/log.h>
static int YGAndroidLog(

Просмотреть файл

@ -17,16 +17,9 @@
#include <stdbool.h>
#endif
// Not defined in MSVC++
#ifndef NAN
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
#define NAN (*(const float*)__nan)
#endif
#define YGUndefined NAN
#include "YGEnums.h"
#include "YGMacros.h"
#include "YGValue.h"
YG_EXTERN_C_BEGIN
@ -35,25 +28,6 @@ typedef struct YGSize {
float height;
} YGSize;
typedef struct YGValue {
float value;
YGUnit unit;
} YGValue;
extern const YGValue YGValueUndefined;
extern const YGValue YGValueAuto;
#ifdef __cplusplus
YG_EXTERN_C_END
extern bool operator==(const YGValue& lhs, const YGValue& rhs);
extern bool operator!=(const YGValue& lhs, const YGValue& rhs);
YG_EXTERN_C_BEGIN
#endif
typedef struct YGConfig* YGConfigRef;
typedef struct YGNode* YGNodeRef;