From 2da08884b276eedc0ceee3502d8ae77435f08365 Mon Sep 17 00:00:00 2001 From: mattpodwysocki Date: Thu, 22 Sep 2016 16:22:34 -0700 Subject: [PATCH] Introducing .NET version of css-layout using P/Invoke Summary: This version of the css-layout project includes support for .NET projects. Up in the air is how many configurations of .NET projects we allow for, such as Portable Class Libraries, Universal Windows Platform, .NET Core, etc. Still needs integration with Buck. Closes https://github.com/facebook/css-layout/pull/220 Reviewed By: lucasr Differential Revision: D3909367 Pulled By: emilsjolander fbshipit-source-id: aaaa9c4ff2d3452649f256c3268cf873cf33a0b9 --- React/CSSLayout/CSSLayout.h | 38 ++++++++++++++++++------------------- React/CSSLayout/CSSMacros.h | 6 ++++++ 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/React/CSSLayout/CSSLayout.h b/React/CSSLayout/CSSLayout.h index 3ebce6855e1..f3353fdf05e 100644 --- a/React/CSSLayout/CSSLayout.h +++ b/React/CSSLayout/CSSLayout.h @@ -122,16 +122,16 @@ typedef CSSSize (*CSSMeasureFunc)(void *context, typedef void (*CSSPrintFunc)(void *context); // CSSNode -CSSNodeRef CSSNodeNew(); -void CSSNodeInit(const CSSNodeRef node); -void CSSNodeFree(const CSSNodeRef node); +WIN_EXPORT CSSNodeRef CSSNodeNew(); +WIN_EXPORT void CSSNodeInit(const CSSNodeRef node); +WIN_EXPORT void CSSNodeFree(const CSSNodeRef node); -void CSSNodeInsertChild(const CSSNodeRef node, const CSSNodeRef child, const uint32_t index); -void CSSNodeRemoveChild(const CSSNodeRef node, const CSSNodeRef child); -CSSNodeRef CSSNodeGetChild(const CSSNodeRef node, const uint32_t index); -uint32_t CSSNodeChildCount(const CSSNodeRef node); +WIN_EXPORT void CSSNodeInsertChild(const CSSNodeRef node, const CSSNodeRef child, const uint32_t index); +WIN_EXPORT void CSSNodeRemoveChild(const CSSNodeRef node, const CSSNodeRef child); +WIN_EXPORT CSSNodeRef CSSNodeGetChild(const CSSNodeRef node, const uint32_t index); +WIN_EXPORT uint32_t CSSNodeChildCount(const CSSNodeRef node); -void CSSNodeCalculateLayout(const CSSNodeRef node, +WIN_EXPORT void CSSNodeCalculateLayout(const CSSNodeRef node, const float availableWidth, const float availableHeight, const CSSDirection parentDirection); @@ -142,26 +142,26 @@ void CSSNodeCalculateLayout(const CSSNodeRef node, // measure functions // depends on information not known to CSSLayout they must perform this dirty // marking manually. -void CSSNodeMarkDirty(const CSSNodeRef node); -bool CSSNodeIsDirty(const CSSNodeRef node); +WIN_EXPORT void CSSNodeMarkDirty(const CSSNodeRef node); +WIN_EXPORT bool CSSNodeIsDirty(const CSSNodeRef node); -void CSSNodePrint(const CSSNodeRef node, const CSSPrintOptions options); +WIN_EXPORT void CSSNodePrint(const CSSNodeRef node, const CSSPrintOptions options); -bool CSSValueIsUndefined(const float value); +WIN_EXPORT bool CSSValueIsUndefined(const float value); #define CSS_NODE_PROPERTY(type, name, paramName) \ - void CSSNodeSet##name(const CSSNodeRef node, type paramName); \ - type CSSNodeGet##name(const CSSNodeRef node); + WIN_EXPORT void CSSNodeSet##name(const CSSNodeRef node, type paramName); \ + WIN_EXPORT type CSSNodeGet##name(const CSSNodeRef node); #define CSS_NODE_STYLE_PROPERTY(type, name, paramName) \ - void CSSNodeStyleSet##name(const CSSNodeRef node, const type paramName); \ - type CSSNodeStyleGet##name(const CSSNodeRef node); + WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, const type paramName); \ + WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node); #define CSS_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \ - void CSSNodeStyleSet##name(const CSSNodeRef node, const CSSEdge edge, const type paramName); \ - type CSSNodeStyleGet##name(const CSSNodeRef node, const CSSEdge edge); + WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, const CSSEdge edge, const type paramName); \ + WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node, const CSSEdge edge); -#define CSS_NODE_LAYOUT_PROPERTY(type, name) type CSSNodeLayoutGet##name(const CSSNodeRef node); +#define CSS_NODE_LAYOUT_PROPERTY(type, name) WIN_EXPORT type CSSNodeLayoutGet##name(const CSSNodeRef node); CSS_NODE_PROPERTY(void *, Context, context); CSS_NODE_PROPERTY(CSSMeasureFunc, MeasureFunc, measureFunc); diff --git a/React/CSSLayout/CSSMacros.h b/React/CSSLayout/CSSMacros.h index eb05985699a..f4e29a1e3ff 100644 --- a/React/CSSLayout/CSSMacros.h +++ b/React/CSSLayout/CSSMacros.h @@ -17,6 +17,12 @@ #define CSS_EXTERN_C_END #endif +#ifdef _WINDLL +#define WIN_EXPORT __declspec(dllexport) +#else +#define WIN_EXPORT +#endif + #ifndef FB_ASSERTIONS_ENABLED #define FB_ASSERTIONS_ENABLED 1 #endif