blob: a7ab0249acbc4789dc47e1e737f34dea00b7a91e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Diagnostics;
using System.Runtime.ExceptionServices;
using System.Threading;
namespace System.Runtime.InteropServices.ObjectiveC
{
public static unsafe partial class ObjectiveCMarshal
{
private static readonly IntPtr[] s_ObjcMessageSendFunctions = new IntPtr[(int)MessageSendFunction.MsgSendSuperStret + 1];
[ThreadStatic]
private static Exception? t_pendingExceptionObject;
/// <summary>
/// Sets a pending exception to be thrown the next time the runtime is entered from an Objective-C msgSend P/Invoke.
/// </summary>
/// <param name="exception">The exception.</param>
/// <remarks>
/// If <c>null</c> is supplied any pending exception is discarded.
/// </remarks>
public static void SetMessageSendPendingException(Exception? exception)
{
t_pendingExceptionObject = exception;
}
private static bool TrySetGlobalMessageSendCallback(
MessageSendFunction msgSendFunction,
IntPtr func)
{
return Interlocked.CompareExchange(ref s_ObjcMessageSendFunctions[(int)msgSendFunction], func, IntPtr.Zero) == IntPtr.Zero;
}
internal static bool TryGetGlobalMessageSendCallback(int msgSendFunction, out IntPtr func)
{
func = s_ObjcMessageSendFunctions[msgSendFunction];
return func != IntPtr.Zero;
}
[StackTraceHidden]
internal static void ThrowPendingExceptionObject()
{
Exception? ex = t_pendingExceptionObject;
if (ex != null)
{
t_pendingExceptionObject = null;
ExceptionDispatchInfo.Throw(ex);
}
}
private static bool TryInitializeReferenceTracker(
delegate* unmanaged<void> beginEndCallback,
delegate* unmanaged<IntPtr, int> isReferencedCallback,
delegate* unmanaged<IntPtr, void> trackedObjectEnteredFinalization)
{
throw new NotImplementedException();
}
private static IntPtr CreateReferenceTrackingHandleInternal(
object obj,
out int memInSizeT,
out IntPtr mem)
{
throw new NotImplementedException();
}
}
}
|