]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Add long/ulong support
authorForest <chocozilla@gmail.com>
Wed, 30 Jun 2021 03:11:45 +0000 (20:11 -0700)
committerForest <chocozilla@gmail.com>
Wed, 30 Jun 2021 03:11:45 +0000 (20:11 -0700)
Hazel/MessageReader.cs
Hazel/MessageWriter.cs

index 190be12a8a073aa83ce78ebed986a1b658767526..4e0cd2a6c654530d7f92a1baa28e1b8a99aa0b50 100644 (file)
@@ -309,6 +309,34 @@ namespace Hazel
             return output;
         }
 
+        public ulong ReadUInt64()
+        {
+            ulong output = (ulong)this.FastByte()
+                | (ulong)this.FastByte() << 8
+                | (ulong)this.FastByte() << 16
+                | (ulong)this.FastByte() << 24
+                | (ulong)this.FastByte() << 32
+                | (ulong)this.FastByte() << 40
+                | (ulong)this.FastByte() << 48
+                | (ulong)this.FastByte() << 56;
+
+            return output;
+        }
+
+        public long ReadInt64()
+        {
+            long output = (long)this.FastByte()
+                | (long)this.FastByte() << 8
+                | (long)this.FastByte() << 16
+                | (long)this.FastByte() << 24
+                | (long)this.FastByte() << 32
+                | (long)this.FastByte() << 40
+                | (long)this.FastByte() << 48
+                | (long)this.FastByte() << 56;
+
+            return output;
+        }
+
         public unsafe float ReadSingle()
         {
             float output = 0;
index 0cabb66c7386ebc06f5a94a82336480b3077810e..7d4e0509bb21da75c0cff777328d73bb6fd86544 100644 (file)
@@ -204,6 +204,32 @@ namespace Hazel
             if (this.Position > this.Length) this.Length = this.Position;
         }
 
+        public void Write(ulong value)
+        {
+            this.Buffer[this.Position++] = (byte)value;
+            this.Buffer[this.Position++] = (byte)(value >> 8);
+            this.Buffer[this.Position++] = (byte)(value >> 16);
+            this.Buffer[this.Position++] = (byte)(value >> 24);
+            this.Buffer[this.Position++] = (byte)(value >> 32);
+            this.Buffer[this.Position++] = (byte)(value >> 40);
+            this.Buffer[this.Position++] = (byte)(value >> 48);
+            this.Buffer[this.Position++] = (byte)(value >> 56);
+            if (this.Position > this.Length) this.Length = this.Position;
+        }
+
+        public void Write(long value)
+        {
+            this.Buffer[this.Position++] = (byte)value;
+            this.Buffer[this.Position++] = (byte)(value >> 8);
+            this.Buffer[this.Position++] = (byte)(value >> 16);
+            this.Buffer[this.Position++] = (byte)(value >> 24);
+            this.Buffer[this.Position++] = (byte)(value >> 32);
+            this.Buffer[this.Position++] = (byte)(value >> 40);
+            this.Buffer[this.Position++] = (byte)(value >> 48);
+            this.Buffer[this.Position++] = (byte)(value >> 56);
+            if (this.Position > this.Length) this.Length = this.Position;
+        }
+
         public unsafe void Write(float value)
         {
             fixed (byte* ptr = &this.Buffer[this.Position])