[CoreText] Make P/Invokes in CTRunDelegate have blittable signatures. (#20461)
Contributes towards #15684.
This commit is contained in:
Родитель
9643bd1c83
Коммит
595f1ecb7d
|
@ -59,10 +59,10 @@ namespace CoreText {
|
|||
[StructLayout (LayoutKind.Sequential)]
|
||||
struct CTRunDelegateCallbacks {
|
||||
public /* CFIndex */ nint version;
|
||||
public CTRunDelegateDeallocateCallback dealloc;
|
||||
public CTRunDelegateGetCallback getAscent;
|
||||
public CTRunDelegateGetCallback getDescent;
|
||||
public CTRunDelegateGetCallback getWidth;
|
||||
public IntPtr dealloc;
|
||||
public IntPtr getAscent;
|
||||
public IntPtr getDescent;
|
||||
public IntPtr getWidth;
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
|
@ -152,10 +152,10 @@ namespace CoreText {
|
|||
#else
|
||||
callbacks = new CTRunDelegateCallbacks () {
|
||||
version = 1, // kCTRunDelegateVersion1
|
||||
dealloc = Deallocate,
|
||||
getAscent = GetAscent,
|
||||
getDescent = GetDescent,
|
||||
getWidth = GetWidth,
|
||||
dealloc = Marshal.GetFunctionPointerForDelegate (DeallocateDelegate),
|
||||
getAscent = Marshal.GetFunctionPointerForDelegate (GetAscentDelegate),
|
||||
getDescent = Marshal.GetFunctionPointerForDelegate (GetDescentDelegate),
|
||||
getWidth = Marshal.GetFunctionPointerForDelegate (GetWidthDelegate),
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
@ -165,6 +165,7 @@ namespace CoreText {
|
|||
#if NET
|
||||
[UnmanagedCallersOnly]
|
||||
#else
|
||||
static CTRunDelegateDeallocateCallback DeallocateDelegate = Deallocate;
|
||||
[MonoPInvokeCallback (typeof (CTRunDelegateDeallocateCallback))]
|
||||
#endif
|
||||
static void Deallocate (IntPtr refCon)
|
||||
|
@ -190,6 +191,7 @@ namespace CoreText {
|
|||
#if NET
|
||||
[UnmanagedCallersOnly]
|
||||
#else
|
||||
static CTRunDelegateGetCallback GetAscentDelegate = GetAscent;
|
||||
[MonoPInvokeCallback (typeof (CTRunDelegateGetCallback))]
|
||||
#endif
|
||||
static nfloat GetAscent (IntPtr refCon)
|
||||
|
@ -203,6 +205,7 @@ namespace CoreText {
|
|||
#if NET
|
||||
[UnmanagedCallersOnly]
|
||||
#else
|
||||
static CTRunDelegateGetCallback GetDescentDelegate = GetDescent;
|
||||
[MonoPInvokeCallback (typeof (CTRunDelegateGetCallback))]
|
||||
#endif
|
||||
static nfloat GetDescent (IntPtr refCon)
|
||||
|
@ -216,6 +219,7 @@ namespace CoreText {
|
|||
#if NET
|
||||
[UnmanagedCallersOnly]
|
||||
#else
|
||||
static CTRunDelegateGetCallback GetWidthDelegate = GetWidth;
|
||||
[MonoPInvokeCallback (typeof (CTRunDelegateGetCallback))]
|
||||
#endif
|
||||
static nfloat GetWidth (IntPtr refCon)
|
||||
|
@ -242,7 +246,7 @@ namespace CoreText {
|
|||
|
||||
#region RunDelegate Creation
|
||||
[DllImport (Constants.CoreTextLibrary)]
|
||||
static extern IntPtr CTRunDelegateCreate (ref CTRunDelegateCallbacks callbacks, IntPtr refCon);
|
||||
unsafe static extern IntPtr CTRunDelegateCreate (CTRunDelegateCallbacks* callbacks, IntPtr refCon);
|
||||
|
||||
static IntPtr Create (CTRunDelegateOperations operations)
|
||||
{
|
||||
|
@ -250,7 +254,9 @@ namespace CoreText {
|
|||
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (operations));
|
||||
|
||||
CTRunDelegateCallbacks callbacks = operations.GetCallbacks ();
|
||||
return CTRunDelegateCreate (ref callbacks, operations.Handle);
|
||||
unsafe {
|
||||
return CTRunDelegateCreate (&callbacks, operations.Handle);
|
||||
}
|
||||
}
|
||||
|
||||
public CTRunDelegate (CTRunDelegateOperations operations)
|
||||
|
|
|
@ -268,7 +268,6 @@ namespace Cecil.Tests {
|
|||
"System.Int32 Security.SslContext::SSLCopyALPNProtocols(System.IntPtr,System.IntPtr&)",
|
||||
"System.Int32 Security.SslContext::SSLSetSessionTicketsEnabled(System.IntPtr,System.Boolean)",
|
||||
"System.IntPtr CoreText.CTFontManager::CTFontManagerCopyRegisteredFontDescriptors(CoreText.CTFontManagerScope,System.Boolean)",
|
||||
"System.IntPtr CoreText.CTRunDelegate::CTRunDelegateCreate(CoreText.CTRunDelegateCallbacks&,System.IntPtr)",
|
||||
"System.IntPtr CoreVideo.CVBuffer::CVBufferCopyAttachment(System.IntPtr,System.IntPtr,CoreVideo.CVAttachmentMode&)",
|
||||
"System.IntPtr CoreVideo.CVBuffer::CVBufferGetAttachment(System.IntPtr,System.IntPtr,CoreVideo.CVAttachmentMode&)",
|
||||
"System.IntPtr Foundation.NSSearchPath::NSSearchPathForDirectoriesInDomains(System.UIntPtr,System.UIntPtr,System.Boolean)",
|
||||
|
|
Загрузка…
Ссылка в новой задаче