-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into prefer_collection_expression_implicit_obje…
…ct_creation
- Loading branch information
Showing
15 changed files
with
1,318 additions
and
354 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
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
32 changes: 32 additions & 0 deletions
32
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,32 @@ | ||
using SharpMetal.Foundation; | ||
using SharpMetal.ObjectiveCCore; | ||
using System.Runtime.Versioning; | ||
// ReSharper disable InconsistentNaming | ||
|
||
namespace Ryujinx.Graphics.Metal.SharpMetalExtensions | ||
{ | ||
[SupportedOSPlatform("macOS")] | ||
public static class NSHelper | ||
{ | ||
private static readonly Selector sel_getCStringMaxLengthEncoding = "getCString:maxLength:encoding:"; | ||
private static readonly Selector sel_stringWithUTF8String = "stringWithUTF8String:"; | ||
|
||
public static unsafe string ToDotNetString(this NSString source) | ||
{ | ||
char[] sourceBuffer = new char[source.Length]; | ||
fixed (char* pSourceBuffer = sourceBuffer) | ||
{ | ||
ObjectiveC.bool_objc_msgSend(source, | ||
sel_getCStringMaxLengthEncoding, | ||
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(nameof(NSString)), sel_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
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.