Fix C# delegate calling conventions
Summary: When using CSS-Layout in a C# UWP project in x86, by default the MSVC compiler defaults the delegate calling convention to cdecl, while .NET assumes that all delegates are declared using stdcall. This causes a problem when invoking such as this error: ``` Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention. ``` This PR changes the calling convention in the C# code to reflect cdecl by using the `UnmanagedFunctionPointer` attribute and setting the calling convention to `CallingConvention.Cdecl`. ```csharp [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate CSSSize CSSMeasureFunc( IntPtr context, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode); ``` I have updated all calls as well to other functions. I Closes https://github.com/facebook/css-layout/pull/231 Reviewed By: emilsjolander Differential Revision: D4063437 Pulled By: splhack fbshipit-source-id: b1069a1b9f675d2623a64a1c5f3189292a18a646
This commit is contained in:
committed by
Facebook Github Bot
parent
7673de823f
commit
1488f822c3
@@ -8,11 +8,13 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
internal static class CSSAssert
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void FailFunc(string message);
|
||||
|
||||
private static bool _assertInitialized;
|
||||
|
Reference in New Issue
Block a user