mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-24 02:07:11 +02:00
metal: Bump SharpMetal to preview 21
This commit is contained in:
parent
153d1ef06b
commit
664c63c6a8
5 changed files with 39 additions and 18 deletions
28
src/Ryujinx.Graphics.Metal.SharpMetalExtensions/NSHelper.cs
Normal file
28
src/Ryujinx.Graphics.Metal.SharpMetalExtensions/NSHelper.cs
Normal file
|
@ -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));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue