Use compiler flag -fvisibility=hidden

Summary:
Using compiler flag -fvisibility=hidden and explicitly setting visibility to default to public methods

#Changelog:
[Internal] [Yoga] Use compiler flag -fvisibility=hidden for reducing yoga binary size

Reviewed By: astreet

Differential Revision: D18029030

fbshipit-source-id: 545e73f9c25f3108fc9d9bb7f08c157dbc8da005
This commit is contained in:
Sidharth Guglani
2019-11-01 11:45:19 -07:00
committed by Facebook Github Bot
parent fb07dcff40
commit 8c3ee81d6e
17 changed files with 241 additions and 140 deletions

View File

@@ -7,6 +7,13 @@ cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_VERBOSE_MAKEFILE on) set(CMAKE_VERBOSE_MAKEFILE on)
add_compile_options(
-fno-omit-frame-pointer
-fexceptions
-fvisibility=hidden
-Wall
-std=c++11)
file(GLOB_RECURSE yogacore_SRC yoga/*.cpp) file(GLOB_RECURSE yogacore_SRC yoga/*.cpp)
add_library(yogacore STATIC ${yogacore_SRC}) add_library(yogacore STATIC ${yogacore_SRC})

View File

@@ -25,6 +25,7 @@ yoga_cxx_library(
compiler_flags = [ compiler_flags = [
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
"-fexceptions", "-fexceptions",
"-fvisibility=hidden",
"-fPIC", "-fPIC",
"-Wall", "-Wall",
"-Werror", "-Werror",

View File

@@ -24,6 +24,7 @@ add_subdirectory(${yogacore_DIR} ${yogacore_build_DIR})
add_compile_options( add_compile_options(
-fno-omit-frame-pointer -fno-omit-frame-pointer
-fexceptions -fexceptions
-fvisibility=hidden
-Wall -Wall
-std=c++11) -std=c++11)

View File

@@ -42,7 +42,8 @@ jint ensureInitialized(JNIEnv** env, JavaVM* vm) {
return JNI_VERSION_1_6; return JNI_VERSION_1_6;
} }
JNIEnv* getCurrentEnv() { // TODO why we need JNIEXPORT for getCurrentEnv ?
JNIEXPORT JNIEnv* getCurrentEnv() {
JNIEnv* env; JNIEnv* env;
jint ret = globalVm->GetEnv((void**) &env, JNI_VERSION_1_6); jint ret = globalVm->GetEnv((void**) &env, JNI_VERSION_1_6);
if (ret != JNI_OK) { if (ret != JNI_OK) {

View File

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

View File

@@ -53,6 +53,7 @@ CXX_LIBRARY_WHITELIST = [
BASE_COMPILER_FLAGS = [ BASE_COMPILER_FLAGS = [
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
"-fexceptions", "-fexceptions",
"-fvisibility=hidden",
"-Wall", "-Wall",
"-Werror", "-Werror",
"-O2", "-O2",

View File

@@ -12,12 +12,20 @@
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#ifndef YOGA_EXPORT
#ifdef _MSC_VER
#define YOGA_EXPORT
#else
#define YOGA_EXPORT __attribute__((visibility("default")))
#endif
#endif
namespace facebook { namespace facebook {
namespace yoga { namespace yoga {
namespace detail { namespace detail {
class FreeList { class YOGA_EXPORT FreeList {
std::stack<void*> free_; std::stack<void*> free_;
void* getRaw(); void* getRaw();
@@ -72,7 +80,7 @@ public:
/// std::accumulate(counters.begin(), counters.end(), 0); /// std::accumulate(counters.begin(), counters.end(), 0);
/// ///
template <typename T, void (*ReturnPolicy)(T&) = nullptr> template <typename T, void (*ReturnPolicy)(T&) = nullptr>
class SingleWriterValueList { class YOGA_EXPORT SingleWriterValueList {
std::forward_list<T> values_{}; std::forward_list<T> values_{};
std::mutex acquireMutex_{}; std::mutex acquireMutex_{};
detail::FreeList freeValuesList_{}; detail::FreeList freeValuesList_{};

View File

@@ -8,7 +8,7 @@
#pragma once #pragma once
#include "YGValue.h" #include "YGValue.h"
#include "YGMacros.h"
#include <cmath> #include <cmath>
#include <cstdint> #include <cstdint>
#include <limits> #include <limits>
@@ -40,7 +40,7 @@ namespace detail {
// 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 CompactValue { class YOGA_EXPORT CompactValue {
friend constexpr bool operator==(CompactValue, CompactValue) noexcept; friend constexpr bool operator==(CompactValue, CompactValue) noexcept;
public: public:

View File

@@ -9,7 +9,7 @@
#include "Yoga-internal.h" #include "Yoga-internal.h"
#include "Yoga.h" #include "Yoga.h"
struct YGConfig { struct YOGA_EXPORT YGConfig {
using LogWithContextFn = int (*)( using LogWithContextFn = int (*)(
YGConfigRef config, YGConfigRef config,
YGNodeRef node, YGNodeRef node,

View File

@@ -21,6 +21,14 @@
#define WIN_EXPORT #define WIN_EXPORT
#endif #endif
#ifndef YOGA_EXPORT
#ifdef _MSC_VER
#define YOGA_EXPORT
#else
#define YOGA_EXPORT __attribute__((visibility("default")))
#endif
#endif
#ifdef NS_ENUM #ifdef NS_ENUM
// Cannot use NSInteger as NSInteger has a different size than int (which is the // Cannot use NSInteger as NSInteger has a different size than int (which is the
// default type of a enum). Therefor when linking the Yoga C library into obj-c // default type of a enum). Therefor when linking the Yoga C library into obj-c

View File

@@ -188,7 +188,7 @@ void YGNode::setMeasureFunc(YGMeasureFunc measureFunc) {
setMeasureFunc(m); setMeasureFunc(m);
} }
void YGNode::setMeasureFunc(MeasureWithContextFn measureFunc) { YOGA_EXPORT void YGNode::setMeasureFunc(MeasureWithContextFn measureFunc) {
flags_.at<measureUsesContext_>() = true; flags_.at<measureUsesContext_>() = true;
decltype(YGNode::measure_) m; decltype(YGNode::measure_) m;
m.withContext = measureFunc; m.withContext = measureFunc;
@@ -378,7 +378,7 @@ YGDirection YGNode::resolveDirection(const YGDirection ownerDirection) {
} }
} }
void YGNode::clearChildren() { YOGA_EXPORT void YGNode::clearChildren() {
children_.clear(); children_.clear();
children_.shrink_to_fit(); children_.shrink_to_fit();
} }

View File

@@ -18,7 +18,7 @@
YGConfigRef YGConfigGetDefault(); YGConfigRef YGConfigGetDefault();
struct YGNode { struct YOGA_EXPORT YGNode {
using MeasureWithContextFn = using MeasureWithContextFn =
YGSize (*)(YGNode*, float, YGMeasureMode, float, YGMeasureMode, void*); YGSize (*)(YGNode*, float, YGMeasureMode, float, YGMeasureMode, void*);
using BaselineWithContextFn = float (*)(YGNode*, float, float, void*); using BaselineWithContextFn = float (*)(YGNode*, float, float, void*);

View File

@@ -17,7 +17,7 @@
#include "Yoga-internal.h" #include "Yoga-internal.h"
#include "Yoga.h" #include "Yoga.h"
class YGStyle { class YOGA_EXPORT YGStyle {
template <typename Enum> template <typename Enum>
using Values = using Values =
facebook::yoga::detail::Values<facebook::yoga::enums::count<Enum>()>; facebook::yoga::detail::Values<facebook::yoga::enums::count<Enum>()>;
@@ -197,7 +197,7 @@ public:
Ref<YGFloatOptional, &YGStyle::aspectRatio_> aspectRatio() { return {*this}; } Ref<YGFloatOptional, &YGStyle::aspectRatio_> aspectRatio() { return {*this}; }
}; };
bool operator==(const YGStyle& lhs, const YGStyle& rhs); YOGA_EXPORT bool operator==(const YGStyle& lhs, const YGStyle& rhs);
inline bool operator!=(const YGStyle& lhs, const YGStyle& rhs) { YOGA_EXPORT inline bool operator!=(const YGStyle& lhs, const YGStyle& rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }

View File

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

View File

@@ -106,7 +106,7 @@ static int YGDefaultLog(
#undef YG_UNUSED #undef YG_UNUSED
#endif #endif
bool YGFloatIsUndefined(const float value) { YOGA_EXPORT bool YGFloatIsUndefined(const float value) {
return facebook::yoga::isUndefined(value); return facebook::yoga::isUndefined(value);
} }
@@ -140,77 +140,84 @@ detail::CompactValue YGComputedEdgeValue(
return defaultValue; return defaultValue;
} }
void* YGNodeGetContext(YGNodeRef node) { YOGA_EXPORT void* YGNodeGetContext(YGNodeRef node) {
return node->getContext(); return node->getContext();
} }
void YGNodeSetContext(YGNodeRef node, void* context) { YOGA_EXPORT void YGNodeSetContext(YGNodeRef node, void* context) {
return node->setContext(context); return node->setContext(context);
} }
bool YGNodeHasMeasureFunc(YGNodeRef node) { YOGA_EXPORT bool YGNodeHasMeasureFunc(YGNodeRef node) {
return node->hasMeasureFunc(); return node->hasMeasureFunc();
} }
void YGNodeSetMeasureFunc(YGNodeRef node, YGMeasureFunc measureFunc) { YOGA_EXPORT void YGNodeSetMeasureFunc(
YGNodeRef node,
YGMeasureFunc measureFunc) {
node->setMeasureFunc(measureFunc); node->setMeasureFunc(measureFunc);
} }
bool YGNodeHasBaselineFunc(YGNodeRef node) { YOGA_EXPORT bool YGNodeHasBaselineFunc(YGNodeRef node) {
return node->hasBaselineFunc(); return node->hasBaselineFunc();
} }
void YGNodeSetBaselineFunc(YGNodeRef node, YGBaselineFunc baselineFunc) { YOGA_EXPORT void YGNodeSetBaselineFunc(
YGNodeRef node,
YGBaselineFunc baselineFunc) {
node->setBaselineFunc(baselineFunc); node->setBaselineFunc(baselineFunc);
} }
YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeRef node) { YOGA_EXPORT YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeRef node) {
return node->getDirtied(); return node->getDirtied();
} }
void YGNodeSetDirtiedFunc(YGNodeRef node, YGDirtiedFunc dirtiedFunc) { YOGA_EXPORT void YGNodeSetDirtiedFunc(
YGNodeRef node,
YGDirtiedFunc dirtiedFunc) {
node->setDirtiedFunc(dirtiedFunc); node->setDirtiedFunc(dirtiedFunc);
} }
void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc) { YOGA_EXPORT void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc) {
node->setPrintFunc(printFunc); node->setPrintFunc(printFunc);
} }
bool YGNodeGetHasNewLayout(YGNodeRef node) { YOGA_EXPORT bool YGNodeGetHasNewLayout(YGNodeRef node) {
return node->getHasNewLayout(); return node->getHasNewLayout();
} }
void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled) { YOGA_EXPORT void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled) {
config->printTree = enabled; config->printTree = enabled;
} }
void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout) { YOGA_EXPORT void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout) {
node->setHasNewLayout(hasNewLayout); node->setHasNewLayout(hasNewLayout);
} }
YGNodeType YGNodeGetNodeType(YGNodeRef node) { YOGA_EXPORT YGNodeType YGNodeGetNodeType(YGNodeRef node) {
return node->getNodeType(); return node->getNodeType();
} }
void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType) { YOGA_EXPORT void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType) {
return node->setNodeType(nodeType); return node->setNodeType(nodeType);
} }
bool YGNodeIsDirty(YGNodeRef node) { YOGA_EXPORT bool YGNodeIsDirty(YGNodeRef node) {
return node->isDirty(); return node->isDirty();
} }
bool YGNodeLayoutGetDidUseLegacyFlag(const YGNodeRef node) { YOGA_EXPORT bool YGNodeLayoutGetDidUseLegacyFlag(const YGNodeRef node) {
return node->didUseLegacyFlag(); return node->didUseLegacyFlag();
} }
void YGNodeMarkDirtyAndPropogateToDescendants(const YGNodeRef node) { YOGA_EXPORT void YGNodeMarkDirtyAndPropogateToDescendants(
const YGNodeRef node) {
return node->markDirtyAndPropogateDownwards(); return node->markDirtyAndPropogateDownwards();
} }
int32_t gConfigInstanceCount = 0; int32_t gConfigInstanceCount = 0;
WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) { YOGA_EXPORT WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) {
const YGNodeRef node = new YGNode{config}; const YGNodeRef node = new YGNode{config};
YGAssertWithConfig( YGAssertWithConfig(
config, node != nullptr, "Could not allocate memory for node"); config, node != nullptr, "Could not allocate memory for node");
@@ -219,16 +226,16 @@ WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) {
return node; return node;
} }
YGConfigRef YGConfigGetDefault() { YOGA_EXPORT YGConfigRef YGConfigGetDefault() {
static YGConfigRef defaultConfig = YGConfigNew(); static YGConfigRef defaultConfig = YGConfigNew();
return defaultConfig; return defaultConfig;
} }
YGNodeRef YGNodeNew(void) { YOGA_EXPORT YGNodeRef YGNodeNew(void) {
return YGNodeNewWithConfig(YGConfigGetDefault()); return YGNodeNewWithConfig(YGConfigGetDefault());
} }
YGNodeRef YGNodeClone(YGNodeRef oldNode) { YOGA_EXPORT YGNodeRef YGNodeClone(YGNodeRef oldNode) {
YGNodeRef node = new YGNode(*oldNode); YGNodeRef node = new YGNode(*oldNode);
YGAssertWithConfig( YGAssertWithConfig(
oldNode->getConfig(), oldNode->getConfig(),
@@ -268,7 +275,7 @@ static YGNodeRef YGNodeDeepClone(YGNodeRef oldNode) {
return node; return node;
} }
void YGNodeFree(const YGNodeRef node) { YOGA_EXPORT void YGNodeFree(const YGNodeRef node) {
if (YGNodeRef owner = node->getOwner()) { if (YGNodeRef owner = node->getOwner()) {
owner->removeChild(node); owner->removeChild(node);
node->setOwner(nullptr); node->setOwner(nullptr);
@@ -296,7 +303,7 @@ static void YGConfigFreeRecursive(const YGNodeRef root) {
} }
} }
void YGNodeFreeRecursiveWithCleanupFunc( YOGA_EXPORT void YGNodeFreeRecursiveWithCleanupFunc(
const YGNodeRef root, const YGNodeRef root,
YGNodeCleanupFunc cleanup) { YGNodeCleanupFunc cleanup) {
uint32_t skipped = 0; uint32_t skipped = 0;
@@ -316,11 +323,11 @@ void YGNodeFreeRecursiveWithCleanupFunc(
YGNodeFree(root); YGNodeFree(root);
} }
void YGNodeFreeRecursive(const YGNodeRef root) { YOGA_EXPORT void YGNodeFreeRecursive(const YGNodeRef root) {
return YGNodeFreeRecursiveWithCleanupFunc(root, nullptr); return YGNodeFreeRecursiveWithCleanupFunc(root, nullptr);
} }
void YGNodeReset(YGNodeRef node) { YOGA_EXPORT void YGNodeReset(YGNodeRef node) {
node->reset(); node->reset();
} }
@@ -328,7 +335,7 @@ int32_t YGConfigGetInstanceCount(void) {
return gConfigInstanceCount; return gConfigInstanceCount;
} }
YGConfigRef YGConfigNew(void) { YOGA_EXPORT YGConfigRef YGConfigNew(void) {
#ifdef ANDROID #ifdef ANDROID
const YGConfigRef config = new YGConfig(YGAndroidLog); const YGConfigRef config = new YGConfig(YGAndroidLog);
#else #else
@@ -338,7 +345,7 @@ YGConfigRef YGConfigNew(void) {
return config; return config;
} }
void YGConfigFree(const YGConfigRef config) { YOGA_EXPORT void YGConfigFree(const YGConfigRef config) {
delete config; delete config;
gConfigInstanceCount--; gConfigInstanceCount--;
} }
@@ -347,18 +354,20 @@ void YGConfigCopy(const YGConfigRef dest, const YGConfigRef src) {
memcpy(dest, src, sizeof(YGConfig)); memcpy(dest, src, sizeof(YGConfig));
} }
void YGNodeSetIsReferenceBaseline(YGNodeRef node, bool isReferenceBaseline) { YOGA_EXPORT void YGNodeSetIsReferenceBaseline(
YGNodeRef node,
bool isReferenceBaseline) {
if (node->isReferenceBaseline() != isReferenceBaseline) { if (node->isReferenceBaseline() != isReferenceBaseline) {
node->setIsReferenceBaseline(isReferenceBaseline); node->setIsReferenceBaseline(isReferenceBaseline);
node->markDirtyAndPropogate(); node->markDirtyAndPropogate();
} }
} }
bool YGNodeIsReferenceBaseline(YGNodeRef node) { YOGA_EXPORT bool YGNodeIsReferenceBaseline(YGNodeRef node) {
return node->isReferenceBaseline(); return node->isReferenceBaseline();
} }
void YGNodeInsertChild( YOGA_EXPORT void YGNodeInsertChild(
const YGNodeRef owner, const YGNodeRef owner,
const YGNodeRef child, const YGNodeRef child,
const uint32_t index) { const uint32_t index) {
@@ -377,7 +386,9 @@ void YGNodeInsertChild(
owner->markDirtyAndPropogate(); owner->markDirtyAndPropogate();
} }
void YGNodeRemoveChild(const YGNodeRef owner, const YGNodeRef excludedChild) { YOGA_EXPORT void YGNodeRemoveChild(
const YGNodeRef owner,
const YGNodeRef excludedChild) {
if (YGNodeGetChildCount(owner) == 0) { if (YGNodeGetChildCount(owner) == 0) {
// This is an empty set. Nothing to remove. // This is an empty set. Nothing to remove.
return; return;
@@ -396,7 +407,7 @@ void YGNodeRemoveChild(const YGNodeRef owner, const YGNodeRef excludedChild) {
} }
} }
void YGNodeRemoveAllChildren(const YGNodeRef owner) { YOGA_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef owner) {
const uint32_t childCount = YGNodeGetChildCount(owner); const uint32_t childCount = YGNodeGetChildCount(owner);
if (childCount == 0) { if (childCount == 0) {
// This is an empty set already. Nothing to do. // This is an empty set already. Nothing to do.
@@ -456,7 +467,7 @@ static void YGNodeSetChildrenInternal(
} }
} }
void YGNodeSetChildren( YOGA_EXPORT void YGNodeSetChildren(
const YGNodeRef owner, const YGNodeRef owner,
const YGNodeRef c[], const YGNodeRef c[],
const uint32_t count) { const uint32_t count) {
@@ -464,32 +475,33 @@ void YGNodeSetChildren(
YGNodeSetChildrenInternal(owner, children); YGNodeSetChildrenInternal(owner, children);
} }
void YGNodeSetChildren( YOGA_EXPORT void YGNodeSetChildren(
YGNodeRef const owner, YGNodeRef const owner,
const std::vector<YGNodeRef>& children) { const std::vector<YGNodeRef>& children) {
YGNodeSetChildrenInternal(owner, children); YGNodeSetChildrenInternal(owner, children);
} }
YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index) { YOGA_EXPORT YGNodeRef
YGNodeGetChild(const YGNodeRef node, const uint32_t index) {
if (index < node->getChildren().size()) { if (index < node->getChildren().size()) {
return node->getChild(index); return node->getChild(index);
} }
return nullptr; return nullptr;
} }
uint32_t YGNodeGetChildCount(const YGNodeRef node) { YOGA_EXPORT uint32_t YGNodeGetChildCount(const YGNodeRef node) {
return static_cast<uint32_t>(node->getChildren().size()); return static_cast<uint32_t>(node->getChildren().size());
} }
YGNodeRef YGNodeGetOwner(const YGNodeRef node) { YOGA_EXPORT YGNodeRef YGNodeGetOwner(const YGNodeRef node) {
return node->getOwner(); return node->getOwner();
} }
YGNodeRef YGNodeGetParent(const YGNodeRef node) { YOGA_EXPORT YGNodeRef YGNodeGetParent(const YGNodeRef node) {
return node->getOwner(); return node->getOwner();
} }
void YGNodeMarkDirty(const YGNodeRef node) { YOGA_EXPORT void YGNodeMarkDirty(const YGNodeRef node) {
YGAssertWithNode( YGAssertWithNode(
node, node,
node->hasMeasureFunc(), node->hasMeasureFunc(),
@@ -499,20 +511,22 @@ void YGNodeMarkDirty(const YGNodeRef node) {
node->markDirtyAndPropogate(); node->markDirtyAndPropogate();
} }
void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode) { YOGA_EXPORT void YGNodeCopyStyle(
const YGNodeRef dstNode,
const YGNodeRef srcNode) {
if (!(dstNode->getStyle() == srcNode->getStyle())) { if (!(dstNode->getStyle() == srcNode->getStyle())) {
dstNode->setStyle(srcNode->getStyle()); dstNode->setStyle(srcNode->getStyle());
dstNode->markDirtyAndPropogate(); dstNode->markDirtyAndPropogate();
} }
} }
float YGNodeStyleGetFlexGrow(const YGNodeConstRef node) { YOGA_EXPORT float YGNodeStyleGetFlexGrow(const YGNodeConstRef node) {
return node->getStyle().flexGrow().isUndefined() return node->getStyle().flexGrow().isUndefined()
? kDefaultFlexGrow ? kDefaultFlexGrow
: node->getStyle().flexGrow().unwrap(); : node->getStyle().flexGrow().unwrap();
} }
float YGNodeStyleGetFlexShrink(const YGNodeConstRef node) { YOGA_EXPORT float YGNodeStyleGetFlexShrink(const YGNodeConstRef node) {
return node->getStyle().flexShrink().isUndefined() return node->getStyle().flexShrink().isUndefined()
? (node->getConfig()->useWebDefaults ? kWebDefaultFlexShrink ? (node->getConfig()->useWebDefaults ? kWebDefaultFlexShrink
: kDefaultFlexShrink) : kDefaultFlexShrink)
@@ -565,113 +579,131 @@ void updateIndexedStyleProp(
// decltype, MSVC will prefer the non-const version. // decltype, MSVC will prefer the non-const version.
#define MSVC_HINT(PROP) decltype(YGStyle{}.PROP()) #define MSVC_HINT(PROP) decltype(YGStyle{}.PROP())
void YGNodeStyleSetDirection(const YGNodeRef node, const YGDirection value) { YOGA_EXPORT void YGNodeStyleSetDirection(
const YGNodeRef node,
const YGDirection value) {
updateStyle<MSVC_HINT(direction)>(node, &YGStyle::direction, value); updateStyle<MSVC_HINT(direction)>(node, &YGStyle::direction, value);
} }
YGDirection YGNodeStyleGetDirection(const YGNodeConstRef node) { YOGA_EXPORT YGDirection YGNodeStyleGetDirection(const YGNodeConstRef node) {
return node->getStyle().direction(); return node->getStyle().direction();
} }
void YGNodeStyleSetFlexDirection( YOGA_EXPORT void YGNodeStyleSetFlexDirection(
const YGNodeRef node, const YGNodeRef node,
const YGFlexDirection flexDirection) { const YGFlexDirection flexDirection) {
updateStyle<MSVC_HINT(flexDirection)>( updateStyle<MSVC_HINT(flexDirection)>(
node, &YGStyle::flexDirection, flexDirection); node, &YGStyle::flexDirection, flexDirection);
} }
YGFlexDirection YGNodeStyleGetFlexDirection(const YGNodeConstRef node) { YOGA_EXPORT YGFlexDirection
YGNodeStyleGetFlexDirection(const YGNodeConstRef node) {
return node->getStyle().flexDirection(); return node->getStyle().flexDirection();
} }
void YGNodeStyleSetJustifyContent( YOGA_EXPORT void YGNodeStyleSetJustifyContent(
const YGNodeRef node, const YGNodeRef node,
const YGJustify justifyContent) { const YGJustify justifyContent) {
updateStyle<MSVC_HINT(justifyContent)>( updateStyle<MSVC_HINT(justifyContent)>(
node, &YGStyle::justifyContent, justifyContent); node, &YGStyle::justifyContent, justifyContent);
} }
YGJustify YGNodeStyleGetJustifyContent(const YGNodeConstRef node) { YOGA_EXPORT YGJustify YGNodeStyleGetJustifyContent(const YGNodeConstRef node) {
return node->getStyle().justifyContent(); return node->getStyle().justifyContent();
} }
void YGNodeStyleSetAlignContent( YOGA_EXPORT void YGNodeStyleSetAlignContent(
const YGNodeRef node, const YGNodeRef node,
const YGAlign alignContent) { const YGAlign alignContent) {
updateStyle<MSVC_HINT(alignContent)>( updateStyle<MSVC_HINT(alignContent)>(
node, &YGStyle::alignContent, alignContent); node, &YGStyle::alignContent, alignContent);
} }
YGAlign YGNodeStyleGetAlignContent(const YGNodeConstRef node) { YOGA_EXPORT YGAlign YGNodeStyleGetAlignContent(const YGNodeConstRef node) {
return node->getStyle().alignContent(); return node->getStyle().alignContent();
} }
void YGNodeStyleSetAlignItems(const YGNodeRef node, const YGAlign alignItems) { YOGA_EXPORT void YGNodeStyleSetAlignItems(
const YGNodeRef node,
const YGAlign alignItems) {
updateStyle<MSVC_HINT(alignItems)>(node, &YGStyle::alignItems, alignItems); updateStyle<MSVC_HINT(alignItems)>(node, &YGStyle::alignItems, alignItems);
} }
YGAlign YGNodeStyleGetAlignItems(const YGNodeConstRef node) { YOGA_EXPORT YGAlign YGNodeStyleGetAlignItems(const YGNodeConstRef node) {
return node->getStyle().alignItems(); return node->getStyle().alignItems();
} }
void YGNodeStyleSetAlignSelf(const YGNodeRef node, const YGAlign alignSelf) { YOGA_EXPORT void YGNodeStyleSetAlignSelf(
const YGNodeRef node,
const YGAlign alignSelf) {
updateStyle<MSVC_HINT(alignSelf)>(node, &YGStyle::alignSelf, alignSelf); updateStyle<MSVC_HINT(alignSelf)>(node, &YGStyle::alignSelf, alignSelf);
} }
YGAlign YGNodeStyleGetAlignSelf(const YGNodeConstRef node) { YOGA_EXPORT YGAlign YGNodeStyleGetAlignSelf(const YGNodeConstRef node) {
return node->getStyle().alignSelf(); return node->getStyle().alignSelf();
} }
void YGNodeStyleSetPositionType( YOGA_EXPORT void YGNodeStyleSetPositionType(
const YGNodeRef node, const YGNodeRef node,
const YGPositionType positionType) { const YGPositionType positionType) {
updateStyle<MSVC_HINT(positionType)>( updateStyle<MSVC_HINT(positionType)>(
node, &YGStyle::positionType, positionType); node, &YGStyle::positionType, positionType);
} }
YGPositionType YGNodeStyleGetPositionType(const YGNodeConstRef node) { YOGA_EXPORT YGPositionType
YGNodeStyleGetPositionType(const YGNodeConstRef node) {
return node->getStyle().positionType(); return node->getStyle().positionType();
} }
void YGNodeStyleSetFlexWrap(const YGNodeRef node, const YGWrap flexWrap) { YOGA_EXPORT void YGNodeStyleSetFlexWrap(
const YGNodeRef node,
const YGWrap flexWrap) {
updateStyle<MSVC_HINT(flexWrap)>(node, &YGStyle::flexWrap, flexWrap); updateStyle<MSVC_HINT(flexWrap)>(node, &YGStyle::flexWrap, flexWrap);
} }
YGWrap YGNodeStyleGetFlexWrap(const YGNodeConstRef node) { YOGA_EXPORT YGWrap YGNodeStyleGetFlexWrap(const YGNodeConstRef node) {
return node->getStyle().flexWrap(); return node->getStyle().flexWrap();
} }
void YGNodeStyleSetOverflow(const YGNodeRef node, const YGOverflow overflow) { YOGA_EXPORT void YGNodeStyleSetOverflow(
const YGNodeRef node,
const YGOverflow overflow) {
updateStyle<MSVC_HINT(overflow)>(node, &YGStyle::overflow, overflow); updateStyle<MSVC_HINT(overflow)>(node, &YGStyle::overflow, overflow);
} }
YGOverflow YGNodeStyleGetOverflow(const YGNodeConstRef node) { YOGA_EXPORT YGOverflow YGNodeStyleGetOverflow(const YGNodeConstRef node) {
return node->getStyle().overflow(); return node->getStyle().overflow();
} }
void YGNodeStyleSetDisplay(const YGNodeRef node, const YGDisplay display) { YOGA_EXPORT void YGNodeStyleSetDisplay(
const YGNodeRef node,
const YGDisplay display) {
updateStyle<MSVC_HINT(display)>(node, &YGStyle::display, display); updateStyle<MSVC_HINT(display)>(node, &YGStyle::display, display);
} }
YGDisplay YGNodeStyleGetDisplay(const YGNodeConstRef node) { YOGA_EXPORT YGDisplay YGNodeStyleGetDisplay(const YGNodeConstRef node) {
return node->getStyle().display(); return node->getStyle().display();
} }
// TODO(T26792433): Change the API to accept YGFloatOptional. // TODO(T26792433): Change the API to accept YGFloatOptional.
void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { YOGA_EXPORT void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
updateStyle<MSVC_HINT(flex)>(node, &YGStyle::flex, YGFloatOptional{flex}); updateStyle<MSVC_HINT(flex)>(node, &YGStyle::flex, YGFloatOptional{flex});
} }
// TODO(T26792433): Change the API to accept YGFloatOptional. // TODO(T26792433): Change the API to accept YGFloatOptional.
float YGNodeStyleGetFlex(const YGNodeConstRef node) { YOGA_EXPORT float YGNodeStyleGetFlex(const YGNodeConstRef node) {
return node->getStyle().flex().isUndefined() return node->getStyle().flex().isUndefined()
? YGUndefined ? YGUndefined
: node->getStyle().flex().unwrap(); : node->getStyle().flex().unwrap();
} }
// TODO(T26792433): Change the API to accept YGFloatOptional. // TODO(T26792433): Change the API to accept YGFloatOptional.
void YGNodeStyleSetFlexGrow(const YGNodeRef node, const float flexGrow) { YOGA_EXPORT void YGNodeStyleSetFlexGrow(
const YGNodeRef node,
const float flexGrow) {
updateStyle<MSVC_HINT(flexGrow)>( updateStyle<MSVC_HINT(flexGrow)>(
node, &YGStyle::flexGrow, YGFloatOptional{flexGrow}); node, &YGStyle::flexGrow, YGFloatOptional{flexGrow});
} }
// TODO(T26792433): Change the API to accept YGFloatOptional. // TODO(T26792433): Change the API to accept YGFloatOptional.
void YGNodeStyleSetFlexShrink(const YGNodeRef node, const float flexShrink) { YOGA_EXPORT void YGNodeStyleSetFlexShrink(
const YGNodeRef node,
const float flexShrink) {
updateStyle<MSVC_HINT(flexShrink)>( updateStyle<MSVC_HINT(flexShrink)>(
node, &YGStyle::flexShrink, YGFloatOptional{flexShrink}); node, &YGStyle::flexShrink, YGFloatOptional{flexShrink});
} }
YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) { YOGA_EXPORT YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
YGValue flexBasis = node->getStyle().flexBasis(); YGValue flexBasis = 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
@@ -680,71 +712,91 @@ YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
return flexBasis; return flexBasis;
} }
void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) { YOGA_EXPORT void YGNodeStyleSetFlexBasis(
const YGNodeRef node,
const float flexBasis) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(flexBasis); auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(flexBasis);
updateStyle<MSVC_HINT(flexBasis)>(node, &YGStyle::flexBasis, value); updateStyle<MSVC_HINT(flexBasis)>(node, &YGStyle::flexBasis, value);
} }
void YGNodeStyleSetFlexBasisPercent( YOGA_EXPORT void YGNodeStyleSetFlexBasisPercent(
const YGNodeRef node, const YGNodeRef node,
const float flexBasisPercent) { const float flexBasisPercent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(flexBasisPercent); auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(flexBasisPercent);
updateStyle<MSVC_HINT(flexBasis)>(node, &YGStyle::flexBasis, value); updateStyle<MSVC_HINT(flexBasis)>(node, &YGStyle::flexBasis, value);
} }
void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) { YOGA_EXPORT void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
updateStyle<MSVC_HINT(flexBasis)>( updateStyle<MSVC_HINT(flexBasis)>(
node, &YGStyle::flexBasis, detail::CompactValue::ofAuto()); node, &YGStyle::flexBasis, detail::CompactValue::ofAuto());
} }
void YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float points) { YOGA_EXPORT void YGNodeStyleSetPosition(
YGNodeRef node,
YGEdge edge,
float points) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points); auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
updateIndexedStyleProp<MSVC_HINT(position)>( updateIndexedStyleProp<MSVC_HINT(position)>(
node, &YGStyle::position, edge, value); node, &YGStyle::position, edge, value);
} }
void YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float percent) { YOGA_EXPORT void YGNodeStyleSetPositionPercent(
YGNodeRef node,
YGEdge edge,
float percent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent); auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
updateIndexedStyleProp<MSVC_HINT(position)>( updateIndexedStyleProp<MSVC_HINT(position)>(
node, &YGStyle::position, edge, value); node, &YGStyle::position, edge, value);
} }
YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) { YOGA_EXPORT YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) {
return node->getStyle().position()[edge]; return node->getStyle().position()[edge];
} }
void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float points) { YOGA_EXPORT void YGNodeStyleSetMargin(
YGNodeRef node,
YGEdge edge,
float points) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points); auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
updateIndexedStyleProp<MSVC_HINT(margin)>( updateIndexedStyleProp<MSVC_HINT(margin)>(
node, &YGStyle::margin, edge, value); node, &YGStyle::margin, edge, value);
} }
void YGNodeStyleSetMarginPercent(YGNodeRef node, YGEdge edge, float percent) { YOGA_EXPORT void YGNodeStyleSetMarginPercent(
YGNodeRef node,
YGEdge edge,
float percent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent); auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
updateIndexedStyleProp<MSVC_HINT(margin)>( updateIndexedStyleProp<MSVC_HINT(margin)>(
node, &YGStyle::margin, edge, value); node, &YGStyle::margin, edge, value);
} }
void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) { YOGA_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) {
updateIndexedStyleProp<MSVC_HINT(margin)>( updateIndexedStyleProp<MSVC_HINT(margin)>(
node, &YGStyle::margin, edge, detail::CompactValue::ofAuto()); node, &YGStyle::margin, edge, detail::CompactValue::ofAuto());
} }
YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) { YOGA_EXPORT YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) {
return node->getStyle().margin()[edge]; return node->getStyle().margin()[edge];
} }
void YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge, float points) { YOGA_EXPORT void YGNodeStyleSetPadding(
YGNodeRef node,
YGEdge edge,
float points) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points); auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
updateIndexedStyleProp<MSVC_HINT(padding)>( updateIndexedStyleProp<MSVC_HINT(padding)>(
node, &YGStyle::padding, edge, value); node, &YGStyle::padding, edge, value);
} }
void YGNodeStyleSetPaddingPercent(YGNodeRef node, YGEdge edge, float percent) { YOGA_EXPORT void YGNodeStyleSetPaddingPercent(
YGNodeRef node,
YGEdge edge,
float percent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent); auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
updateIndexedStyleProp<MSVC_HINT(padding)>( updateIndexedStyleProp<MSVC_HINT(padding)>(
node, &YGStyle::padding, edge, value); node, &YGStyle::padding, edge, value);
} }
YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge) { YOGA_EXPORT YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge) {
return node->getStyle().padding()[edge]; return node->getStyle().padding()[edge];
} }
// TODO(T26792433): Change the API to accept YGFloatOptional. // TODO(T26792433): Change the API to accept YGFloatOptional.
void YGNodeStyleSetBorder( YOGA_EXPORT void YGNodeStyleSetBorder(
const YGNodeRef node, const YGNodeRef node,
const YGEdge edge, const YGEdge edge,
const float border) { const float border) {
@@ -753,7 +805,9 @@ void YGNodeStyleSetBorder(
node, &YGStyle::border, edge, value); node, &YGStyle::border, edge, value);
} }
float YGNodeStyleGetBorder(const YGNodeConstRef node, const YGEdge edge) { YOGA_EXPORT float YGNodeStyleGetBorder(
const YGNodeConstRef node,
const YGEdge edge) {
auto border = node->getStyle().border()[edge]; auto border = 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
@@ -767,126 +821,141 @@ float YGNodeStyleGetBorder(const YGNodeConstRef node, const YGEdge edge) {
// Yoga specific properties, not compatible with flexbox specification // Yoga specific properties, not compatible with flexbox specification
// TODO(T26792433): Change the API to accept YGFloatOptional. // TODO(T26792433): Change the API to accept YGFloatOptional.
float YGNodeStyleGetAspectRatio(const YGNodeConstRef node) { YOGA_EXPORT float YGNodeStyleGetAspectRatio(const YGNodeConstRef node) {
const YGFloatOptional op = node->getStyle().aspectRatio(); const YGFloatOptional op = node->getStyle().aspectRatio();
return op.isUndefined() ? YGUndefined : op.unwrap(); return op.isUndefined() ? YGUndefined : op.unwrap();
} }
// TODO(T26792433): Change the API to accept YGFloatOptional. // TODO(T26792433): Change the API to accept YGFloatOptional.
void YGNodeStyleSetAspectRatio(const YGNodeRef node, const float aspectRatio) { YOGA_EXPORT void YGNodeStyleSetAspectRatio(
const YGNodeRef node,
const float aspectRatio) {
updateStyle<MSVC_HINT(aspectRatio)>( updateStyle<MSVC_HINT(aspectRatio)>(
node, &YGStyle::aspectRatio, YGFloatOptional{aspectRatio}); node, &YGStyle::aspectRatio, YGFloatOptional{aspectRatio});
} }
void YGNodeStyleSetWidth(YGNodeRef node, float points) { YOGA_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float points) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points); auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
updateIndexedStyleProp<MSVC_HINT(dimensions)>( updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &YGStyle::dimensions, YGDimensionWidth, value); node, &YGStyle::dimensions, YGDimensionWidth, value);
} }
void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) { YOGA_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent); auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
updateIndexedStyleProp<MSVC_HINT(dimensions)>( updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &YGStyle::dimensions, YGDimensionWidth, value); node, &YGStyle::dimensions, YGDimensionWidth, value);
} }
void YGNodeStyleSetWidthAuto(YGNodeRef node) { YOGA_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node) {
updateIndexedStyleProp<MSVC_HINT(dimensions)>( updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, node,
&YGStyle::dimensions, &YGStyle::dimensions,
YGDimensionWidth, YGDimensionWidth,
detail::CompactValue::ofAuto()); detail::CompactValue::ofAuto());
} }
YGValue YGNodeStyleGetWidth(YGNodeConstRef node) { YOGA_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
return node->getStyle().dimensions()[YGDimensionWidth]; return node->getStyle().dimensions()[YGDimensionWidth];
} }
void YGNodeStyleSetHeight(YGNodeRef node, float points) { YOGA_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, float points) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points); auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
updateIndexedStyleProp<MSVC_HINT(dimensions)>( updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &YGStyle::dimensions, YGDimensionHeight, value); node, &YGStyle::dimensions, YGDimensionHeight, value);
} }
void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) { YOGA_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent); auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
updateIndexedStyleProp<MSVC_HINT(dimensions)>( updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &YGStyle::dimensions, YGDimensionHeight, value); node, &YGStyle::dimensions, YGDimensionHeight, value);
} }
void YGNodeStyleSetHeightAuto(YGNodeRef node) { YOGA_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node) {
updateIndexedStyleProp<MSVC_HINT(dimensions)>( updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, node,
&YGStyle::dimensions, &YGStyle::dimensions,
YGDimensionHeight, YGDimensionHeight,
detail::CompactValue::ofAuto()); detail::CompactValue::ofAuto());
} }
YGValue YGNodeStyleGetHeight(YGNodeConstRef node) { YOGA_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
return node->getStyle().dimensions()[YGDimensionHeight]; return node->getStyle().dimensions()[YGDimensionHeight];
} }
void YGNodeStyleSetMinWidth(const YGNodeRef node, const float minWidth) { YOGA_EXPORT void YGNodeStyleSetMinWidth(
const YGNodeRef node,
const float minWidth) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(minWidth); auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(minWidth);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>( updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &YGStyle::minDimensions, YGDimensionWidth, value); node, &YGStyle::minDimensions, YGDimensionWidth, value);
} }
void YGNodeStyleSetMinWidthPercent(const YGNodeRef node, const float minWidth) { YOGA_EXPORT void YGNodeStyleSetMinWidthPercent(
const YGNodeRef node,
const float minWidth) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(minWidth); auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(minWidth);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>( updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &YGStyle::minDimensions, YGDimensionWidth, value); node, &YGStyle::minDimensions, YGDimensionWidth, value);
} }
YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) { YOGA_EXPORT YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
return node->getStyle().minDimensions()[YGDimensionWidth]; return node->getStyle().minDimensions()[YGDimensionWidth];
}; };
void YGNodeStyleSetMinHeight(const YGNodeRef node, const float minHeight) { YOGA_EXPORT void YGNodeStyleSetMinHeight(
const YGNodeRef node,
const float minHeight) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(minHeight); auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(minHeight);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>( updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &YGStyle::minDimensions, YGDimensionHeight, value); node, &YGStyle::minDimensions, YGDimensionHeight, value);
} }
void YGNodeStyleSetMinHeightPercent( YOGA_EXPORT void YGNodeStyleSetMinHeightPercent(
const YGNodeRef node, const YGNodeRef node,
const float minHeight) { const float minHeight) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(minHeight); auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(minHeight);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>( updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &YGStyle::minDimensions, YGDimensionHeight, value); node, &YGStyle::minDimensions, YGDimensionHeight, value);
} }
YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) { YOGA_EXPORT YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
return node->getStyle().minDimensions()[YGDimensionHeight]; return node->getStyle().minDimensions()[YGDimensionHeight];
}; };
void YGNodeStyleSetMaxWidth(const YGNodeRef node, const float maxWidth) { YOGA_EXPORT void YGNodeStyleSetMaxWidth(
const YGNodeRef node,
const float maxWidth) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(maxWidth); auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(maxWidth);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>( updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &YGStyle::maxDimensions, YGDimensionWidth, value); node, &YGStyle::maxDimensions, YGDimensionWidth, value);
} }
void YGNodeStyleSetMaxWidthPercent(const YGNodeRef node, const float maxWidth) { YOGA_EXPORT void YGNodeStyleSetMaxWidthPercent(
const YGNodeRef node,
const float maxWidth) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(maxWidth); auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(maxWidth);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>( updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &YGStyle::maxDimensions, YGDimensionWidth, value); node, &YGStyle::maxDimensions, YGDimensionWidth, value);
} }
YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) { YOGA_EXPORT YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
return node->getStyle().maxDimensions()[YGDimensionWidth]; return node->getStyle().maxDimensions()[YGDimensionWidth];
}; };
void YGNodeStyleSetMaxHeight(const YGNodeRef node, const float maxHeight) { YOGA_EXPORT void YGNodeStyleSetMaxHeight(
const YGNodeRef node,
const float maxHeight) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(maxHeight); auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(maxHeight);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>( updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &YGStyle::maxDimensions, YGDimensionHeight, value); node, &YGStyle::maxDimensions, YGDimensionHeight, value);
} }
void YGNodeStyleSetMaxHeightPercent( YOGA_EXPORT void YGNodeStyleSetMaxHeightPercent(
const YGNodeRef node, const YGNodeRef node,
const float maxHeight) { const float maxHeight) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(maxHeight); auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(maxHeight);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>( updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &YGStyle::maxDimensions, YGDimensionHeight, value); node, &YGStyle::maxDimensions, YGDimensionHeight, value);
} }
YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) { YOGA_EXPORT YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
return node->getStyle().maxDimensions()[YGDimensionHeight]; return node->getStyle().maxDimensions()[YGDimensionHeight];
}; };
#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \ #define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \
type YGNodeLayoutGet##name(const YGNodeRef node) { \ YOGA_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node) { \
return node->getLayout().instanceName; \ return node->getLayout().instanceName; \
} }
#define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \ #define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \
type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \ YOGA_EXPORT type YGNodeLayoutGet##name( \
const YGNodeRef node, const YGEdge edge) { \
YGAssertWithNode( \ YGAssertWithNode( \
node, \ node, \
edge <= YGEdgeEnd, \ edge <= YGEdgeEnd, \
@@ -924,7 +993,8 @@ YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Margin, margin);
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Border, border); 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);
bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(const YGNodeRef node) { YOGA_EXPORT bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(
const YGNodeRef node) {
return node->getLayout().doesLegacyStretchFlagAffectsLayout(); return node->getLayout().doesLegacyStretchFlagAffectsLayout();
} }
@@ -956,7 +1026,9 @@ static void YGNodePrintInternal(
Log::log(node, YGLogLevelDebug, nullptr, str.c_str()); Log::log(node, YGLogLevelDebug, nullptr, str.c_str());
} }
void YGNodePrint(const YGNodeRef node, const YGPrintOptions options) { YOGA_EXPORT void YGNodePrint(
const YGNodeRef node,
const YGPrintOptions options) {
YGNodePrintInternal(node, options); YGNodePrintInternal(node, options);
} }
#endif #endif
@@ -3970,7 +4042,7 @@ bool YGLayoutNodeInternal(
return (needToVisitNode || cachedResults == nullptr); return (needToVisitNode || cachedResults == nullptr);
} }
void YGConfigSetPointScaleFactor( YOGA_EXPORT void YGConfigSetPointScaleFactor(
const YGConfigRef config, const YGConfigRef config,
const float pixelsInPoint) { const float pixelsInPoint) {
YGAssertWithConfig( YGAssertWithConfig(
@@ -4067,7 +4139,7 @@ static void unsetUseLegacyFlagRecursively(YGNodeRef node) {
} }
} }
void YGNodeCalculateLayoutWithContext( YOGA_EXPORT void YGNodeCalculateLayoutWithContext(
const YGNodeRef node, const YGNodeRef node,
const float ownerWidth, const float ownerWidth,
const float ownerHeight, const float ownerHeight,
@@ -4219,7 +4291,7 @@ void YGNodeCalculateLayoutWithContext(
} }
} }
void YGNodeCalculateLayout( YOGA_EXPORT void YGNodeCalculateLayout(
const YGNodeRef node, const YGNodeRef node,
const float ownerWidth, const float ownerWidth,
const float ownerHeight, const float ownerHeight,
@@ -4228,7 +4300,7 @@ void YGNodeCalculateLayout(
node, ownerWidth, ownerHeight, ownerDirection, nullptr); node, ownerWidth, ownerHeight, ownerDirection, nullptr);
} }
void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) { YOGA_EXPORT void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) {
if (logger != nullptr) { if (logger != nullptr) {
config->setLogger(logger); config->setLogger(logger);
} else { } else {
@@ -4240,7 +4312,7 @@ void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) {
} }
} }
void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour( YOGA_EXPORT void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
const YGConfigRef config, const YGConfigRef config,
const bool shouldDiffLayout) { const bool shouldDiffLayout) {
config->shouldDiffLayoutWithoutLegacyStretchBehaviour = shouldDiffLayout; config->shouldDiffLayoutWithoutLegacyStretchBehaviour = shouldDiffLayout;
@@ -4270,7 +4342,7 @@ void YGAssertWithConfig(
} }
} }
void YGConfigSetExperimentalFeatureEnabled( YOGA_EXPORT void YGConfigSetExperimentalFeatureEnabled(
const YGConfigRef config, const YGConfigRef config,
const YGExperimentalFeature feature, const YGExperimentalFeature feature,
const bool enabled) { const bool enabled) {
@@ -4283,11 +4355,13 @@ inline bool YGConfigIsExperimentalFeatureEnabled(
return config->experimentalFeatures[feature]; return config->experimentalFeatures[feature];
} }
void YGConfigSetUseWebDefaults(const YGConfigRef config, const bool enabled) { YOGA_EXPORT void YGConfigSetUseWebDefaults(
const YGConfigRef config,
const bool enabled) {
config->useWebDefaults = enabled; config->useWebDefaults = enabled;
} }
void YGConfigSetUseLegacyStretchBehaviour( YOGA_EXPORT void YGConfigSetUseLegacyStretchBehaviour(
const YGConfigRef config, const YGConfigRef config,
const bool useLegacyStretchBehaviour) { const bool useLegacyStretchBehaviour) {
config->useLegacyStretchBehaviour = useLegacyStretchBehaviour; config->useLegacyStretchBehaviour = useLegacyStretchBehaviour;
@@ -4297,15 +4371,15 @@ bool YGConfigGetUseWebDefaults(const YGConfigRef config) {
return config->useWebDefaults; return config->useWebDefaults;
} }
void YGConfigSetContext(const YGConfigRef config, void* context) { YOGA_EXPORT void YGConfigSetContext(const YGConfigRef config, void* context) {
config->context = context; config->context = context;
} }
void* YGConfigGetContext(const YGConfigRef config) { YOGA_EXPORT void* YGConfigGetContext(const YGConfigRef config) {
return config->context; return config->context;
} }
void YGConfigSetCloneNodeFunc( YOGA_EXPORT void YGConfigSetCloneNodeFunc(
const YGConfigRef config, const YGConfigRef config,
const YGCloneNodeFunc callback) { const YGCloneNodeFunc callback) {
config->setCloneNodeCallback(callback); config->setCloneNodeCallback(callback);

View File

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

View File

@@ -33,7 +33,7 @@ void vlog(
} }
} // namespace } // namespace
void Log::log( YOGA_EXPORT void Log::log(
YGNode* node, YGNode* node,
YGLogLevel level, YGLogLevel level,
void* context, void* context,