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
23 lines
637 B
C#
23 lines
637 B
C#
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Facebook.CSSLayout
|
|
{
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public delegate CSSSize CSSMeasureFunc(
|
|
IntPtr context,
|
|
float width,
|
|
CSSMeasureMode widthMode,
|
|
float height,
|
|
CSSMeasureMode heightMode);
|
|
}
|