diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/string/string_name.cpp | 1 | ||||
-rw-r--r-- | core/string/string_name.h | 13 | ||||
-rw-r--r-- | core/string/ustring.cpp | 3 |
3 files changed, 16 insertions, 1 deletions
diff --git a/core/string/string_name.cpp b/core/string/string_name.cpp index 2e941b8037..9c4fc4e1b7 100644 --- a/core/string/string_name.cpp +++ b/core/string/string_name.cpp @@ -247,6 +247,7 @@ StringName::StringName(const char *p_name, bool p_static) { _data->cname = nullptr; _data->next = _table[idx]; _data->prev = nullptr; + #ifdef DEBUG_ENABLED if (unlikely(debug_stringname)) { // Keep in memory, force static. diff --git a/core/string/string_name.h b/core/string/string_name.h index f4233854ac..ff4c41af94 100644 --- a/core/string/string_name.h +++ b/core/string/string_name.h @@ -35,6 +35,8 @@ #include "core/string/ustring.h" #include "core/templates/safe_refcount.h" +#define UNIQUE_NODE_PREFIX "%" + class Main; struct StaticCString { @@ -100,6 +102,17 @@ public: bool operator==(const String &p_name) const; bool operator==(const char *p_name) const; bool operator!=(const String &p_name) const; + + _FORCE_INLINE_ bool is_node_unique_name() const { + if (!_data) { + return false; + } + if (_data->cname != nullptr) { + return (char32_t)_data->cname[0] == (char32_t)UNIQUE_NODE_PREFIX[0]; + } else { + return (char32_t)_data->name[0] == (char32_t)UNIQUE_NODE_PREFIX[0]; + } + } _FORCE_INLINE_ bool operator<(const StringName &p_name) const { return _data < p_name._data; } diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 7cfd34b53e..7199121932 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -35,6 +35,7 @@ #include "core/math/math_funcs.h" #include "core/os/memory.h" #include "core/string/print_string.h" +#include "core/string/string_name.h" #include "core/string/translation.h" #include "core/string/ucaps.h" #include "core/variant/variant.h" @@ -4357,7 +4358,7 @@ String String::property_name_encode() const { } // Changes made to the set of invalid characters must also be reflected in the String documentation. -const String String::invalid_node_name_characters = ". : @ / \""; +const String String::invalid_node_name_characters = ". : @ / \" " UNIQUE_NODE_PREFIX; String String::validate_node_name() const { Vector<String> chars = String::invalid_node_name_characters.split(" "); |