-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metal: Bump SharpMetal to preview 21
- Loading branch information
Showing
5 changed files
with
39 additions
and
18 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
28 changes: 28 additions & 0 deletions
28
src/Ryujinx.Graphics.Metal.SharpMetalExtensions/NSHelper.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,28 @@ | ||
using SharpMetal.Foundation; | ||
using SharpMetal.ObjectiveCCore; | ||
using System.Runtime.Versioning; | ||
|
||
namespace Ryujinx.Graphics.Metal.SharpMetalExtensions | ||
{ | ||
[SupportedOSPlatform("macOS")] | ||
public static class NSHelper | ||
{ | ||
public static unsafe string ToDotNetString(this NSString source) | ||
{ | ||
char[] sourceBuffer = new char[source.Length]; | ||
fixed (char* pSourceBuffer = sourceBuffer) | ||
{ | ||
ObjectiveC.bool_objc_msgSend(source, | ||
"getCString:maxLength:encoding:", | ||
pSourceBuffer, | ||
source.MaximumLengthOfBytes(NSStringEncoding.UTF16) + 1, | ||
(ulong)NSStringEncoding.UTF16); | ||
} | ||
|
||
return new string(sourceBuffer); | ||
} | ||
|
||
public static NSString ToNSString(this string source) | ||
=> new(ObjectiveC.IntPtr_objc_msgSend(new ObjectiveCClass("NSString"), "stringWithUTF8String:", source)); | ||
} | ||
} |
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