From dff5312fdd797f84f09826c08917dc0b8bd21163 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Mon, 11 Sep 2023 17:33:59 -0700 Subject: [PATCH] Fixup exports Summary: D18029030 added `-fvisibility-hidden`, and a corresponding `YOGA_EXPORT` macro for defining shared library visibility. There was already a `WIN_EXPORT` macro doing the same thing when building a DLL, but in the header, instead of CPP files, and sometimes missing for important parts of the public API? This reconciles those into a single visiblity macro, that we always place with declaration instead of definition. Differential Revision: D49132643 fbshipit-source-id: d913618643cf364b950c6b5d33497058ac87ec7c --- tests/util/TestUtil.h | 2 +- yoga/YGMacros.h | 16 +- yoga/YGValue.h | 6 +- yoga/Yoga-internal.h | 4 +- yoga/Yoga.cpp | 329 +++++++++++++++----------------------- yoga/Yoga.h | 287 ++++++++++++++++----------------- yoga/config/Config.h | 2 +- yoga/event/event.h | 2 +- yoga/node/Node.cpp | 4 +- yoga/node/Node.h | 2 +- yoga/style/CompactValue.h | 2 +- yoga/style/Style.h | 6 +- 12 files changed, 291 insertions(+), 371 deletions(-) diff --git a/tests/util/TestUtil.h b/tests/util/TestUtil.h index 1fd3a92194..1f5bf74359 100644 --- a/tests/util/TestUtil.h +++ b/tests/util/TestUtil.h @@ -13,7 +13,7 @@ namespace facebook::yoga::test { -struct YOGA_EXPORT TestUtil { +struct TestUtil { static void startCountingNodes(); static int nodeCount(); static int stopCountingNodes(); diff --git a/yoga/YGMacros.h b/yoga/YGMacros.h index 18bf6d3f40..d03116d051 100644 --- a/yoga/YGMacros.h +++ b/yoga/YGMacros.h @@ -28,17 +28,11 @@ #endif #ifdef _WINDLL -#define WIN_EXPORT __declspec(dllexport) +#define YG_EXPORT __declspec(dllexport) +#elif !defined(_MSC_VER) +#define YG_EXPORT __attribute__((visibility("default"))) #else -#define WIN_EXPORT -#endif - -#ifndef YOGA_EXPORT -#ifdef _MSC_VER -#define YOGA_EXPORT -#else -#define YOGA_EXPORT __attribute__((visibility("default"))) -#endif +#define YG_EXPORT #endif #ifdef NS_ENUM @@ -113,7 +107,7 @@ constexpr int n() { #define YG_ENUM_DECL(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 #define YG_ENUM_SEQ_DECL(NAME, ...) \ diff --git a/yoga/YGValue.h b/yoga/YGValue.h index 59f6f5e461..d6051070b0 100644 --- a/yoga/YGValue.h +++ b/yoga/YGValue.h @@ -17,9 +17,9 @@ typedef struct YGValue { YGUnit unit; } YGValue; -YOGA_EXPORT extern const YGValue YGValueAuto; -YOGA_EXPORT extern const YGValue YGValueUndefined; -YOGA_EXPORT extern const YGValue YGValueZero; +YG_EXPORT extern const YGValue YGValueAuto; +YG_EXPORT extern const YGValue YGValueUndefined; +YG_EXPORT extern const YGValue YGValueZero; YG_EXTERN_C_END diff --git a/yoga/Yoga-internal.h b/yoga/Yoga-internal.h index b10cf5d246..5ad0dd6937 100644 --- a/yoga/Yoga-internal.h +++ b/yoga/Yoga-internal.h @@ -15,7 +15,7 @@ YG_EXTERN_C_BEGIN -void YGNodeCalculateLayoutWithContext( +YG_EXPORT void YGNodeCalculateLayoutWithContext( YGNodeRef node, float availableWidth, float availableHeight, @@ -24,6 +24,6 @@ void YGNodeCalculateLayoutWithContext( // Deallocates a Yoga Node. Unlike YGNodeFree, does not remove the node from // its parent or children. -void YGNodeDeallocate(YGNodeRef node); +YG_EXPORT void YGNodeDeallocate(YGNodeRef node); YG_EXTERN_C_END diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index 141c4c7466..5c5f6a8cca 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -20,91 +20,83 @@ using namespace facebook; using namespace facebook::yoga; -YOGA_EXPORT bool YGFloatIsUndefined(const float value) { +bool YGFloatIsUndefined(const float value) { return yoga::isUndefined(value); } -YOGA_EXPORT void* YGNodeGetContext(YGNodeConstRef node) { +void* YGNodeGetContext(YGNodeConstRef node) { return resolveRef(node)->getContext(); } -YOGA_EXPORT void YGNodeSetContext(YGNodeRef node, void* context) { +void YGNodeSetContext(YGNodeRef node, void* context) { return resolveRef(node)->setContext(context); } -YOGA_EXPORT YGConfigConstRef YGNodeGetConfig(YGNodeRef node) { +YGConfigConstRef YGNodeGetConfig(YGNodeRef node) { return resolveRef(node)->getConfig(); } -YOGA_EXPORT void YGNodeSetConfig(YGNodeRef node, YGConfigRef config) { +void YGNodeSetConfig(YGNodeRef node, YGConfigRef config) { resolveRef(node)->setConfig(resolveRef(config)); } -YOGA_EXPORT bool YGNodeHasMeasureFunc(YGNodeConstRef node) { +bool YGNodeHasMeasureFunc(YGNodeConstRef node) { return resolveRef(node)->hasMeasureFunc(); } -YOGA_EXPORT void YGNodeSetMeasureFunc( - YGNodeRef node, - YGMeasureFunc measureFunc) { +void YGNodeSetMeasureFunc(YGNodeRef node, YGMeasureFunc measureFunc) { resolveRef(node)->setMeasureFunc(measureFunc); } -YOGA_EXPORT bool YGNodeHasBaselineFunc(YGNodeConstRef node) { +bool YGNodeHasBaselineFunc(YGNodeConstRef node) { return resolveRef(node)->hasBaselineFunc(); } -YOGA_EXPORT void YGNodeSetBaselineFunc( - YGNodeRef node, - YGBaselineFunc baselineFunc) { +void YGNodeSetBaselineFunc(YGNodeRef node, YGBaselineFunc baselineFunc) { resolveRef(node)->setBaselineFunc(baselineFunc); } -YOGA_EXPORT YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeConstRef node) { +YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeConstRef node) { return resolveRef(node)->getDirtied(); } -YOGA_EXPORT void YGNodeSetDirtiedFunc( - YGNodeRef node, - YGDirtiedFunc dirtiedFunc) { +void YGNodeSetDirtiedFunc(YGNodeRef node, YGDirtiedFunc dirtiedFunc) { resolveRef(node)->setDirtiedFunc(dirtiedFunc); } -YOGA_EXPORT void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc) { +void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc) { resolveRef(node)->setPrintFunc(printFunc); } -YOGA_EXPORT bool YGNodeGetHasNewLayout(YGNodeConstRef node) { +bool YGNodeGetHasNewLayout(YGNodeConstRef node) { return resolveRef(node)->getHasNewLayout(); } -YOGA_EXPORT void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled) { +void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled) { resolveRef(config)->setShouldPrintTree(enabled); } -YOGA_EXPORT void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout) { +void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout) { resolveRef(node)->setHasNewLayout(hasNewLayout); } -YOGA_EXPORT YGNodeType YGNodeGetNodeType(YGNodeConstRef node) { +YGNodeType YGNodeGetNodeType(YGNodeConstRef node) { return resolveRef(node)->getNodeType(); } -YOGA_EXPORT void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType) { +void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType) { return resolveRef(node)->setNodeType(nodeType); } -YOGA_EXPORT bool YGNodeIsDirty(YGNodeConstRef node) { +bool YGNodeIsDirty(YGNodeConstRef node) { return resolveRef(node)->isDirty(); } -YOGA_EXPORT void YGNodeMarkDirtyAndPropagateToDescendants( - const YGNodeRef node) { +void YGNodeMarkDirtyAndPropagateToDescendants(const YGNodeRef node) { return resolveRef(node)->markDirtyAndPropagateDownwards(); } -YOGA_EXPORT WIN_EXPORT YGNodeRef -YGNodeNewWithConfig(const YGConfigConstRef config) { +YGNodeRef YGNodeNewWithConfig(const YGConfigConstRef config) { auto* node = new yoga::Node{resolveRef(config)}; yoga::assertFatal( config != nullptr, "Tried to construct YGNode with null config"); @@ -113,15 +105,15 @@ YGNodeNewWithConfig(const YGConfigConstRef config) { return node; } -YOGA_EXPORT YGConfigConstRef YGConfigGetDefault() { +YGConfigConstRef YGConfigGetDefault() { return &yoga::Config::getDefault(); } -YOGA_EXPORT YGNodeRef YGNodeNew(void) { +YGNodeRef YGNodeNew(void) { return YGNodeNewWithConfig(YGConfigGetDefault()); } -YOGA_EXPORT YGNodeRef YGNodeClone(YGNodeConstRef oldNodeRef) { +YGNodeRef YGNodeClone(YGNodeConstRef oldNodeRef) { auto oldNode = resolveRef(oldNodeRef); const auto node = new yoga::Node(*oldNode); yoga::assertFatalWithConfig( @@ -133,7 +125,7 @@ YOGA_EXPORT YGNodeRef YGNodeClone(YGNodeConstRef oldNodeRef) { return node; } -YOGA_EXPORT void YGNodeFree(const YGNodeRef nodeRef) { +void YGNodeFree(const YGNodeRef nodeRef) { const auto node = resolveRef(nodeRef); if (auto owner = node->getOwner()) { @@ -151,12 +143,12 @@ YOGA_EXPORT void YGNodeFree(const YGNodeRef nodeRef) { YGNodeDeallocate(node); } -YOGA_EXPORT void YGNodeDeallocate(const YGNodeRef node) { +void YGNodeDeallocate(const YGNodeRef node) { Event::publish(node, {YGNodeGetConfig(node)}); delete resolveRef(node); } -YOGA_EXPORT void YGNodeFreeRecursiveWithCleanupFunc( +void YGNodeFreeRecursiveWithCleanupFunc( const YGNodeRef rootRef, YGNodeCleanupFunc cleanup) { const auto root = resolveRef(rootRef); @@ -178,25 +170,23 @@ YOGA_EXPORT void YGNodeFreeRecursiveWithCleanupFunc( YGNodeFree(root); } -YOGA_EXPORT void YGNodeFreeRecursive(const YGNodeRef root) { +void YGNodeFreeRecursive(const YGNodeRef root) { return YGNodeFreeRecursiveWithCleanupFunc(root, nullptr); } -YOGA_EXPORT void YGNodeReset(YGNodeRef node) { +void YGNodeReset(YGNodeRef node) { resolveRef(node)->reset(); } -YOGA_EXPORT YGConfigRef YGConfigNew(void) { +YGConfigRef YGConfigNew(void) { return new yoga::Config(getDefaultLogger()); } -YOGA_EXPORT void YGConfigFree(const YGConfigRef config) { +void YGConfigFree(const YGConfigRef config) { delete resolveRef(config); } -YOGA_EXPORT void YGNodeSetIsReferenceBaseline( - YGNodeRef nodeRef, - bool isReferenceBaseline) { +void YGNodeSetIsReferenceBaseline(YGNodeRef nodeRef, bool isReferenceBaseline) { const auto node = resolveRef(nodeRef); if (node->isReferenceBaseline() != 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(); } -YOGA_EXPORT void YGNodeInsertChild( +void YGNodeInsertChild( const YGNodeRef ownerRef, const YGNodeRef childRef, const size_t index) { @@ -230,7 +220,7 @@ YOGA_EXPORT void YGNodeInsertChild( owner->markDirtyAndPropagate(); } -YOGA_EXPORT void YGNodeSwapChild( +void YGNodeSwapChild( const YGNodeRef ownerRef, const YGNodeRef childRef, const size_t index) { @@ -241,7 +231,7 @@ YOGA_EXPORT void YGNodeSwapChild( child->setOwner(owner); } -YOGA_EXPORT void YGNodeRemoveChild( +void YGNodeRemoveChild( const YGNodeRef ownerRef, const YGNodeRef excludedChildRef) { 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); const size_t childCount = owner->getChildCount(); @@ -292,7 +282,7 @@ YOGA_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef ownerRef) { owner->markDirtyAndPropagate(); } -YOGA_EXPORT void YGNodeSetChildren( +void YGNodeSetChildren( const YGNodeRef ownerRef, const YGNodeRef* childrenRefs, const size_t count) { @@ -333,8 +323,7 @@ YOGA_EXPORT void YGNodeSetChildren( } } -YOGA_EXPORT YGNodeRef -YGNodeGetChild(const YGNodeRef nodeRef, const size_t index) { +YGNodeRef YGNodeGetChild(const YGNodeRef nodeRef, const size_t index) { const auto node = resolveRef(nodeRef); if (index < node->getChildren().size()) { @@ -343,19 +332,19 @@ YGNodeGetChild(const YGNodeRef nodeRef, const size_t index) { return nullptr; } -YOGA_EXPORT size_t YGNodeGetChildCount(const YGNodeConstRef node) { +size_t YGNodeGetChildCount(const YGNodeConstRef node) { return resolveRef(node)->getChildren().size(); } -YOGA_EXPORT YGNodeRef YGNodeGetOwner(const YGNodeRef node) { +YGNodeRef YGNodeGetOwner(const YGNodeRef node) { return resolveRef(node)->getOwner(); } -YOGA_EXPORT YGNodeRef YGNodeGetParent(const YGNodeRef node) { +YGNodeRef YGNodeGetParent(const YGNodeRef node) { return resolveRef(node)->getOwner(); } -YOGA_EXPORT void YGNodeMarkDirty(const YGNodeRef nodeRef) { +void YGNodeMarkDirty(const YGNodeRef nodeRef) { const auto node = resolveRef(nodeRef); yoga::assertFatalWithNode( @@ -367,7 +356,7 @@ YOGA_EXPORT void YGNodeMarkDirty(const YGNodeRef nodeRef) { node->markDirtyAndPropagate(); } -YOGA_EXPORT void YGNodeCopyStyle( +void YGNodeCopyStyle( const YGNodeRef dstNodeRef, const YGNodeConstRef srcNodeRef) { 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); return node->getStyle().flexGrow().isUndefined() ? Style::DefaultFlexGrow : node->getStyle().flexGrow().unwrap(); } -YOGA_EXPORT float YGNodeStyleGetFlexShrink(const YGNodeConstRef nodeRef) { +float YGNodeStyleGetFlexShrink(const YGNodeConstRef nodeRef) { const auto node = resolveRef(nodeRef); return node->getStyle().flexShrink().isUndefined() ? (node->getConfig()->useWebDefaults() ? Style::WebDefaultFlexShrink @@ -439,109 +428,95 @@ void updateIndexedStyleProp( // decltype, MSVC will prefer the non-const version. #define MSVC_HINT(PROP) decltype(Style{}.PROP()) -YOGA_EXPORT void YGNodeStyleSetDirection( - const YGNodeRef node, - const YGDirection value) { +void YGNodeStyleSetDirection(const YGNodeRef node, const YGDirection value) { updateStyle(node, &Style::direction, value); } -YOGA_EXPORT YGDirection YGNodeStyleGetDirection(const YGNodeConstRef node) { +YGDirection YGNodeStyleGetDirection(const YGNodeConstRef node) { return resolveRef(node)->getStyle().direction(); } -YOGA_EXPORT void YGNodeStyleSetFlexDirection( +void YGNodeStyleSetFlexDirection( const YGNodeRef node, const YGFlexDirection flexDirection) { updateStyle( node, &Style::flexDirection, flexDirection); } -YOGA_EXPORT YGFlexDirection -YGNodeStyleGetFlexDirection(const YGNodeConstRef node) { +YGFlexDirection YGNodeStyleGetFlexDirection(const YGNodeConstRef node) { return resolveRef(node)->getStyle().flexDirection(); } -YOGA_EXPORT void YGNodeStyleSetJustifyContent( +void YGNodeStyleSetJustifyContent( const YGNodeRef node, const YGJustify justifyContent) { updateStyle( node, &Style::justifyContent, justifyContent); } -YOGA_EXPORT YGJustify YGNodeStyleGetJustifyContent(const YGNodeConstRef node) { +YGJustify YGNodeStyleGetJustifyContent(const YGNodeConstRef node) { return resolveRef(node)->getStyle().justifyContent(); } -YOGA_EXPORT void YGNodeStyleSetAlignContent( +void YGNodeStyleSetAlignContent( const YGNodeRef node, const YGAlign alignContent) { updateStyle( node, &Style::alignContent, alignContent); } -YOGA_EXPORT YGAlign YGNodeStyleGetAlignContent(const YGNodeConstRef node) { +YGAlign YGNodeStyleGetAlignContent(const YGNodeConstRef node) { return resolveRef(node)->getStyle().alignContent(); } -YOGA_EXPORT void YGNodeStyleSetAlignItems( - const YGNodeRef node, - const YGAlign alignItems) { +void YGNodeStyleSetAlignItems(const YGNodeRef node, const YGAlign alignItems) { updateStyle(node, &Style::alignItems, alignItems); } -YOGA_EXPORT YGAlign YGNodeStyleGetAlignItems(const YGNodeConstRef node) { +YGAlign YGNodeStyleGetAlignItems(const YGNodeConstRef node) { return resolveRef(node)->getStyle().alignItems(); } -YOGA_EXPORT void YGNodeStyleSetAlignSelf( - const YGNodeRef node, - const YGAlign alignSelf) { +void YGNodeStyleSetAlignSelf(const YGNodeRef node, const YGAlign alignSelf) { updateStyle(node, &Style::alignSelf, alignSelf); } -YOGA_EXPORT YGAlign YGNodeStyleGetAlignSelf(const YGNodeConstRef node) { +YGAlign YGNodeStyleGetAlignSelf(const YGNodeConstRef node) { return resolveRef(node)->getStyle().alignSelf(); } -YOGA_EXPORT void YGNodeStyleSetPositionType( +void YGNodeStyleSetPositionType( const YGNodeRef node, const YGPositionType positionType) { updateStyle( node, &Style::positionType, positionType); } -YOGA_EXPORT YGPositionType -YGNodeStyleGetPositionType(const YGNodeConstRef node) { +YGPositionType YGNodeStyleGetPositionType(const YGNodeConstRef node) { return resolveRef(node)->getStyle().positionType(); } -YOGA_EXPORT void YGNodeStyleSetFlexWrap( - const YGNodeRef node, - const YGWrap flexWrap) { +void YGNodeStyleSetFlexWrap(const YGNodeRef node, const YGWrap flexWrap) { updateStyle(node, &Style::flexWrap, flexWrap); } -YOGA_EXPORT YGWrap YGNodeStyleGetFlexWrap(const YGNodeConstRef node) { +YGWrap YGNodeStyleGetFlexWrap(const YGNodeConstRef node) { return resolveRef(node)->getStyle().flexWrap(); } -YOGA_EXPORT void YGNodeStyleSetOverflow( - const YGNodeRef node, - const YGOverflow overflow) { +void YGNodeStyleSetOverflow(const YGNodeRef node, const YGOverflow overflow) { updateStyle(node, &Style::overflow, overflow); } -YOGA_EXPORT YGOverflow YGNodeStyleGetOverflow(const YGNodeConstRef node) { +YGOverflow YGNodeStyleGetOverflow(const YGNodeConstRef node) { return resolveRef(node)->getStyle().overflow(); } -YOGA_EXPORT void YGNodeStyleSetDisplay( - const YGNodeRef node, - const YGDisplay display) { +void YGNodeStyleSetDisplay(const YGNodeRef node, const YGDisplay display) { updateStyle(node, &Style::display, display); } -YOGA_EXPORT YGDisplay YGNodeStyleGetDisplay(const YGNodeConstRef node) { +YGDisplay YGNodeStyleGetDisplay(const YGNodeConstRef node) { return resolveRef(node)->getStyle().display(); } // 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(node, &Style::flex, FloatOptional{flex}); } // 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); return node->getStyle().flex().isUndefined() ? YGUndefined @@ -549,22 +524,18 @@ YOGA_EXPORT float YGNodeStyleGetFlex(const YGNodeConstRef nodeRef) { } // TODO(T26792433): Change the API to accept FloatOptional. -YOGA_EXPORT void YGNodeStyleSetFlexGrow( - const YGNodeRef node, - const float flexGrow) { +void YGNodeStyleSetFlexGrow(const YGNodeRef node, const float flexGrow) { updateStyle( node, &Style::flexGrow, FloatOptional{flexGrow}); } // TODO(T26792433): Change the API to accept FloatOptional. -YOGA_EXPORT void YGNodeStyleSetFlexShrink( - const YGNodeRef node, - const float flexShrink) { +void YGNodeStyleSetFlexShrink(const YGNodeRef node, const float flexShrink) { updateStyle( node, &Style::flexShrink, FloatOptional{flexShrink}); } -YOGA_EXPORT YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) { +YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) { YGValue flexBasis = resolveRef(node)->getStyle().flexBasis(); if (flexBasis.unit == YGUnitUndefined || flexBasis.unit == YGUnitAuto) { // 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; } -YOGA_EXPORT void YGNodeStyleSetFlexBasis( - const YGNodeRef node, - const float flexBasis) { +void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) { auto value = CompactValue::ofMaybe(flexBasis); updateStyle(node, &Style::flexBasis, value); } -YOGA_EXPORT void YGNodeStyleSetFlexBasisPercent( +void YGNodeStyleSetFlexBasisPercent( const YGNodeRef node, const float flexBasisPercent) { auto value = CompactValue::ofMaybe(flexBasisPercent); updateStyle(node, &Style::flexBasis, value); } -YOGA_EXPORT void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) { +void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) { updateStyle( node, &Style::flexBasis, CompactValue::ofAuto()); } -YOGA_EXPORT void YGNodeStyleSetPosition( - YGNodeRef node, - YGEdge edge, - float points) { +void YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float points) { auto value = CompactValue::ofMaybe(points); updateIndexedStyleProp( node, &Style::position, edge, value); } -YOGA_EXPORT void YGNodeStyleSetPositionPercent( - YGNodeRef node, - YGEdge edge, - float percent) { +void YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float percent) { auto value = CompactValue::ofMaybe(percent); updateIndexedStyleProp( 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]; } -YOGA_EXPORT void YGNodeStyleSetMargin( - YGNodeRef node, - YGEdge edge, - float points) { +void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float points) { auto value = CompactValue::ofMaybe(points); updateIndexedStyleProp(node, &Style::margin, edge, value); } -YOGA_EXPORT void YGNodeStyleSetMarginPercent( - YGNodeRef node, - YGEdge edge, - float percent) { +void YGNodeStyleSetMarginPercent(YGNodeRef node, YGEdge edge, float percent) { auto value = CompactValue::ofMaybe(percent); updateIndexedStyleProp(node, &Style::margin, edge, value); } -YOGA_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) { +void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) { updateIndexedStyleProp( 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]; } -YOGA_EXPORT void YGNodeStyleSetPadding( - YGNodeRef node, - YGEdge edge, - float points) { +void YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge, float points) { auto value = CompactValue::ofMaybe(points); updateIndexedStyleProp( node, &Style::padding, edge, value); } -YOGA_EXPORT void YGNodeStyleSetPaddingPercent( - YGNodeRef node, - YGEdge edge, - float percent) { +void YGNodeStyleSetPaddingPercent(YGNodeRef node, YGEdge edge, float percent) { auto value = CompactValue::ofMaybe(percent); updateIndexedStyleProp( 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]; } // TODO(T26792433): Change the API to accept FloatOptional. -YOGA_EXPORT void YGNodeStyleSetBorder( +void YGNodeStyleSetBorder( const YGNodeRef node, const YGEdge edge, const float border) { @@ -663,9 +614,7 @@ YOGA_EXPORT void YGNodeStyleSetBorder( updateIndexedStyleProp(node, &Style::border, edge, value); } -YOGA_EXPORT float YGNodeStyleGetBorder( - const YGNodeConstRef node, - const YGEdge edge) { +float YGNodeStyleGetBorder(const YGNodeConstRef node, const YGEdge edge) { auto border = resolveRef(node)->getStyle().border()[edge]; if (border.isUndefined() || border.isAuto()) { // TODO(T26792433): Rather than returning YGUndefined, change the api to @@ -676,7 +625,7 @@ YOGA_EXPORT float YGNodeStyleGetBorder( return static_cast(border).value; } -YOGA_EXPORT void YGNodeStyleSetGap( +void YGNodeStyleSetGap( const YGNodeRef node, const YGGutter gutter, const float gapLength) { @@ -684,9 +633,7 @@ YOGA_EXPORT void YGNodeStyleSetGap( updateIndexedStyleProp(node, &Style::gap, gutter, length); } -YOGA_EXPORT float YGNodeStyleGetGap( - const YGNodeConstRef node, - const YGGutter gutter) { +float YGNodeStyleGetGap(const YGNodeConstRef node, const YGGutter gutter) { auto gapLength = resolveRef(node)->getStyle().gap()[gutter]; if (gapLength.isUndefined() || gapLength.isAuto()) { // 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 // 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(); return op.isUndefined() ? YGUndefined : op.unwrap(); } // TODO(T26792433): Change the API to accept FloatOptional. -YOGA_EXPORT void YGNodeStyleSetAspectRatio( - const YGNodeRef node, - const float aspectRatio) { +void YGNodeStyleSetAspectRatio(const YGNodeRef node, const float aspectRatio) { updateStyle( node, &Style::aspectRatio, FloatOptional{aspectRatio}); } -YOGA_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float points) { +void YGNodeStyleSetWidth(YGNodeRef node, float points) { auto value = CompactValue::ofMaybe(points); updateIndexedStyleProp( node, &Style::dimensions, YGDimensionWidth, value); } -YOGA_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) { +void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) { auto value = CompactValue::ofMaybe(percent); updateIndexedStyleProp( node, &Style::dimensions, YGDimensionWidth, value); } -YOGA_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node) { +void YGNodeStyleSetWidthAuto(YGNodeRef node) { updateIndexedStyleProp( node, &Style::dimensions, YGDimensionWidth, CompactValue::ofAuto()); } -YOGA_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node) { +YGValue YGNodeStyleGetWidth(YGNodeConstRef node) { return resolveRef(node)->getStyle().dimensions()[YGDimensionWidth]; } -YOGA_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, float points) { +void YGNodeStyleSetHeight(YGNodeRef node, float points) { auto value = CompactValue::ofMaybe(points); updateIndexedStyleProp( node, &Style::dimensions, YGDimensionHeight, value); } -YOGA_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) { +void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) { auto value = CompactValue::ofMaybe(percent); updateIndexedStyleProp( node, &Style::dimensions, YGDimensionHeight, value); } -YOGA_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node) { +void YGNodeStyleSetHeightAuto(YGNodeRef node) { updateIndexedStyleProp( node, &Style::dimensions, YGDimensionHeight, CompactValue::ofAuto()); } -YOGA_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node) { +YGValue YGNodeStyleGetHeight(YGNodeConstRef node) { return resolveRef(node)->getStyle().dimensions()[YGDimensionHeight]; } -YOGA_EXPORT void YGNodeStyleSetMinWidth( - const YGNodeRef node, - const float minWidth) { +void YGNodeStyleSetMinWidth(const YGNodeRef node, const float minWidth) { auto value = CompactValue::ofMaybe(minWidth); updateIndexedStyleProp( node, &Style::minDimensions, YGDimensionWidth, value); } -YOGA_EXPORT void YGNodeStyleSetMinWidthPercent( - const YGNodeRef node, - const float minWidth) { +void YGNodeStyleSetMinWidthPercent(const YGNodeRef node, const float minWidth) { auto value = CompactValue::ofMaybe(minWidth); updateIndexedStyleProp( node, &Style::minDimensions, YGDimensionWidth, value); } -YOGA_EXPORT YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) { +YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) { return resolveRef(node)->getStyle().minDimensions()[YGDimensionWidth]; } -YOGA_EXPORT void YGNodeStyleSetMinHeight( - const YGNodeRef node, - const float minHeight) { +void YGNodeStyleSetMinHeight(const YGNodeRef node, const float minHeight) { auto value = CompactValue::ofMaybe(minHeight); updateIndexedStyleProp( node, &Style::minDimensions, YGDimensionHeight, value); } -YOGA_EXPORT void YGNodeStyleSetMinHeightPercent( +void YGNodeStyleSetMinHeightPercent( const YGNodeRef node, const float minHeight) { auto value = CompactValue::ofMaybe(minHeight); updateIndexedStyleProp( node, &Style::minDimensions, YGDimensionHeight, value); } -YOGA_EXPORT YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) { +YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) { return resolveRef(node)->getStyle().minDimensions()[YGDimensionHeight]; } -YOGA_EXPORT void YGNodeStyleSetMaxWidth( - const YGNodeRef node, - const float maxWidth) { +void YGNodeStyleSetMaxWidth(const YGNodeRef node, const float maxWidth) { auto value = CompactValue::ofMaybe(maxWidth); updateIndexedStyleProp( node, &Style::maxDimensions, YGDimensionWidth, value); } -YOGA_EXPORT void YGNodeStyleSetMaxWidthPercent( - const YGNodeRef node, - const float maxWidth) { +void YGNodeStyleSetMaxWidthPercent(const YGNodeRef node, const float maxWidth) { auto value = CompactValue::ofMaybe(maxWidth); updateIndexedStyleProp( node, &Style::maxDimensions, YGDimensionWidth, value); } -YOGA_EXPORT YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) { +YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) { return resolveRef(node)->getStyle().maxDimensions()[YGDimensionWidth]; } -YOGA_EXPORT void YGNodeStyleSetMaxHeight( - const YGNodeRef node, - const float maxHeight) { +void YGNodeStyleSetMaxHeight(const YGNodeRef node, const float maxHeight) { auto value = CompactValue::ofMaybe(maxHeight); updateIndexedStyleProp( node, &Style::maxDimensions, YGDimensionHeight, value); } -YOGA_EXPORT void YGNodeStyleSetMaxHeightPercent( +void YGNodeStyleSetMaxHeightPercent( const YGNodeRef node, const float maxHeight) { auto value = CompactValue::ofMaybe(maxHeight); updateIndexedStyleProp( node, &Style::maxDimensions, YGDimensionHeight, value); } -YOGA_EXPORT YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) { +YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) { return resolveRef(node)->getStyle().maxDimensions()[YGDimensionHeight]; } -#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \ - YOGA_EXPORT type YGNodeLayoutGet##name(const YGNodeConstRef node) { \ - return resolveRef(node)->getLayout().instanceName; \ +#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \ + type YGNodeLayoutGet##name(const YGNodeConstRef node) { \ + return resolveRef(node)->getLayout().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 auto node = resolveRef(nodeRef); \ yoga::assertFatalWithNode( \ @@ -868,9 +801,7 @@ YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Border, border) YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Padding, padding) #ifdef DEBUG -YOGA_EXPORT void YGNodePrint( - const YGNodeConstRef nodeRef, - const YGPrintOptions options) { +void YGNodePrint(const YGNodeConstRef nodeRef, const YGPrintOptions options) { const auto node = resolveRef(nodeRef); std::string str; yoga::nodeToString(str, node, options, 0); @@ -878,7 +809,7 @@ YOGA_EXPORT void YGNodePrint( } #endif -YOGA_EXPORT void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) { +void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) { if (logger != nullptr) { resolveRef(config)->setLogger(logger); } else { @@ -886,7 +817,7 @@ YOGA_EXPORT void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) { } } -YOGA_EXPORT void YGConfigSetPointScaleFactor( +void YGConfigSetPointScaleFactor( const YGConfigRef config, const float pixelsInPoint) { 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(); } -YOGA_EXPORT float YGRoundValueToPixelGrid( +float YGRoundValueToPixelGrid( const double value, const double pointScaleFactor, const bool forceCeil, @@ -916,22 +847,20 @@ YOGA_EXPORT float YGRoundValueToPixelGrid( value, pointScaleFactor, forceCeil, forceFloor); } -YOGA_EXPORT void YGConfigSetExperimentalFeatureEnabled( +void YGConfigSetExperimentalFeatureEnabled( const YGConfigRef config, const YGExperimentalFeature feature, const bool enabled) { resolveRef(config)->setExperimentalFeatureEnabled(feature, enabled); } -YOGA_EXPORT bool YGConfigIsExperimentalFeatureEnabled( +bool YGConfigIsExperimentalFeatureEnabled( const YGConfigConstRef config, const YGExperimentalFeature feature) { return resolveRef(config)->isExperimentalFeatureEnabled(feature); } -YOGA_EXPORT void YGConfigSetUseWebDefaults( - const YGConfigRef config, - const bool enabled) { +void YGConfigSetUseWebDefaults(const YGConfigRef config, const bool enabled) { resolveRef(config)->setUseWebDefaults(enabled); } @@ -939,23 +868,23 @@ bool YGConfigGetUseWebDefaults(const YGConfigConstRef config) { return resolveRef(config)->useWebDefaults(); } -YOGA_EXPORT void YGConfigSetContext(const YGConfigRef config, void* context) { +void YGConfigSetContext(const YGConfigRef config, void* context) { resolveRef(config)->setContext(context); } -YOGA_EXPORT void* YGConfigGetContext(const YGConfigConstRef config) { +void* YGConfigGetContext(const YGConfigConstRef config) { return resolveRef(config)->getContext(); } -YOGA_EXPORT void YGConfigSetErrata(YGConfigRef config, YGErrata errata) { +void YGConfigSetErrata(YGConfigRef config, YGErrata errata) { resolveRef(config)->setErrata(errata); } -YOGA_EXPORT YGErrata YGConfigGetErrata(YGConfigConstRef config) { +YGErrata YGConfigGetErrata(YGConfigConstRef config) { return resolveRef(config)->getErrata(); } -YOGA_EXPORT void YGConfigSetCloneNodeFunc( +void YGConfigSetCloneNodeFunc( const YGConfigRef config, const YGCloneNodeFunc 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 // ComponentKit usage of it. -YOGA_EXPORT bool YGNodeCanUseCachedMeasurement( +bool YGNodeCanUseCachedMeasurement( YGMeasureMode widthMode, float availableWidth, YGMeasureMode heightMode, @@ -993,7 +922,7 @@ YOGA_EXPORT bool YGNodeCanUseCachedMeasurement( resolveRef(config)); } -YOGA_EXPORT void YGNodeCalculateLayout( +void YGNodeCalculateLayout( const YGNodeRef node, const float ownerWidth, const float ownerHeight, @@ -1002,7 +931,7 @@ YOGA_EXPORT void YGNodeCalculateLayout( node, ownerWidth, ownerHeight, ownerDirection, nullptr); } -YOGA_EXPORT void YGNodeCalculateLayoutWithContext( +void YGNodeCalculateLayoutWithContext( const YGNodeRef node, const float ownerWidth, const float ownerHeight, diff --git a/yoga/Yoga.h b/yoga/Yoga.h index 208f76ada1..b1ebf8856c 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -51,41 +51,38 @@ typedef YGNodeRef (*YGCloneNodeFunc)( size_t childIndex); // YGNode -WIN_EXPORT YGNodeRef YGNodeNew(void); -WIN_EXPORT YGNodeRef YGNodeNewWithConfig(YGConfigConstRef config); -WIN_EXPORT YGNodeRef YGNodeClone(YGNodeConstRef node); -WIN_EXPORT void YGNodeFree(YGNodeRef node); -WIN_EXPORT void YGNodeFreeRecursiveWithCleanupFunc( +YG_EXPORT YGNodeRef YGNodeNew(void); +YG_EXPORT YGNodeRef YGNodeNewWithConfig(YGConfigConstRef config); +YG_EXPORT YGNodeRef YGNodeClone(YGNodeConstRef node); +YG_EXPORT void YGNodeFree(YGNodeRef node); +YG_EXPORT void YGNodeFreeRecursiveWithCleanupFunc( YGNodeRef node, YGNodeCleanupFunc cleanup); -WIN_EXPORT void YGNodeFreeRecursive(YGNodeRef node); -WIN_EXPORT void YGNodeReset(YGNodeRef node); +YG_EXPORT void YGNodeFreeRecursive(YGNodeRef node); +YG_EXPORT void YGNodeReset(YGNodeRef node); -WIN_EXPORT void YGNodeInsertChild( - YGNodeRef node, - YGNodeRef child, - size_t index); - -WIN_EXPORT void YGNodeSwapChild(YGNodeRef node, YGNodeRef child, size_t index); - -WIN_EXPORT void YGNodeRemoveChild(YGNodeRef node, YGNodeRef child); -WIN_EXPORT void YGNodeRemoveAllChildren(YGNodeRef node); -WIN_EXPORT YGNodeRef YGNodeGetChild(YGNodeRef node, size_t index); -WIN_EXPORT YGNodeRef YGNodeGetOwner(YGNodeRef node); -WIN_EXPORT YGNodeRef YGNodeGetParent(YGNodeRef node); -WIN_EXPORT size_t YGNodeGetChildCount(YGNodeConstRef node); -WIN_EXPORT void YGNodeSetChildren( +YG_EXPORT void YGNodeInsertChild(YGNodeRef node, YGNodeRef child, size_t index); + +YG_EXPORT void YGNodeSwapChild(YGNodeRef node, YGNodeRef child, size_t index); + +YG_EXPORT void YGNodeRemoveChild(YGNodeRef node, YGNodeRef child); +YG_EXPORT void YGNodeRemoveAllChildren(YGNodeRef node); +YG_EXPORT YGNodeRef YGNodeGetChild(YGNodeRef node, size_t index); +YG_EXPORT YGNodeRef YGNodeGetOwner(YGNodeRef node); +YG_EXPORT YGNodeRef YGNodeGetParent(YGNodeRef node); +YG_EXPORT size_t YGNodeGetChildCount(YGNodeConstRef node); +YG_EXPORT void YGNodeSetChildren( YGNodeRef owner, const YGNodeRef* children, size_t count); -WIN_EXPORT void YGNodeSetIsReferenceBaseline( +YG_EXPORT void YGNodeSetIsReferenceBaseline( YGNodeRef node, bool isReferenceBaseline); -WIN_EXPORT bool YGNodeIsReferenceBaseline(YGNodeConstRef node); +YG_EXPORT bool YGNodeIsReferenceBaseline(YGNodeConstRef node); -WIN_EXPORT void YGNodeCalculateLayout( +YG_EXPORT void YGNodeCalculateLayout( YGNodeRef node, float availableWidth, float availableHeight, @@ -97,21 +94,21 @@ WIN_EXPORT void YGNodeCalculateLayout( // 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 // 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. // // Intended to be used for Yoga benchmarks. Don't use in production, as calling // `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 // ComponentKit usage of it. -WIN_EXPORT bool YGNodeCanUseCachedMeasurement( +YG_EXPORT bool YGNodeCanUseCachedMeasurement( YGMeasureMode widthMode, float availableWidth, YGMeasureMode heightMode, @@ -126,142 +123,142 @@ WIN_EXPORT bool YGNodeCanUseCachedMeasurement( float marginColumn, YGConfigRef config); -WIN_EXPORT void YGNodeCopyStyle(YGNodeRef dstNode, YGNodeConstRef srcNode); - -WIN_EXPORT void* YGNodeGetContext(YGNodeConstRef node); -WIN_EXPORT void YGNodeSetContext(YGNodeRef node, void* context); +YG_EXPORT void YGNodeCopyStyle(YGNodeRef dstNode, YGNodeConstRef srcNode); -WIN_EXPORT YGConfigConstRef YGNodeGetConfig(YGNodeRef node); -WIN_EXPORT void YGNodeSetConfig(YGNodeRef node, YGConfigRef config); +YG_EXPORT void* YGNodeGetContext(YGNodeConstRef node); +YG_EXPORT void YGNodeSetContext(YGNodeRef node, void* context); -void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled); -bool YGNodeHasMeasureFunc(YGNodeConstRef node); -WIN_EXPORT void YGNodeSetMeasureFunc(YGNodeRef node, YGMeasureFunc measureFunc); -bool YGNodeHasBaselineFunc(YGNodeConstRef node); -void YGNodeSetBaselineFunc(YGNodeRef node, YGBaselineFunc baselineFunc); -YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeConstRef node); -void YGNodeSetDirtiedFunc(YGNodeRef node, YGDirtiedFunc dirtiedFunc); -void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc); -WIN_EXPORT bool YGNodeGetHasNewLayout(YGNodeConstRef node); -WIN_EXPORT void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout); -YGNodeType YGNodeGetNodeType(YGNodeConstRef node); -void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType); -WIN_EXPORT bool YGNodeIsDirty(YGNodeConstRef node); +YG_EXPORT YGConfigConstRef YGNodeGetConfig(YGNodeRef node); +YG_EXPORT void YGNodeSetConfig(YGNodeRef node, YGConfigRef config); -WIN_EXPORT void YGNodeStyleSetDirection(YGNodeRef node, YGDirection direction); -WIN_EXPORT YGDirection YGNodeStyleGetDirection(YGNodeConstRef node); - -WIN_EXPORT void YGNodeStyleSetFlexDirection( +YG_EXPORT void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled); +YG_EXPORT bool YGNodeHasMeasureFunc(YGNodeConstRef node); +YG_EXPORT void YGNodeSetMeasureFunc(YGNodeRef node, YGMeasureFunc measureFunc); +YG_EXPORT bool YGNodeHasBaselineFunc(YGNodeConstRef node); +YG_EXPORT void YGNodeSetBaselineFunc( + YGNodeRef node, + YGBaselineFunc baselineFunc); +YG_EXPORT YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeConstRef node); +YG_EXPORT void YGNodeSetDirtiedFunc(YGNodeRef node, YGDirtiedFunc dirtiedFunc); +YG_EXPORT void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc); +YG_EXPORT bool YGNodeGetHasNewLayout(YGNodeConstRef node); +YG_EXPORT void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout); +YG_EXPORT YGNodeType YGNodeGetNodeType(YGNodeConstRef node); +YG_EXPORT void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType); +YG_EXPORT bool YGNodeIsDirty(YGNodeConstRef node); + +YG_EXPORT void YGNodeStyleSetDirection(YGNodeRef node, YGDirection direction); +YG_EXPORT YGDirection YGNodeStyleGetDirection(YGNodeConstRef node); + +YG_EXPORT void YGNodeStyleSetFlexDirection( YGNodeRef node, YGFlexDirection flexDirection); -WIN_EXPORT YGFlexDirection YGNodeStyleGetFlexDirection(YGNodeConstRef node); +YG_EXPORT YGFlexDirection YGNodeStyleGetFlexDirection(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetJustifyContent( +YG_EXPORT void YGNodeStyleSetJustifyContent( YGNodeRef node, YGJustify justifyContent); -WIN_EXPORT YGJustify YGNodeStyleGetJustifyContent(YGNodeConstRef node); +YG_EXPORT YGJustify YGNodeStyleGetJustifyContent(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetAlignContent( - YGNodeRef node, - YGAlign alignContent); -WIN_EXPORT YGAlign YGNodeStyleGetAlignContent(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetAlignContent(YGNodeRef node, YGAlign alignContent); +YG_EXPORT YGAlign YGNodeStyleGetAlignContent(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetAlignItems(YGNodeRef node, YGAlign alignItems); -WIN_EXPORT YGAlign YGNodeStyleGetAlignItems(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetAlignItems(YGNodeRef node, YGAlign alignItems); +YG_EXPORT YGAlign YGNodeStyleGetAlignItems(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetAlignSelf(YGNodeRef node, YGAlign alignSelf); -WIN_EXPORT YGAlign YGNodeStyleGetAlignSelf(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetAlignSelf(YGNodeRef node, YGAlign alignSelf); +YG_EXPORT YGAlign YGNodeStyleGetAlignSelf(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetPositionType( +YG_EXPORT void YGNodeStyleSetPositionType( YGNodeRef node, YGPositionType positionType); -WIN_EXPORT YGPositionType YGNodeStyleGetPositionType(YGNodeConstRef node); +YG_EXPORT YGPositionType YGNodeStyleGetPositionType(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetFlexWrap(YGNodeRef node, YGWrap flexWrap); -WIN_EXPORT YGWrap YGNodeStyleGetFlexWrap(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetFlexWrap(YGNodeRef node, YGWrap flexWrap); +YG_EXPORT YGWrap YGNodeStyleGetFlexWrap(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetOverflow(YGNodeRef node, YGOverflow overflow); -WIN_EXPORT YGOverflow YGNodeStyleGetOverflow(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetOverflow(YGNodeRef node, YGOverflow overflow); +YG_EXPORT YGOverflow YGNodeStyleGetOverflow(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetDisplay(YGNodeRef node, YGDisplay display); -WIN_EXPORT YGDisplay YGNodeStyleGetDisplay(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetDisplay(YGNodeRef node, YGDisplay display); +YG_EXPORT YGDisplay YGNodeStyleGetDisplay(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetFlex(YGNodeRef node, float flex); -WIN_EXPORT float YGNodeStyleGetFlex(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetFlex(YGNodeRef node, float flex); +YG_EXPORT float YGNodeStyleGetFlex(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetFlexGrow(YGNodeRef node, float flexGrow); -WIN_EXPORT float YGNodeStyleGetFlexGrow(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetFlexGrow(YGNodeRef node, float flexGrow); +YG_EXPORT float YGNodeStyleGetFlexGrow(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetFlexShrink(YGNodeRef node, float flexShrink); -WIN_EXPORT float YGNodeStyleGetFlexShrink(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetFlexShrink(YGNodeRef node, float flexShrink); +YG_EXPORT float YGNodeStyleGetFlexShrink(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetFlexBasis(YGNodeRef node, float flexBasis); -WIN_EXPORT void YGNodeStyleSetFlexBasisPercent(YGNodeRef node, float flexBasis); -WIN_EXPORT void YGNodeStyleSetFlexBasisAuto(YGNodeRef node); -WIN_EXPORT YGValue YGNodeStyleGetFlexBasis(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetFlexBasis(YGNodeRef node, float flexBasis); +YG_EXPORT void YGNodeStyleSetFlexBasisPercent(YGNodeRef node, float flexBasis); +YG_EXPORT void YGNodeStyleSetFlexBasisAuto(YGNodeRef node); +YG_EXPORT YGValue YGNodeStyleGetFlexBasis(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetPosition( +YG_EXPORT void YGNodeStyleSetPosition( YGNodeRef node, YGEdge edge, float position); -WIN_EXPORT void YGNodeStyleSetPositionPercent( +YG_EXPORT void YGNodeStyleSetPositionPercent( YGNodeRef node, YGEdge edge, 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); -WIN_EXPORT void YGNodeStyleSetMarginPercent( +YG_EXPORT void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float margin); +YG_EXPORT void YGNodeStyleSetMarginPercent( YGNodeRef node, YGEdge edge, float margin); -WIN_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge); -WIN_EXPORT YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge); +YG_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge); +YG_EXPORT YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge); -WIN_EXPORT void YGNodeStyleSetPadding( +YG_EXPORT void YGNodeStyleSetPadding( YGNodeRef node, YGEdge edge, float padding); -WIN_EXPORT void YGNodeStyleSetPaddingPercent( +YG_EXPORT void YGNodeStyleSetPaddingPercent( YGNodeRef node, YGEdge edge, 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); -WIN_EXPORT float YGNodeStyleGetBorder(YGNodeConstRef node, YGEdge edge); +YG_EXPORT void YGNodeStyleSetBorder(YGNodeRef node, YGEdge edge, float border); +YG_EXPORT float YGNodeStyleGetBorder(YGNodeConstRef node, YGEdge edge); -WIN_EXPORT void YGNodeStyleSetGap( +YG_EXPORT void YGNodeStyleSetGap( YGNodeRef node, YGGutter gutter, 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); -WIN_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float width); -WIN_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node); -WIN_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float width); +YG_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float width); +YG_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node); +YG_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, float height); -WIN_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, float height); -WIN_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node); -WIN_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, float height); +YG_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, float height); +YG_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node); +YG_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetMinWidth(YGNodeRef node, float minWidth); -WIN_EXPORT void YGNodeStyleSetMinWidthPercent(YGNodeRef node, float minWidth); -WIN_EXPORT YGValue YGNodeStyleGetMinWidth(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetMinWidth(YGNodeRef node, float minWidth); +YG_EXPORT void YGNodeStyleSetMinWidthPercent(YGNodeRef node, float minWidth); +YG_EXPORT YGValue YGNodeStyleGetMinWidth(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetMinHeight(YGNodeRef node, float minHeight); -WIN_EXPORT void YGNodeStyleSetMinHeightPercent(YGNodeRef node, float minHeight); -WIN_EXPORT YGValue YGNodeStyleGetMinHeight(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetMinHeight(YGNodeRef node, float minHeight); +YG_EXPORT void YGNodeStyleSetMinHeightPercent(YGNodeRef node, float minHeight); +YG_EXPORT YGValue YGNodeStyleGetMinHeight(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetMaxWidth(YGNodeRef node, float maxWidth); -WIN_EXPORT void YGNodeStyleSetMaxWidthPercent(YGNodeRef node, float maxWidth); -WIN_EXPORT YGValue YGNodeStyleGetMaxWidth(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetMaxWidth(YGNodeRef node, float maxWidth); +YG_EXPORT void YGNodeStyleSetMaxWidthPercent(YGNodeRef node, float maxWidth); +YG_EXPORT YGValue YGNodeStyleGetMaxWidth(YGNodeConstRef node); -WIN_EXPORT void YGNodeStyleSetMaxHeight(YGNodeRef node, float maxHeight); -WIN_EXPORT void YGNodeStyleSetMaxHeightPercent(YGNodeRef node, float maxHeight); -WIN_EXPORT YGValue YGNodeStyleGetMaxHeight(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetMaxHeight(YGNodeRef node, float maxHeight); +YG_EXPORT void YGNodeStyleSetMaxHeightPercent(YGNodeRef node, float maxHeight); +YG_EXPORT YGValue YGNodeStyleGetMaxHeight(YGNodeConstRef node); // Yoga specific properties, not compatible with flexbox specification Aspect // 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 // in the cross axis if unset // - Aspect ratio takes min/max dimensions into account -WIN_EXPORT void YGNodeStyleSetAspectRatio(YGNodeRef node, float aspectRatio); -WIN_EXPORT float YGNodeStyleGetAspectRatio(YGNodeConstRef node); - -WIN_EXPORT float YGNodeLayoutGetLeft(YGNodeConstRef node); -WIN_EXPORT float YGNodeLayoutGetTop(YGNodeConstRef node); -WIN_EXPORT float YGNodeLayoutGetRight(YGNodeConstRef node); -WIN_EXPORT float YGNodeLayoutGetBottom(YGNodeConstRef node); -WIN_EXPORT float YGNodeLayoutGetWidth(YGNodeConstRef node); -WIN_EXPORT float YGNodeLayoutGetHeight(YGNodeConstRef node); -WIN_EXPORT YGDirection YGNodeLayoutGetDirection(YGNodeConstRef node); -WIN_EXPORT bool YGNodeLayoutGetHadOverflow(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetAspectRatio(YGNodeRef node, float aspectRatio); +YG_EXPORT float YGNodeStyleGetAspectRatio(YGNodeConstRef node); + +YG_EXPORT float YGNodeLayoutGetLeft(YGNodeConstRef node); +YG_EXPORT float YGNodeLayoutGetTop(YGNodeConstRef node); +YG_EXPORT float YGNodeLayoutGetRight(YGNodeConstRef node); +YG_EXPORT float YGNodeLayoutGetBottom(YGNodeConstRef node); +YG_EXPORT float YGNodeLayoutGetWidth(YGNodeConstRef node); +YG_EXPORT float YGNodeLayoutGetHeight(YGNodeConstRef node); +YG_EXPORT YGDirection YGNodeLayoutGetDirection(YGNodeConstRef node); +YG_EXPORT bool YGNodeLayoutGetHadOverflow(YGNodeConstRef node); // 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 // YGNodeStyleGetXXX. However if they were set using a percentage value then the // returned value is the computed value used during layout. -WIN_EXPORT float YGNodeLayoutGetMargin(YGNodeConstRef node, YGEdge edge); -WIN_EXPORT float YGNodeLayoutGetBorder(YGNodeConstRef node, YGEdge edge); -WIN_EXPORT float YGNodeLayoutGetPadding(YGNodeConstRef node, YGEdge edge); +YG_EXPORT float YGNodeLayoutGetMargin(YGNodeConstRef node, YGEdge edge); +YG_EXPORT float YGNodeLayoutGetBorder(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 // want to avoid rounding - set PointScaleFactor to 0 -WIN_EXPORT void YGConfigSetPointScaleFactor( +YG_EXPORT void YGConfigSetPointScaleFactor( YGConfigRef config, float pixelsInPoint); -WIN_EXPORT float YGConfigGetPointScaleFactor(YGConfigConstRef config); +YG_EXPORT float YGConfigGetPointScaleFactor(YGConfigConstRef config); // YGConfig -WIN_EXPORT YGConfigRef YGConfigNew(void); -WIN_EXPORT void YGConfigFree(YGConfigRef config); +YG_EXPORT YGConfigRef YGConfigNew(void); +YG_EXPORT void YGConfigFree(YGConfigRef config); -WIN_EXPORT void YGConfigSetExperimentalFeatureEnabled( +YG_EXPORT void YGConfigSetExperimentalFeatureEnabled( YGConfigRef config, YGExperimentalFeature feature, bool enabled); -WIN_EXPORT bool YGConfigIsExperimentalFeatureEnabled( +YG_EXPORT bool YGConfigIsExperimentalFeatureEnabled( YGConfigConstRef config, YGExperimentalFeature feature); // Using the web defaults is the preferred configuration for new projects. Usage // of non web defaults should be considered as legacy. -WIN_EXPORT void YGConfigSetUseWebDefaults(YGConfigRef config, bool enabled); -WIN_EXPORT bool YGConfigGetUseWebDefaults(YGConfigConstRef config); +YG_EXPORT void YGConfigSetUseWebDefaults(YGConfigRef config, bool enabled); +YG_EXPORT bool YGConfigGetUseWebDefaults(YGConfigConstRef config); -WIN_EXPORT void YGConfigSetCloneNodeFunc( +YG_EXPORT void YGConfigSetCloneNodeFunc( YGConfigRef config, YGCloneNodeFunc callback); -WIN_EXPORT YGConfigConstRef YGConfigGetDefault(void); +YG_EXPORT YGConfigConstRef YGConfigGetDefault(void); -WIN_EXPORT void YGConfigSetContext(YGConfigRef config, void* context); -WIN_EXPORT void* YGConfigGetContext(YGConfigConstRef config); +YG_EXPORT void YGConfigSetContext(YGConfigRef config, void* context); +YG_EXPORT void* YGConfigGetContext(YGConfigConstRef config); -WIN_EXPORT void YGConfigSetErrata(YGConfigRef config, YGErrata errata); -WIN_EXPORT YGErrata YGConfigGetErrata(YGConfigConstRef config); +YG_EXPORT void YGConfigSetErrata(YGConfigRef config, YGErrata errata); +YG_EXPORT YGErrata YGConfigGetErrata(YGConfigConstRef config); -WIN_EXPORT float YGRoundValueToPixelGrid( +YG_EXPORT float YGRoundValueToPixelGrid( double value, double pointScaleFactor, bool forceCeil, diff --git a/yoga/config/Config.h b/yoga/config/Config.h index 168bd7e890..dfea29c588 100644 --- a/yoga/config/Config.h +++ b/yoga/config/Config.h @@ -50,7 +50,7 @@ struct ConfigFlags { }; #pragma pack(pop) -class YOGA_EXPORT Config : public ::YGConfig { +class YG_EXPORT Config : public ::YGConfig { public: Config(YGLogger logger); diff --git a/yoga/event/event.h b/yoga/event/event.h index f9a8bc19dc..3335954032 100644 --- a/yoga/event/event.h +++ b/yoga/event/event.h @@ -48,7 +48,7 @@ struct LayoutData { const char* LayoutPassReasonToString(const LayoutPassReason value); -struct YOGA_EXPORT Event { +struct YG_EXPORT Event { enum Type { NodeAllocation, NodeDeallocation, diff --git a/yoga/node/Node.cpp b/yoga/node/Node.cpp index b9a4da12ca..ac6a5b88f7 100644 --- a/yoga/node/Node.cpp +++ b/yoga/node/Node.cpp @@ -260,7 +260,7 @@ void Node::setMeasureFunc(YGMeasureFunc measureFunc) { setMeasureFunc(m); } -YOGA_EXPORT void Node::setMeasureFunc(MeasureWithContextFn measureFunc) { +void Node::setMeasureFunc(MeasureWithContextFn measureFunc) { flags_.measureUsesContext = true; decltype(Node::measure_) m; m.withContext = measureFunc; @@ -478,7 +478,7 @@ YGDirection Node::resolveDirection(const YGDirection ownerDirection) { } } -YOGA_EXPORT void Node::clearChildren() { +void Node::clearChildren() { children_.clear(); children_.shrink_to_fit(); } diff --git a/yoga/node/Node.h b/yoga/node/Node.h index 7f45802e69..e749179122 100644 --- a/yoga/node/Node.h +++ b/yoga/node/Node.h @@ -36,7 +36,7 @@ struct NodeFlags { }; #pragma pack(pop) -class YOGA_EXPORT Node : public ::YGNode { +class YG_EXPORT Node : public ::YGNode { public: // Internal variants of callbacks, currently used only by JNI bindings. // TODO: Reconcile this with the public API diff --git a/yoga/style/CompactValue.h b/yoga/style/CompactValue.h index 282a518f1a..596331ad86 100644 --- a/yoga/style/CompactValue.h +++ b/yoga/style/CompactValue.h @@ -41,7 +41,7 @@ namespace facebook::yoga { // 0x40000000 0x7f7fffff // - Zero is supported, negative zero is not // - values outside of the representable range are clamped -class YOGA_EXPORT CompactValue { +class YG_EXPORT CompactValue { friend constexpr bool operator==(CompactValue, CompactValue) noexcept; public: diff --git a/yoga/style/Style.h b/yoga/style/Style.h index 5b78fa31e5..14efebd216 100644 --- a/yoga/style/Style.h +++ b/yoga/style/Style.h @@ -20,7 +20,7 @@ namespace facebook::yoga { -class YOGA_EXPORT Style { +class YG_EXPORT Style { template using Values = std::array()>; @@ -224,8 +224,8 @@ class YOGA_EXPORT Style { Ref aspectRatio() { return {*this}; } }; -YOGA_EXPORT bool operator==(const Style& lhs, const Style& rhs); -YOGA_EXPORT inline bool operator!=(const Style& lhs, const Style& rhs) { +YG_EXPORT bool operator==(const Style& lhs, const Style& rhs); +YG_EXPORT inline bool operator!=(const Style& lhs, const Style& rhs) { return !(lhs == rhs); } } // namespace facebook::yoga