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.
Introduce CallConvSwift and special register types to represent the S…
…wift ABI calling convention (dotnet#95065) * Add CallConvSwift attribute and introduce types to represent each of the special registers --------- Co-authored-by: Aaron Robinson <arobins@microsoft.com>
- Loading branch information
1 parent
03f0331
commit adfae48
Showing
4 changed files
with
102 additions
and
0 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
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
71 changes: 71 additions & 0 deletions
71
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Swift/SwiftTypes.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,71 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace System.Runtime.InteropServices.Swift | ||
{ | ||
/// <summary> | ||
/// Represents the Swift 'self' context, indicating that the argument is the self context. | ||
/// </summary> | ||
/// <remarks> | ||
/// <para> | ||
/// This struct is used to pass the 'self' context to Swift functions in the context of interop with .NET. | ||
/// </para> | ||
/// <para> | ||
/// Here's an example of how a SwiftSelf context can be declared: | ||
/// <code lang="csharp"> | ||
/// [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvSwift) })] | ||
/// [DllImport("SwiftLibrary", EntryPoint = "export")] | ||
/// public static extern void swiftFunction(SwiftSelf self); | ||
/// </code> | ||
/// </para> | ||
/// </remarks> | ||
[CLSCompliantAttribute(false)] | ||
public readonly unsafe struct SwiftSelf | ||
{ | ||
/// <summary> | ||
/// Creates a new instance of the SwiftSelf struct with the specified pointer value. | ||
/// </summary> | ||
/// <param name="value">The pointer value representing the self context.</param> | ||
public SwiftSelf(void* value) | ||
{ | ||
Value = value; | ||
} | ||
/// <summary> | ||
/// Gets the pointer of the self context. | ||
/// </summary> | ||
public void* Value { get; } | ||
} | ||
|
||
/// <summary> | ||
/// Represents the Swift error context, indicating that the argument is the error context. | ||
/// </summary> | ||
/// <remarks> | ||
/// <para> | ||
/// This struct is used to retrieve the 'error' context from Swift functions in the context of interop with .NET. | ||
/// </para> | ||
/// <para> | ||
/// Here's an example of how a SwiftError can be declared: | ||
/// <code lang="csharp"> | ||
/// [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvSwift) })] | ||
/// [DllImport("SwiftLibrary", EntryPoint = "export")] | ||
/// public static extern void swiftFunction(SwiftError* error); | ||
/// </code> | ||
/// </para> | ||
/// </remarks> | ||
[CLSCompliantAttribute(false)] | ||
public readonly unsafe struct SwiftError | ||
{ | ||
/// <summary> | ||
/// Creates a new instance of the SwiftError struct with the specified pointer value. | ||
/// </summary> | ||
/// <param name="value">The pointer value representing the error context.</param> | ||
public SwiftError(void* value) | ||
{ | ||
Value = value; | ||
} | ||
/// <summary> | ||
/// Gets the pointer of the error context. | ||
/// </summary> | ||
public void* Value { get; } | ||
} | ||
} |
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