Skip to content

Commit

Permalink
Adds fixes for react-native-windows UWP (#848)
Browse files Browse the repository at this point in the history
Summary:
Specifically, updates the UWP .vcxproj for MSBuild and also exposes the UseLegacyStretchBehaviour API for use with react-native-windows.
Pull Request resolved: facebook/yoga#848

Reviewed By: SidharthGuglani

Differential Revision: D13848609

Pulled By: davidaurelio

fbshipit-source-id: eab046ff3c47e49706f515e209d8aaf750c2198f
  • Loading branch information
rozele authored and facebook-github-bot committed Feb 1, 2019
1 parent 8691cda commit 307cf09
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 113 deletions.
34 changes: 18 additions & 16 deletions csharp/Facebook.Yoga/Native.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@

namespace Facebook.Yoga
{
#if WINDOWS_UWP_ARM
using YogaValueType = IntPtr;
#else
using YogaValueType = YogaValue;
#endif

internal static class Native
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
Expand Down Expand Up @@ -74,6 +68,14 @@ public static extern void YGConfigSetUseWebDefaults(
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern bool YGConfigGetUseWebDefaults(YGConfigHandle config);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigSetUseLegacyStretchBehaviour(
YGConfigHandle config,
bool useLegacyStretchBehavior);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern bool YGConfigGetUseLegacyStretchBehaviour(YGConfigHandle config);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigSetPointScaleFactor(
YGConfigHandle config,
Expand Down Expand Up @@ -226,7 +228,7 @@ public static extern void YGNodeSetHasNewLayout(
public static extern void YGNodeStyleSetFlexBasisAuto(YGNodeHandle node);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetFlexBasis(YGNodeHandle node);
public static extern YogaValue YGNodeStyleGetFlexBasis(YGNodeHandle node);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width);
Expand All @@ -238,7 +240,7 @@ public static extern void YGNodeSetHasNewLayout(
public static extern void YGNodeStyleSetWidthAuto(YGNodeHandle node);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetWidth(YGNodeHandle node);
public static extern YogaValue YGNodeStyleGetWidth(YGNodeHandle node);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height);
Expand All @@ -250,7 +252,7 @@ public static extern void YGNodeSetHasNewLayout(
public static extern void YGNodeStyleSetHeightAuto(YGNodeHandle node);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetHeight(YGNodeHandle node);
public static extern YogaValue YGNodeStyleGetHeight(YGNodeHandle node);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth);
Expand All @@ -259,7 +261,7 @@ public static extern void YGNodeSetHasNewLayout(
public static extern void YGNodeStyleSetMinWidthPercent(YGNodeHandle node, float minWidth);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetMinWidth(YGNodeHandle node);
public static extern YogaValue YGNodeStyleGetMinWidth(YGNodeHandle node);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight);
Expand All @@ -268,7 +270,7 @@ public static extern void YGNodeSetHasNewLayout(
public static extern void YGNodeStyleSetMinHeightPercent(YGNodeHandle node, float minHeight);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetMinHeight(YGNodeHandle node);
public static extern YogaValue YGNodeStyleGetMinHeight(YGNodeHandle node);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth);
Expand All @@ -277,7 +279,7 @@ public static extern void YGNodeSetHasNewLayout(
public static extern void YGNodeStyleSetMaxWidthPercent(YGNodeHandle node, float maxWidth);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetMaxWidth(YGNodeHandle node);
public static extern YogaValue YGNodeStyleGetMaxWidth(YGNodeHandle node);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight);
Expand All @@ -286,7 +288,7 @@ public static extern void YGNodeSetHasNewLayout(
public static extern void YGNodeStyleSetMaxHeightPercent(YGNodeHandle node, float maxHeight);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetMaxHeight(YGNodeHandle node);
public static extern YogaValue YGNodeStyleGetMaxHeight(YGNodeHandle node);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio);
Expand All @@ -305,7 +307,7 @@ public static extern void YGNodeSetHasNewLayout(
public static extern void YGNodeStyleSetPositionPercent(YGNodeHandle node, YogaEdge edge, float position);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);
public static extern YogaValue YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin);
Expand All @@ -317,7 +319,7 @@ public static extern void YGNodeSetHasNewLayout(
public static extern void YGNodeStyleSetMarginAuto(YGNodeHandle node, YogaEdge edge);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);
public static extern YogaValue YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding);
Expand All @@ -326,7 +328,7 @@ public static extern void YGNodeSetHasNewLayout(
public static extern void YGNodeStyleSetPaddingPercent(YGNodeHandle node, YogaEdge edge, float padding);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);
public static extern YogaValue YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);

[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border);
Expand Down
15 changes: 14 additions & 1 deletion csharp/Facebook.Yoga/YogaConfig.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
Expand Down Expand Up @@ -117,6 +117,19 @@ public bool UseWebDefaults
}
}

public bool UseLegacyStretchBehaviour
{
get
{
return Native.YGConfigGetUseLegacyStretchBehaviour(_ygConfig);
}

set
{
Native.YGConfigSetUseLegacyStretchBehaviour(_ygConfig, value);
}
}

public float PointScaleFactor
{
set
Expand Down
50 changes: 25 additions & 25 deletions csharp/Facebook.Yoga/YogaNode.Spacing.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
Expand All @@ -13,7 +13,7 @@ public YogaValue Left
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left));
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left);
}

set
Expand All @@ -26,7 +26,7 @@ public YogaValue Top
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top));
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top);
}

set
Expand All @@ -39,7 +39,7 @@ public YogaValue Right
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right));
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right);
}

set
Expand All @@ -52,7 +52,7 @@ public YogaValue Bottom
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom));
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom);
}

set
Expand All @@ -65,7 +65,7 @@ public YogaValue Start
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start));
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start);
}

set
Expand All @@ -78,7 +78,7 @@ public YogaValue End
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End));
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End);
}

set
Expand All @@ -103,7 +103,7 @@ public YogaValue MarginLeft
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left);
}

set
Expand All @@ -116,7 +116,7 @@ public YogaValue MarginTop
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top);
}

set
Expand All @@ -129,7 +129,7 @@ public YogaValue MarginRight
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right);
}

set
Expand All @@ -142,7 +142,7 @@ public YogaValue MarginBottom
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom);
}

set
Expand All @@ -155,7 +155,7 @@ public YogaValue MarginStart
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start);
}

set
Expand All @@ -168,7 +168,7 @@ public YogaValue MarginEnd
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End);
}

set
Expand All @@ -181,7 +181,7 @@ public YogaValue MarginHorizontal
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal);
}

set
Expand All @@ -194,7 +194,7 @@ public YogaValue MarginVertical
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical);
}

set
Expand All @@ -207,7 +207,7 @@ public YogaValue Margin
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All);
}

set
Expand Down Expand Up @@ -236,7 +236,7 @@ public YogaValue PaddingLeft
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left);
}

set
Expand All @@ -249,7 +249,7 @@ public YogaValue PaddingTop
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top);
}

set
Expand All @@ -262,7 +262,7 @@ public YogaValue PaddingRight
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right);
}

set
Expand All @@ -275,7 +275,7 @@ public YogaValue PaddingBottom
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom);
}

set
Expand All @@ -288,7 +288,7 @@ public YogaValue PaddingStart
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start);
}

set
Expand All @@ -301,7 +301,7 @@ public YogaValue PaddingEnd
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End);
}

set
Expand All @@ -314,7 +314,7 @@ public YogaValue PaddingHorizontal
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal);
}

set
Expand All @@ -327,7 +327,7 @@ public YogaValue PaddingVertical
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical);
}

set
Expand All @@ -340,7 +340,7 @@ public YogaValue Padding
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All);
}

set
Expand Down
Loading

0 comments on commit 307cf09

Please sign in to comment.