diff --git a/binding_generator.py b/binding_generator.py index 380033d7..fd994bf8 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -570,22 +570,26 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl # Special cases. if class_name == "String": - result.append("String &operator=(const char *p_str);") - result.append("String &operator=(const wchar_t *p_str);") - result.append("String &operator=(const char16_t *p_str);") - result.append("String &operator=(const char32_t *p_str);") - result.append("bool operator==(const char *p_str) const;") - result.append("bool operator==(const wchar_t *p_str) const;") - result.append("bool operator==(const char16_t *p_str) const;") - result.append("bool operator==(const char32_t *p_str) const;") - result.append("bool operator!=(const char *p_str) const;") - result.append("bool operator!=(const wchar_t *p_str) const;") - result.append("bool operator!=(const char16_t *p_str) const;") - result.append("bool operator!=(const char32_t *p_str) const;") - result.append(f"\tconst char32_t &operator[](int p_index) const;") - result.append(f"\tchar32_t &operator[](int p_index);") - result.append(f"\tconst char32_t *ptr() const;") - result.append(f"\tchar32_t *ptrw();") + result.append("\tString &operator=(const char *p_str);") + result.append("\tString &operator=(const wchar_t *p_str);") + result.append("\tString &operator=(const char16_t *p_str);") + result.append("\tString &operator=(const char32_t *p_str);") + result.append("\tbool operator==(const char *p_str) const;") + result.append("\tbool operator==(const wchar_t *p_str) const;") + result.append("\tbool operator==(const char16_t *p_str) const;") + result.append("\tbool operator==(const char32_t *p_str) const;") + result.append("\tbool operator!=(const char *p_str) const;") + result.append("\tbool operator!=(const wchar_t *p_str) const;") + result.append("\tbool operator!=(const char16_t *p_str) const;") + result.append("\tbool operator!=(const char32_t *p_str) const;") + result.append("\tString operator+(const char *p_chr);") + result.append("\tString operator+(const wchar_t *p_chr);") + result.append("\tString operator+(const char16_t *p_chr);") + result.append("\tString operator+(const char32_t *p_chr);") + result.append("\tconst char32_t &operator[](int p_index) const;") + result.append("\tchar32_t &operator[](int p_index);") + result.append("\tconst char32_t *ptr() const;") + result.append("\tchar32_t *ptrw();") if class_name == "Array": result.append("\ttemplate ") diff --git a/src/variant/char_string.cpp b/src/variant/char_string.cpp index cc217401..33e10dbf 100644 --- a/src/variant/char_string.cpp +++ b/src/variant/char_string.cpp @@ -327,6 +327,22 @@ bool String::operator!=(const char32_t *p_str) const { return *this != String(p_str); } +String String::operator+(const char *p_chr) { + return *this + String(p_chr); +} + +String String::operator+(const wchar_t *p_chr) { + return *this + String(p_chr); +} + +String String::operator+(const char16_t *p_chr) { + return *this + String(p_chr); +} + +String String::operator+(const char32_t *p_chr) { + return *this + String(p_chr); +} + const char32_t &String::operator[](int p_index) const { return *internal::gdn_interface->string_operator_index_const((GDNativeStringPtr)this, p_index); }