refactor: Update Unity to 2022.3.62
This commit is contained in:
@@ -24,7 +24,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// Copies the memory in the span to another span.
|
||||
/// </summary>
|
||||
/// <param name="dest">The destination span.</param>
|
||||
public void CopyTo(PdtVariableMemory dest) {
|
||||
public readonly void CopyTo(PdtVariableMemory dest) {
|
||||
CopyTo(dest._ptr, 0, Length);
|
||||
}
|
||||
/// <summary>
|
||||
@@ -32,7 +32,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// </summary>
|
||||
/// <param name="dest">The destination buffer.</param>
|
||||
/// <param name="destOffset">The offset on the destination buffer to start copying to.</param>
|
||||
public void CopyTo(byte[] dest, int destOffset) {
|
||||
public readonly void CopyTo(byte[] dest, int destOffset) {
|
||||
fixed (byte* ptr = dest) {
|
||||
CopyTo(ptr, destOffset, Length);
|
||||
}
|
||||
@@ -44,13 +44,13 @@ namespace Cryville.Common.Pdt {
|
||||
/// <param name="destOffset">The offset on the destination buffer to start copying to.</param>
|
||||
/// <param name="length">The length to copy.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="length" /> is greater than the length of the span.</exception>
|
||||
public void CopyTo(byte* dest, int destOffset, int length) {
|
||||
public readonly void CopyTo(byte* dest, int destOffset, int length) {
|
||||
if (length > Length) throw new ArgumentOutOfRangeException("length");
|
||||
for (int i = 0; i < length; i++)
|
||||
dest[destOffset + i] = _ptr[i];
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public bool Equals(PdtVariableMemory obj) {
|
||||
public readonly bool Equals(PdtVariableMemory obj) {
|
||||
if (Type != obj.Type || Length != obj.Length) return false;
|
||||
for (int i = 0; i < Length; i++) {
|
||||
if (*(_ptr + i) != *(obj._ptr + i)) return false;
|
||||
@@ -63,7 +63,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// <param name="offset">The offset on the span to start reading from.</param>
|
||||
/// <returns>A number.</returns>
|
||||
/// <exception cref="InvalidCastException">The span at the offset does not represent a number.</exception>
|
||||
public float AsNumber(int offset = 0) {
|
||||
public readonly float AsNumber(int offset = 0) {
|
||||
if (Type != PdtInternalType.Number && Type != PdtInternalType.Vector)
|
||||
throw new InvalidCastException("Not a number");
|
||||
float value;
|
||||
@@ -79,7 +79,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// <param name="offset">The offset from the start of the span.</param>
|
||||
/// <exception cref="InvalidCastException">The span at the offset does not represent a number.</exception>
|
||||
/// <exception cref="InvalidOperationException">The length of the span is not sufficient.</exception>
|
||||
public void SetNumber(float value, int offset = 0) {
|
||||
public readonly void SetNumber(float value, int offset = 0) {
|
||||
if (Type != PdtInternalType.Number && Type != PdtInternalType.Vector)
|
||||
throw new InvalidCastException("Not a number");
|
||||
if (Length < sizeof(float) + offset)
|
||||
@@ -94,7 +94,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// <param name="offset">The offset on the span to start reading from.</param>
|
||||
/// <returns>A string.</returns>
|
||||
/// <exception cref="InvalidCastException">The span at the offset does not represent a string.</exception>
|
||||
public string AsString(int offset = 0) {
|
||||
public readonly string AsString(int offset = 0) {
|
||||
if (Type != PdtInternalType.String && Type != PdtInternalType.Array)
|
||||
throw new InvalidCastException("Not a string");
|
||||
var len = *(int*)(_ptr + offset);
|
||||
@@ -107,7 +107,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// <param name="offset">The offset from the start of the span.</param>
|
||||
/// <exception cref="InvalidCastException">The span at the offset does not represent a string.</exception>
|
||||
/// <exception cref="InvalidOperationException">The length of the span is not sufficient.</exception>
|
||||
public void SetString(string value, int offset = 0) {
|
||||
public readonly void SetString(string value, int offset = 0) {
|
||||
if (Type != PdtInternalType.String && Type != PdtInternalType.Array)
|
||||
throw new InvalidCastException("Not a string");
|
||||
int strlen = value.Length;
|
||||
@@ -124,7 +124,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// <param name="offset">The offset on the span to start reading from.</param>
|
||||
/// <returns>The name of an undefined identifier.</returns>
|
||||
/// <exception cref="InvalidCastException">The span does not represent an undefined identifier.</exception>
|
||||
public int AsIdentifier(int offset = 0) {
|
||||
public readonly int AsIdentifier(int offset = 0) {
|
||||
if (Type != PdtInternalType.Undefined && Type != PdtInternalType.Array)
|
||||
throw new InvalidCastException("Not an identifier");
|
||||
return *(int*)(_ptr + offset);
|
||||
@@ -140,7 +140,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// <remarks>
|
||||
/// <para>Use <see cref="AsNumber(int)" /> instead while reading an unaligned number.</para>
|
||||
/// </remarks>
|
||||
public T As<T>(int offset = 0) {
|
||||
public readonly T As<T>(int offset = 0) {
|
||||
var len = Unsafe.SizeOf<T>();
|
||||
if (offset >= Length)
|
||||
throw new ArgumentOutOfRangeException("offset");
|
||||
@@ -159,7 +159,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// <remarks>
|
||||
/// <para>Use <see cref="SetNumber(float, int)" /> instead while writing an unaligned number.</para>
|
||||
/// </remarks>
|
||||
public void Set<T>(T value, int offset = 0) {
|
||||
public readonly void Set<T>(T value, int offset = 0) {
|
||||
var len = Unsafe.SizeOf<T>();
|
||||
if (offset >= Length)
|
||||
throw new ArgumentOutOfRangeException("offset");
|
||||
@@ -173,7 +173,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// <param name="arrtype">The type of the array.</param>
|
||||
/// <param name="pc">The item count of the array.</param>
|
||||
/// <exception cref="InvalidCastException">The span does not represent an array.</exception>
|
||||
public void GetArraySuffix(out int arrtype, out int pc) {
|
||||
public readonly void GetArraySuffix(out int arrtype, out int pc) {
|
||||
if (Type != PdtInternalType.Vector && Type != PdtInternalType.Array)
|
||||
throw new InvalidCastException("Not an array or vector");
|
||||
arrtype = *(int*)(_ptr + Length - sizeof(int));
|
||||
@@ -186,7 +186,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// <param name="arrtype">The type of the array.</param>
|
||||
/// <param name="pc">The item count of the array.</param>
|
||||
/// <exception cref="InvalidCastException">The span does not represent an array.</exception>
|
||||
public void SetArraySuffix(int arrtype, int pc = 0) {
|
||||
public readonly void SetArraySuffix(int arrtype, int pc = 0) {
|
||||
if (Type != PdtInternalType.Vector && Type != PdtInternalType.Array)
|
||||
throw new InvalidCastException("Not an array or vector");
|
||||
*(int*)(_ptr + Length - sizeof(int)) = arrtype;
|
||||
|
Reference in New Issue
Block a user