SOURCE DUMP v1

This commit is contained in:
Rian Drake 2026-10-15 14:09:11 +13:00
commit fb20299e9d
7 changed files with 768360 additions and 0 deletions

View file

@ -0,0 +1,28 @@
// <auto-generated /> - edit Vector.copy.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool2
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly void CopyTo(Span<bool> destination)
{
if (destination.Length < ComponentCount)
throw new ArgumentException("Length must be at least 2.", nameof(destination));
Unsafe.WriteUnaligned(ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetReference(destination)), this);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool TryCopyTo(Span<bool> destination)
{
if (destination.Length < ComponentCount)
return false;
Unsafe.WriteUnaligned(ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetReference(destination)), this);
return true;
}
}

View file

@ -0,0 +1,41 @@
// <auto-generated /> - edit Vector.equality.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool2
{
/// <inheritdoc />
public readonly override int GetHashCode()
{
return HashCode.Combine(X, Y);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Equals(bool2 other)
{
return X == other.X && Y == other.Y;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is bool2 other && Equals(other);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(bool2 a, bool2 b)
{
return a.Equals(b);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(bool2 a, bool2 b)
{
return !(a == b);
}
}

View file

@ -0,0 +1,38 @@
// <auto-generated /> - edit Vector.format.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool2 : ISpanFormattable, IUtf8SpanFormattable
{
/// <inheritdoc />
public readonly override string ToString()
{
return ToString("G", CultureInfo.CurrentCulture);
}
/// <inheritdoc cref="Vector2.ToString(string?)" />
public readonly string ToString(string? format)
{
return ToString(format, CultureInfo.CurrentCulture);
}
/// <inheritdoc />
public readonly string ToString(string? format, IFormatProvider? formatProvider)
{
var separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
return $"<{X.ToString()}{separator} {Y.ToString()}>";
}
/// <inheritdoc />
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
{
return StringHelpers.TryFormat<bool2, bool>(this, destination, out charsWritten, format, provider);
}
/// <inheritdoc />
public readonly bool TryFormat(Span<byte> destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
{
return StringHelpers.TryFormat<bool2, bool>(this, destination, out bytesWritten, format, provider);
}
}

View file

@ -0,0 +1,105 @@
// <auto-generated /> - edit Vector.tt to modify
#nullable enable
namespace Brutal.Numerics;
/// <summary>
/// Implements a 2D vector with bool components.
/// </summary>
public partial struct bool2 : IVector2<bool2, bool>
, IBooleanVector<bool2, bool>
{
/// <inheritdoc />
public static int ComponentSize => sizeof(bool);
/// <summary>Gets the number of components.</summary>
public static int ComponentCount => 2;
/// <inheritdoc cref="Vector2.X" />
[XmlAttribute]
public bool X;
/// <inheritdoc cref="Vector2.Y" />
[XmlAttribute]
public bool Y;
bool IVector2<bool2, bool>.X { readonly get => X; set => X = value; }
bool IVector2<bool2, bool>.Y { readonly get => Y; set => Y = value; }
/// <inheritdoc cref="Vector2(float, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool2(bool x, bool y)
{
X = x;
Y = y;
}
/// <inheritdoc cref="Vector2(float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool2(bool xy)
: this(xy, xy) { }
/// <summary>Creates a vector from the leading 2 elements of a span.</summary>
/// <param name="span">The elements to read; must contain at least 2, and any beyond that are ignored.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="span" /> holds fewer than 2 elements.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool2(ReadOnlySpan<bool> span)
{
if (span.Length < 2)
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 2.");
this = Unsafe.ReadUnaligned<bool2>(ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetReference(span)));
}
/// <inheritdoc cref="bool2(ReadOnlySpan{bool})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool2 IComponentTuple<bool2, bool>.Create(ReadOnlySpan<bool> span) => new(span);
/// <inheritdoc />
public static bool2 UnitX => new(true, false);
/// <inheritdoc />
public static bool2 UnitY => new(false, true);
/// <inheritdoc />
public bool this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get
{
if ((uint)index >= ComponentCount)
throw new ArgumentOutOfRangeException(nameof(index));
return Unsafe.Add(ref Unsafe.AsRef(in X), index);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
if ((uint)index >= ComponentCount)
throw new ArgumentOutOfRangeException(nameof(index));
Unsafe.Add(ref X, index) = value;
}
}
public readonly void Deconstruct(out bool x, out bool y)
{
x = X;
y = Y;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span<bool> AsSpan()
{
return MemoryMarshal.CreateSpan(ref Unsafe.As<bool2, bool>(ref this), 2);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ReadOnlySpan<bool> AsReadOnlySpan()
{
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<bool2, bool>(ref Unsafe.AsRef(in this)), 2);
}
}

View file

@ -0,0 +1,13 @@
// <auto-generated /> - edit Vector.math.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool2
{
/// <inheritdoc />
public readonly bool Any => X || Y;
/// <inheritdoc />
public readonly bool All => X && Y;
}

View file

@ -0,0 +1,53 @@
// <auto-generated /> - edit Vector.numerics.tt to modify
#nullable enable
namespace Brutal.Numerics;
// INumberBase
public partial struct bool2
{
/// <inheritdoc />
public static bool2 Zero => new(false);
/// <inheritdoc />
public static bool2 One => new(true);
}
// IBitwiseOperators
public partial struct bool2 : IBitwiseOperators<bool2, bool2, bool2>
{
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool2 operator |(bool2 a, bool2 b)
{
return new bool2(a.X | b.X, a.Y | b.Y);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool2 operator &(bool2 a, bool2 b)
{
return new bool2(a.X & b.X, a.Y & b.Y);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool2 operator ^(bool2 a, bool2 b)
{
return new bool2(a.X ^ b.X, a.Y ^ b.Y);
}
/// <inheritdoc cref="IBitwiseOperators{TSelf, TOther, TResult}.op_OnesComplement" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool2 operator !(bool2 value)
{
return new bool2(!value.X, !value.Y);
}
// bool has no ~; the interface's complement is componentwise logical not
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool2 IBitwiseOperators<bool2, bool2, bool2>.operator ~(bool2 value)
{
return !value;
}
}

View file

@ -0,0 +1,80 @@
// <auto-generated /> - edit Vector.swizzle.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct bool2
{
/// <summary>
/// Swizzle readonly getter/setter for the X and Y components of the vector.
/// </summary>
[XmlIgnore]
public bool2 XY
{
readonly get => this;
set => this = value;
}
/// <summary>
/// Swizzle readonly getter/setter for the Y and X components of the vector.
/// </summary>
[XmlIgnore]
public bool2 YX
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(Y, X);
set
{
Y = value.X;
X = value.Y;
}
}
}
public partial struct bool2
{
/// <summary>
/// The Red component of the vector (synonym for X).
/// </summary>
[XmlIgnore]
public bool R
{
readonly get => X;
set => X = value;
}
/// <summary>
/// The Green component of the vector (synonym for Y).
/// </summary>
[XmlIgnore]
public bool G
{
readonly get => Y;
set => Y = value;
}
/// <summary>
/// Swizzle readonly getter/setter for the Red and Green components of the vector.
/// </summary>
[XmlIgnore]
public bool2 RG
{
readonly get => this;
set => this = value;
}
/// <summary>
/// Swizzle readonly getter/setter for the Green and Red components of the vector.
/// </summary>
[XmlIgnore]
public bool2 GR
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get => new(G, R);
set
{
G = value.R;
R = value.G;
}
}
}