You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Create onready variables when dropping nodes and holding Ctrl
This commit is contained in:
@@ -3655,6 +3655,31 @@ bool String::is_absolute_path() const {
|
||||
}
|
||||
}
|
||||
|
||||
static _FORCE_INLINE_ bool _is_valid_identifier_bit(int p_index, char32_t p_char) {
|
||||
if (p_index == 0 && is_digit(p_char)) {
|
||||
return false; // No start with number plz.
|
||||
}
|
||||
return is_ascii_identifier_char(p_char);
|
||||
}
|
||||
|
||||
String String::validate_identifier() const {
|
||||
if (is_empty()) {
|
||||
return "_"; // Empty string is not a valid identifier;
|
||||
}
|
||||
|
||||
String result = *this;
|
||||
int len = result.length();
|
||||
char32_t *buffer = result.ptrw();
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (!_is_valid_identifier_bit(i, buffer[i])) {
|
||||
buffer[i] = '_';
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool String::is_valid_identifier() const {
|
||||
int len = length();
|
||||
|
||||
@@ -3665,15 +3690,7 @@ bool String::is_valid_identifier() const {
|
||||
const char32_t *str = &operator[](0);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (i == 0) {
|
||||
if (is_digit(str[0])) {
|
||||
return false; // no start with number plz
|
||||
}
|
||||
}
|
||||
|
||||
bool valid_char = is_ascii_identifier_char(str[i]);
|
||||
|
||||
if (!valid_char) {
|
||||
if (!_is_valid_identifier_bit(i, str[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user