diff --git a/GlitchyEngine/src/Math/VectorAttribute.bf b/GlitchyEngine/src/Math/VectorAttribute.bf index aad3d54..93c2524 100644 --- a/GlitchyEngine/src/Math/VectorAttribute.bf +++ b/GlitchyEngine/src/Math/VectorAttribute.bf @@ -20,6 +20,8 @@ struct VectorAttribute : Attribute, IComptimeTypeApply where GenerateEqualityOperators(type); GenerateArrayAccess(type); + + GenerateToString(type); } [Comptime] @@ -311,6 +313,30 @@ struct VectorAttribute : Attribute, IComptimeTypeApply where Compiler.EmitTypeBody(type, arrayAccess); } + + [Comptime] + private static void GenerateToString(Type type) + { + String string = scope String(); + + for (int i < ComponentCount) + { + if (i != 0) + string.Append(", "); + + string.AppendF($"{{{ComponentNames[i]}}}"); + } + + String func = scope $""" + public void ToString(System.String buffer) + {{ + buffer.AppendF($"({string})"); + }} + + """; + + Compiler.EmitTypeBody(type, func); + } } [AttributeUsage(.Struct | .Class)]