diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2018-12-04 22:52:39 -0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-04 22:52:39 -0200 |
| commit | 3615a70cae3f89197fe185dfc5d0a47fa42151d9 (patch) | |
| tree | 8e4737422fba15199c1a6ce7c6345996c0e907b5 /Ryujinx.HLE/Utilities | |
| parent | 85dbb9559ad317a657dafd24da27fec4b3f5250f (diff) | |
Revert "Adjust naming conventions and general refactoring in HLE Project (#490)" (#526)
This reverts commit 85dbb9559ad317a657dafd24da27fec4b3f5250f.
Diffstat (limited to 'Ryujinx.HLE/Utilities')
| -rw-r--r-- | Ryujinx.HLE/Utilities/EndianSwap.cs | 14 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/FontUtils.cs | 18 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/IntUtils.cs | 16 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/LinuxError.cs | 5 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/StringUtils.cs | 52 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/StructReader.cs | 28 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/StructWriter.cs | 12 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/UInt128.cs | 26 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/WSAError.cs | 83 |
9 files changed, 124 insertions, 130 deletions
diff --git a/Ryujinx.HLE/Utilities/EndianSwap.cs b/Ryujinx.HLE/Utilities/EndianSwap.cs index df08191a..5d0c8a84 100644 --- a/Ryujinx.HLE/Utilities/EndianSwap.cs +++ b/Ryujinx.HLE/Utilities/EndianSwap.cs @@ -2,16 +2,16 @@ { static class EndianSwap { - public static ushort Swap16(ushort value) => (ushort)(((value >> 8) & 0xff) | (value << 8)); + public static ushort Swap16(ushort Value) => (ushort)(((Value >> 8) & 0xff) | (Value << 8)); - public static int Swap32(int value) + public static int Swap32(int Value) { - uint uintVal = (uint)value; + uint UintVal = (uint)Value; - return (int)(((uintVal >> 24) & 0x000000ff) | - ((uintVal >> 8) & 0x0000ff00) | - ((uintVal << 8) & 0x00ff0000) | - ((uintVal << 24) & 0xff000000)); + return (int)(((UintVal >> 24) & 0x000000ff) | + ((UintVal >> 8) & 0x0000ff00) | + ((UintVal << 8) & 0x00ff0000) | + ((UintVal << 24) & 0xff000000)); } } } diff --git a/Ryujinx.HLE/Utilities/FontUtils.cs b/Ryujinx.HLE/Utilities/FontUtils.cs index 3da0ef68..efe7560c 100644 --- a/Ryujinx.HLE/Utilities/FontUtils.cs +++ b/Ryujinx.HLE/Utilities/FontUtils.cs @@ -6,29 +6,29 @@ namespace Ryujinx.HLE.Utilities { private static readonly uint FontKey = 0x06186249; - public static byte[] DecryptFont(Stream bfttfStream) + public static byte[] DecryptFont(Stream BFTTFStream) { uint KXor(uint In) => In ^ 0x06186249; - using (BinaryReader reader = new BinaryReader(bfttfStream)) + using (BinaryReader Reader = new BinaryReader(BFTTFStream)) { - using (MemoryStream ttfStream = new MemoryStream()) + using (MemoryStream TTFStream = new MemoryStream()) { - using (BinaryWriter output = new BinaryWriter(ttfStream)) + using (BinaryWriter Output = new BinaryWriter(TTFStream)) { - if (KXor(reader.ReadUInt32()) != 0x18029a7f) + if (KXor(Reader.ReadUInt32()) != 0x18029a7f) { throw new InvalidDataException("Error: Input file is not in BFTTF format!"); } - bfttfStream.Position += 4; + BFTTFStream.Position += 4; - for (int i = 0; i < (bfttfStream.Length - 8) / 4; i++) + for (int i = 0; i < (BFTTFStream.Length - 8) / 4; i++) { - output.Write(KXor(reader.ReadUInt32())); + Output.Write(KXor(Reader.ReadUInt32())); } - return ttfStream.ToArray(); + return TTFStream.ToArray(); } } } diff --git a/Ryujinx.HLE/Utilities/IntUtils.cs b/Ryujinx.HLE/Utilities/IntUtils.cs index a7178d80..57e9d396 100644 --- a/Ryujinx.HLE/Utilities/IntUtils.cs +++ b/Ryujinx.HLE/Utilities/IntUtils.cs @@ -2,24 +2,24 @@ namespace Ryujinx.HLE.Utilities { static class IntUtils { - public static int AlignUp(int value, int size) + public static int AlignUp(int Value, int Size) { - return (value + (size - 1)) & ~(size - 1); + return (Value + (Size - 1)) & ~(Size - 1); } - public static long AlignUp(long value, int size) + public static long AlignUp(long Value, int Size) { - return (value + (size - 1)) & ~((long)size - 1); + return (Value + (Size - 1)) & ~((long)Size - 1); } - public static int AlignDown(int value, int size) + public static int AlignDown(int Value, int Size) { - return value & ~(size - 1); + return Value & ~(Size - 1); } - public static long AlignDown(long value, int size) + public static long AlignDown(long Value, int Size) { - return value & ~((long)size - 1); + return Value & ~((long)Size - 1); } } } diff --git a/Ryujinx.HLE/Utilities/LinuxError.cs b/Ryujinx.HLE/Utilities/LinuxError.cs index 81a9d7be..5c322f83 100644 --- a/Ryujinx.HLE/Utilities/LinuxError.cs +++ b/Ryujinx.HLE/Utilities/LinuxError.cs @@ -1,8 +1,5 @@ -using System.Diagnostics.CodeAnalysis; - namespace Ryujinx.HLE.Utilities { - [SuppressMessage("ReSharper", "InconsistentNaming")] enum LinuxError { SUCCESS = 0, @@ -150,6 +147,6 @@ namespace Ryujinx.HLE.Utilities ERFKILL = 132 /* Operation not possible due to RF-kill */, - EHWPOISON = 133 /* Memory page has hardware error */ + EHWPOISON = 133 /* Memory page has hardware error */, } }
\ No newline at end of file diff --git a/Ryujinx.HLE/Utilities/StringUtils.cs b/Ryujinx.HLE/Utilities/StringUtils.cs index e6602f48..a10273ee 100644 --- a/Ryujinx.HLE/Utilities/StringUtils.cs +++ b/Ryujinx.HLE/Utilities/StringUtils.cs @@ -9,67 +9,67 @@ namespace Ryujinx.HLE.Utilities { static class StringUtils { - public static byte[] GetFixedLengthBytes(string inputString, int size, Encoding encoding) + public static byte[] GetFixedLengthBytes(string InputString, int Size, Encoding Encoding) { - inputString = inputString + "\0"; + InputString = InputString + "\0"; - int bytesCount = encoding.GetByteCount(inputString); + int BytesCount = Encoding.GetByteCount(InputString); - byte[] output = new byte[size]; + byte[] Output = new byte[Size]; - if (bytesCount < size) + if (BytesCount < Size) { - encoding.GetBytes(inputString, 0, inputString.Length, output, 0); + Encoding.GetBytes(InputString, 0, InputString.Length, Output, 0); } else { - int nullSize = encoding.GetByteCount("\0"); + int NullSize = Encoding.GetByteCount("\0"); - output = encoding.GetBytes(inputString); + Output = Encoding.GetBytes(InputString); - Array.Resize(ref output, size - nullSize); + Array.Resize(ref Output, Size - NullSize); - output = output.Concat(encoding.GetBytes("\0")).ToArray(); + Output = Output.Concat(Encoding.GetBytes("\0")).ToArray(); } - return output; + return Output; } - public static byte[] HexToBytes(string hexString) + public static byte[] HexToBytes(string HexString) { //Ignore last charactor if HexLength % 2 != 0. - int bytesInHex = hexString.Length / 2; + int BytesInHex = HexString.Length / 2; - byte[] output = new byte[bytesInHex]; + byte[] Output = new byte[BytesInHex]; - for (int index = 0; index < bytesInHex; index++) + for (int Index = 0; Index < BytesInHex; Index++) { - output[index] = byte.Parse(hexString.Substring(index * 2, 2), NumberStyles.HexNumber); + Output[Index] = byte.Parse(HexString.Substring(Index * 2, 2), NumberStyles.HexNumber); } - return output; + return Output; } - public static string ReadUtf8String(ServiceCtx context, int index = 0) + public static string ReadUtf8String(ServiceCtx Context, int Index = 0) { - long position = context.Request.PtrBuff[index].Position; - long size = context.Request.PtrBuff[index].Size; + long Position = Context.Request.PtrBuff[Index].Position; + long Size = Context.Request.PtrBuff[Index].Size; - using (MemoryStream ms = new MemoryStream()) + using (MemoryStream MS = new MemoryStream()) { - while (size-- > 0) + while (Size-- > 0) { - byte value = context.Memory.ReadByte(position++); + byte Value = Context.Memory.ReadByte(Position++); - if (value == 0) + if (Value == 0) { break; } - ms.WriteByte(value); + MS.WriteByte(Value); } - return Encoding.UTF8.GetString(ms.ToArray()); + return Encoding.UTF8.GetString(MS.ToArray()); } } } diff --git a/Ryujinx.HLE/Utilities/StructReader.cs b/Ryujinx.HLE/Utilities/StructReader.cs index 441dfd19..19fd2674 100644 --- a/Ryujinx.HLE/Utilities/StructReader.cs +++ b/Ryujinx.HLE/Utilities/StructReader.cs @@ -5,41 +5,41 @@ namespace Ryujinx.HLE.Utilities { class StructReader { - private MemoryManager _memory; + private MemoryManager Memory; public long Position { get; private set; } - public StructReader(MemoryManager memory, long position) + public StructReader(MemoryManager Memory, long Position) { - _memory = memory; - Position = position; + this.Memory = Memory; + this.Position = Position; } public T Read<T>() where T : struct { - T value = MemoryHelper.Read<T>(_memory, Position); + T Value = MemoryHelper.Read<T>(Memory, Position); Position += Marshal.SizeOf<T>(); - return value; + return Value; } - public T[] Read<T>(int size) where T : struct + public T[] Read<T>(int Size) where T : struct { - int structSize = Marshal.SizeOf<T>(); + int StructSize = Marshal.SizeOf<T>(); - int count = size / structSize; + int Count = Size / StructSize; - T[] output = new T[count]; + T[] Output = new T[Count]; - for (int index = 0; index < count; index++) + for (int Index = 0; Index < Count; Index++) { - output[index] = MemoryHelper.Read<T>(_memory, Position); + Output[Index] = MemoryHelper.Read<T>(Memory, Position); - Position += structSize; + Position += StructSize; } - return output; + return Output; } } } diff --git a/Ryujinx.HLE/Utilities/StructWriter.cs b/Ryujinx.HLE/Utilities/StructWriter.cs index 86cfeedd..a537e7a4 100644 --- a/Ryujinx.HLE/Utilities/StructWriter.cs +++ b/Ryujinx.HLE/Utilities/StructWriter.cs @@ -5,19 +5,19 @@ namespace Ryujinx.HLE.Utilities { class StructWriter { - private MemoryManager _memory; + private MemoryManager Memory; public long Position { get; private set; } - public StructWriter(MemoryManager memory, long position) + public StructWriter(MemoryManager Memory, long Position) { - _memory = memory; - Position = position; + this.Memory = Memory; + this.Position = Position; } - public void Write<T>(T value) where T : struct + public void Write<T>(T Value) where T : struct { - MemoryHelper.Write(_memory, Position, value); + MemoryHelper.Write(Memory, Position, Value); Position += Marshal.SizeOf<T>(); } diff --git a/Ryujinx.HLE/Utilities/UInt128.cs b/Ryujinx.HLE/Utilities/UInt128.cs index 9e685c18..14e04e4a 100644 --- a/Ryujinx.HLE/Utilities/UInt128.cs +++ b/Ryujinx.HLE/Utilities/UInt128.cs @@ -6,30 +6,30 @@ namespace Ryujinx.HLE.Utilities { public struct UInt128 { - public long High { get; } - public long Low { get; } + public long High { get; private set; } + public long Low { get; private set; } - public UInt128(long low, long high) + public UInt128(long Low, long High) { - Low = low; - High = high; + this.Low = Low; + this.High = High; } - public UInt128(string hex) + public UInt128(string UInt128Hex) { - if (hex == null || hex.Length != 32 || !hex.All("0123456789abcdefABCDEF".Contains)) + if (UInt128Hex == null || UInt128Hex.Length != 32 || !UInt128Hex.All("0123456789abcdefABCDEF".Contains)) { - throw new ArgumentException("Invalid Hex value!", nameof(hex)); + throw new ArgumentException("Invalid Hex value!", nameof(UInt128Hex)); } - Low = Convert.ToInt64(hex.Substring(16), 16); - High = Convert.ToInt64(hex.Substring(0, 16), 16); + Low = Convert.ToInt64(UInt128Hex.Substring(16), 16); + High = Convert.ToInt64(UInt128Hex.Substring(0, 16), 16); } - public void Write(BinaryWriter binaryWriter) + public void Write(BinaryWriter BinaryWriter) { - binaryWriter.Write(Low); - binaryWriter.Write(High); + BinaryWriter.Write(Low); + BinaryWriter.Write(High); } public override string ToString() diff --git a/Ryujinx.HLE/Utilities/WSAError.cs b/Ryujinx.HLE/Utilities/WSAError.cs index 81294b8b..ff0896d4 100644 --- a/Ryujinx.HLE/Utilities/WSAError.cs +++ b/Ryujinx.HLE/Utilities/WSAError.cs @@ -1,9 +1,6 @@ -using System.Diagnostics.CodeAnalysis; - -namespace Ryujinx.HLE.Utilities +namespace Ryujinx.HLE.Utilities { - [SuppressMessage("ReSharper", "InconsistentNaming")] - enum WsaError + enum WSAError { /* * All Windows Sockets error constants are biased by WSABASEERR from @@ -24,43 +21,43 @@ namespace Ryujinx.HLE.Utilities /* * Windows Sockets definitions of regular Berkeley error constants */ - WSAEWOULDBLOCK = (WSABASEERR + 35), - WSAEINPROGRESS = (WSABASEERR + 36), - WSAEALREADY = (WSABASEERR + 37), - WSAENOTSOCK = (WSABASEERR + 38), - WSAEDESTADDRREQ = (WSABASEERR + 39), - WSAEMSGSIZE = (WSABASEERR + 40), - WSAEPROTOTYPE = (WSABASEERR + 41), - WSAENOPROTOOPT = (WSABASEERR + 42), - WSAEPROTONOSUPPORT = (WSABASEERR + 43), - WSAESOCKTNOSUPPORT = (WSABASEERR + 44), - WSAEOPNOTSUPP = (WSABASEERR + 45), - WSAEPFNOSUPPORT = (WSABASEERR + 46), - WSAEAFNOSUPPORT = (WSABASEERR + 47), - WSAEADDRINUSE = (WSABASEERR + 48), - WSAEADDRNOTAVAIL = (WSABASEERR + 49), - WSAENETDOWN = (WSABASEERR + 50), - WSAENETUNREACH = (WSABASEERR + 51), - WSAENETRESET = (WSABASEERR + 52), - WSAECONNABORTED = (WSABASEERR + 53), - WSAECONNRESET = (WSABASEERR + 54), - WSAENOBUFS = (WSABASEERR + 55), - WSAEISCONN = (WSABASEERR + 56), - WSAENOTCONN = (WSABASEERR + 57), - WSAESHUTDOWN = (WSABASEERR + 58), - WSAETOOMANYREFS = (WSABASEERR + 59), - WSAETIMEDOUT = (WSABASEERR + 60), - WSAECONNREFUSED = (WSABASEERR + 61), - WSAELOOP = (WSABASEERR + 62), - WSAENAMETOOLONG = (WSABASEERR + 63), - WSAEHOSTDOWN = (WSABASEERR + 64), - WSAEHOSTUNREACH = (WSABASEERR + 65), - WSAENOTEMPTY = (WSABASEERR + 66), - WSAEPROCLIM = (WSABASEERR + 67), - WSAEUSERS = (WSABASEERR + 68), - WSAEDQUOT = (WSABASEERR + 69), - WSAESTALE = (WSABASEERR + 70), - WSAEREMOTE = (WSABASEERR + 71), + WSAEWOULDBLOCK = (WSABASEERR + 35), + WSAEINPROGRESS = (WSABASEERR + 36), + WSAEALREADY = (WSABASEERR + 37), + WSAENOTSOCK = (WSABASEERR + 38), + WSAEDESTADDRREQ = (WSABASEERR + 39), + WSAEMSGSIZE = (WSABASEERR + 40), + WSAEPROTOTYPE = (WSABASEERR + 41), + WSAENOPROTOOPT = (WSABASEERR + 42), + WSAEPROTONOSUPPORT = (WSABASEERR + 43), + WSAESOCKTNOSUPPORT = (WSABASEERR + 44), + WSAEOPNOTSUPP = (WSABASEERR + 45), + WSAEPFNOSUPPORT = (WSABASEERR + 46), + WSAEAFNOSUPPORT = (WSABASEERR + 47), + WSAEADDRINUSE = (WSABASEERR + 48), + WSAEADDRNOTAVAIL = (WSABASEERR + 49), + WSAENETDOWN = (WSABASEERR + 50), + WSAENETUNREACH = (WSABASEERR + 51), + WSAENETRESET = (WSABASEERR + 52), + WSAECONNABORTED = (WSABASEERR + 53), + WSAECONNRESET = (WSABASEERR + 54), + WSAENOBUFS = (WSABASEERR + 55), + WSAEISCONN = (WSABASEERR + 56), + WSAENOTCONN = (WSABASEERR + 57), + WSAESHUTDOWN = (WSABASEERR + 58), + WSAETOOMANYREFS = (WSABASEERR + 59), + WSAETIMEDOUT = (WSABASEERR + 60), + WSAECONNREFUSED = (WSABASEERR + 61), + WSAELOOP = (WSABASEERR + 62), + WSAENAMETOOLONG = (WSABASEERR + 63), + WSAEHOSTDOWN = (WSABASEERR + 64), + WSAEHOSTUNREACH = (WSABASEERR + 65), + WSAENOTEMPTY = (WSABASEERR + 66), + WSAEPROCLIM = (WSABASEERR + 67), + WSAEUSERS = (WSABASEERR + 68), + WSAEDQUOT = (WSABASEERR + 69), + WSAESTALE = (WSABASEERR + 70), + WSAEREMOTE = (WSABASEERR + 71), /* * Extended Windows Sockets error constant definitions @@ -129,6 +126,6 @@ namespace Ryujinx.HLE.Utilities * buffer in general */ WSA_QOS_TRAFFIC_CTRL_ERROR = (WSABASEERR + 1014), /* problem with some part of the flowspec */ - WSA_QOS_GENERIC_ERROR = (WSABASEERR + 1015) + WSA_QOS_GENERIC_ERROR = (WSABASEERR + 1015), } } |
