forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Low level API support for Objective-C interop. (dotnet#52146)
* Add Objective-C interop support. * Include handling of HNDTYPE_REFCOUNTED when FEATURE_OBJCMARSHAL is defined (dotnet#47534) * Allow overriding of Objective-C message send P/Invokes (dotnet#47721) * Add new flag to MethodTable for types with ObjectiveCTrackedTypeAttribute. Discover attribute during type load and set bit. Update EagerFinalizer callout to query bit. * Add testing for API * Bridge API for propagating managed exception to native. * Update GCEE interface to support GCServer scenario for Objective-C. The new callbacks now fire when before the GC scans handles and is non-concurrent. * Comment added for ExceptionTracker non-NULL condition. Co-authored-by: Jeremy Koritzinsky <[email protected]> Co-authored-by: Elinor Fung <[email protected]> Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
- Loading branch information
1 parent
d77854a
commit c1e7ca8
Showing
69 changed files
with
2,590 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...lr/System.Private.CoreLib/src/System/Runtime/InteropServices/ObjectiveCMarshal.CoreCLR.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Diagnostics; | ||
using System.Runtime.Versioning; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace System.Runtime.InteropServices.ObjectiveC | ||
{ | ||
public static partial class ObjectiveCMarshal | ||
{ | ||
/// <summary> | ||
/// Sets a pending exception to be thrown the next time the runtime is entered from an overridden 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) | ||
{ | ||
System.StubHelpers.StubHelpers.SetPendingExceptionObject(exception); | ||
} | ||
|
||
[DllImport(RuntimeHelpers.QCall)] | ||
private static extern bool TrySetGlobalMessageSendCallback( | ||
MessageSendFunction msgSendFunction, | ||
IntPtr func); | ||
|
||
[DllImport(RuntimeHelpers.QCall)] | ||
private static unsafe extern bool TryInitializeReferenceTracker( | ||
delegate* unmanaged<void> beginEndCallback, | ||
delegate* unmanaged<IntPtr, int> isReferencedCallback, | ||
delegate* unmanaged<IntPtr, void> trackedObjectEnteredFinalization); | ||
|
||
[DllImport(RuntimeHelpers.QCall)] | ||
private static extern IntPtr CreateReferenceTrackingHandleInternal( | ||
ObjectHandleOnStack obj, | ||
out int memInSizeT, | ||
out IntPtr mem); | ||
|
||
internal static bool AvailableUnhandledExceptionPropagation() | ||
{ | ||
return s_unhandledExceptionPropagationHandler != null; | ||
} | ||
|
||
internal static unsafe void* InvokeUnhandledExceptionPropagation( | ||
Exception exception, | ||
object methodInfoStub, | ||
out IntPtr context) | ||
{ | ||
context = IntPtr.Zero; | ||
if (s_unhandledExceptionPropagationHandler == null) | ||
return null; | ||
|
||
Debug.Assert(methodInfoStub is RuntimeMethodInfoStub); | ||
var runtimeHandle = new RuntimeMethodHandle((RuntimeMethodInfoStub)methodInfoStub); | ||
var callback = s_unhandledExceptionPropagationHandler(exception, runtimeHandle, out context); | ||
if (callback != null) | ||
return callback; | ||
|
||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.