Skip to content

Commit

Permalink
Fixup exports
Browse files Browse the repository at this point in the history
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
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Sep 12, 2023
1 parent 7dab2a7 commit dff5312
Show file tree
Hide file tree
Showing 12 changed files with 291 additions and 371 deletions.
2 changes: 1 addition & 1 deletion tests/util/TestUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace facebook::yoga::test {

struct YOGA_EXPORT TestUtil {
struct TestUtil {
static void startCountingNodes();
static int nodeCount();
static int stopCountingNodes();
Expand Down
16 changes: 5 additions & 11 deletions yoga/YGMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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, ...) \
Expand Down
6 changes: 3 additions & 3 deletions yoga/YGValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions yoga/Yoga-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

YG_EXTERN_C_BEGIN

void YGNodeCalculateLayoutWithContext(
YG_EXPORT void YGNodeCalculateLayoutWithContext(
YGNodeRef node,
float availableWidth,
float availableHeight,
Expand All @@ -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
Loading

0 comments on commit dff5312

Please sign in to comment.