Fix compilation on MSVC by moving YGConfig to C++
Summary: This PR fixes the compilation on MSVC. I moved the `YGConfig` creation to a C++ constructor. Addionally it removes the "dot" notation on `YGValue`, I didn't want to change that type to a C++ constructor, because I think this will break the ABI. Closes https://github.com/facebook/yoga/pull/746 Differential Revision: D7498141 Pulled By: emilsjolander fbshipit-source-id: 5f5308ff838dcd803065785ddc08b2404524acb9
This commit is contained in:
committed by
Facebook Github Bot
parent
9550126f76
commit
6b08db68bb
@@ -227,19 +227,31 @@
|
|||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\yoga\Yoga.h" />
|
<ClInclude Include="..\..\yoga\Utils.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\YGConfig.h" />
|
||||||
<ClInclude Include="..\..\yoga\YGEnums.h" />
|
<ClInclude Include="..\..\yoga\YGEnums.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\YGFloatOptional.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\YGLayout.h" />
|
||||||
<ClInclude Include="..\..\yoga\YGMacros.h" />
|
<ClInclude Include="..\..\yoga\YGMacros.h" />
|
||||||
<ClInclude Include="..\..\yoga\YGNodeList.h" />
|
<ClInclude Include="..\..\yoga\YGNode.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\YGNodePrint.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\YGStyle.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\Yoga-internal.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\Yoga.h" />
|
||||||
<ClInclude Include="resource.h" />
|
<ClInclude Include="resource.h" />
|
||||||
<ClInclude Include="YGInterop.h" />
|
|
||||||
<ClInclude Include="stdafx.h" />
|
<ClInclude Include="stdafx.h" />
|
||||||
<ClInclude Include="targetver.h" />
|
<ClInclude Include="targetver.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\yoga\Yoga.c" />
|
<ClCompile Include="..\..\yoga\Utils.cpp" />
|
||||||
<ClCompile Include="..\..\yoga\YGEnums.c" />
|
<ClCompile Include="..\..\yoga\YGConfig.cpp" />
|
||||||
<ClCompile Include="..\..\yoga\YGNodeList.c" />
|
<ClCompile Include="..\..\yoga\YGEnums.cpp" />
|
||||||
|
<ClCompile Include="..\..\yoga\YGFloatOptional.cpp" />
|
||||||
|
<ClCompile Include="..\..\yoga\YGLayout.cpp" />
|
||||||
|
<ClCompile Include="..\..\yoga\YGNode.cpp" />
|
||||||
|
<ClCompile Include="..\..\yoga\YGNodePrint.cpp" />
|
||||||
|
<ClCompile Include="..\..\yoga\YGStyle.cpp" />
|
||||||
|
<ClCompile Include="..\..\yoga\Yoga.cpp" />
|
||||||
<ClCompile Include="YGInterop.cpp" />
|
<ClCompile Include="YGInterop.cpp" />
|
||||||
<ClCompile Include="dllmain.cpp">
|
<ClCompile Include="dllmain.cpp">
|
||||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
|
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
|
||||||
|
@@ -21,19 +21,40 @@
|
|||||||
<ClInclude Include="targetver.h">
|
<ClInclude Include="targetver.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\yoga\Yoga.h">
|
<ClInclude Include="resource.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\yoga\Utils.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\yoga\YGEnums.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\yoga\YGFloatOptional.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\yoga\YGLayout.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\yoga\YGMacros.h">
|
<ClInclude Include="..\..\yoga\YGMacros.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\yoga\YGNodeList.h">
|
<ClInclude Include="..\..\yoga\YGNode.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="YGInterop.h">
|
<ClInclude Include="..\..\yoga\YGNodePrint.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="resource.h">
|
<ClInclude Include="..\..\yoga\YGStyle.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\yoga\Yoga.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\yoga\Yoga-internal.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\yoga\YGConfig.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -44,15 +65,36 @@
|
|||||||
<ClCompile Include="dllmain.cpp">
|
<ClCompile Include="dllmain.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\yoga\Yoga.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\yoga\YGNodeList.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="YGInterop.cpp">
|
<ClCompile Include="YGInterop.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\Utils.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\YGEnums.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\YGFloatOptional.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\YGLayout.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\YGNode.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\YGNodePrint.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\YGStyle.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\Yoga.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\yoga\YGConfig.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="Yoga.rc">
|
<ResourceCompile Include="Yoga.rc">
|
||||||
|
19
yoga/YGConfig.cpp
Normal file
19
yoga/YGConfig.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "YGConfig.h"
|
||||||
|
|
||||||
|
const std::array<bool, YGExperimentalFeatureCount>
|
||||||
|
kYGDefaultExperimentalFeatures = {{false}};
|
||||||
|
|
||||||
|
YGConfig::YGConfig(YGLogger logger)
|
||||||
|
: experimentalFeatures(kYGDefaultExperimentalFeatures),
|
||||||
|
useWebDefaults(false),
|
||||||
|
useLegacyStretchBehaviour(false),
|
||||||
|
shouldDiffLayoutWithoutLegacyStretchBehaviour(false),
|
||||||
|
pointScaleFactor(1.0f), logger(logger), cloneNodeCallback(nullptr),
|
||||||
|
context(nullptr) {}
|
23
yoga/YGConfig.h
Normal file
23
yoga/YGConfig.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* 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 "Yoga-internal.h"
|
||||||
|
#include "Yoga.h"
|
||||||
|
|
||||||
|
struct YGConfig {
|
||||||
|
std::array<bool, YGExperimentalFeatureCount> experimentalFeatures;
|
||||||
|
bool useWebDefaults;
|
||||||
|
bool useLegacyStretchBehaviour;
|
||||||
|
bool shouldDiffLayoutWithoutLegacyStretchBehaviour;
|
||||||
|
float pointScaleFactor;
|
||||||
|
YGLogger logger;
|
||||||
|
YGCloneNodeFunc cloneNodeCallback;
|
||||||
|
void* context;
|
||||||
|
|
||||||
|
YGConfig(YGLogger logger);
|
||||||
|
};
|
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "YGConfig.h"
|
||||||
#include "YGLayout.h"
|
#include "YGLayout.h"
|
||||||
#include "YGStyle.h"
|
#include "YGStyle.h"
|
||||||
#include "Yoga-internal.h"
|
#include "Yoga-internal.h"
|
||||||
|
@@ -87,16 +87,6 @@ struct YGCachedMeasurement {
|
|||||||
// layouts should not require more than 16 entries to fit within the cache.
|
// layouts should not require more than 16 entries to fit within the cache.
|
||||||
#define YG_MAX_CACHED_RESULT_COUNT 16
|
#define YG_MAX_CACHED_RESULT_COUNT 16
|
||||||
|
|
||||||
struct YGConfig {
|
|
||||||
bool experimentalFeatures[YGExperimentalFeatureCount + 1];
|
|
||||||
bool useWebDefaults;
|
|
||||||
bool useLegacyStretchBehaviour;
|
|
||||||
bool shouldDiffLayoutWithoutLegacyStretchBehaviour;
|
|
||||||
float pointScaleFactor;
|
|
||||||
YGLogger logger;
|
|
||||||
YGCloneNodeFunc cloneNodeCallback;
|
|
||||||
void* context;
|
|
||||||
};
|
|
||||||
|
|
||||||
static const float kDefaultFlexGrow = 0.0f;
|
static const float kDefaultFlexGrow = 0.0f;
|
||||||
static const float kDefaultFlexShrink = 0.0f;
|
static const float kDefaultFlexShrink = 0.0f;
|
||||||
|
277
yoga/Yoga.cpp
277
yoga/Yoga.cpp
@@ -41,25 +41,7 @@ static int YGDefaultLog(const YGConfigRef config,
|
|||||||
va_list args);
|
va_list args);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static YGConfig gYGConfigDefaults = {
|
const YGValue YGValueZero = {0, YGUnitPoint};
|
||||||
.experimentalFeatures =
|
|
||||||
{
|
|
||||||
[YGExperimentalFeatureWebFlexBasis] = false,
|
|
||||||
},
|
|
||||||
.useWebDefaults = false,
|
|
||||||
.useLegacyStretchBehaviour = false,
|
|
||||||
.shouldDiffLayoutWithoutLegacyStretchBehaviour = false,
|
|
||||||
.pointScaleFactor = 1.0f,
|
|
||||||
#ifdef ANDROID
|
|
||||||
.logger = &YGAndroidLog,
|
|
||||||
#else
|
|
||||||
.logger = &YGDefaultLog,
|
|
||||||
#endif
|
|
||||||
.cloneNodeCallback = nullptr,
|
|
||||||
.context = nullptr,
|
|
||||||
};
|
|
||||||
|
|
||||||
const YGValue YGValueZero = {.value = 0, .unit = YGUnitPoint};
|
|
||||||
const YGValue YGValueUndefined = {YGUndefined, YGUnitUndefined};
|
const YGValue YGValueUndefined = {YGUndefined, YGUnitUndefined};
|
||||||
const YGValue YGValueAuto = {YGUndefined, YGUnitAuto};
|
const YGValue YGValueAuto = {YGUndefined, YGUnitAuto};
|
||||||
|
|
||||||
@@ -246,8 +228,13 @@ WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) {
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
YGConfigRef YGConfigGetDefault() {
|
||||||
|
static YGConfigRef defaultConfig = YGConfigNew();
|
||||||
|
return defaultConfig;
|
||||||
|
}
|
||||||
|
|
||||||
YGNodeRef YGNodeNew(void) {
|
YGNodeRef YGNodeNew(void) {
|
||||||
return YGNodeNewWithConfig(&gYGConfigDefaults);
|
return YGNodeNewWithConfig(YGConfigGetDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
YGNodeRef YGNodeClone(YGNodeRef oldNode) {
|
YGNodeRef YGNodeClone(YGNodeRef oldNode) {
|
||||||
@@ -363,19 +350,13 @@ int32_t YGConfigGetInstanceCount(void) {
|
|||||||
return gConfigInstanceCount;
|
return gConfigInstanceCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Export only for C#
|
|
||||||
YGConfigRef YGConfigGetDefault() {
|
|
||||||
return &gYGConfigDefaults;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGConfigRef YGConfigNew(void) {
|
YGConfigRef YGConfigNew(void) {
|
||||||
const YGConfigRef config = (const YGConfigRef)malloc(sizeof(YGConfig));
|
#ifdef ANDROID
|
||||||
YGAssert(config != nullptr, "Could not allocate memory for config");
|
const YGConfigRef config = new YGConfig(YGAndroidLog);
|
||||||
if (config == nullptr) {
|
#else
|
||||||
abort();
|
const YGConfigRef config = new YGConfig(YGDefaultLog);
|
||||||
}
|
#endif
|
||||||
gConfigInstanceCount++;
|
gConfigInstanceCount++;
|
||||||
memcpy(config, &gYGConfigDefaults, sizeof(YGConfig));
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -590,79 +571,78 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL( \
|
#define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL( \
|
||||||
type, name, paramName, instanceName) \
|
type, name, paramName, instanceName) \
|
||||||
void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \
|
void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \
|
||||||
YGValue value = { \
|
YGValue value = { \
|
||||||
.value = YGFloatSanitize(paramName), \
|
YGFloatSanitize(paramName), \
|
||||||
.unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint, \
|
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint, \
|
||||||
}; \
|
}; \
|
||||||
if ((node->getStyle().instanceName.value != value.value && \
|
if ((node->getStyle().instanceName.value != value.value && \
|
||||||
value.unit != YGUnitUndefined) || \
|
value.unit != YGUnitUndefined) || \
|
||||||
node->getStyle().instanceName.unit != value.unit) { \
|
node->getStyle().instanceName.unit != value.unit) { \
|
||||||
YGStyle style = node->getStyle(); \
|
YGStyle style = node->getStyle(); \
|
||||||
style.instanceName = value; \
|
style.instanceName = value; \
|
||||||
node->setStyle(style); \
|
node->setStyle(style); \
|
||||||
node->markDirtyAndPropogate(); \
|
node->markDirtyAndPropogate(); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void YGNodeStyleSet##name##Percent( \
|
void YGNodeStyleSet##name##Percent( \
|
||||||
const YGNodeRef node, const type paramName) { \
|
const YGNodeRef node, const type paramName) { \
|
||||||
YGValue value = { \
|
YGValue value = { \
|
||||||
.value = YGFloatSanitize(paramName), \
|
YGFloatSanitize(paramName), \
|
||||||
.unit = \
|
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent, \
|
||||||
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent, \
|
}; \
|
||||||
}; \
|
if ((node->getStyle().instanceName.value != value.value && \
|
||||||
if ((node->getStyle().instanceName.value != value.value && \
|
value.unit != YGUnitUndefined) || \
|
||||||
value.unit != YGUnitUndefined) || \
|
node->getStyle().instanceName.unit != value.unit) { \
|
||||||
node->getStyle().instanceName.unit != value.unit) { \
|
YGStyle style = node->getStyle(); \
|
||||||
YGStyle style = node->getStyle(); \
|
\
|
||||||
\
|
style.instanceName = value; \
|
||||||
style.instanceName = value; \
|
node->setStyle(style); \
|
||||||
node->setStyle(style); \
|
node->markDirtyAndPropogate(); \
|
||||||
node->markDirtyAndPropogate(); \
|
} \
|
||||||
} \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_AUTO_IMPL( \
|
#define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_AUTO_IMPL( \
|
||||||
type, name, paramName, instanceName) \
|
type, name, paramName, instanceName) \
|
||||||
void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \
|
void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \
|
||||||
YGValue value = { \
|
YGValue value = { \
|
||||||
.value = YGFloatSanitize(paramName), \
|
YGFloatSanitize(paramName), \
|
||||||
.unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint, \
|
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint, \
|
||||||
}; \
|
}; \
|
||||||
if ((node->getStyle().instanceName.value != value.value && \
|
if ((node->getStyle().instanceName.value != value.value && \
|
||||||
value.unit != YGUnitUndefined) || \
|
value.unit != YGUnitUndefined) || \
|
||||||
node->getStyle().instanceName.unit != value.unit) { \
|
node->getStyle().instanceName.unit != value.unit) { \
|
||||||
YGStyle style = node->getStyle(); \
|
YGStyle style = node->getStyle(); \
|
||||||
style.instanceName = value; \
|
style.instanceName = value; \
|
||||||
node->setStyle(style); \
|
node->setStyle(style); \
|
||||||
node->markDirtyAndPropogate(); \
|
node->markDirtyAndPropogate(); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void YGNodeStyleSet##name##Percent( \
|
void YGNodeStyleSet##name##Percent( \
|
||||||
const YGNodeRef node, const type paramName) { \
|
const YGNodeRef node, const type paramName) { \
|
||||||
if (node->getStyle().instanceName.value != YGFloatSanitize(paramName) || \
|
if (node->getStyle().instanceName.value != YGFloatSanitize(paramName) || \
|
||||||
node->getStyle().instanceName.unit != YGUnitPercent) { \
|
node->getStyle().instanceName.unit != YGUnitPercent) { \
|
||||||
YGStyle style = node->getStyle(); \
|
YGStyle style = node->getStyle(); \
|
||||||
style.instanceName.value = YGFloatSanitize(paramName); \
|
style.instanceName.value = YGFloatSanitize(paramName); \
|
||||||
style.instanceName.unit = \
|
style.instanceName.unit = \
|
||||||
YGFloatIsUndefined(paramName) ? YGUnitAuto : YGUnitPercent; \
|
YGFloatIsUndefined(paramName) ? YGUnitAuto : YGUnitPercent; \
|
||||||
node->setStyle(style); \
|
node->setStyle(style); \
|
||||||
node->markDirtyAndPropogate(); \
|
node->markDirtyAndPropogate(); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void YGNodeStyleSet##name##Auto(const YGNodeRef node) { \
|
void YGNodeStyleSet##name##Auto(const YGNodeRef node) { \
|
||||||
if (node->getStyle().instanceName.unit != YGUnitAuto) { \
|
if (node->getStyle().instanceName.unit != YGUnitAuto) { \
|
||||||
YGStyle style = node->getStyle(); \
|
YGStyle style = node->getStyle(); \
|
||||||
style.instanceName.value = 0; \
|
style.instanceName.value = 0; \
|
||||||
style.instanceName.unit = YGUnitAuto; \
|
style.instanceName.unit = YGUnitAuto; \
|
||||||
node->setStyle(style); \
|
node->setStyle(style); \
|
||||||
node->markDirtyAndPropogate(); \
|
node->markDirtyAndPropogate(); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_STYLE_PROPERTY_IMPL(type, name, paramName, instanceName) \
|
#define YG_NODE_STYLE_PROPERTY_IMPL(type, name, paramName, instanceName) \
|
||||||
@@ -708,48 +688,47 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL( \
|
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL( \
|
||||||
type, name, paramName, instanceName) \
|
type, name, paramName, instanceName) \
|
||||||
void YGNodeStyleSet##name( \
|
void YGNodeStyleSet##name( \
|
||||||
const YGNodeRef node, const YGEdge edge, const float paramName) { \
|
const YGNodeRef node, const YGEdge edge, const float paramName) { \
|
||||||
YGValue value = { \
|
YGValue value = { \
|
||||||
.value = YGFloatSanitize(paramName), \
|
YGFloatSanitize(paramName), \
|
||||||
.unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint, \
|
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint, \
|
||||||
}; \
|
}; \
|
||||||
if ((node->getStyle().instanceName[edge].value != value.value && \
|
if ((node->getStyle().instanceName[edge].value != value.value && \
|
||||||
value.unit != YGUnitUndefined) || \
|
value.unit != YGUnitUndefined) || \
|
||||||
node->getStyle().instanceName[edge].unit != value.unit) { \
|
node->getStyle().instanceName[edge].unit != value.unit) { \
|
||||||
YGStyle style = node->getStyle(); \
|
YGStyle style = node->getStyle(); \
|
||||||
style.instanceName[edge] = value; \
|
style.instanceName[edge] = value; \
|
||||||
node->setStyle(style); \
|
node->setStyle(style); \
|
||||||
node->markDirtyAndPropogate(); \
|
node->markDirtyAndPropogate(); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void YGNodeStyleSet##name##Percent( \
|
void YGNodeStyleSet##name##Percent( \
|
||||||
const YGNodeRef node, const YGEdge edge, const float paramName) { \
|
const YGNodeRef node, const YGEdge edge, const float paramName) { \
|
||||||
YGValue value = { \
|
YGValue value = { \
|
||||||
.value = YGFloatSanitize(paramName), \
|
YGFloatSanitize(paramName), \
|
||||||
.unit = \
|
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent, \
|
||||||
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent, \
|
}; \
|
||||||
}; \
|
if ((node->getStyle().instanceName[edge].value != value.value && \
|
||||||
if ((node->getStyle().instanceName[edge].value != value.value && \
|
value.unit != YGUnitUndefined) || \
|
||||||
value.unit != YGUnitUndefined) || \
|
node->getStyle().instanceName[edge].unit != value.unit) { \
|
||||||
node->getStyle().instanceName[edge].unit != value.unit) { \
|
YGStyle style = node->getStyle(); \
|
||||||
YGStyle style = node->getStyle(); \
|
style.instanceName[edge] = value; \
|
||||||
style.instanceName[edge] = value; \
|
node->setStyle(style); \
|
||||||
node->setStyle(style); \
|
node->markDirtyAndPropogate(); \
|
||||||
node->markDirtyAndPropogate(); \
|
} \
|
||||||
} \
|
} \
|
||||||
} \
|
\
|
||||||
\
|
WIN_STRUCT(type) \
|
||||||
WIN_STRUCT(type) \
|
YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \
|
||||||
YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \
|
YGValue value = node->getStyle().instanceName[edge]; \
|
||||||
YGValue value = node->getStyle().instanceName[edge]; \
|
if (value.unit == YGUnitUndefined || value.unit == YGUnitAuto) { \
|
||||||
if (value.unit == YGUnitUndefined || value.unit == YGUnitAuto) { \
|
value.value = YGUndefined; \
|
||||||
value.value = YGUndefined; \
|
} \
|
||||||
} \
|
return WIN_STRUCT_REF(value); \
|
||||||
return WIN_STRUCT_REF(value); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \
|
#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \
|
||||||
@@ -858,8 +837,8 @@ YGValue YGNodeStyleGetFlexBasis(const YGNodeRef node) {
|
|||||||
|
|
||||||
void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
|
void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
|
||||||
YGValue value = {
|
YGValue value = {
|
||||||
.value = YGFloatSanitize(flexBasis),
|
YGFloatSanitize(flexBasis),
|
||||||
.unit = YGFloatIsUndefined(flexBasis) ? YGUnitUndefined : YGUnitPoint,
|
YGFloatIsUndefined(flexBasis) ? YGUnitUndefined : YGUnitPoint,
|
||||||
};
|
};
|
||||||
if ((node->getStyle().flexBasis.value != value.value &&
|
if ((node->getStyle().flexBasis.value != value.value &&
|
||||||
value.unit != YGUnitUndefined) ||
|
value.unit != YGUnitUndefined) ||
|
||||||
@@ -906,8 +885,8 @@ void YGNodeStyleSetBorder(
|
|||||||
const YGEdge edge,
|
const YGEdge edge,
|
||||||
const float border) {
|
const float border) {
|
||||||
YGValue value = {
|
YGValue value = {
|
||||||
.value = YGFloatSanitize(border),
|
YGFloatSanitize(border),
|
||||||
.unit = YGFloatIsUndefined(border) ? YGUnitUndefined : YGUnitPoint,
|
YGFloatIsUndefined(border) ? YGUnitUndefined : YGUnitPoint,
|
||||||
};
|
};
|
||||||
if ((node->getStyle().border[edge].value != value.value &&
|
if ((node->getStyle().border[edge].value != value.value &&
|
||||||
value.unit != YGUnitUndefined) ||
|
value.unit != YGUnitUndefined) ||
|
||||||
@@ -3977,7 +3956,7 @@ static void YGVLog(const YGConfigRef config,
|
|||||||
YGLogLevel level,
|
YGLogLevel level,
|
||||||
const char *format,
|
const char *format,
|
||||||
va_list args) {
|
va_list args) {
|
||||||
const YGConfigRef logConfig = config != nullptr ? config : &gYGConfigDefaults;
|
const YGConfigRef logConfig = config != nullptr ? config : YGConfigGetDefault();
|
||||||
logConfig->logger(logConfig, node, level, format, args);
|
logConfig->logger(logConfig, node, level, format, args);
|
||||||
|
|
||||||
if (level == YGLogLevelFatal) {
|
if (level == YGLogLevelFatal) {
|
||||||
|
Reference in New Issue
Block a user