mirror of
https://git.ryujinx.app/kenji-nx/ryujinx.git
synced 2025-12-18 01:37:04 +00:00
Android changes
This commit is contained in:
parent
df21f6019e
commit
e8e4c5aa61
464 changed files with 23351 additions and 1429 deletions
46
src/LibKenjinx/Android/Jni/Values/JValue.cs
Normal file
46
src/LibKenjinx/Android/Jni/Values/JValue.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using LibKenjinx.Jni.References;
|
||||
|
||||
using Rxmxnx.PInvoke;
|
||||
|
||||
namespace LibKenjinx.Jni.Values;
|
||||
|
||||
internal readonly struct JValue
|
||||
{
|
||||
private delegate Boolean IsDefaultDelegate(in JValue value);
|
||||
|
||||
private static readonly Int32 size = NativeUtilities.SizeOf<JValue>();
|
||||
|
||||
private static readonly IsDefaultDelegate isDefault = JValue.GetIsDefault();
|
||||
|
||||
#pragma warning disable 0649
|
||||
#pragma warning disable 0169
|
||||
private readonly Byte _value1;
|
||||
private readonly Byte _value2;
|
||||
private readonly Int16 _value3;
|
||||
private readonly Int32 _value4;
|
||||
#pragma warning restore 0169
|
||||
#pragma warning restore 0649
|
||||
|
||||
public Boolean IsDefault => JValue.isDefault(this);
|
||||
|
||||
public static JValue Create(in ReadOnlySpan<Byte> source)
|
||||
{
|
||||
Byte[] result = new Byte[JValue.size];
|
||||
for (Int32 i = 0; i < source.Length; i++)
|
||||
result[i] = source[i];
|
||||
return result.ToValue<JValue>();
|
||||
}
|
||||
|
||||
private static IsDefaultDelegate GetIsDefault() => Environment.Is64BitProcess ? JValue.DefaultLong : JValue.Default;
|
||||
|
||||
private static Boolean Default(in JValue jValue)
|
||||
=> jValue._value1 + jValue._value2 + jValue._value3 == default && jValue._value4 == default;
|
||||
|
||||
private static Boolean DefaultLong(in JValue jValue)
|
||||
=> Unsafe.AsRef(in jValue).Transform<JValue, Int64>() == default;
|
||||
|
||||
public static explicit operator JValue(JObjectLocalRef a) => JValue.Create(NativeUtilities.AsBytes(in a));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue