Cleanup visibility macros (#1372)

Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1372

X-link: https://github.com/facebook/react-native/pull/39375

D18029030 added `-fvisibility-hidden`, and a corresponding `YOGA_EXPORT` macro for defining shared library visibility. This is used inline next to function and class definitions that should be exported out of the binary.

There was already a `WIN_EXPORT` macro doing the same thing when building a DLL, defined in the headers instead of CPP files, and it seems like sometimes folks forgot to add it to new public APIs after?

This reconciles the redundant macros into a single visibility macro, that we always place with declaration instead of definition. We also rename `YOGA_EXPORT` to `YG_EXPORT` to match the naming convention of other Yoga macros.

Reviewed By: rshest

Differential Revision: D49132643

fbshipit-source-id: cafa6de0c300788a72d9a446ce07c5ac89a20a8e
This commit is contained in:
Nick Gerleman
2023-09-11 19:51:40 -07:00
committed by Facebook GitHub Bot
parent 0720e0b22a
commit 241c5e4baf
12 changed files with 286 additions and 366 deletions

View File

@@ -13,7 +13,7 @@
namespace facebook::yoga::test { namespace facebook::yoga::test {
struct YOGA_EXPORT TestUtil { struct TestUtil {
static void startCountingNodes(); static void startCountingNodes();
static int nodeCount(); static int nodeCount();
static int stopCountingNodes(); static int stopCountingNodes();

View File

@@ -28,17 +28,11 @@
#endif #endif
#ifdef _WINDLL #ifdef _WINDLL
#define WIN_EXPORT __declspec(dllexport) #define YG_EXPORT __declspec(dllexport)
#elif !defined(_MSC_VER)
#define YG_EXPORT __attribute__((visibility("default")))
#else #else
#define WIN_EXPORT #define YG_EXPORT
#endif
#ifndef YOGA_EXPORT
#ifdef _MSC_VER
#define YOGA_EXPORT
#else
#define YOGA_EXPORT __attribute__((visibility("default")))
#endif
#endif #endif
#ifdef NS_ENUM #ifdef NS_ENUM
@@ -113,7 +107,7 @@ constexpr int n() {
#define YG_ENUM_DECL(NAME, ...) \ #define YG_ENUM_DECL(NAME, ...) \
typedef YG_ENUM_BEGIN(NAME){__VA_ARGS__} YG_ENUM_END(NAME); \ typedef YG_ENUM_BEGIN(NAME){__VA_ARGS__} YG_ENUM_END(NAME); \
WIN_EXPORT const char* NAME##ToString(NAME); YG_EXPORT const char* NAME##ToString(NAME);
#ifdef __cplusplus #ifdef __cplusplus
#define YG_ENUM_SEQ_DECL(NAME, ...) \ #define YG_ENUM_SEQ_DECL(NAME, ...) \

View File

@@ -17,9 +17,9 @@ typedef struct YGValue {
YGUnit unit; YGUnit unit;
} YGValue; } YGValue;
YOGA_EXPORT extern const YGValue YGValueAuto; YG_EXPORT extern const YGValue YGValueAuto;
YOGA_EXPORT extern const YGValue YGValueUndefined; YG_EXPORT extern const YGValue YGValueUndefined;
YOGA_EXPORT extern const YGValue YGValueZero; YG_EXPORT extern const YGValue YGValueZero;
YG_EXTERN_C_END YG_EXTERN_C_END

View File

@@ -15,7 +15,7 @@
YG_EXTERN_C_BEGIN YG_EXTERN_C_BEGIN
void YGNodeCalculateLayoutWithContext( YG_EXPORT void YGNodeCalculateLayoutWithContext(
YGNodeRef node, YGNodeRef node,
float availableWidth, float availableWidth,
float availableHeight, float availableHeight,
@@ -24,6 +24,6 @@ void YGNodeCalculateLayoutWithContext(
// Deallocates a Yoga Node. Unlike YGNodeFree, does not remove the node from // Deallocates a Yoga Node. Unlike YGNodeFree, does not remove the node from
// its parent or children. // its parent or children.
void YGNodeDeallocate(YGNodeRef node); YG_EXPORT void YGNodeDeallocate(YGNodeRef node);
YG_EXTERN_C_END YG_EXTERN_C_END

View File

@@ -20,91 +20,83 @@
using namespace facebook; using namespace facebook;
using namespace facebook::yoga; using namespace facebook::yoga;
YOGA_EXPORT bool YGFloatIsUndefined(const float value) { bool YGFloatIsUndefined(const float value) {
return yoga::isUndefined(value); return yoga::isUndefined(value);
} }
YOGA_EXPORT void* YGNodeGetContext(YGNodeConstRef node) { void* YGNodeGetContext(YGNodeConstRef node) {
return resolveRef(node)->getContext(); return resolveRef(node)->getContext();
} }
YOGA_EXPORT void YGNodeSetContext(YGNodeRef node, void* context) { void YGNodeSetContext(YGNodeRef node, void* context) {
return resolveRef(node)->setContext(context); return resolveRef(node)->setContext(context);
} }
YOGA_EXPORT YGConfigConstRef YGNodeGetConfig(YGNodeRef node) { YGConfigConstRef YGNodeGetConfig(YGNodeRef node) {
return resolveRef(node)->getConfig(); return resolveRef(node)->getConfig();
} }
YOGA_EXPORT void YGNodeSetConfig(YGNodeRef node, YGConfigRef config) { void YGNodeSetConfig(YGNodeRef node, YGConfigRef config) {
resolveRef(node)->setConfig(resolveRef(config)); resolveRef(node)->setConfig(resolveRef(config));
} }
YOGA_EXPORT bool YGNodeHasMeasureFunc(YGNodeConstRef node) { bool YGNodeHasMeasureFunc(YGNodeConstRef node) {
return resolveRef(node)->hasMeasureFunc(); return resolveRef(node)->hasMeasureFunc();
} }
YOGA_EXPORT void YGNodeSetMeasureFunc( void YGNodeSetMeasureFunc(YGNodeRef node, YGMeasureFunc measureFunc) {
YGNodeRef node,
YGMeasureFunc measureFunc) {
resolveRef(node)->setMeasureFunc(measureFunc); resolveRef(node)->setMeasureFunc(measureFunc);
} }
YOGA_EXPORT bool YGNodeHasBaselineFunc(YGNodeConstRef node) { bool YGNodeHasBaselineFunc(YGNodeConstRef node) {
return resolveRef(node)->hasBaselineFunc(); return resolveRef(node)->hasBaselineFunc();
} }
YOGA_EXPORT void YGNodeSetBaselineFunc( void YGNodeSetBaselineFunc(YGNodeRef node, YGBaselineFunc baselineFunc) {
YGNodeRef node,
YGBaselineFunc baselineFunc) {
resolveRef(node)->setBaselineFunc(baselineFunc); resolveRef(node)->setBaselineFunc(baselineFunc);
} }
YOGA_EXPORT YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeConstRef node) { YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeConstRef node) {
return resolveRef(node)->getDirtied(); return resolveRef(node)->getDirtied();
} }
YOGA_EXPORT void YGNodeSetDirtiedFunc( void YGNodeSetDirtiedFunc(YGNodeRef node, YGDirtiedFunc dirtiedFunc) {
YGNodeRef node,
YGDirtiedFunc dirtiedFunc) {
resolveRef(node)->setDirtiedFunc(dirtiedFunc); resolveRef(node)->setDirtiedFunc(dirtiedFunc);
} }
YOGA_EXPORT void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc) { void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc) {
resolveRef(node)->setPrintFunc(printFunc); resolveRef(node)->setPrintFunc(printFunc);
} }
YOGA_EXPORT bool YGNodeGetHasNewLayout(YGNodeConstRef node) { bool YGNodeGetHasNewLayout(YGNodeConstRef node) {
return resolveRef(node)->getHasNewLayout(); return resolveRef(node)->getHasNewLayout();
} }
YOGA_EXPORT void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled) { void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled) {
resolveRef(config)->setShouldPrintTree(enabled); resolveRef(config)->setShouldPrintTree(enabled);
} }
YOGA_EXPORT void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout) { void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout) {
resolveRef(node)->setHasNewLayout(hasNewLayout); resolveRef(node)->setHasNewLayout(hasNewLayout);
} }
YOGA_EXPORT YGNodeType YGNodeGetNodeType(YGNodeConstRef node) { YGNodeType YGNodeGetNodeType(YGNodeConstRef node) {
return resolveRef(node)->getNodeType(); return resolveRef(node)->getNodeType();
} }
YOGA_EXPORT void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType) { void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType) {
return resolveRef(node)->setNodeType(nodeType); return resolveRef(node)->setNodeType(nodeType);
} }
YOGA_EXPORT bool YGNodeIsDirty(YGNodeConstRef node) { bool YGNodeIsDirty(YGNodeConstRef node) {
return resolveRef(node)->isDirty(); return resolveRef(node)->isDirty();
} }
YOGA_EXPORT void YGNodeMarkDirtyAndPropagateToDescendants( void YGNodeMarkDirtyAndPropagateToDescendants(const YGNodeRef node) {
const YGNodeRef node) {
return resolveRef(node)->markDirtyAndPropagateDownwards(); return resolveRef(node)->markDirtyAndPropagateDownwards();
} }
YOGA_EXPORT WIN_EXPORT YGNodeRef YGNodeRef YGNodeNewWithConfig(const YGConfigConstRef config) {
YGNodeNewWithConfig(const YGConfigConstRef config) {
auto* node = new yoga::Node{resolveRef(config)}; auto* node = new yoga::Node{resolveRef(config)};
yoga::assertFatal( yoga::assertFatal(
config != nullptr, "Tried to construct YGNode with null config"); config != nullptr, "Tried to construct YGNode with null config");
@@ -113,15 +105,15 @@ YGNodeNewWithConfig(const YGConfigConstRef config) {
return node; return node;
} }
YOGA_EXPORT YGConfigConstRef YGConfigGetDefault() { YGConfigConstRef YGConfigGetDefault() {
return &yoga::Config::getDefault(); return &yoga::Config::getDefault();
} }
YOGA_EXPORT YGNodeRef YGNodeNew(void) { YGNodeRef YGNodeNew(void) {
return YGNodeNewWithConfig(YGConfigGetDefault()); return YGNodeNewWithConfig(YGConfigGetDefault());
} }
YOGA_EXPORT YGNodeRef YGNodeClone(YGNodeConstRef oldNodeRef) { YGNodeRef YGNodeClone(YGNodeConstRef oldNodeRef) {
auto oldNode = resolveRef(oldNodeRef); auto oldNode = resolveRef(oldNodeRef);
const auto node = new yoga::Node(*oldNode); const auto node = new yoga::Node(*oldNode);
yoga::assertFatalWithConfig( yoga::assertFatalWithConfig(
@@ -133,7 +125,7 @@ YOGA_EXPORT YGNodeRef YGNodeClone(YGNodeConstRef oldNodeRef) {
return node; return node;
} }
YOGA_EXPORT void YGNodeFree(const YGNodeRef nodeRef) { void YGNodeFree(const YGNodeRef nodeRef) {
const auto node = resolveRef(nodeRef); const auto node = resolveRef(nodeRef);
if (auto owner = node->getOwner()) { if (auto owner = node->getOwner()) {
@@ -151,12 +143,12 @@ YOGA_EXPORT void YGNodeFree(const YGNodeRef nodeRef) {
YGNodeDeallocate(node); YGNodeDeallocate(node);
} }
YOGA_EXPORT void YGNodeDeallocate(const YGNodeRef node) { void YGNodeDeallocate(const YGNodeRef node) {
Event::publish<Event::NodeDeallocation>(node, {YGNodeGetConfig(node)}); Event::publish<Event::NodeDeallocation>(node, {YGNodeGetConfig(node)});
delete resolveRef(node); delete resolveRef(node);
} }
YOGA_EXPORT void YGNodeFreeRecursiveWithCleanupFunc( void YGNodeFreeRecursiveWithCleanupFunc(
const YGNodeRef rootRef, const YGNodeRef rootRef,
YGNodeCleanupFunc cleanup) { YGNodeCleanupFunc cleanup) {
const auto root = resolveRef(rootRef); const auto root = resolveRef(rootRef);
@@ -178,25 +170,23 @@ YOGA_EXPORT void YGNodeFreeRecursiveWithCleanupFunc(
YGNodeFree(root); YGNodeFree(root);
} }
YOGA_EXPORT void YGNodeFreeRecursive(const YGNodeRef root) { void YGNodeFreeRecursive(const YGNodeRef root) {
return YGNodeFreeRecursiveWithCleanupFunc(root, nullptr); return YGNodeFreeRecursiveWithCleanupFunc(root, nullptr);
} }
YOGA_EXPORT void YGNodeReset(YGNodeRef node) { void YGNodeReset(YGNodeRef node) {
resolveRef(node)->reset(); resolveRef(node)->reset();
} }
YOGA_EXPORT YGConfigRef YGConfigNew(void) { YGConfigRef YGConfigNew(void) {
return new yoga::Config(getDefaultLogger()); return new yoga::Config(getDefaultLogger());
} }
YOGA_EXPORT void YGConfigFree(const YGConfigRef config) { void YGConfigFree(const YGConfigRef config) {
delete resolveRef(config); delete resolveRef(config);
} }
YOGA_EXPORT void YGNodeSetIsReferenceBaseline( void YGNodeSetIsReferenceBaseline(YGNodeRef nodeRef, bool isReferenceBaseline) {
YGNodeRef nodeRef,
bool isReferenceBaseline) {
const auto node = resolveRef(nodeRef); const auto node = resolveRef(nodeRef);
if (node->isReferenceBaseline() != isReferenceBaseline) { if (node->isReferenceBaseline() != isReferenceBaseline) {
node->setIsReferenceBaseline(isReferenceBaseline); node->setIsReferenceBaseline(isReferenceBaseline);
@@ -204,11 +194,11 @@ YOGA_EXPORT void YGNodeSetIsReferenceBaseline(
} }
} }
YOGA_EXPORT bool YGNodeIsReferenceBaseline(YGNodeConstRef node) { bool YGNodeIsReferenceBaseline(YGNodeConstRef node) {
return resolveRef(node)->isReferenceBaseline(); return resolveRef(node)->isReferenceBaseline();
} }
YOGA_EXPORT void YGNodeInsertChild( void YGNodeInsertChild(
const YGNodeRef ownerRef, const YGNodeRef ownerRef,
const YGNodeRef childRef, const YGNodeRef childRef,
const size_t index) { const size_t index) {
@@ -230,7 +220,7 @@ YOGA_EXPORT void YGNodeInsertChild(
owner->markDirtyAndPropagate(); owner->markDirtyAndPropagate();
} }
YOGA_EXPORT void YGNodeSwapChild( void YGNodeSwapChild(
const YGNodeRef ownerRef, const YGNodeRef ownerRef,
const YGNodeRef childRef, const YGNodeRef childRef,
const size_t index) { const size_t index) {
@@ -241,7 +231,7 @@ YOGA_EXPORT void YGNodeSwapChild(
child->setOwner(owner); child->setOwner(owner);
} }
YOGA_EXPORT void YGNodeRemoveChild( void YGNodeRemoveChild(
const YGNodeRef ownerRef, const YGNodeRef ownerRef,
const YGNodeRef excludedChildRef) { const YGNodeRef excludedChildRef) {
auto owner = resolveRef(ownerRef); auto owner = resolveRef(ownerRef);
@@ -265,7 +255,7 @@ YOGA_EXPORT void YGNodeRemoveChild(
} }
} }
YOGA_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef ownerRef) { void YGNodeRemoveAllChildren(const YGNodeRef ownerRef) {
auto owner = resolveRef(ownerRef); auto owner = resolveRef(ownerRef);
const size_t childCount = owner->getChildCount(); const size_t childCount = owner->getChildCount();
@@ -292,7 +282,7 @@ YOGA_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef ownerRef) {
owner->markDirtyAndPropagate(); owner->markDirtyAndPropagate();
} }
YOGA_EXPORT void YGNodeSetChildren( void YGNodeSetChildren(
const YGNodeRef ownerRef, const YGNodeRef ownerRef,
const YGNodeRef* childrenRefs, const YGNodeRef* childrenRefs,
const size_t count) { const size_t count) {
@@ -333,8 +323,7 @@ YOGA_EXPORT void YGNodeSetChildren(
} }
} }
YOGA_EXPORT YGNodeRef YGNodeRef YGNodeGetChild(const YGNodeRef nodeRef, const size_t index) {
YGNodeGetChild(const YGNodeRef nodeRef, const size_t index) {
const auto node = resolveRef(nodeRef); const auto node = resolveRef(nodeRef);
if (index < node->getChildren().size()) { if (index < node->getChildren().size()) {
@@ -343,19 +332,19 @@ YGNodeGetChild(const YGNodeRef nodeRef, const size_t index) {
return nullptr; return nullptr;
} }
YOGA_EXPORT size_t YGNodeGetChildCount(const YGNodeConstRef node) { size_t YGNodeGetChildCount(const YGNodeConstRef node) {
return resolveRef(node)->getChildren().size(); return resolveRef(node)->getChildren().size();
} }
YOGA_EXPORT YGNodeRef YGNodeGetOwner(const YGNodeRef node) { YGNodeRef YGNodeGetOwner(const YGNodeRef node) {
return resolveRef(node)->getOwner(); return resolveRef(node)->getOwner();
} }
YOGA_EXPORT YGNodeRef YGNodeGetParent(const YGNodeRef node) { YGNodeRef YGNodeGetParent(const YGNodeRef node) {
return resolveRef(node)->getOwner(); return resolveRef(node)->getOwner();
} }
YOGA_EXPORT void YGNodeMarkDirty(const YGNodeRef nodeRef) { void YGNodeMarkDirty(const YGNodeRef nodeRef) {
const auto node = resolveRef(nodeRef); const auto node = resolveRef(nodeRef);
yoga::assertFatalWithNode( yoga::assertFatalWithNode(
@@ -367,7 +356,7 @@ YOGA_EXPORT void YGNodeMarkDirty(const YGNodeRef nodeRef) {
node->markDirtyAndPropagate(); node->markDirtyAndPropagate();
} }
YOGA_EXPORT void YGNodeCopyStyle( void YGNodeCopyStyle(
const YGNodeRef dstNodeRef, const YGNodeRef dstNodeRef,
const YGNodeConstRef srcNodeRef) { const YGNodeConstRef srcNodeRef) {
auto dstNode = resolveRef(dstNodeRef); auto dstNode = resolveRef(dstNodeRef);
@@ -379,14 +368,14 @@ YOGA_EXPORT void YGNodeCopyStyle(
} }
} }
YOGA_EXPORT float YGNodeStyleGetFlexGrow(const YGNodeConstRef nodeRef) { float YGNodeStyleGetFlexGrow(const YGNodeConstRef nodeRef) {
const auto node = resolveRef(nodeRef); const auto node = resolveRef(nodeRef);
return node->getStyle().flexGrow().isUndefined() return node->getStyle().flexGrow().isUndefined()
? Style::DefaultFlexGrow ? Style::DefaultFlexGrow
: node->getStyle().flexGrow().unwrap(); : node->getStyle().flexGrow().unwrap();
} }
YOGA_EXPORT float YGNodeStyleGetFlexShrink(const YGNodeConstRef nodeRef) { float YGNodeStyleGetFlexShrink(const YGNodeConstRef nodeRef) {
const auto node = resolveRef(nodeRef); const auto node = resolveRef(nodeRef);
return node->getStyle().flexShrink().isUndefined() return node->getStyle().flexShrink().isUndefined()
? (node->getConfig()->useWebDefaults() ? Style::WebDefaultFlexShrink ? (node->getConfig()->useWebDefaults() ? Style::WebDefaultFlexShrink
@@ -439,109 +428,95 @@ void updateIndexedStyleProp(
// decltype, MSVC will prefer the non-const version. // decltype, MSVC will prefer the non-const version.
#define MSVC_HINT(PROP) decltype(Style{}.PROP()) #define MSVC_HINT(PROP) decltype(Style{}.PROP())
YOGA_EXPORT void YGNodeStyleSetDirection( void YGNodeStyleSetDirection(const YGNodeRef node, const YGDirection value) {
const YGNodeRef node,
const YGDirection value) {
updateStyle<MSVC_HINT(direction)>(node, &Style::direction, value); updateStyle<MSVC_HINT(direction)>(node, &Style::direction, value);
} }
YOGA_EXPORT YGDirection YGNodeStyleGetDirection(const YGNodeConstRef node) { YGDirection YGNodeStyleGetDirection(const YGNodeConstRef node) {
return resolveRef(node)->getStyle().direction(); return resolveRef(node)->getStyle().direction();
} }
YOGA_EXPORT void YGNodeStyleSetFlexDirection( void YGNodeStyleSetFlexDirection(
const YGNodeRef node, const YGNodeRef node,
const YGFlexDirection flexDirection) { const YGFlexDirection flexDirection) {
updateStyle<MSVC_HINT(flexDirection)>( updateStyle<MSVC_HINT(flexDirection)>(
node, &Style::flexDirection, flexDirection); node, &Style::flexDirection, flexDirection);
} }
YOGA_EXPORT YGFlexDirection YGFlexDirection YGNodeStyleGetFlexDirection(const YGNodeConstRef node) {
YGNodeStyleGetFlexDirection(const YGNodeConstRef node) {
return resolveRef(node)->getStyle().flexDirection(); return resolveRef(node)->getStyle().flexDirection();
} }
YOGA_EXPORT void YGNodeStyleSetJustifyContent( void YGNodeStyleSetJustifyContent(
const YGNodeRef node, const YGNodeRef node,
const YGJustify justifyContent) { const YGJustify justifyContent) {
updateStyle<MSVC_HINT(justifyContent)>( updateStyle<MSVC_HINT(justifyContent)>(
node, &Style::justifyContent, justifyContent); node, &Style::justifyContent, justifyContent);
} }
YOGA_EXPORT YGJustify YGNodeStyleGetJustifyContent(const YGNodeConstRef node) { YGJustify YGNodeStyleGetJustifyContent(const YGNodeConstRef node) {
return resolveRef(node)->getStyle().justifyContent(); return resolveRef(node)->getStyle().justifyContent();
} }
YOGA_EXPORT void YGNodeStyleSetAlignContent( void YGNodeStyleSetAlignContent(
const YGNodeRef node, const YGNodeRef node,
const YGAlign alignContent) { const YGAlign alignContent) {
updateStyle<MSVC_HINT(alignContent)>( updateStyle<MSVC_HINT(alignContent)>(
node, &Style::alignContent, alignContent); node, &Style::alignContent, alignContent);
} }
YOGA_EXPORT YGAlign YGNodeStyleGetAlignContent(const YGNodeConstRef node) { YGAlign YGNodeStyleGetAlignContent(const YGNodeConstRef node) {
return resolveRef(node)->getStyle().alignContent(); return resolveRef(node)->getStyle().alignContent();
} }
YOGA_EXPORT void YGNodeStyleSetAlignItems( void YGNodeStyleSetAlignItems(const YGNodeRef node, const YGAlign alignItems) {
const YGNodeRef node,
const YGAlign alignItems) {
updateStyle<MSVC_HINT(alignItems)>(node, &Style::alignItems, alignItems); updateStyle<MSVC_HINT(alignItems)>(node, &Style::alignItems, alignItems);
} }
YOGA_EXPORT YGAlign YGNodeStyleGetAlignItems(const YGNodeConstRef node) { YGAlign YGNodeStyleGetAlignItems(const YGNodeConstRef node) {
return resolveRef(node)->getStyle().alignItems(); return resolveRef(node)->getStyle().alignItems();
} }
YOGA_EXPORT void YGNodeStyleSetAlignSelf( void YGNodeStyleSetAlignSelf(const YGNodeRef node, const YGAlign alignSelf) {
const YGNodeRef node,
const YGAlign alignSelf) {
updateStyle<MSVC_HINT(alignSelf)>(node, &Style::alignSelf, alignSelf); updateStyle<MSVC_HINT(alignSelf)>(node, &Style::alignSelf, alignSelf);
} }
YOGA_EXPORT YGAlign YGNodeStyleGetAlignSelf(const YGNodeConstRef node) { YGAlign YGNodeStyleGetAlignSelf(const YGNodeConstRef node) {
return resolveRef(node)->getStyle().alignSelf(); return resolveRef(node)->getStyle().alignSelf();
} }
YOGA_EXPORT void YGNodeStyleSetPositionType( void YGNodeStyleSetPositionType(
const YGNodeRef node, const YGNodeRef node,
const YGPositionType positionType) { const YGPositionType positionType) {
updateStyle<MSVC_HINT(positionType)>( updateStyle<MSVC_HINT(positionType)>(
node, &Style::positionType, positionType); node, &Style::positionType, positionType);
} }
YOGA_EXPORT YGPositionType YGPositionType YGNodeStyleGetPositionType(const YGNodeConstRef node) {
YGNodeStyleGetPositionType(const YGNodeConstRef node) {
return resolveRef(node)->getStyle().positionType(); return resolveRef(node)->getStyle().positionType();
} }
YOGA_EXPORT void YGNodeStyleSetFlexWrap( void YGNodeStyleSetFlexWrap(const YGNodeRef node, const YGWrap flexWrap) {
const YGNodeRef node,
const YGWrap flexWrap) {
updateStyle<MSVC_HINT(flexWrap)>(node, &Style::flexWrap, flexWrap); updateStyle<MSVC_HINT(flexWrap)>(node, &Style::flexWrap, flexWrap);
} }
YOGA_EXPORT YGWrap YGNodeStyleGetFlexWrap(const YGNodeConstRef node) { YGWrap YGNodeStyleGetFlexWrap(const YGNodeConstRef node) {
return resolveRef(node)->getStyle().flexWrap(); return resolveRef(node)->getStyle().flexWrap();
} }
YOGA_EXPORT void YGNodeStyleSetOverflow( void YGNodeStyleSetOverflow(const YGNodeRef node, const YGOverflow overflow) {
const YGNodeRef node,
const YGOverflow overflow) {
updateStyle<MSVC_HINT(overflow)>(node, &Style::overflow, overflow); updateStyle<MSVC_HINT(overflow)>(node, &Style::overflow, overflow);
} }
YOGA_EXPORT YGOverflow YGNodeStyleGetOverflow(const YGNodeConstRef node) { YGOverflow YGNodeStyleGetOverflow(const YGNodeConstRef node) {
return resolveRef(node)->getStyle().overflow(); return resolveRef(node)->getStyle().overflow();
} }
YOGA_EXPORT void YGNodeStyleSetDisplay( void YGNodeStyleSetDisplay(const YGNodeRef node, const YGDisplay display) {
const YGNodeRef node,
const YGDisplay display) {
updateStyle<MSVC_HINT(display)>(node, &Style::display, display); updateStyle<MSVC_HINT(display)>(node, &Style::display, display);
} }
YOGA_EXPORT YGDisplay YGNodeStyleGetDisplay(const YGNodeConstRef node) { YGDisplay YGNodeStyleGetDisplay(const YGNodeConstRef node) {
return resolveRef(node)->getStyle().display(); return resolveRef(node)->getStyle().display();
} }
// TODO(T26792433): Change the API to accept FloatOptional. // TODO(T26792433): Change the API to accept FloatOptional.
YOGA_EXPORT void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
updateStyle<MSVC_HINT(flex)>(node, &Style::flex, FloatOptional{flex}); updateStyle<MSVC_HINT(flex)>(node, &Style::flex, FloatOptional{flex});
} }
// TODO(T26792433): Change the API to accept FloatOptional. // TODO(T26792433): Change the API to accept FloatOptional.
YOGA_EXPORT float YGNodeStyleGetFlex(const YGNodeConstRef nodeRef) { float YGNodeStyleGetFlex(const YGNodeConstRef nodeRef) {
const auto node = resolveRef(nodeRef); const auto node = resolveRef(nodeRef);
return node->getStyle().flex().isUndefined() return node->getStyle().flex().isUndefined()
? YGUndefined ? YGUndefined
@@ -549,22 +524,18 @@ YOGA_EXPORT float YGNodeStyleGetFlex(const YGNodeConstRef nodeRef) {
} }
// TODO(T26792433): Change the API to accept FloatOptional. // TODO(T26792433): Change the API to accept FloatOptional.
YOGA_EXPORT void YGNodeStyleSetFlexGrow( void YGNodeStyleSetFlexGrow(const YGNodeRef node, const float flexGrow) {
const YGNodeRef node,
const float flexGrow) {
updateStyle<MSVC_HINT(flexGrow)>( updateStyle<MSVC_HINT(flexGrow)>(
node, &Style::flexGrow, FloatOptional{flexGrow}); node, &Style::flexGrow, FloatOptional{flexGrow});
} }
// TODO(T26792433): Change the API to accept FloatOptional. // TODO(T26792433): Change the API to accept FloatOptional.
YOGA_EXPORT void YGNodeStyleSetFlexShrink( void YGNodeStyleSetFlexShrink(const YGNodeRef node, const float flexShrink) {
const YGNodeRef node,
const float flexShrink) {
updateStyle<MSVC_HINT(flexShrink)>( updateStyle<MSVC_HINT(flexShrink)>(
node, &Style::flexShrink, FloatOptional{flexShrink}); node, &Style::flexShrink, FloatOptional{flexShrink});
} }
YOGA_EXPORT YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) { YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
YGValue flexBasis = resolveRef(node)->getStyle().flexBasis(); YGValue flexBasis = resolveRef(node)->getStyle().flexBasis();
if (flexBasis.unit == YGUnitUndefined || flexBasis.unit == YGUnitAuto) { if (flexBasis.unit == YGUnitUndefined || flexBasis.unit == YGUnitAuto) {
// TODO(T26792433): Get rid off the use of YGUndefined at client side // TODO(T26792433): Get rid off the use of YGUndefined at client side
@@ -573,89 +544,69 @@ YOGA_EXPORT YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
return flexBasis; return flexBasis;
} }
YOGA_EXPORT void YGNodeStyleSetFlexBasis( void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
const YGNodeRef node,
const float flexBasis) {
auto value = CompactValue::ofMaybe<YGUnitPoint>(flexBasis); auto value = CompactValue::ofMaybe<YGUnitPoint>(flexBasis);
updateStyle<MSVC_HINT(flexBasis)>(node, &Style::flexBasis, value); updateStyle<MSVC_HINT(flexBasis)>(node, &Style::flexBasis, value);
} }
YOGA_EXPORT void YGNodeStyleSetFlexBasisPercent( void YGNodeStyleSetFlexBasisPercent(
const YGNodeRef node, const YGNodeRef node,
const float flexBasisPercent) { const float flexBasisPercent) {
auto value = CompactValue::ofMaybe<YGUnitPercent>(flexBasisPercent); auto value = CompactValue::ofMaybe<YGUnitPercent>(flexBasisPercent);
updateStyle<MSVC_HINT(flexBasis)>(node, &Style::flexBasis, value); updateStyle<MSVC_HINT(flexBasis)>(node, &Style::flexBasis, value);
} }
YOGA_EXPORT void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) { void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
updateStyle<MSVC_HINT(flexBasis)>( updateStyle<MSVC_HINT(flexBasis)>(
node, &Style::flexBasis, CompactValue::ofAuto()); node, &Style::flexBasis, CompactValue::ofAuto());
} }
YOGA_EXPORT void YGNodeStyleSetPosition( void YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float points) {
YGNodeRef node,
YGEdge edge,
float points) {
auto value = CompactValue::ofMaybe<YGUnitPoint>(points); auto value = CompactValue::ofMaybe<YGUnitPoint>(points);
updateIndexedStyleProp<MSVC_HINT(position)>( updateIndexedStyleProp<MSVC_HINT(position)>(
node, &Style::position, edge, value); node, &Style::position, edge, value);
} }
YOGA_EXPORT void YGNodeStyleSetPositionPercent( void YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float percent) {
YGNodeRef node,
YGEdge edge,
float percent) {
auto value = CompactValue::ofMaybe<YGUnitPercent>(percent); auto value = CompactValue::ofMaybe<YGUnitPercent>(percent);
updateIndexedStyleProp<MSVC_HINT(position)>( updateIndexedStyleProp<MSVC_HINT(position)>(
node, &Style::position, edge, value); node, &Style::position, edge, value);
} }
YOGA_EXPORT YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) { YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) {
return resolveRef(node)->getStyle().position()[edge]; return resolveRef(node)->getStyle().position()[edge];
} }
YOGA_EXPORT void YGNodeStyleSetMargin( void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float points) {
YGNodeRef node,
YGEdge edge,
float points) {
auto value = CompactValue::ofMaybe<YGUnitPoint>(points); auto value = CompactValue::ofMaybe<YGUnitPoint>(points);
updateIndexedStyleProp<MSVC_HINT(margin)>(node, &Style::margin, edge, value); updateIndexedStyleProp<MSVC_HINT(margin)>(node, &Style::margin, edge, value);
} }
YOGA_EXPORT void YGNodeStyleSetMarginPercent( void YGNodeStyleSetMarginPercent(YGNodeRef node, YGEdge edge, float percent) {
YGNodeRef node,
YGEdge edge,
float percent) {
auto value = CompactValue::ofMaybe<YGUnitPercent>(percent); auto value = CompactValue::ofMaybe<YGUnitPercent>(percent);
updateIndexedStyleProp<MSVC_HINT(margin)>(node, &Style::margin, edge, value); updateIndexedStyleProp<MSVC_HINT(margin)>(node, &Style::margin, edge, value);
} }
YOGA_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) { void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) {
updateIndexedStyleProp<MSVC_HINT(margin)>( updateIndexedStyleProp<MSVC_HINT(margin)>(
node, &Style::margin, edge, CompactValue::ofAuto()); node, &Style::margin, edge, CompactValue::ofAuto());
} }
YOGA_EXPORT YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) { YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) {
return resolveRef(node)->getStyle().margin()[edge]; return resolveRef(node)->getStyle().margin()[edge];
} }
YOGA_EXPORT void YGNodeStyleSetPadding( void YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge, float points) {
YGNodeRef node,
YGEdge edge,
float points) {
auto value = CompactValue::ofMaybe<YGUnitPoint>(points); auto value = CompactValue::ofMaybe<YGUnitPoint>(points);
updateIndexedStyleProp<MSVC_HINT(padding)>( updateIndexedStyleProp<MSVC_HINT(padding)>(
node, &Style::padding, edge, value); node, &Style::padding, edge, value);
} }
YOGA_EXPORT void YGNodeStyleSetPaddingPercent( void YGNodeStyleSetPaddingPercent(YGNodeRef node, YGEdge edge, float percent) {
YGNodeRef node,
YGEdge edge,
float percent) {
auto value = CompactValue::ofMaybe<YGUnitPercent>(percent); auto value = CompactValue::ofMaybe<YGUnitPercent>(percent);
updateIndexedStyleProp<MSVC_HINT(padding)>( updateIndexedStyleProp<MSVC_HINT(padding)>(
node, &Style::padding, edge, value); node, &Style::padding, edge, value);
} }
YOGA_EXPORT YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge) { YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge) {
return resolveRef(node)->getStyle().padding()[edge]; return resolveRef(node)->getStyle().padding()[edge];
} }
// TODO(T26792433): Change the API to accept FloatOptional. // TODO(T26792433): Change the API to accept FloatOptional.
YOGA_EXPORT void YGNodeStyleSetBorder( void YGNodeStyleSetBorder(
const YGNodeRef node, const YGNodeRef node,
const YGEdge edge, const YGEdge edge,
const float border) { const float border) {
@@ -663,9 +614,7 @@ YOGA_EXPORT void YGNodeStyleSetBorder(
updateIndexedStyleProp<MSVC_HINT(border)>(node, &Style::border, edge, value); updateIndexedStyleProp<MSVC_HINT(border)>(node, &Style::border, edge, value);
} }
YOGA_EXPORT float YGNodeStyleGetBorder( float YGNodeStyleGetBorder(const YGNodeConstRef node, const YGEdge edge) {
const YGNodeConstRef node,
const YGEdge edge) {
auto border = resolveRef(node)->getStyle().border()[edge]; auto border = resolveRef(node)->getStyle().border()[edge];
if (border.isUndefined() || border.isAuto()) { if (border.isUndefined() || border.isAuto()) {
// TODO(T26792433): Rather than returning YGUndefined, change the api to // TODO(T26792433): Rather than returning YGUndefined, change the api to
@@ -676,7 +625,7 @@ YOGA_EXPORT float YGNodeStyleGetBorder(
return static_cast<YGValue>(border).value; return static_cast<YGValue>(border).value;
} }
YOGA_EXPORT void YGNodeStyleSetGap( void YGNodeStyleSetGap(
const YGNodeRef node, const YGNodeRef node,
const YGGutter gutter, const YGGutter gutter,
const float gapLength) { const float gapLength) {
@@ -684,9 +633,7 @@ YOGA_EXPORT void YGNodeStyleSetGap(
updateIndexedStyleProp<MSVC_HINT(gap)>(node, &Style::gap, gutter, length); updateIndexedStyleProp<MSVC_HINT(gap)>(node, &Style::gap, gutter, length);
} }
YOGA_EXPORT float YGNodeStyleGetGap( float YGNodeStyleGetGap(const YGNodeConstRef node, const YGGutter gutter) {
const YGNodeConstRef node,
const YGGutter gutter) {
auto gapLength = resolveRef(node)->getStyle().gap()[gutter]; auto gapLength = resolveRef(node)->getStyle().gap()[gutter];
if (gapLength.isUndefined() || gapLength.isAuto()) { if (gapLength.isUndefined() || gapLength.isAuto()) {
// TODO(T26792433): Rather than returning YGUndefined, change the api to // TODO(T26792433): Rather than returning YGUndefined, change the api to
@@ -700,134 +647,120 @@ YOGA_EXPORT float YGNodeStyleGetGap(
// Yoga specific properties, not compatible with flexbox specification // Yoga specific properties, not compatible with flexbox specification
// TODO(T26792433): Change the API to accept FloatOptional. // TODO(T26792433): Change the API to accept FloatOptional.
YOGA_EXPORT float YGNodeStyleGetAspectRatio(const YGNodeConstRef node) { float YGNodeStyleGetAspectRatio(const YGNodeConstRef node) {
const FloatOptional op = resolveRef(node)->getStyle().aspectRatio(); const FloatOptional op = resolveRef(node)->getStyle().aspectRatio();
return op.isUndefined() ? YGUndefined : op.unwrap(); return op.isUndefined() ? YGUndefined : op.unwrap();
} }
// TODO(T26792433): Change the API to accept FloatOptional. // TODO(T26792433): Change the API to accept FloatOptional.
YOGA_EXPORT void YGNodeStyleSetAspectRatio( void YGNodeStyleSetAspectRatio(const YGNodeRef node, const float aspectRatio) {
const YGNodeRef node,
const float aspectRatio) {
updateStyle<MSVC_HINT(aspectRatio)>( updateStyle<MSVC_HINT(aspectRatio)>(
node, &Style::aspectRatio, FloatOptional{aspectRatio}); node, &Style::aspectRatio, FloatOptional{aspectRatio});
} }
YOGA_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float points) { void YGNodeStyleSetWidth(YGNodeRef node, float points) {
auto value = CompactValue::ofMaybe<YGUnitPoint>(points); auto value = CompactValue::ofMaybe<YGUnitPoint>(points);
updateIndexedStyleProp<MSVC_HINT(dimensions)>( updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &Style::dimensions, YGDimensionWidth, value); node, &Style::dimensions, YGDimensionWidth, value);
} }
YOGA_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) { void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) {
auto value = CompactValue::ofMaybe<YGUnitPercent>(percent); auto value = CompactValue::ofMaybe<YGUnitPercent>(percent);
updateIndexedStyleProp<MSVC_HINT(dimensions)>( updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &Style::dimensions, YGDimensionWidth, value); node, &Style::dimensions, YGDimensionWidth, value);
} }
YOGA_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node) { void YGNodeStyleSetWidthAuto(YGNodeRef node) {
updateIndexedStyleProp<MSVC_HINT(dimensions)>( updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &Style::dimensions, YGDimensionWidth, CompactValue::ofAuto()); node, &Style::dimensions, YGDimensionWidth, CompactValue::ofAuto());
} }
YOGA_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node) { YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
return resolveRef(node)->getStyle().dimensions()[YGDimensionWidth]; return resolveRef(node)->getStyle().dimensions()[YGDimensionWidth];
} }
YOGA_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, float points) { void YGNodeStyleSetHeight(YGNodeRef node, float points) {
auto value = CompactValue::ofMaybe<YGUnitPoint>(points); auto value = CompactValue::ofMaybe<YGUnitPoint>(points);
updateIndexedStyleProp<MSVC_HINT(dimensions)>( updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &Style::dimensions, YGDimensionHeight, value); node, &Style::dimensions, YGDimensionHeight, value);
} }
YOGA_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) { void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) {
auto value = CompactValue::ofMaybe<YGUnitPercent>(percent); auto value = CompactValue::ofMaybe<YGUnitPercent>(percent);
updateIndexedStyleProp<MSVC_HINT(dimensions)>( updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &Style::dimensions, YGDimensionHeight, value); node, &Style::dimensions, YGDimensionHeight, value);
} }
YOGA_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node) { void YGNodeStyleSetHeightAuto(YGNodeRef node) {
updateIndexedStyleProp<MSVC_HINT(dimensions)>( updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &Style::dimensions, YGDimensionHeight, CompactValue::ofAuto()); node, &Style::dimensions, YGDimensionHeight, CompactValue::ofAuto());
} }
YOGA_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node) { YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
return resolveRef(node)->getStyle().dimensions()[YGDimensionHeight]; return resolveRef(node)->getStyle().dimensions()[YGDimensionHeight];
} }
YOGA_EXPORT void YGNodeStyleSetMinWidth( void YGNodeStyleSetMinWidth(const YGNodeRef node, const float minWidth) {
const YGNodeRef node,
const float minWidth) {
auto value = CompactValue::ofMaybe<YGUnitPoint>(minWidth); auto value = CompactValue::ofMaybe<YGUnitPoint>(minWidth);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>( updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &Style::minDimensions, YGDimensionWidth, value); node, &Style::minDimensions, YGDimensionWidth, value);
} }
YOGA_EXPORT void YGNodeStyleSetMinWidthPercent( void YGNodeStyleSetMinWidthPercent(const YGNodeRef node, const float minWidth) {
const YGNodeRef node,
const float minWidth) {
auto value = CompactValue::ofMaybe<YGUnitPercent>(minWidth); auto value = CompactValue::ofMaybe<YGUnitPercent>(minWidth);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>( updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &Style::minDimensions, YGDimensionWidth, value); node, &Style::minDimensions, YGDimensionWidth, value);
} }
YOGA_EXPORT YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) { YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
return resolveRef(node)->getStyle().minDimensions()[YGDimensionWidth]; return resolveRef(node)->getStyle().minDimensions()[YGDimensionWidth];
} }
YOGA_EXPORT void YGNodeStyleSetMinHeight( void YGNodeStyleSetMinHeight(const YGNodeRef node, const float minHeight) {
const YGNodeRef node,
const float minHeight) {
auto value = CompactValue::ofMaybe<YGUnitPoint>(minHeight); auto value = CompactValue::ofMaybe<YGUnitPoint>(minHeight);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>( updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &Style::minDimensions, YGDimensionHeight, value); node, &Style::minDimensions, YGDimensionHeight, value);
} }
YOGA_EXPORT void YGNodeStyleSetMinHeightPercent( void YGNodeStyleSetMinHeightPercent(
const YGNodeRef node, const YGNodeRef node,
const float minHeight) { const float minHeight) {
auto value = CompactValue::ofMaybe<YGUnitPercent>(minHeight); auto value = CompactValue::ofMaybe<YGUnitPercent>(minHeight);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>( updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &Style::minDimensions, YGDimensionHeight, value); node, &Style::minDimensions, YGDimensionHeight, value);
} }
YOGA_EXPORT YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) { YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
return resolveRef(node)->getStyle().minDimensions()[YGDimensionHeight]; return resolveRef(node)->getStyle().minDimensions()[YGDimensionHeight];
} }
YOGA_EXPORT void YGNodeStyleSetMaxWidth( void YGNodeStyleSetMaxWidth(const YGNodeRef node, const float maxWidth) {
const YGNodeRef node,
const float maxWidth) {
auto value = CompactValue::ofMaybe<YGUnitPoint>(maxWidth); auto value = CompactValue::ofMaybe<YGUnitPoint>(maxWidth);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>( updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &Style::maxDimensions, YGDimensionWidth, value); node, &Style::maxDimensions, YGDimensionWidth, value);
} }
YOGA_EXPORT void YGNodeStyleSetMaxWidthPercent( void YGNodeStyleSetMaxWidthPercent(const YGNodeRef node, const float maxWidth) {
const YGNodeRef node,
const float maxWidth) {
auto value = CompactValue::ofMaybe<YGUnitPercent>(maxWidth); auto value = CompactValue::ofMaybe<YGUnitPercent>(maxWidth);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>( updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &Style::maxDimensions, YGDimensionWidth, value); node, &Style::maxDimensions, YGDimensionWidth, value);
} }
YOGA_EXPORT YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) { YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
return resolveRef(node)->getStyle().maxDimensions()[YGDimensionWidth]; return resolveRef(node)->getStyle().maxDimensions()[YGDimensionWidth];
} }
YOGA_EXPORT void YGNodeStyleSetMaxHeight( void YGNodeStyleSetMaxHeight(const YGNodeRef node, const float maxHeight) {
const YGNodeRef node,
const float maxHeight) {
auto value = CompactValue::ofMaybe<YGUnitPoint>(maxHeight); auto value = CompactValue::ofMaybe<YGUnitPoint>(maxHeight);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>( updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &Style::maxDimensions, YGDimensionHeight, value); node, &Style::maxDimensions, YGDimensionHeight, value);
} }
YOGA_EXPORT void YGNodeStyleSetMaxHeightPercent( void YGNodeStyleSetMaxHeightPercent(
const YGNodeRef node, const YGNodeRef node,
const float maxHeight) { const float maxHeight) {
auto value = CompactValue::ofMaybe<YGUnitPercent>(maxHeight); auto value = CompactValue::ofMaybe<YGUnitPercent>(maxHeight);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>( updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &Style::maxDimensions, YGDimensionHeight, value); node, &Style::maxDimensions, YGDimensionHeight, value);
} }
YOGA_EXPORT YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) { YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
return resolveRef(node)->getStyle().maxDimensions()[YGDimensionHeight]; return resolveRef(node)->getStyle().maxDimensions()[YGDimensionHeight];
} }
#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \ #define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \
YOGA_EXPORT type YGNodeLayoutGet##name(const YGNodeConstRef node) { \ type YGNodeLayoutGet##name(const YGNodeConstRef node) { \
return resolveRef(node)->getLayout().instanceName; \ return resolveRef(node)->getLayout().instanceName; \
} }
#define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \ #define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \
YOGA_EXPORT type YGNodeLayoutGet##name( \ type YGNodeLayoutGet##name( \
const YGNodeConstRef nodeRef, const YGEdge edge) { \ const YGNodeConstRef nodeRef, const YGEdge edge) { \
const auto node = resolveRef(nodeRef); \ const auto node = resolveRef(nodeRef); \
yoga::assertFatalWithNode( \ yoga::assertFatalWithNode( \
@@ -868,9 +801,7 @@ YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Border, border)
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Padding, padding) YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Padding, padding)
#ifdef DEBUG #ifdef DEBUG
YOGA_EXPORT void YGNodePrint( void YGNodePrint(const YGNodeConstRef nodeRef, const YGPrintOptions options) {
const YGNodeConstRef nodeRef,
const YGPrintOptions options) {
const auto node = resolveRef(nodeRef); const auto node = resolveRef(nodeRef);
std::string str; std::string str;
yoga::nodeToString(str, node, options, 0); yoga::nodeToString(str, node, options, 0);
@@ -878,7 +809,7 @@ YOGA_EXPORT void YGNodePrint(
} }
#endif #endif
YOGA_EXPORT void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) { void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) {
if (logger != nullptr) { if (logger != nullptr) {
resolveRef(config)->setLogger(logger); resolveRef(config)->setLogger(logger);
} else { } else {
@@ -886,7 +817,7 @@ YOGA_EXPORT void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) {
} }
} }
YOGA_EXPORT void YGConfigSetPointScaleFactor( void YGConfigSetPointScaleFactor(
const YGConfigRef config, const YGConfigRef config,
const float pixelsInPoint) { const float pixelsInPoint) {
yoga::assertFatalWithConfig( yoga::assertFatalWithConfig(
@@ -903,11 +834,11 @@ YOGA_EXPORT void YGConfigSetPointScaleFactor(
} }
} }
YOGA_EXPORT float YGConfigGetPointScaleFactor(const YGConfigConstRef config) { float YGConfigGetPointScaleFactor(const YGConfigConstRef config) {
return resolveRef(config)->getPointScaleFactor(); return resolveRef(config)->getPointScaleFactor();
} }
YOGA_EXPORT float YGRoundValueToPixelGrid( float YGRoundValueToPixelGrid(
const double value, const double value,
const double pointScaleFactor, const double pointScaleFactor,
const bool forceCeil, const bool forceCeil,
@@ -916,22 +847,20 @@ YOGA_EXPORT float YGRoundValueToPixelGrid(
value, pointScaleFactor, forceCeil, forceFloor); value, pointScaleFactor, forceCeil, forceFloor);
} }
YOGA_EXPORT void YGConfigSetExperimentalFeatureEnabled( void YGConfigSetExperimentalFeatureEnabled(
const YGConfigRef config, const YGConfigRef config,
const YGExperimentalFeature feature, const YGExperimentalFeature feature,
const bool enabled) { const bool enabled) {
resolveRef(config)->setExperimentalFeatureEnabled(feature, enabled); resolveRef(config)->setExperimentalFeatureEnabled(feature, enabled);
} }
YOGA_EXPORT bool YGConfigIsExperimentalFeatureEnabled( bool YGConfigIsExperimentalFeatureEnabled(
const YGConfigConstRef config, const YGConfigConstRef config,
const YGExperimentalFeature feature) { const YGExperimentalFeature feature) {
return resolveRef(config)->isExperimentalFeatureEnabled(feature); return resolveRef(config)->isExperimentalFeatureEnabled(feature);
} }
YOGA_EXPORT void YGConfigSetUseWebDefaults( void YGConfigSetUseWebDefaults(const YGConfigRef config, const bool enabled) {
const YGConfigRef config,
const bool enabled) {
resolveRef(config)->setUseWebDefaults(enabled); resolveRef(config)->setUseWebDefaults(enabled);
} }
@@ -939,23 +868,23 @@ bool YGConfigGetUseWebDefaults(const YGConfigConstRef config) {
return resolveRef(config)->useWebDefaults(); return resolveRef(config)->useWebDefaults();
} }
YOGA_EXPORT void YGConfigSetContext(const YGConfigRef config, void* context) { void YGConfigSetContext(const YGConfigRef config, void* context) {
resolveRef(config)->setContext(context); resolveRef(config)->setContext(context);
} }
YOGA_EXPORT void* YGConfigGetContext(const YGConfigConstRef config) { void* YGConfigGetContext(const YGConfigConstRef config) {
return resolveRef(config)->getContext(); return resolveRef(config)->getContext();
} }
YOGA_EXPORT void YGConfigSetErrata(YGConfigRef config, YGErrata errata) { void YGConfigSetErrata(YGConfigRef config, YGErrata errata) {
resolveRef(config)->setErrata(errata); resolveRef(config)->setErrata(errata);
} }
YOGA_EXPORT YGErrata YGConfigGetErrata(YGConfigConstRef config) { YGErrata YGConfigGetErrata(YGConfigConstRef config) {
return resolveRef(config)->getErrata(); return resolveRef(config)->getErrata();
} }
YOGA_EXPORT void YGConfigSetCloneNodeFunc( void YGConfigSetCloneNodeFunc(
const YGConfigRef config, const YGConfigRef config,
const YGCloneNodeFunc callback) { const YGCloneNodeFunc callback) {
resolveRef(config)->setCloneNodeCallback(callback); resolveRef(config)->setCloneNodeCallback(callback);
@@ -963,7 +892,7 @@ YOGA_EXPORT void YGConfigSetCloneNodeFunc(
// TODO: This should not be part of the public API. Remove after removing // TODO: This should not be part of the public API. Remove after removing
// ComponentKit usage of it. // ComponentKit usage of it.
YOGA_EXPORT bool YGNodeCanUseCachedMeasurement( bool YGNodeCanUseCachedMeasurement(
YGMeasureMode widthMode, YGMeasureMode widthMode,
float availableWidth, float availableWidth,
YGMeasureMode heightMode, YGMeasureMode heightMode,
@@ -993,7 +922,7 @@ YOGA_EXPORT bool YGNodeCanUseCachedMeasurement(
resolveRef(config)); resolveRef(config));
} }
YOGA_EXPORT void YGNodeCalculateLayout( void YGNodeCalculateLayout(
const YGNodeRef node, const YGNodeRef node,
const float ownerWidth, const float ownerWidth,
const float ownerHeight, const float ownerHeight,
@@ -1002,7 +931,7 @@ YOGA_EXPORT void YGNodeCalculateLayout(
node, ownerWidth, ownerHeight, ownerDirection, nullptr); node, ownerWidth, ownerHeight, ownerDirection, nullptr);
} }
YOGA_EXPORT void YGNodeCalculateLayoutWithContext( void YGNodeCalculateLayoutWithContext(
const YGNodeRef node, const YGNodeRef node,
const float ownerWidth, const float ownerWidth,
const float ownerHeight, const float ownerHeight,

View File

@@ -51,41 +51,38 @@ typedef YGNodeRef (*YGCloneNodeFunc)(
size_t childIndex); size_t childIndex);
// YGNode // YGNode
WIN_EXPORT YGNodeRef YGNodeNew(void); YG_EXPORT YGNodeRef YGNodeNew(void);
WIN_EXPORT YGNodeRef YGNodeNewWithConfig(YGConfigConstRef config); YG_EXPORT YGNodeRef YGNodeNewWithConfig(YGConfigConstRef config);
WIN_EXPORT YGNodeRef YGNodeClone(YGNodeConstRef node); YG_EXPORT YGNodeRef YGNodeClone(YGNodeConstRef node);
WIN_EXPORT void YGNodeFree(YGNodeRef node); YG_EXPORT void YGNodeFree(YGNodeRef node);
WIN_EXPORT void YGNodeFreeRecursiveWithCleanupFunc( YG_EXPORT void YGNodeFreeRecursiveWithCleanupFunc(
YGNodeRef node, YGNodeRef node,
YGNodeCleanupFunc cleanup); YGNodeCleanupFunc cleanup);
WIN_EXPORT void YGNodeFreeRecursive(YGNodeRef node); YG_EXPORT void YGNodeFreeRecursive(YGNodeRef node);
WIN_EXPORT void YGNodeReset(YGNodeRef node); YG_EXPORT void YGNodeReset(YGNodeRef node);
WIN_EXPORT void YGNodeInsertChild( YG_EXPORT void YGNodeInsertChild(YGNodeRef node, YGNodeRef child, size_t index);
YGNodeRef node,
YGNodeRef child,
size_t index);
WIN_EXPORT void YGNodeSwapChild(YGNodeRef node, YGNodeRef child, size_t index); YG_EXPORT void YGNodeSwapChild(YGNodeRef node, YGNodeRef child, size_t index);
WIN_EXPORT void YGNodeRemoveChild(YGNodeRef node, YGNodeRef child); YG_EXPORT void YGNodeRemoveChild(YGNodeRef node, YGNodeRef child);
WIN_EXPORT void YGNodeRemoveAllChildren(YGNodeRef node); YG_EXPORT void YGNodeRemoveAllChildren(YGNodeRef node);
WIN_EXPORT YGNodeRef YGNodeGetChild(YGNodeRef node, size_t index); YG_EXPORT YGNodeRef YGNodeGetChild(YGNodeRef node, size_t index);
WIN_EXPORT YGNodeRef YGNodeGetOwner(YGNodeRef node); YG_EXPORT YGNodeRef YGNodeGetOwner(YGNodeRef node);
WIN_EXPORT YGNodeRef YGNodeGetParent(YGNodeRef node); YG_EXPORT YGNodeRef YGNodeGetParent(YGNodeRef node);
WIN_EXPORT size_t YGNodeGetChildCount(YGNodeConstRef node); YG_EXPORT size_t YGNodeGetChildCount(YGNodeConstRef node);
WIN_EXPORT void YGNodeSetChildren( YG_EXPORT void YGNodeSetChildren(
YGNodeRef owner, YGNodeRef owner,
const YGNodeRef* children, const YGNodeRef* children,
size_t count); size_t count);
WIN_EXPORT void YGNodeSetIsReferenceBaseline( YG_EXPORT void YGNodeSetIsReferenceBaseline(
YGNodeRef node, YGNodeRef node,
bool isReferenceBaseline); bool isReferenceBaseline);
WIN_EXPORT bool YGNodeIsReferenceBaseline(YGNodeConstRef node); YG_EXPORT bool YGNodeIsReferenceBaseline(YGNodeConstRef node);
WIN_EXPORT void YGNodeCalculateLayout( YG_EXPORT void YGNodeCalculateLayout(
YGNodeRef node, YGNodeRef node,
float availableWidth, float availableWidth,
float availableHeight, float availableHeight,
@@ -97,21 +94,21 @@ WIN_EXPORT void YGNodeCalculateLayout(
// Yoga knows when to mark all other nodes as dirty but because nodes with // Yoga knows when to mark all other nodes as dirty but because nodes with
// measure functions depend on information not known to Yoga they must perform // measure functions depend on information not known to Yoga they must perform
// this dirty marking manually. // this dirty marking manually.
WIN_EXPORT void YGNodeMarkDirty(YGNodeRef node); YG_EXPORT void YGNodeMarkDirty(YGNodeRef node);
// Marks the current node and all its descendants as dirty. // Marks the current node and all its descendants as dirty.
// //
// Intended to be used for Yoga benchmarks. Don't use in production, as calling // Intended to be used for Yoga benchmarks. Don't use in production, as calling
// `YGCalculateLayout` will cause the recalculation of each and every node. // `YGCalculateLayout` will cause the recalculation of each and every node.
WIN_EXPORT void YGNodeMarkDirtyAndPropagateToDescendants(YGNodeRef node); YG_EXPORT void YGNodeMarkDirtyAndPropagateToDescendants(YGNodeRef node);
WIN_EXPORT void YGNodePrint(YGNodeConstRef node, YGPrintOptions options); YG_EXPORT void YGNodePrint(YGNodeConstRef node, YGPrintOptions options);
WIN_EXPORT bool YGFloatIsUndefined(float value); YG_EXPORT bool YGFloatIsUndefined(float value);
// TODO: This should not be part of the public API. Remove after removing // TODO: This should not be part of the public API. Remove after removing
// ComponentKit usage of it. // ComponentKit usage of it.
WIN_EXPORT bool YGNodeCanUseCachedMeasurement( YG_EXPORT bool YGNodeCanUseCachedMeasurement(
YGMeasureMode widthMode, YGMeasureMode widthMode,
float availableWidth, float availableWidth,
YGMeasureMode heightMode, YGMeasureMode heightMode,
@@ -126,142 +123,142 @@ WIN_EXPORT bool YGNodeCanUseCachedMeasurement(
float marginColumn, float marginColumn,
YGConfigRef config); YGConfigRef config);
WIN_EXPORT void YGNodeCopyStyle(YGNodeRef dstNode, YGNodeConstRef srcNode); YG_EXPORT void YGNodeCopyStyle(YGNodeRef dstNode, YGNodeConstRef srcNode);
WIN_EXPORT void* YGNodeGetContext(YGNodeConstRef node); YG_EXPORT void* YGNodeGetContext(YGNodeConstRef node);
WIN_EXPORT void YGNodeSetContext(YGNodeRef node, void* context); YG_EXPORT void YGNodeSetContext(YGNodeRef node, void* context);
WIN_EXPORT YGConfigConstRef YGNodeGetConfig(YGNodeRef node); YG_EXPORT YGConfigConstRef YGNodeGetConfig(YGNodeRef node);
WIN_EXPORT void YGNodeSetConfig(YGNodeRef node, YGConfigRef config); YG_EXPORT void YGNodeSetConfig(YGNodeRef node, YGConfigRef config);
void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled); YG_EXPORT void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled);
bool YGNodeHasMeasureFunc(YGNodeConstRef node); YG_EXPORT bool YGNodeHasMeasureFunc(YGNodeConstRef node);
WIN_EXPORT void YGNodeSetMeasureFunc(YGNodeRef node, YGMeasureFunc measureFunc); YG_EXPORT void YGNodeSetMeasureFunc(YGNodeRef node, YGMeasureFunc measureFunc);
bool YGNodeHasBaselineFunc(YGNodeConstRef node); YG_EXPORT bool YGNodeHasBaselineFunc(YGNodeConstRef node);
void YGNodeSetBaselineFunc(YGNodeRef node, YGBaselineFunc baselineFunc); YG_EXPORT void YGNodeSetBaselineFunc(
YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeConstRef node); YGNodeRef node,
void YGNodeSetDirtiedFunc(YGNodeRef node, YGDirtiedFunc dirtiedFunc); YGBaselineFunc baselineFunc);
void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc); YG_EXPORT YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeConstRef node);
WIN_EXPORT bool YGNodeGetHasNewLayout(YGNodeConstRef node); YG_EXPORT void YGNodeSetDirtiedFunc(YGNodeRef node, YGDirtiedFunc dirtiedFunc);
WIN_EXPORT void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout); YG_EXPORT void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc);
YGNodeType YGNodeGetNodeType(YGNodeConstRef node); YG_EXPORT bool YGNodeGetHasNewLayout(YGNodeConstRef node);
void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType); YG_EXPORT void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout);
WIN_EXPORT bool YGNodeIsDirty(YGNodeConstRef node); YG_EXPORT YGNodeType YGNodeGetNodeType(YGNodeConstRef node);
YG_EXPORT void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType);
YG_EXPORT bool YGNodeIsDirty(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetDirection(YGNodeRef node, YGDirection direction); YG_EXPORT void YGNodeStyleSetDirection(YGNodeRef node, YGDirection direction);
WIN_EXPORT YGDirection YGNodeStyleGetDirection(YGNodeConstRef node); YG_EXPORT YGDirection YGNodeStyleGetDirection(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetFlexDirection( YG_EXPORT void YGNodeStyleSetFlexDirection(
YGNodeRef node, YGNodeRef node,
YGFlexDirection flexDirection); YGFlexDirection flexDirection);
WIN_EXPORT YGFlexDirection YGNodeStyleGetFlexDirection(YGNodeConstRef node); YG_EXPORT YGFlexDirection YGNodeStyleGetFlexDirection(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetJustifyContent( YG_EXPORT void YGNodeStyleSetJustifyContent(
YGNodeRef node, YGNodeRef node,
YGJustify justifyContent); YGJustify justifyContent);
WIN_EXPORT YGJustify YGNodeStyleGetJustifyContent(YGNodeConstRef node); YG_EXPORT YGJustify YGNodeStyleGetJustifyContent(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetAlignContent( YG_EXPORT void YGNodeStyleSetAlignContent(YGNodeRef node, YGAlign alignContent);
YGNodeRef node, YG_EXPORT YGAlign YGNodeStyleGetAlignContent(YGNodeConstRef node);
YGAlign alignContent);
WIN_EXPORT YGAlign YGNodeStyleGetAlignContent(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetAlignItems(YGNodeRef node, YGAlign alignItems); YG_EXPORT void YGNodeStyleSetAlignItems(YGNodeRef node, YGAlign alignItems);
WIN_EXPORT YGAlign YGNodeStyleGetAlignItems(YGNodeConstRef node); YG_EXPORT YGAlign YGNodeStyleGetAlignItems(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetAlignSelf(YGNodeRef node, YGAlign alignSelf); YG_EXPORT void YGNodeStyleSetAlignSelf(YGNodeRef node, YGAlign alignSelf);
WIN_EXPORT YGAlign YGNodeStyleGetAlignSelf(YGNodeConstRef node); YG_EXPORT YGAlign YGNodeStyleGetAlignSelf(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetPositionType( YG_EXPORT void YGNodeStyleSetPositionType(
YGNodeRef node, YGNodeRef node,
YGPositionType positionType); YGPositionType positionType);
WIN_EXPORT YGPositionType YGNodeStyleGetPositionType(YGNodeConstRef node); YG_EXPORT YGPositionType YGNodeStyleGetPositionType(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetFlexWrap(YGNodeRef node, YGWrap flexWrap); YG_EXPORT void YGNodeStyleSetFlexWrap(YGNodeRef node, YGWrap flexWrap);
WIN_EXPORT YGWrap YGNodeStyleGetFlexWrap(YGNodeConstRef node); YG_EXPORT YGWrap YGNodeStyleGetFlexWrap(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetOverflow(YGNodeRef node, YGOverflow overflow); YG_EXPORT void YGNodeStyleSetOverflow(YGNodeRef node, YGOverflow overflow);
WIN_EXPORT YGOverflow YGNodeStyleGetOverflow(YGNodeConstRef node); YG_EXPORT YGOverflow YGNodeStyleGetOverflow(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetDisplay(YGNodeRef node, YGDisplay display); YG_EXPORT void YGNodeStyleSetDisplay(YGNodeRef node, YGDisplay display);
WIN_EXPORT YGDisplay YGNodeStyleGetDisplay(YGNodeConstRef node); YG_EXPORT YGDisplay YGNodeStyleGetDisplay(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetFlex(YGNodeRef node, float flex); YG_EXPORT void YGNodeStyleSetFlex(YGNodeRef node, float flex);
WIN_EXPORT float YGNodeStyleGetFlex(YGNodeConstRef node); YG_EXPORT float YGNodeStyleGetFlex(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetFlexGrow(YGNodeRef node, float flexGrow); YG_EXPORT void YGNodeStyleSetFlexGrow(YGNodeRef node, float flexGrow);
WIN_EXPORT float YGNodeStyleGetFlexGrow(YGNodeConstRef node); YG_EXPORT float YGNodeStyleGetFlexGrow(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetFlexShrink(YGNodeRef node, float flexShrink); YG_EXPORT void YGNodeStyleSetFlexShrink(YGNodeRef node, float flexShrink);
WIN_EXPORT float YGNodeStyleGetFlexShrink(YGNodeConstRef node); YG_EXPORT float YGNodeStyleGetFlexShrink(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetFlexBasis(YGNodeRef node, float flexBasis); YG_EXPORT void YGNodeStyleSetFlexBasis(YGNodeRef node, float flexBasis);
WIN_EXPORT void YGNodeStyleSetFlexBasisPercent(YGNodeRef node, float flexBasis); YG_EXPORT void YGNodeStyleSetFlexBasisPercent(YGNodeRef node, float flexBasis);
WIN_EXPORT void YGNodeStyleSetFlexBasisAuto(YGNodeRef node); YG_EXPORT void YGNodeStyleSetFlexBasisAuto(YGNodeRef node);
WIN_EXPORT YGValue YGNodeStyleGetFlexBasis(YGNodeConstRef node); YG_EXPORT YGValue YGNodeStyleGetFlexBasis(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetPosition( YG_EXPORT void YGNodeStyleSetPosition(
YGNodeRef node, YGNodeRef node,
YGEdge edge, YGEdge edge,
float position); float position);
WIN_EXPORT void YGNodeStyleSetPositionPercent( YG_EXPORT void YGNodeStyleSetPositionPercent(
YGNodeRef node, YGNodeRef node,
YGEdge edge, YGEdge edge,
float position); float position);
WIN_EXPORT YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge); YG_EXPORT YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge);
WIN_EXPORT void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float margin); YG_EXPORT void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float margin);
WIN_EXPORT void YGNodeStyleSetMarginPercent( YG_EXPORT void YGNodeStyleSetMarginPercent(
YGNodeRef node, YGNodeRef node,
YGEdge edge, YGEdge edge,
float margin); float margin);
WIN_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge); YG_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge);
WIN_EXPORT YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge); YG_EXPORT YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge);
WIN_EXPORT void YGNodeStyleSetPadding( YG_EXPORT void YGNodeStyleSetPadding(
YGNodeRef node, YGNodeRef node,
YGEdge edge, YGEdge edge,
float padding); float padding);
WIN_EXPORT void YGNodeStyleSetPaddingPercent( YG_EXPORT void YGNodeStyleSetPaddingPercent(
YGNodeRef node, YGNodeRef node,
YGEdge edge, YGEdge edge,
float padding); float padding);
WIN_EXPORT YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge); YG_EXPORT YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge);
WIN_EXPORT void YGNodeStyleSetBorder(YGNodeRef node, YGEdge edge, float border); YG_EXPORT void YGNodeStyleSetBorder(YGNodeRef node, YGEdge edge, float border);
WIN_EXPORT float YGNodeStyleGetBorder(YGNodeConstRef node, YGEdge edge); YG_EXPORT float YGNodeStyleGetBorder(YGNodeConstRef node, YGEdge edge);
WIN_EXPORT void YGNodeStyleSetGap( YG_EXPORT void YGNodeStyleSetGap(
YGNodeRef node, YGNodeRef node,
YGGutter gutter, YGGutter gutter,
float gapLength); float gapLength);
WIN_EXPORT float YGNodeStyleGetGap(YGNodeConstRef node, YGGutter gutter); YG_EXPORT float YGNodeStyleGetGap(YGNodeConstRef node, YGGutter gutter);
WIN_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float width); YG_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float width);
WIN_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float width); YG_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float width);
WIN_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node); YG_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node);
WIN_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node); YG_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, float height); YG_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, float height);
WIN_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, float height); YG_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, float height);
WIN_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node); YG_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node);
WIN_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node); YG_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetMinWidth(YGNodeRef node, float minWidth); YG_EXPORT void YGNodeStyleSetMinWidth(YGNodeRef node, float minWidth);
WIN_EXPORT void YGNodeStyleSetMinWidthPercent(YGNodeRef node, float minWidth); YG_EXPORT void YGNodeStyleSetMinWidthPercent(YGNodeRef node, float minWidth);
WIN_EXPORT YGValue YGNodeStyleGetMinWidth(YGNodeConstRef node); YG_EXPORT YGValue YGNodeStyleGetMinWidth(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetMinHeight(YGNodeRef node, float minHeight); YG_EXPORT void YGNodeStyleSetMinHeight(YGNodeRef node, float minHeight);
WIN_EXPORT void YGNodeStyleSetMinHeightPercent(YGNodeRef node, float minHeight); YG_EXPORT void YGNodeStyleSetMinHeightPercent(YGNodeRef node, float minHeight);
WIN_EXPORT YGValue YGNodeStyleGetMinHeight(YGNodeConstRef node); YG_EXPORT YGValue YGNodeStyleGetMinHeight(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetMaxWidth(YGNodeRef node, float maxWidth); YG_EXPORT void YGNodeStyleSetMaxWidth(YGNodeRef node, float maxWidth);
WIN_EXPORT void YGNodeStyleSetMaxWidthPercent(YGNodeRef node, float maxWidth); YG_EXPORT void YGNodeStyleSetMaxWidthPercent(YGNodeRef node, float maxWidth);
WIN_EXPORT YGValue YGNodeStyleGetMaxWidth(YGNodeConstRef node); YG_EXPORT YGValue YGNodeStyleGetMaxWidth(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetMaxHeight(YGNodeRef node, float maxHeight); YG_EXPORT void YGNodeStyleSetMaxHeight(YGNodeRef node, float maxHeight);
WIN_EXPORT void YGNodeStyleSetMaxHeightPercent(YGNodeRef node, float maxHeight); YG_EXPORT void YGNodeStyleSetMaxHeightPercent(YGNodeRef node, float maxHeight);
WIN_EXPORT YGValue YGNodeStyleGetMaxHeight(YGNodeConstRef node); YG_EXPORT YGValue YGNodeStyleGetMaxHeight(YGNodeConstRef node);
// Yoga specific properties, not compatible with flexbox specification Aspect // Yoga specific properties, not compatible with flexbox specification Aspect
// ratio control the size of the undefined dimension of a node. Aspect ratio is // ratio control the size of the undefined dimension of a node. Aspect ratio is
@@ -278,64 +275,64 @@ WIN_EXPORT YGValue YGNodeStyleGetMaxHeight(YGNodeConstRef node);
// - On a node with flex grow/shrink aspect ratio controls the size of the node // - On a node with flex grow/shrink aspect ratio controls the size of the node
// in the cross axis if unset // in the cross axis if unset
// - Aspect ratio takes min/max dimensions into account // - Aspect ratio takes min/max dimensions into account
WIN_EXPORT void YGNodeStyleSetAspectRatio(YGNodeRef node, float aspectRatio); YG_EXPORT void YGNodeStyleSetAspectRatio(YGNodeRef node, float aspectRatio);
WIN_EXPORT float YGNodeStyleGetAspectRatio(YGNodeConstRef node); YG_EXPORT float YGNodeStyleGetAspectRatio(YGNodeConstRef node);
WIN_EXPORT float YGNodeLayoutGetLeft(YGNodeConstRef node); YG_EXPORT float YGNodeLayoutGetLeft(YGNodeConstRef node);
WIN_EXPORT float YGNodeLayoutGetTop(YGNodeConstRef node); YG_EXPORT float YGNodeLayoutGetTop(YGNodeConstRef node);
WIN_EXPORT float YGNodeLayoutGetRight(YGNodeConstRef node); YG_EXPORT float YGNodeLayoutGetRight(YGNodeConstRef node);
WIN_EXPORT float YGNodeLayoutGetBottom(YGNodeConstRef node); YG_EXPORT float YGNodeLayoutGetBottom(YGNodeConstRef node);
WIN_EXPORT float YGNodeLayoutGetWidth(YGNodeConstRef node); YG_EXPORT float YGNodeLayoutGetWidth(YGNodeConstRef node);
WIN_EXPORT float YGNodeLayoutGetHeight(YGNodeConstRef node); YG_EXPORT float YGNodeLayoutGetHeight(YGNodeConstRef node);
WIN_EXPORT YGDirection YGNodeLayoutGetDirection(YGNodeConstRef node); YG_EXPORT YGDirection YGNodeLayoutGetDirection(YGNodeConstRef node);
WIN_EXPORT bool YGNodeLayoutGetHadOverflow(YGNodeConstRef node); YG_EXPORT bool YGNodeLayoutGetHadOverflow(YGNodeConstRef node);
// Get the computed values for these nodes after performing layout. If they were // Get the computed values for these nodes after performing layout. If they were
// set using point values then the returned value will be the same as // set using point values then the returned value will be the same as
// YGNodeStyleGetXXX. However if they were set using a percentage value then the // YGNodeStyleGetXXX. However if they were set using a percentage value then the
// returned value is the computed value used during layout. // returned value is the computed value used during layout.
WIN_EXPORT float YGNodeLayoutGetMargin(YGNodeConstRef node, YGEdge edge); YG_EXPORT float YGNodeLayoutGetMargin(YGNodeConstRef node, YGEdge edge);
WIN_EXPORT float YGNodeLayoutGetBorder(YGNodeConstRef node, YGEdge edge); YG_EXPORT float YGNodeLayoutGetBorder(YGNodeConstRef node, YGEdge edge);
WIN_EXPORT float YGNodeLayoutGetPadding(YGNodeConstRef node, YGEdge edge); YG_EXPORT float YGNodeLayoutGetPadding(YGNodeConstRef node, YGEdge edge);
WIN_EXPORT void YGConfigSetLogger(YGConfigRef config, YGLogger logger); YG_EXPORT void YGConfigSetLogger(YGConfigRef config, YGLogger logger);
// Set this to number of pixels in 1 point to round calculation results If you // Set this to number of pixels in 1 point to round calculation results If you
// want to avoid rounding - set PointScaleFactor to 0 // want to avoid rounding - set PointScaleFactor to 0
WIN_EXPORT void YGConfigSetPointScaleFactor( YG_EXPORT void YGConfigSetPointScaleFactor(
YGConfigRef config, YGConfigRef config,
float pixelsInPoint); float pixelsInPoint);
WIN_EXPORT float YGConfigGetPointScaleFactor(YGConfigConstRef config); YG_EXPORT float YGConfigGetPointScaleFactor(YGConfigConstRef config);
// YGConfig // YGConfig
WIN_EXPORT YGConfigRef YGConfigNew(void); YG_EXPORT YGConfigRef YGConfigNew(void);
WIN_EXPORT void YGConfigFree(YGConfigRef config); YG_EXPORT void YGConfigFree(YGConfigRef config);
WIN_EXPORT void YGConfigSetExperimentalFeatureEnabled( YG_EXPORT void YGConfigSetExperimentalFeatureEnabled(
YGConfigRef config, YGConfigRef config,
YGExperimentalFeature feature, YGExperimentalFeature feature,
bool enabled); bool enabled);
WIN_EXPORT bool YGConfigIsExperimentalFeatureEnabled( YG_EXPORT bool YGConfigIsExperimentalFeatureEnabled(
YGConfigConstRef config, YGConfigConstRef config,
YGExperimentalFeature feature); YGExperimentalFeature feature);
// Using the web defaults is the preferred configuration for new projects. Usage // Using the web defaults is the preferred configuration for new projects. Usage
// of non web defaults should be considered as legacy. // of non web defaults should be considered as legacy.
WIN_EXPORT void YGConfigSetUseWebDefaults(YGConfigRef config, bool enabled); YG_EXPORT void YGConfigSetUseWebDefaults(YGConfigRef config, bool enabled);
WIN_EXPORT bool YGConfigGetUseWebDefaults(YGConfigConstRef config); YG_EXPORT bool YGConfigGetUseWebDefaults(YGConfigConstRef config);
WIN_EXPORT void YGConfigSetCloneNodeFunc( YG_EXPORT void YGConfigSetCloneNodeFunc(
YGConfigRef config, YGConfigRef config,
YGCloneNodeFunc callback); YGCloneNodeFunc callback);
WIN_EXPORT YGConfigConstRef YGConfigGetDefault(void); YG_EXPORT YGConfigConstRef YGConfigGetDefault(void);
WIN_EXPORT void YGConfigSetContext(YGConfigRef config, void* context); YG_EXPORT void YGConfigSetContext(YGConfigRef config, void* context);
WIN_EXPORT void* YGConfigGetContext(YGConfigConstRef config); YG_EXPORT void* YGConfigGetContext(YGConfigConstRef config);
WIN_EXPORT void YGConfigSetErrata(YGConfigRef config, YGErrata errata); YG_EXPORT void YGConfigSetErrata(YGConfigRef config, YGErrata errata);
WIN_EXPORT YGErrata YGConfigGetErrata(YGConfigConstRef config); YG_EXPORT YGErrata YGConfigGetErrata(YGConfigConstRef config);
WIN_EXPORT float YGRoundValueToPixelGrid( YG_EXPORT float YGRoundValueToPixelGrid(
double value, double value,
double pointScaleFactor, double pointScaleFactor,
bool forceCeil, bool forceCeil,

View File

@@ -50,7 +50,7 @@ struct ConfigFlags {
}; };
#pragma pack(pop) #pragma pack(pop)
class YOGA_EXPORT Config : public ::YGConfig { class YG_EXPORT Config : public ::YGConfig {
public: public:
Config(YGLogger logger); Config(YGLogger logger);

View File

@@ -48,7 +48,7 @@ struct LayoutData {
const char* LayoutPassReasonToString(const LayoutPassReason value); const char* LayoutPassReasonToString(const LayoutPassReason value);
struct YOGA_EXPORT Event { struct YG_EXPORT Event {
enum Type { enum Type {
NodeAllocation, NodeAllocation,
NodeDeallocation, NodeDeallocation,

View File

@@ -260,7 +260,7 @@ void Node::setMeasureFunc(YGMeasureFunc measureFunc) {
setMeasureFunc(m); setMeasureFunc(m);
} }
YOGA_EXPORT void Node::setMeasureFunc(MeasureWithContextFn measureFunc) { void Node::setMeasureFunc(MeasureWithContextFn measureFunc) {
flags_.measureUsesContext = true; flags_.measureUsesContext = true;
decltype(Node::measure_) m; decltype(Node::measure_) m;
m.withContext = measureFunc; m.withContext = measureFunc;
@@ -478,7 +478,7 @@ YGDirection Node::resolveDirection(const YGDirection ownerDirection) {
} }
} }
YOGA_EXPORT void Node::clearChildren() { void Node::clearChildren() {
children_.clear(); children_.clear();
children_.shrink_to_fit(); children_.shrink_to_fit();
} }

View File

@@ -36,7 +36,7 @@ struct NodeFlags {
}; };
#pragma pack(pop) #pragma pack(pop)
class YOGA_EXPORT Node : public ::YGNode { class YG_EXPORT Node : public ::YGNode {
public: public:
// Internal variants of callbacks, currently used only by JNI bindings. // Internal variants of callbacks, currently used only by JNI bindings.
// TODO: Reconcile this with the public API // TODO: Reconcile this with the public API

View File

@@ -41,7 +41,7 @@ namespace facebook::yoga {
// 0x40000000 0x7f7fffff // 0x40000000 0x7f7fffff
// - Zero is supported, negative zero is not // - Zero is supported, negative zero is not
// - values outside of the representable range are clamped // - values outside of the representable range are clamped
class YOGA_EXPORT CompactValue { class YG_EXPORT CompactValue {
friend constexpr bool operator==(CompactValue, CompactValue) noexcept; friend constexpr bool operator==(CompactValue, CompactValue) noexcept;
public: public:

View File

@@ -20,7 +20,7 @@
namespace facebook::yoga { namespace facebook::yoga {
class YOGA_EXPORT Style { class YG_EXPORT Style {
template <typename Enum> template <typename Enum>
using Values = std::array<CompactValue, enums::count<Enum>()>; using Values = std::array<CompactValue, enums::count<Enum>()>;
@@ -224,8 +224,8 @@ public:
Ref<FloatOptional, &Style::aspectRatio_> aspectRatio() { return {*this}; } Ref<FloatOptional, &Style::aspectRatio_> aspectRatio() { return {*this}; }
}; };
YOGA_EXPORT bool operator==(const Style& lhs, const Style& rhs); YG_EXPORT bool operator==(const Style& lhs, const Style& rhs);
YOGA_EXPORT inline bool operator!=(const Style& lhs, const Style& rhs) { YG_EXPORT inline bool operator!=(const Style& lhs, const Style& rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }
} // namespace facebook::yoga } // namespace facebook::yoga