/* * SPDX-License-Identifier: AGPL-3.0-or-later * Copyright (C) 2025 Sergej Görzen * This file is part of xAPI4Unity. */ #if UNITY_EDITOR namespace xAPI4Unity.Editor.Parser.Code.SyntaxTree { /// /// An argument in the syntax tree /// internal class Argument { // Backing storage for the argument's value. Kept as 'object' to support heterogeneous argument types. private object _value; /// /// Name of the argument /// public string Name { get; private set; } /// /// Value of the argument /// /// /// Exposed as a ref readonly to avoid copying large values while still preventing external mutation /// of the backing field reference. /// public ref readonly object Value => ref _value; /// /// Initializes a new, empty argument with no name and no value assigned. /// public Argument() { } /// /// Initializes a new argument with the provided value and optional name. /// /// The value to assign to this argument. /// Optional name for the argument. If omitted, the argument remains unnamed. public Argument(object value, string name = default) { this._value = value; Name = name; } /// /// Sets the argument name. /// /// The name to assign. /// The same Argument instance for fluent chaining. public Argument WithName(string name) { Name = name; return this; } /// /// Sets the argument value. /// /// The value to assign. /// The same Argument instance for fluent chaining. public Argument WithValue(object value) { _value = value; return this; } } } #endif