From e9e1b6e9749fe8b5779570ec20070771dfb76496 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 24 Feb 2021 17:47:58 +0100 Subject: [PATCH] Refactored vector type indexers, switched to ref --- .../Primitives/Bool/Bool2.cs | 10 --------- .../Primitives/Bool/Bool2.g.cs | 9 ++++++++ .../Primitives/Bool/Bool3.cs | 10 --------- .../Primitives/Bool/Bool3.g.cs | 9 ++++++++ .../Primitives/Bool/Bool4.cs | 10 --------- .../Primitives/Bool/Bool4.g.cs | 9 ++++++++ .../Primitives/Double/Double2.cs | 10 --------- .../Primitives/Double/Double2.g.cs | 9 ++++++++ .../Primitives/Double/Double3.cs | 10 --------- .../Primitives/Double/Double3.g.cs | 9 ++++++++ .../Primitives/Double/Double4.cs | 10 --------- .../Primitives/Double/Double4.g.cs | 9 ++++++++ .../Primitives/Float/Float2.cs | 10 --------- .../Primitives/Float/Float2.g.cs | 9 ++++++++ .../Primitives/Float/Float3.cs | 10 --------- .../Primitives/Float/Float3.g.cs | 9 ++++++++ .../Primitives/Float/Float4.cs | 10 --------- .../Primitives/Float/Float4.g.cs | 9 ++++++++ src/ComputeSharp.Core/Primitives/Int/Int2.cs | 10 --------- .../Primitives/Int/Int2.g.cs | 9 ++++++++ src/ComputeSharp.Core/Primitives/Int/Int3.cs | 10 --------- .../Primitives/Int/Int3.g.cs | 9 ++++++++ src/ComputeSharp.Core/Primitives/Int/Int4.cs | 10 --------- .../Primitives/Int/Int4.g.cs | 9 ++++++++ .../Primitives/UInt/UInt2.cs | 10 --------- .../Primitives/UInt/UInt2.g.cs | 9 ++++++++ .../Primitives/UInt/UInt3.cs | 10 --------- .../Primitives/UInt/UInt3.g.cs | 9 ++++++++ .../Primitives/UInt/UInt4.cs | 10 --------- .../Primitives/UInt/UInt4.g.cs | 9 ++++++++ .../Primitives/VectorType.ttinclude | 22 +++++++++++++------ 31 files changed, 150 insertions(+), 157 deletions(-) diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool2.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool2.cs index 26c70e2c..80313e55 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool2.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool2.cs @@ -84,16 +84,6 @@ namespace ComputeSharp set => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(G)}"); } - /// - /// Gets or sets a specific component in the current instance. - /// - /// The index of the component to access. - public bool this[int i] - { - get => throw new InvalidExecutionContextException($"{nameof(Bool2)}[int]"); - set => throw new InvalidExecutionContextException($"{nameof(Bool2)}[int]"); - } - /// /// Creates a new value with the same value for all its components. /// diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs index 39488a29..a5f16d1b 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs @@ -5,6 +5,15 @@ namespace ComputeSharp /// public partial struct Bool2 { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref bool this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(Bool2)}[int]"); + } + /// /// Gets a value with the values , . /// diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool3.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool3.cs index 00b193fa..e8456dc1 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool3.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool3.cs @@ -112,16 +112,6 @@ namespace ComputeSharp set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(B)}"); } - /// - /// Gets or sets a specific component in the current instance. - /// - /// The index of the component to access. - public bool this[int i] - { - get => throw new InvalidExecutionContextException($"{nameof(Bool3)}[int]"); - set => throw new InvalidExecutionContextException($"{nameof(Bool3)}[int]"); - } - /// /// Creates a new value with the same value for all its components. /// diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs index f2155f8d..05187362 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs @@ -5,6 +5,15 @@ namespace ComputeSharp /// public partial struct Bool3 { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref bool this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(Bool3)}[int]"); + } + /// /// Gets a value with the values , . /// diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool4.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool4.cs index 226b7793..de9daba1 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool4.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool4.cs @@ -140,16 +140,6 @@ namespace ComputeSharp set => throw new InvalidExecutionContextException($"{nameof(Bool4)}.{nameof(A)}"); } - /// - /// Gets or sets a specific component in the current instance. - /// - /// The index of the component to access. - public bool this[int i] - { - get => throw new InvalidExecutionContextException($"{nameof(Bool4)}[int]"); - set => throw new InvalidExecutionContextException($"{nameof(Bool4)}[int]"); - } - /// /// Creates a new value with the same value for all its components. /// diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs index 8bd1d60e..03acab43 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs @@ -5,6 +5,15 @@ namespace ComputeSharp /// public partial struct Bool4 { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref bool this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(Bool4)}[int]"); + } + /// /// Gets a value with the values , . /// diff --git a/src/ComputeSharp.Core/Primitives/Double/Double2.cs b/src/ComputeSharp.Core/Primitives/Double/Double2.cs index e070003a..6d0fc441 100644 --- a/src/ComputeSharp.Core/Primitives/Double/Double2.cs +++ b/src/ComputeSharp.Core/Primitives/Double/Double2.cs @@ -70,16 +70,6 @@ namespace ComputeSharp set => throw new InvalidExecutionContextException($"{nameof(Double2)}.{nameof(G)}"); } - /// - /// Gets or sets a specific component in the current instance. - /// - /// The index of the component to access. - public double this[int i] - { - get => throw new InvalidExecutionContextException($"{nameof(Double2)}[int]"); - set => throw new InvalidExecutionContextException($"{nameof(Double2)}[int]"); - } - /// /// Creates a new value with the same value for all its components. /// diff --git a/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs b/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs index c0c82baf..6917045b 100644 --- a/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs @@ -5,6 +5,15 @@ namespace ComputeSharp /// public partial struct Double2 { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref double this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(Double2)}[int]"); + } + /// /// Gets a value with the values , . /// diff --git a/src/ComputeSharp.Core/Primitives/Double/Double3.cs b/src/ComputeSharp.Core/Primitives/Double/Double3.cs index aa9b8c88..74c975fc 100644 --- a/src/ComputeSharp.Core/Primitives/Double/Double3.cs +++ b/src/ComputeSharp.Core/Primitives/Double/Double3.cs @@ -91,16 +91,6 @@ namespace ComputeSharp set => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(B)}"); } - /// - /// Gets or sets a specific component in the current instance. - /// - /// The index of the component to access. - public double this[int i] - { - get => throw new InvalidExecutionContextException($"{nameof(Double3)}[int]"); - set => throw new InvalidExecutionContextException($"{nameof(Double3)}[int]"); - } - /// /// Creates a new value with the same value for all its components. /// diff --git a/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs b/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs index 6efca919..df1e37c7 100644 --- a/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs @@ -5,6 +5,15 @@ namespace ComputeSharp /// public partial struct Double3 { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref double this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(Double3)}[int]"); + } + /// /// Gets a value with the values , . /// diff --git a/src/ComputeSharp.Core/Primitives/Double/Double4.cs b/src/ComputeSharp.Core/Primitives/Double/Double4.cs index 566bd983..2258f421 100644 --- a/src/ComputeSharp.Core/Primitives/Double/Double4.cs +++ b/src/ComputeSharp.Core/Primitives/Double/Double4.cs @@ -112,16 +112,6 @@ namespace ComputeSharp set => throw new InvalidExecutionContextException($"{nameof(Double4)}.{nameof(A)}"); } - /// - /// Gets or sets a specific component in the current instance. - /// - /// The index of the component to access. - public double this[int i] - { - get => throw new InvalidExecutionContextException($"{nameof(Double4)}[int]"); - set => throw new InvalidExecutionContextException($"{nameof(Double4)}[int]"); - } - /// /// Creates a new value with the same value for all its components. /// diff --git a/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs b/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs index 8c68cd5b..42f294f6 100644 --- a/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs @@ -5,6 +5,15 @@ namespace ComputeSharp /// public partial struct Double4 { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref double this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(Double4)}[int]"); + } + /// /// Gets a value with the values , . /// diff --git a/src/ComputeSharp.Core/Primitives/Float/Float2.cs b/src/ComputeSharp.Core/Primitives/Float/Float2.cs index 59e87333..0bac51b6 100644 --- a/src/ComputeSharp.Core/Primitives/Float/Float2.cs +++ b/src/ComputeSharp.Core/Primitives/Float/Float2.cs @@ -71,16 +71,6 @@ namespace ComputeSharp set => throw new InvalidExecutionContextException($"{nameof(Float2)}.{nameof(G)}"); } - /// - /// Gets or sets a specific component in the current instance. - /// - /// The index of the component to access. - public float this[int i] - { - get => throw new InvalidExecutionContextException($"{nameof(Float2)}[int]"); - set => throw new InvalidExecutionContextException($"{nameof(Float2)}[int]"); - } - /// /// Creates a new value with the same value for all its components. /// diff --git a/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs b/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs index 15ca666c..9c54ca13 100644 --- a/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs @@ -5,6 +5,15 @@ namespace ComputeSharp /// public partial struct Float2 { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref float this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(Float2)}[int]"); + } + /// /// Gets a value with the values , . /// diff --git a/src/ComputeSharp.Core/Primitives/Float/Float3.cs b/src/ComputeSharp.Core/Primitives/Float/Float3.cs index 49e4f3c8..9672290b 100644 --- a/src/ComputeSharp.Core/Primitives/Float/Float3.cs +++ b/src/ComputeSharp.Core/Primitives/Float/Float3.cs @@ -92,16 +92,6 @@ namespace ComputeSharp set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(B)}"); } - /// - /// Gets or sets a specific component in the current instance. - /// - /// The index of the component to access. - public float this[int i] - { - get => throw new InvalidExecutionContextException($"{nameof(Float3)}[int]"); - set => throw new InvalidExecutionContextException($"{nameof(Float3)}[int]"); - } - /// /// Creates a new value with the same value for all its components. /// diff --git a/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs b/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs index 0ca8f84d..9b1b9b84 100644 --- a/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs @@ -5,6 +5,15 @@ namespace ComputeSharp /// public partial struct Float3 { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref float this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(Float3)}[int]"); + } + /// /// Gets a value with the values , . /// diff --git a/src/ComputeSharp.Core/Primitives/Float/Float4.cs b/src/ComputeSharp.Core/Primitives/Float/Float4.cs index 7ef04328..54c93eda 100644 --- a/src/ComputeSharp.Core/Primitives/Float/Float4.cs +++ b/src/ComputeSharp.Core/Primitives/Float/Float4.cs @@ -113,16 +113,6 @@ namespace ComputeSharp set => throw new InvalidExecutionContextException($"{nameof(Float4)}.{nameof(A)}"); } - /// - /// Gets or sets a specific component in the current instance. - /// - /// The index of the component to access. - public float this[int i] - { - get => throw new InvalidExecutionContextException($"{nameof(Float4)}[int]"); - set => throw new InvalidExecutionContextException($"{nameof(Float4)}[int]"); - } - /// /// Creates a new value with the same value for all its components. /// diff --git a/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs b/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs index dad8179e..769d2d6e 100644 --- a/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs @@ -5,6 +5,15 @@ namespace ComputeSharp /// public partial struct Float4 { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref float this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(Float4)}[int]"); + } + /// /// Gets a value with the values , . /// diff --git a/src/ComputeSharp.Core/Primitives/Int/Int2.cs b/src/ComputeSharp.Core/Primitives/Int/Int2.cs index 9d29dae3..4c6b122d 100644 --- a/src/ComputeSharp.Core/Primitives/Int/Int2.cs +++ b/src/ComputeSharp.Core/Primitives/Int/Int2.cs @@ -70,16 +70,6 @@ namespace ComputeSharp set => throw new InvalidExecutionContextException($"{nameof(Int2)}.{nameof(G)}"); } - /// - /// Gets or sets a specific component in the current instance. - /// - /// The index of the component to access. - public int this[int i] - { - get => throw new InvalidExecutionContextException($"{nameof(Int2)}[int]"); - set => throw new InvalidExecutionContextException($"{nameof(Int2)}[int]"); - } - /// /// Creates a new value with the same value for all its components. /// diff --git a/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs b/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs index 8001eb3a..843e865c 100644 --- a/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs @@ -5,6 +5,15 @@ namespace ComputeSharp /// public partial struct Int2 { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref int this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(Int2)}[int]"); + } + /// /// Gets a value with the values , . /// diff --git a/src/ComputeSharp.Core/Primitives/Int/Int3.cs b/src/ComputeSharp.Core/Primitives/Int/Int3.cs index 0775c520..0fa549e3 100644 --- a/src/ComputeSharp.Core/Primitives/Int/Int3.cs +++ b/src/ComputeSharp.Core/Primitives/Int/Int3.cs @@ -91,16 +91,6 @@ namespace ComputeSharp set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(B)}"); } - /// - /// Gets or sets a specific component in the current instance. - /// - /// The index of the component to access. - public int this[int i] - { - get => throw new InvalidExecutionContextException($"{nameof(Int3)}[int]"); - set => throw new InvalidExecutionContextException($"{nameof(Int3)}[int]"); - } - /// /// Creates a new value with the same value for all its components. /// diff --git a/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs b/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs index d16fa077..75690455 100644 --- a/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs @@ -5,6 +5,15 @@ namespace ComputeSharp /// public partial struct Int3 { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref int this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(Int3)}[int]"); + } + /// /// Gets a value with the values , . /// diff --git a/src/ComputeSharp.Core/Primitives/Int/Int4.cs b/src/ComputeSharp.Core/Primitives/Int/Int4.cs index eee7af6c..2b33a0aa 100644 --- a/src/ComputeSharp.Core/Primitives/Int/Int4.cs +++ b/src/ComputeSharp.Core/Primitives/Int/Int4.cs @@ -112,16 +112,6 @@ namespace ComputeSharp set => throw new InvalidExecutionContextException($"{nameof(Int4)}.{nameof(A)}"); } - /// - /// Gets or sets a specific component in the current instance. - /// - /// The index of the component to access. - public int this[int i] - { - get => throw new InvalidExecutionContextException($"{nameof(Int4)}[int]"); - set => throw new InvalidExecutionContextException($"{nameof(Int4)}[int]"); - } - /// /// Creates a new value with the same value for all its components. /// diff --git a/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs b/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs index d7d17460..4de91f46 100644 --- a/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs @@ -5,6 +5,15 @@ namespace ComputeSharp /// public partial struct Int4 { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref int this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(Int4)}[int]"); + } + /// /// Gets a value with the values , . /// diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt2.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt2.cs index f8bad799..dedffc20 100644 --- a/src/ComputeSharp.Core/Primitives/UInt/UInt2.cs +++ b/src/ComputeSharp.Core/Primitives/UInt/UInt2.cs @@ -70,16 +70,6 @@ namespace ComputeSharp set => throw new InvalidExecutionContextException($"{nameof(UInt2)}.{nameof(G)}"); } - /// - /// Gets or sets a specific component in the current instance. - /// - /// The index of the component to access. - public float this[int i] - { - get => throw new InvalidExecutionContextException($"{nameof(UInt2)}[int]"); - set => throw new InvalidExecutionContextException($"{nameof(UInt2)}[int]"); - } - /// /// Creates a new value with the same value for all its components. /// diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs index 0e99ae4a..c369c10c 100644 --- a/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs +++ b/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs @@ -5,6 +5,15 @@ namespace ComputeSharp /// public partial struct UInt2 { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref uint this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(UInt2)}[int]"); + } + /// /// Gets a value with the values , . /// diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt3.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt3.cs index df2c813b..f22ff6a2 100644 --- a/src/ComputeSharp.Core/Primitives/UInt/UInt3.cs +++ b/src/ComputeSharp.Core/Primitives/UInt/UInt3.cs @@ -91,16 +91,6 @@ namespace ComputeSharp set => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(B)}"); } - /// - /// Gets or sets a specific component in the current instance. - /// - /// The index of the component to access. - public uint this[int i] - { - get => throw new InvalidExecutionContextException($"{nameof(UInt3)}[int]"); - set => throw new InvalidExecutionContextException($"{nameof(UInt3)}[int]"); - } - /// /// Creates a new value with the same value for all its components. /// diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs index c51b3411..35e5d8f3 100644 --- a/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs +++ b/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs @@ -5,6 +5,15 @@ namespace ComputeSharp /// public partial struct UInt3 { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref uint this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(UInt3)}[int]"); + } + /// /// Gets a value with the values , . /// diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt4.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt4.cs index 0a3b70cd..4c41f41b 100644 --- a/src/ComputeSharp.Core/Primitives/UInt/UInt4.cs +++ b/src/ComputeSharp.Core/Primitives/UInt/UInt4.cs @@ -112,16 +112,6 @@ namespace ComputeSharp set => throw new InvalidExecutionContextException($"{nameof(UInt4)}.{nameof(A)}"); } - /// - /// Gets or sets a specific component in the current instance. - /// - /// The index of the component to access. - public uint this[int i] - { - get => throw new InvalidExecutionContextException($"{nameof(UInt4)}[uint]"); - set => throw new InvalidExecutionContextException($"{nameof(UInt4)}[uint]"); - } - /// /// Creates a new value with the same value for all its components. /// diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs index 08ea71e1..9c51f59b 100644 --- a/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs +++ b/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs @@ -5,6 +5,15 @@ namespace ComputeSharp /// public partial struct UInt4 { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref uint this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(UInt4)}[int]"); + } + /// /// Gets a value with the values , . /// diff --git a/src/ComputeSharp.Core/Primitives/VectorType.ttinclude b/src/ComputeSharp.Core/Primitives/VectorType.ttinclude index 54827841..271dd2b7 100644 --- a/src/ComputeSharp.Core/Primitives/VectorType.ttinclude +++ b/src/ComputeSharp.Core/Primitives/VectorType.ttinclude @@ -33,19 +33,29 @@ namespace ComputeSharp /// public partial struct <#=typeName#> { + /// + /// Gets or sets a specific component in the current instance. + /// + /// The index of the component to access. + public ref <#=hlslElementTypeName#> this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(<#=typeName#>)}[int]"); + } <# + PushIndent(" "); PushIndent(" "); - var properties = ( + // Generate the combinatorial swizzling properties + foreach ( + var property in from j in Enumerable.Range(2, i - 1) from source in new[] { "XYZW", "RGBA" } from name in EnumerateCombinations(source.Substring(0, j)) - select (Name: name, Length: j)).ToArray(); - - for (int j = 0; j < properties.Length; j++) + select (Name: name, Length: j)) { - var property = properties[j]; + WriteLine(""); + string propertyType = property.Length == 1 ? hlslElementTypeName : $"{elementTypeName}{property.Length}"; bool isReadonly = property.Name.Distinct().Count() < property.Name.Length; @@ -73,8 +83,6 @@ namespace ComputeSharp PopIndent(); WriteLine("}"); - - if (j < properties.Length - 1) WriteLine(""); } PopIndent();