From 5bc0197c78ad3d07174e9ae02c6f314ae68c1a75 Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Mon, 6 Mar 2017 11:29:52 -0800 Subject: [PATCH] Workaround for P/Invoke AccessViolationException Summary: The issue is on ARM builds for Windows UWP. For the C# P/Invoke API wrapper, any native method that returns the YogaValue struct throws the AccessViolationException. The issue is not with structs in general, as returning the YogaSize / YGSize struct works fine. The issue seems to be limited to structs that have an enum member. I tried a number of things to resolve the issue without changing the underlying native API for Windows. I read the ARM documentation and saw reference to variable enum sizes based on the number of enum members, so I tried to use a number of different UnmanagedType values in a [MarsalAs()] attribute on the enum member of the C# struct declaration. What ultimately worked was to return a pointer to the location of the struct, and use the System.Runtime.InteropServices.PtrToStructure API to read the struct data from that pointer. I added a few new macros that will return the struct address on Windows only, other builds are not affected. Note, I have not tested the impact of this ch Closes https://github.com/facebook/yoga/pull/459 Reviewed By: emilsjolander Differential Revision: D4652278 Pulled By: splhack fbshipit-source-id: bf7ada4da1781e3f813b3ba331974b7bded476d9 --- csharp/Facebook.Yoga/Native.cs | 46 +++++++++++--------- csharp/Facebook.Yoga/YogaNode.Spacing.cs | 50 +++++++++++----------- csharp/Facebook.Yoga/YogaNode.cs | 14 +++--- csharp/Facebook.Yoga/YogaValue.cs | 13 ++++++ csharp/Windows/Facebook.Yoga.Universal.sln | 39 ++++++++--------- csharp/Yoga/Yoga.Universal.vcxproj | 4 +- yoga/YGMacros.h | 8 ++++ yoga/Yoga.c | 4 +- yoga/Yoga.h | 2 +- 9 files changed, 102 insertions(+), 78 deletions(-) diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs index db83f3b9..ba225669 100644 --- a/csharp/Facebook.Yoga/Native.cs +++ b/csharp/Facebook.Yoga/Native.cs @@ -12,6 +12,12 @@ using System.Runtime.InteropServices; 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__ @@ -172,7 +178,7 @@ namespace Facebook.Yoga [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeCopyStyle(YGNodeHandle dstNode, YGNodeHandle srcNode); - #region YG_NODE_PROPERTY +#region YG_NODE_PROPERTY [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeSetMeasureFunc( @@ -193,9 +199,9 @@ namespace Facebook.Yoga [return: MarshalAs(UnmanagedType.I1)] public static extern bool YGNodeGetHasNewLayout(YGNodeHandle node); - #endregion +#endregion - #region YG_NODE_STYLE_PROPERTY +#region YG_NODE_STYLE_PROPERTY [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeStyleSetDirection(YGNodeHandle node, YogaDirection direction); @@ -282,7 +288,7 @@ namespace Facebook.Yoga public static extern void YGNodeStyleSetFlexBasisAuto(YGNodeHandle node); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - public static extern YogaValue YGNodeStyleGetFlexBasis(YGNodeHandle node); + public static extern YogaValueType YGNodeStyleGetFlexBasis(YGNodeHandle node); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width); @@ -294,7 +300,7 @@ namespace Facebook.Yoga public static extern void YGNodeStyleSetWidthAuto(YGNodeHandle node); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - public static extern YogaValue YGNodeStyleGetWidth(YGNodeHandle node); + public static extern YogaValueType YGNodeStyleGetWidth(YGNodeHandle node); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height); @@ -306,7 +312,7 @@ namespace Facebook.Yoga public static extern void YGNodeStyleSetHeightAuto(YGNodeHandle node); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - public static extern YogaValue YGNodeStyleGetHeight(YGNodeHandle node); + public static extern YogaValueType YGNodeStyleGetHeight(YGNodeHandle node); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth); @@ -315,7 +321,7 @@ namespace Facebook.Yoga public static extern void YGNodeStyleSetMinWidthPercent(YGNodeHandle node, float minWidth); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - public static extern YogaValue YGNodeStyleGetMinWidth(YGNodeHandle node); + public static extern YogaValueType YGNodeStyleGetMinWidth(YGNodeHandle node); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight); @@ -324,7 +330,7 @@ namespace Facebook.Yoga public static extern void YGNodeStyleSetMinHeightPercent(YGNodeHandle node, float minHeight); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - public static extern YogaValue YGNodeStyleGetMinHeight(YGNodeHandle node); + public static extern YogaValueType YGNodeStyleGetMinHeight(YGNodeHandle node); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth); @@ -333,7 +339,7 @@ namespace Facebook.Yoga public static extern void YGNodeStyleSetMaxWidthPercent(YGNodeHandle node, float maxWidth); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - public static extern YogaValue YGNodeStyleGetMaxWidth(YGNodeHandle node); + public static extern YogaValueType YGNodeStyleGetMaxWidth(YGNodeHandle node); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight); @@ -342,7 +348,7 @@ namespace Facebook.Yoga public static extern void YGNodeStyleSetMaxHeightPercent(YGNodeHandle node, float maxHeight); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - public static extern YogaValue YGNodeStyleGetMaxHeight(YGNodeHandle node); + public static extern YogaValueType YGNodeStyleGetMaxHeight(YGNodeHandle node); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio); @@ -350,9 +356,9 @@ namespace Facebook.Yoga [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern float YGNodeStyleGetAspectRatio(YGNodeHandle node); - #endregion +#endregion - #region YG_NODE_STYLE_EDGE_PROPERTY +#region YG_NODE_STYLE_EDGE_PROPERTY [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeStyleSetPosition(YGNodeHandle node, YogaEdge edge, float position); @@ -361,7 +367,7 @@ namespace Facebook.Yoga public static extern void YGNodeStyleSetPositionPercent(YGNodeHandle node, YogaEdge edge, float position); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - public static extern YogaValue YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge); + public static extern YogaValueType YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin); @@ -373,7 +379,7 @@ namespace Facebook.Yoga public static extern void YGNodeStyleSetMarginAuto(YGNodeHandle node, YogaEdge edge); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - public static extern YogaValue YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge); + public static extern YogaValueType YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding); @@ -382,7 +388,7 @@ namespace Facebook.Yoga public static extern void YGNodeStyleSetPaddingPercent(YGNodeHandle node, YogaEdge edge, float padding); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - public static extern YogaValue YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge); + public static extern YogaValueType YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge); [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border); @@ -390,9 +396,9 @@ namespace Facebook.Yoga [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern float YGNodeStyleGetBorder(YGNodeHandle node, YogaEdge edge); - #endregion +#endregion - #region YG_NODE_LAYOUT_PROPERTY +#region YG_NODE_LAYOUT_PROPERTY [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern float YGNodeLayoutGetLeft(YGNodeHandle node); @@ -421,9 +427,9 @@ namespace Facebook.Yoga [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern YogaDirection YGNodeLayoutGetDirection(YGNodeHandle node); - #endregion +#endregion - #region IOS +#region IOS #if (UNITY_IOS && !UNITY_EDITOR) || __IOS__ [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] @@ -433,6 +439,6 @@ namespace Facebook.Yoga public static extern void YGNodeSetContext(IntPtr node, IntPtr managed); #endif - #endregion +#endregion } } diff --git a/csharp/Facebook.Yoga/YogaNode.Spacing.cs b/csharp/Facebook.Yoga/YogaNode.Spacing.cs index f078f0f0..841ed698 100644 --- a/csharp/Facebook.Yoga/YogaNode.Spacing.cs +++ b/csharp/Facebook.Yoga/YogaNode.Spacing.cs @@ -7,8 +7,6 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -using System; - namespace Facebook.Yoga { public partial class YogaNode @@ -17,7 +15,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left); + return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left)); } set @@ -30,7 +28,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top); + return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top)); } set @@ -43,7 +41,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right); + return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right)); } set @@ -56,7 +54,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom); + return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom)); } set @@ -69,7 +67,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start); + return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start)); } set @@ -82,7 +80,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End); + return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End)); } set @@ -107,7 +105,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left); + return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left)); } set @@ -120,7 +118,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top); + return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top)); } set @@ -133,7 +131,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right); + return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right)); } set @@ -146,7 +144,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom); + return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom)); } set @@ -159,7 +157,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start); + return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start)); } set @@ -172,7 +170,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End); + return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End)); } set @@ -185,7 +183,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal); + return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal)); } set @@ -198,7 +196,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical); + return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical)); } set @@ -211,7 +209,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All); + return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All)); } set @@ -240,7 +238,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left); + return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left)); } set @@ -253,7 +251,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top); + return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top)); } set @@ -266,7 +264,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right); + return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right)); } set @@ -279,7 +277,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom); + return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom)); } set @@ -292,7 +290,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start); + return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start)); } set @@ -305,7 +303,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End); + return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End)); } set @@ -318,7 +316,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal); + return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal)); } set @@ -331,7 +329,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical); + return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical)); } set @@ -344,7 +342,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All); + return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All)); } set diff --git a/csharp/Facebook.Yoga/YogaNode.cs b/csharp/Facebook.Yoga/YogaNode.cs index 0bb1349f..6ea40e42 100644 --- a/csharp/Facebook.Yoga/YogaNode.cs +++ b/csharp/Facebook.Yoga/YogaNode.cs @@ -318,7 +318,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetFlexBasis(_ygNode); + return YogaValue.MarshalValue(Native.YGNodeStyleGetFlexBasis(_ygNode)); } set @@ -342,7 +342,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetWidth(_ygNode); + return YogaValue.MarshalValue(Native.YGNodeStyleGetWidth(_ygNode)); } set @@ -366,7 +366,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetHeight(_ygNode); + return YogaValue.MarshalValue(Native.YGNodeStyleGetHeight(_ygNode)); } set @@ -390,7 +390,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetMaxWidth(_ygNode); + return YogaValue.MarshalValue(Native.YGNodeStyleGetMaxWidth(_ygNode)); } set @@ -410,7 +410,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetMaxHeight(_ygNode); + return YogaValue.MarshalValue(Native.YGNodeStyleGetMaxHeight(_ygNode)); } set @@ -430,7 +430,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetMinWidth(_ygNode); + return YogaValue.MarshalValue(Native.YGNodeStyleGetMinWidth(_ygNode)); } set @@ -450,7 +450,7 @@ namespace Facebook.Yoga { get { - return Native.YGNodeStyleGetMinHeight(_ygNode); + return YogaValue.MarshalValue(Native.YGNodeStyleGetMinHeight(_ygNode)); } set diff --git a/csharp/Facebook.Yoga/YogaValue.cs b/csharp/Facebook.Yoga/YogaValue.cs index b16a9707..894f7633 100644 --- a/csharp/Facebook.Yoga/YogaValue.cs +++ b/csharp/Facebook.Yoga/YogaValue.cs @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +using System; using System.Runtime.InteropServices; namespace Facebook.Yoga @@ -92,5 +93,17 @@ namespace Facebook.Yoga { return Point(pointValue); } + +#if WINDOWS_UWP_ARM + internal static YogaValue MarshalValue(IntPtr ptr) + { + return Marshal.PtrToStructure(ptr); + } +#else + internal static YogaValue MarshalValue(YogaValue value) + { + return value; + } +#endif } } diff --git a/csharp/Windows/Facebook.Yoga.Universal.sln b/csharp/Windows/Facebook.Yoga.Universal.sln index 2280e229..f7ce196d 100644 --- a/csharp/Windows/Facebook.Yoga.Universal.sln +++ b/csharp/Windows/Facebook.Yoga.Universal.sln @@ -7,7 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{5289E508 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Native", "Native", "{51A8E803-C084-431F-9130-F277481C2BB2}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NETStandard", "NETStandard", "{DCF7899B-A487-49C0-BCDE-DC088B6750C2}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Universal", "Universal", "{1048DB7D-9B95-48CA-B43E-D9C35AB1DCD4}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yoga.uwp", "..\Yoga\Yoga.Universal.vcxproj", "{2EACF721-73B5-46AE-9775-4A8674D05A9C}" EndProject @@ -15,7 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{39A2FF EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Facebook.Yoga.Shared", "..\Facebook.Yoga\Facebook.Yoga.Shared.shproj", "{91C42D32-291D-4B72-90B4-551663D60B8B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga", "Facebook.Yoga\Facebook.Yoga.csproj", "{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Universal", "Facebook.Yoga.Universal\Facebook.Yoga.Universal.csproj", "{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}" ProjectSection(ProjectDependencies) = postProject {2EACF721-73B5-46AE-9775-4A8674D05A9C} = {2EACF721-73B5-46AE-9775-4A8674D05A9C} EndProjectSection @@ -26,7 +26,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Universal.Tes EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution - ..\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{3aace384-fdec-4d91-a3b2-eeb21b46c9ad}*SharedItemsImports = 4 + ..\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{d6477ad6-9edd-4eba-8c60-cd31f77c52c6}*SharedItemsImports = 4 ..\tests\Facebook.Yoga\Facebook.Yoga.Shared.Tests.projitems*{4edc82d9-a201-4831-8fe0-98f468f8e4ae}*SharedItemsImports = 13 ..\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{91c42d32-291d-4b72-90b4-551663d60b8b}*SharedItemsImports = 13 EndGlobalSection @@ -55,22 +55,21 @@ Global {2EACF721-73B5-46AE-9775-4A8674D05A9C}.Release|x64.Build.0 = Release|x64 {2EACF721-73B5-46AE-9775-4A8674D05A9C}.Release|x86.ActiveCfg = Release|Win32 {2EACF721-73B5-46AE-9775-4A8674D05A9C}.Release|x86.Build.0 = Release|Win32 - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|ARM.ActiveCfg = Debug|ARM - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|ARM.Build.0 = Debug|ARM - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|x64.ActiveCfg = Debug|x64 - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|x64.Build.0 = Debug|x64 - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|x86.ActiveCfg = Debug|x86 - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|x86.Build.0 = Debug|x86 - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|Any CPU.Build.0 = Release|Any CPU - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|ARM.ActiveCfg = Release|ARM - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|ARM.Build.0 = Release|ARM - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|x64.ActiveCfg = Release|x64 - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|x64.Build.0 = Release|x64 - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|x86.ActiveCfg = Release|x86 - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|x86.Build.0 = Release|x86 + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|ARM.ActiveCfg = Debug|ARM + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|ARM.Build.0 = Debug|ARM + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x64.ActiveCfg = Debug|x64 + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x64.Build.0 = Debug|x64 + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x86.ActiveCfg = Debug|x86 + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x86.Build.0 = Debug|x86 + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|Any CPU.Build.0 = Release|Any CPU + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|ARM.ActiveCfg = Release|ARM + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|ARM.Build.0 = Release|ARM + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|x64.ActiveCfg = Release|x64 + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|x64.Build.0 = Release|x64 + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|x86.ActiveCfg = Release|x86 {0C76D2FE-6767-44FE-B03D-21B2076BAA73}.Debug|Any CPU.ActiveCfg = Debug|x86 {0C76D2FE-6767-44FE-B03D-21B2076BAA73}.Debug|ARM.ActiveCfg = Debug|ARM {0C76D2FE-6767-44FE-B03D-21B2076BAA73}.Debug|ARM.Build.0 = Debug|ARM @@ -98,7 +97,7 @@ Global GlobalSection(NestedProjects) = preSolution {2EACF721-73B5-46AE-9775-4A8674D05A9C} = {51A8E803-C084-431F-9130-F277481C2BB2} {91C42D32-291D-4B72-90B4-551663D60B8B} = {39A2FFDA-C093-4FA6-8143-45B5019E7DAC} - {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD} = {DCF7899B-A487-49C0-BCDE-DC088B6750C2} + {D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6} = {1048DB7D-9B95-48CA-B43E-D9C35AB1DCD4} {4EDC82D9-A201-4831-8FE0-98F468F8E4AE} = {39A2FFDA-C093-4FA6-8143-45B5019E7DAC} {0C76D2FE-6767-44FE-B03D-21B2076BAA73} = {5289E508-8386-45A1-A12B-258A5899CD45} EndGlobalSection diff --git a/csharp/Yoga/Yoga.Universal.vcxproj b/csharp/Yoga/Yoga.Universal.vcxproj index 03ea80f7..00c8d388 100644 --- a/csharp/Yoga/Yoga.Universal.vcxproj +++ b/csharp/Yoga/Yoga.Universal.vcxproj @@ -159,7 +159,7 @@ Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions) + WINARMDLL;WIN32;_DEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions) true $(ProjectDir)..\..\;%(AdditionalIncludeDirectories) false @@ -210,7 +210,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions) + WINARMDLL;WIN32;NDEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions) true $(ProjectDir)..\..\;%(AdditionalIncludeDirectories) false diff --git a/yoga/YGMacros.h b/yoga/YGMacros.h index 10580db5..2d8f7286 100644 --- a/yoga/YGMacros.h +++ b/yoga/YGMacros.h @@ -23,6 +23,14 @@ #define WIN_EXPORT #endif +#ifdef WINARMDLL +#define WIN_STRUCT(type) type* +#define WIN_STRUCT_REF(value) &value +#else +#define WIN_STRUCT(type) type +#define WIN_STRUCT_REF(value) value +#endif + #ifndef FB_ASSERTIONS_ENABLED #define FB_ASSERTIONS_ENABLED 1 #endif diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 7338319e..6d7595b6 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -613,8 +613,8 @@ static inline const YGValue *YGNodeResolveFlexBasisPtr(const YGNodeRef node) { } \ } \ \ - type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \ - return node->style.instanceName[edge]; \ + WIN_STRUCT(type) YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \ + return WIN_STRUCT_REF(node->style.instanceName[edge]); \ } #define YG_NODE_STYLE_EDGE_PROPERTY_IMPL(type, name, paramName, instanceName) \ diff --git a/yoga/Yoga.h b/yoga/Yoga.h index 3b3b84a9..e7a71a97 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -141,7 +141,7 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, \ const YGEdge edge, \ const float paramName); \ - WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge); + WIN_EXPORT WIN_STRUCT(type) YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge); #define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_AUTO(type, name) \ WIN_EXPORT void YGNodeStyleSet##name##Auto(const YGNodeRef node, const YGEdge edge);