mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-25 06:17:10 +02:00

* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Silence dotnet format IDE0060 warnings * Address dotnet format CA1401 warnings * dotnet-format fixes after rebase * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Another rebase, another dotnet format run * Run dotnet format style after rebase * Add comments to disabled warnings * Remove a few unused parameters * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Address IDE0251 warnings * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * Small optimizations * Remove alignment * Apply formatting * Fix build issues * Final pass for dotnet format * Add trailing commas Co-authored-by: Ac_K <Acoustik666@gmail.com> * Add trailing commas --------- Co-authored-by: Ac_K <Acoustik666@gmail.com>
160 lines
5.2 KiB
C#
160 lines
5.2 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Runtime.Versioning;
|
|
|
|
namespace Ryujinx.Ui.Common.Helper
|
|
{
|
|
[SupportedOSPlatform("macos")]
|
|
public static partial class ObjectiveC
|
|
{
|
|
private const string ObjCRuntime = "/usr/lib/libobjc.A.dylib";
|
|
|
|
[LibraryImport(ObjCRuntime, StringMarshalling = StringMarshalling.Utf8)]
|
|
private static partial IntPtr sel_getUid(string name);
|
|
|
|
[LibraryImport(ObjCRuntime, StringMarshalling = StringMarshalling.Utf8)]
|
|
private static partial IntPtr objc_getClass(string name);
|
|
|
|
[LibraryImport(ObjCRuntime)]
|
|
private static partial void objc_msgSend(IntPtr receiver, Selector selector);
|
|
|
|
[LibraryImport(ObjCRuntime)]
|
|
private static partial void objc_msgSend(IntPtr receiver, Selector selector, byte value);
|
|
|
|
[LibraryImport(ObjCRuntime)]
|
|
private static partial void objc_msgSend(IntPtr receiver, Selector selector, IntPtr value);
|
|
|
|
[LibraryImport(ObjCRuntime)]
|
|
private static partial void objc_msgSend(IntPtr receiver, Selector selector, NSRect point);
|
|
|
|
[LibraryImport(ObjCRuntime)]
|
|
private static partial void objc_msgSend(IntPtr receiver, Selector selector, double value);
|
|
|
|
[LibraryImport(ObjCRuntime, EntryPoint = "objc_msgSend")]
|
|
private static partial IntPtr IntPtr_objc_msgSend(IntPtr receiver, Selector selector);
|
|
|
|
[LibraryImport(ObjCRuntime, EntryPoint = "objc_msgSend")]
|
|
private static partial IntPtr IntPtr_objc_msgSend(IntPtr receiver, Selector selector, IntPtr param);
|
|
|
|
[LibraryImport(ObjCRuntime, EntryPoint = "objc_msgSend", StringMarshalling = StringMarshalling.Utf8)]
|
|
private static partial IntPtr IntPtr_objc_msgSend(IntPtr receiver, Selector selector, string param);
|
|
|
|
[LibraryImport(ObjCRuntime, EntryPoint = "objc_msgSend")]
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
private static partial bool bool_objc_msgSend(IntPtr receiver, Selector selector, IntPtr param);
|
|
|
|
public readonly struct Object
|
|
{
|
|
public readonly IntPtr ObjPtr;
|
|
|
|
private Object(IntPtr pointer)
|
|
{
|
|
ObjPtr = pointer;
|
|
}
|
|
|
|
public Object(string name)
|
|
{
|
|
ObjPtr = objc_getClass(name);
|
|
}
|
|
|
|
public void SendMessage(Selector selector)
|
|
{
|
|
objc_msgSend(ObjPtr, selector);
|
|
}
|
|
|
|
public void SendMessage(Selector selector, byte value)
|
|
{
|
|
objc_msgSend(ObjPtr, selector, value);
|
|
}
|
|
|
|
public void SendMessage(Selector selector, Object obj)
|
|
{
|
|
objc_msgSend(ObjPtr, selector, obj.ObjPtr);
|
|
}
|
|
|
|
public void SendMessage(Selector selector, NSRect point)
|
|
{
|
|
objc_msgSend(ObjPtr, selector, point);
|
|
}
|
|
|
|
public void SendMessage(Selector selector, double value)
|
|
{
|
|
objc_msgSend(ObjPtr, selector, value);
|
|
}
|
|
|
|
public Object GetFromMessage(Selector selector)
|
|
{
|
|
return new Object(IntPtr_objc_msgSend(ObjPtr, selector));
|
|
}
|
|
|
|
public Object GetFromMessage(Selector selector, Object obj)
|
|
{
|
|
return new Object(IntPtr_objc_msgSend(ObjPtr, selector, obj.ObjPtr));
|
|
}
|
|
|
|
public Object GetFromMessage(Selector selector, NSString nsString)
|
|
{
|
|
return new Object(IntPtr_objc_msgSend(ObjPtr, selector, nsString.StrPtr));
|
|
}
|
|
|
|
public Object GetFromMessage(Selector selector, string param)
|
|
{
|
|
return new Object(IntPtr_objc_msgSend(ObjPtr, selector, param));
|
|
}
|
|
|
|
public bool GetBoolFromMessage(Selector selector, Object obj)
|
|
{
|
|
return bool_objc_msgSend(ObjPtr, selector, obj.ObjPtr);
|
|
}
|
|
}
|
|
|
|
public readonly struct Selector
|
|
{
|
|
public readonly IntPtr SelPtr;
|
|
|
|
private Selector(string name)
|
|
{
|
|
SelPtr = sel_getUid(name);
|
|
}
|
|
|
|
public static implicit operator Selector(string value) => new(value);
|
|
}
|
|
|
|
public readonly struct NSString
|
|
{
|
|
public readonly IntPtr StrPtr;
|
|
|
|
public NSString(string aString)
|
|
{
|
|
IntPtr nsString = objc_getClass("NSString");
|
|
StrPtr = IntPtr_objc_msgSend(nsString, "stringWithUTF8String:", aString);
|
|
}
|
|
|
|
public static implicit operator IntPtr(NSString nsString) => nsString.StrPtr;
|
|
}
|
|
|
|
public readonly struct NSPoint
|
|
{
|
|
public readonly double X;
|
|
public readonly double Y;
|
|
|
|
public NSPoint(double x, double y)
|
|
{
|
|
X = x;
|
|
Y = y;
|
|
}
|
|
}
|
|
|
|
public readonly struct NSRect
|
|
{
|
|
public readonly NSPoint Pos;
|
|
public readonly NSPoint Size;
|
|
|
|
public NSRect(double x, double y, double width, double height)
|
|
{
|
|
Pos = new NSPoint(x, y);
|
|
Size = new NSPoint(width, height);
|
|
}
|
|
}
|
|
}
|
|
}
|