-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert our CryptoKit bindings to use Swift structs at the boundary (#…
…102583) * Try converting our CryptoKit bindings to use more Swift types. Also refactor our cryptokit bindings to reduce duplication. * Fix build on macos * Remove target-typed new and other style changes * Don't pass down null with UnsafeBufferPointer * Call copyBytes with a pointer because everything else seems to fail some assert for some reason I can't figure out. * Make copies and use copyBytes(to: buffer) again. * Fix generic value types condition * Put SwiftError parameter first to try working around Mono register allocation bug * Comma
- Loading branch information
1 parent
35aef5c
commit 43dbffa
Showing
8 changed files
with
300 additions
and
255 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/libraries/Common/src/Interop/OSX/Swift.Runtime/UnsafeBufferPointer.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,39 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Swift.Runtime | ||
{ | ||
// <summary> | ||
// Represents Swift UnsafeBufferPointer in C#. | ||
// </summary> | ||
internal readonly unsafe struct UnsafeBufferPointer<T> where T : unmanaged | ||
{ | ||
private readonly T* _baseAddress; | ||
private readonly nint _count; | ||
public UnsafeBufferPointer(T* baseAddress, nint count) | ||
{ | ||
_baseAddress = baseAddress; | ||
_count = count; | ||
} | ||
|
||
public T* BaseAddress => _baseAddress; | ||
public nint Count => _count; | ||
} | ||
|
||
// <summary> | ||
// Represents Swift UnsafeMutableBufferPointer in C#. | ||
// </summary> | ||
internal readonly unsafe struct UnsafeMutableBufferPointer<T> where T : unmanaged | ||
{ | ||
private readonly T* _baseAddress; | ||
private readonly nint _count; | ||
public UnsafeMutableBufferPointer(T* baseAddress, nint count) | ||
{ | ||
_baseAddress = baseAddress; | ||
_count = count; | ||
} | ||
|
||
public T* BaseAddress => _baseAddress; | ||
public nint Count => _count; | ||
} | ||
} |
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.