diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/variant/variant.cpp | 11 | ||||
-rw-r--r-- | core/variant/variant.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index fcbfdd4741..37eb16f9b2 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -3515,6 +3515,17 @@ bool Variant::is_shared() const { return is_type_shared(type); } +bool Variant::is_read_only() const { + switch (type) { + case ARRAY: + return reinterpret_cast<const Array *>(_data._mem)->is_read_only(); + case DICTIONARY: + return reinterpret_cast<const Dictionary *>(_data._mem)->is_read_only(); + default: + return false; + } +} + void Variant::_variant_call_error(const String &p_method, Callable::CallError &error) { switch (error.error) { case Callable::CallError::CALL_ERROR_INVALID_ARGUMENT: { diff --git a/core/variant/variant.h b/core/variant/variant.h index ea6ae02c1e..93953c4e0e 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -349,6 +349,7 @@ public: bool is_zero() const; bool is_one() const; bool is_null() const; + bool is_read_only() const; // Make sure Variant is not implicitly cast when accessing it with bracket notation (GH-49469). Variant &operator[](const Variant &p_key) = delete; |