Remove 32-bit String to_int method
This commit is contained in:
parent
030a26206f
commit
bb8aa107fd
@ -1062,7 +1062,7 @@ Error Expression::_get_token(Token &r_token) {
|
|||||||
if (is_float) {
|
if (is_float) {
|
||||||
r_token.value = num.to_double();
|
r_token.value = num.to_double();
|
||||||
} else {
|
} else {
|
||||||
r_token.value = num.to_int64();
|
r_token.value = num.to_int();
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
|
@ -1742,32 +1742,7 @@ int64_t String::bin_to_int64(bool p_with_prefix) const {
|
|||||||
return binary * sign;
|
return binary * sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
int String::to_int() const {
|
int64_t String::to_int() const {
|
||||||
if (length() == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int to = (find(".") >= 0) ? find(".") : length();
|
|
||||||
|
|
||||||
int integer = 0;
|
|
||||||
int sign = 1;
|
|
||||||
|
|
||||||
for (int i = 0; i < to; i++) {
|
|
||||||
CharType c = operator[](i);
|
|
||||||
if (c >= '0' && c <= '9') {
|
|
||||||
ERR_FAIL_COND_V_MSG(integer > INT32_MAX / 10, sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + *this + " as integer, provided value is " + (sign == 1 ? "too big." : "too small."));
|
|
||||||
integer *= 10;
|
|
||||||
integer += c - '0';
|
|
||||||
|
|
||||||
} else if (integer == 0 && c == '-') {
|
|
||||||
sign = -sign;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return integer * sign;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t String::to_int64() const {
|
|
||||||
if (length() == 0) {
|
if (length() == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1780,7 +1755,7 @@ int64_t String::to_int64() const {
|
|||||||
for (int i = 0; i < to; i++) {
|
for (int i = 0; i < to; i++) {
|
||||||
CharType c = operator[](i);
|
CharType c = operator[](i);
|
||||||
if (c >= '0' && c <= '9') {
|
if (c >= '0' && c <= '9') {
|
||||||
ERR_FAIL_COND_V_MSG(integer > INT64_MAX / 10, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + *this + " as 64-bit integer, provided value is " + (sign == 1 ? "too big." : "too small."));
|
ERR_FAIL_COND_V_MSG(integer > INT64_MAX / 10, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + *this + " as an integer, provided value is " + (sign == 1 ? "too big." : "too small."));
|
||||||
integer *= 10;
|
integer *= 10;
|
||||||
integer += c - '0';
|
integer += c - '0';
|
||||||
|
|
||||||
|
@ -246,11 +246,10 @@ public:
|
|||||||
double to_double() const;
|
double to_double() const;
|
||||||
float to_float() const;
|
float to_float() const;
|
||||||
int hex_to_int(bool p_with_prefix = true) const;
|
int hex_to_int(bool p_with_prefix = true) const;
|
||||||
int to_int() const;
|
|
||||||
|
|
||||||
int64_t hex_to_int64(bool p_with_prefix = true) const;
|
int64_t hex_to_int64(bool p_with_prefix = true) const;
|
||||||
int64_t bin_to_int64(bool p_with_prefix = true) const;
|
int64_t bin_to_int64(bool p_with_prefix = true) const;
|
||||||
int64_t to_int64() const;
|
int64_t to_int() const;
|
||||||
static int to_int(const char *p_str, int p_len = -1);
|
static int to_int(const char *p_str, int p_len = -1);
|
||||||
static double to_double(const char *p_str);
|
static double to_double(const char *p_str);
|
||||||
static double to_double(const CharType *p_str, const CharType **r_end = nullptr);
|
static double to_double(const CharType *p_str, const CharType **r_end = nullptr);
|
||||||
|
@ -1409,7 +1409,7 @@ Variant::operator int64_t() const {
|
|||||||
case FLOAT:
|
case FLOAT:
|
||||||
return _data._float;
|
return _data._float;
|
||||||
case STRING:
|
case STRING:
|
||||||
return operator String().to_int64();
|
return operator String().to_int();
|
||||||
default: {
|
default: {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ _FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IP_Address p_ip, St
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if_v6id = (uint32_t)c.index.to_int64();
|
if_v6id = (uint32_t)c.index.to_int();
|
||||||
if (type == IP::TYPE_IPV6) {
|
if (type == IP::TYPE_IPV6) {
|
||||||
break; // IPv6 uses index.
|
break; // IPv6 uses index.
|
||||||
}
|
}
|
||||||
|
@ -233,9 +233,9 @@ void EditorFileSystem::_scan_filesystem() {
|
|||||||
|
|
||||||
FileCache fc;
|
FileCache fc;
|
||||||
fc.type = split[1];
|
fc.type = split[1];
|
||||||
fc.modification_time = split[2].to_int64();
|
fc.modification_time = split[2].to_int();
|
||||||
fc.import_modification_time = split[3].to_int64();
|
fc.import_modification_time = split[3].to_int();
|
||||||
fc.import_valid = split[4].to_int64() != 0;
|
fc.import_valid = split[4].to_int() != 0;
|
||||||
fc.import_group_file = split[5].strip_edges();
|
fc.import_group_file = split[5].strip_edges();
|
||||||
fc.script_class_name = split[6].get_slice("<>", 0);
|
fc.script_class_name = split[6].get_slice("<>", 0);
|
||||||
fc.script_class_extends = split[6].get_slice("<>", 1);
|
fc.script_class_extends = split[6].get_slice("<>", 1);
|
||||||
|
@ -376,13 +376,13 @@ void EditorPropertyMember::_property_select() {
|
|||||||
selector->select_method_from_base_type(hint_text, current);
|
selector->select_method_from_base_type(hint_text, current);
|
||||||
|
|
||||||
} else if (hint == MEMBER_METHOD_OF_INSTANCE) {
|
} else if (hint == MEMBER_METHOD_OF_INSTANCE) {
|
||||||
Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
|
Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
|
||||||
if (instance) {
|
if (instance) {
|
||||||
selector->select_method_from_instance(instance, current);
|
selector->select_method_from_instance(instance, current);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (hint == MEMBER_METHOD_OF_SCRIPT) {
|
} else if (hint == MEMBER_METHOD_OF_SCRIPT) {
|
||||||
Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
|
Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
|
||||||
if (Object::cast_to<Script>(obj)) {
|
if (Object::cast_to<Script>(obj)) {
|
||||||
selector->select_method_from_script(Object::cast_to<Script>(obj), current);
|
selector->select_method_from_script(Object::cast_to<Script>(obj), current);
|
||||||
}
|
}
|
||||||
@ -407,13 +407,13 @@ void EditorPropertyMember::_property_select() {
|
|||||||
selector->select_property_from_base_type(hint_text, current);
|
selector->select_property_from_base_type(hint_text, current);
|
||||||
|
|
||||||
} else if (hint == MEMBER_PROPERTY_OF_INSTANCE) {
|
} else if (hint == MEMBER_PROPERTY_OF_INSTANCE) {
|
||||||
Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
|
Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
|
||||||
if (instance) {
|
if (instance) {
|
||||||
selector->select_property_from_instance(instance, current);
|
selector->select_property_from_instance(instance, current);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (hint == MEMBER_PROPERTY_OF_SCRIPT) {
|
} else if (hint == MEMBER_PROPERTY_OF_SCRIPT) {
|
||||||
Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
|
Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
|
||||||
if (Object::cast_to<Script>(obj)) {
|
if (Object::cast_to<Script>(obj)) {
|
||||||
selector->select_property_from_script(Object::cast_to<Script>(obj), current);
|
selector->select_property_from_script(Object::cast_to<Script>(obj), current);
|
||||||
}
|
}
|
||||||
@ -487,7 +487,7 @@ void EditorPropertyEnum::setup(const Vector<String> &p_options) {
|
|||||||
for (int i = 0; i < p_options.size(); i++) {
|
for (int i = 0; i < p_options.size(); i++) {
|
||||||
Vector<String> text_split = p_options[i].split(":");
|
Vector<String> text_split = p_options[i].split(":");
|
||||||
if (text_split.size() != 1) {
|
if (text_split.size() != 1) {
|
||||||
current_val = text_split[1].to_int64();
|
current_val = text_split[1].to_int();
|
||||||
}
|
}
|
||||||
options->add_item(text_split[0]);
|
options->add_item(text_split[0]);
|
||||||
options->set_item_metadata(i, current_val);
|
options->set_item_metadata(i, current_val);
|
||||||
|
@ -110,7 +110,7 @@ void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Textur
|
|||||||
uint64_t modified_time = 0;
|
uint64_t modified_time = 0;
|
||||||
|
|
||||||
if (p_str.begins_with("ID:")) {
|
if (p_str.begins_with("ID:")) {
|
||||||
hash = uint32_t(p_str.get_slicec(':', 2).to_int64());
|
hash = uint32_t(p_str.get_slicec(':', 2).to_int());
|
||||||
path = "ID:" + p_str.get_slicec(':', 1);
|
path = "ID:" + p_str.get_slicec(':', 1);
|
||||||
} else {
|
} else {
|
||||||
modified_time = FileAccess::get_modified_time(path);
|
modified_time = FileAccess::get_modified_time(path);
|
||||||
@ -257,9 +257,9 @@ void EditorResourcePreview::_thread() {
|
|||||||
_generate_preview(texture, small_texture, item, cache_base);
|
_generate_preview(texture, small_texture, item, cache_base);
|
||||||
} else {
|
} else {
|
||||||
uint64_t modtime = FileAccess::get_modified_time(item.path);
|
uint64_t modtime = FileAccess::get_modified_time(item.path);
|
||||||
int tsize = f->get_line().to_int64();
|
int tsize = f->get_line().to_int();
|
||||||
bool has_small_texture = f->get_line().to_int();
|
bool has_small_texture = f->get_line().to_int();
|
||||||
uint64_t last_modtime = f->get_line().to_int64();
|
uint64_t last_modtime = f->get_line().to_int();
|
||||||
|
|
||||||
bool cache_valid = true;
|
bool cache_valid = true;
|
||||||
|
|
||||||
|
@ -594,7 +594,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
|
|||||||
} else if (hint == PROPERTY_HINT_METHOD_OF_INSTANCE) {
|
} else if (hint == PROPERTY_HINT_METHOD_OF_INSTANCE) {
|
||||||
MAKE_PROPSELECT
|
MAKE_PROPSELECT
|
||||||
|
|
||||||
Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
|
Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
|
||||||
if (instance) {
|
if (instance) {
|
||||||
property_select->select_method_from_instance(instance, v);
|
property_select->select_method_from_instance(instance, v);
|
||||||
}
|
}
|
||||||
@ -604,7 +604,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
|
|||||||
} else if (hint == PROPERTY_HINT_METHOD_OF_SCRIPT) {
|
} else if (hint == PROPERTY_HINT_METHOD_OF_SCRIPT) {
|
||||||
MAKE_PROPSELECT
|
MAKE_PROPSELECT
|
||||||
|
|
||||||
Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
|
Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
|
||||||
if (Object::cast_to<Script>(obj)) {
|
if (Object::cast_to<Script>(obj)) {
|
||||||
property_select->select_method_from_script(Object::cast_to<Script>(obj), v);
|
property_select->select_method_from_script(Object::cast_to<Script>(obj), v);
|
||||||
}
|
}
|
||||||
@ -643,7 +643,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
|
|||||||
} else if (hint == PROPERTY_HINT_PROPERTY_OF_INSTANCE) {
|
} else if (hint == PROPERTY_HINT_PROPERTY_OF_INSTANCE) {
|
||||||
MAKE_PROPSELECT
|
MAKE_PROPSELECT
|
||||||
|
|
||||||
Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
|
Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
|
||||||
if (instance) {
|
if (instance) {
|
||||||
property_select->select_property_from_instance(instance, v);
|
property_select->select_property_from_instance(instance, v);
|
||||||
}
|
}
|
||||||
@ -654,7 +654,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
|
|||||||
} else if (hint == PROPERTY_HINT_PROPERTY_OF_SCRIPT) {
|
} else if (hint == PROPERTY_HINT_PROPERTY_OF_SCRIPT) {
|
||||||
MAKE_PROPSELECT
|
MAKE_PROPSELECT
|
||||||
|
|
||||||
Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
|
Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
|
||||||
if (Object::cast_to<Script>(obj)) {
|
if (Object::cast_to<Script>(obj)) {
|
||||||
property_select->select_property_from_script(Object::cast_to<Script>(obj), v);
|
property_select->select_property_from_script(Object::cast_to<Script>(obj), v);
|
||||||
}
|
}
|
||||||
|
@ -856,7 +856,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
|||||||
}
|
}
|
||||||
} else if (I->get() == "--allow_focus_steal_pid") { // not exposed to user
|
} else if (I->get() == "--allow_focus_steal_pid") { // not exposed to user
|
||||||
if (I->next()) {
|
if (I->next()) {
|
||||||
allow_focus_steal_pid = I->next()->get().to_int64();
|
allow_focus_steal_pid = I->next()->get().to_int();
|
||||||
N = I->next()->next();
|
N = I->next()->next();
|
||||||
} else {
|
} else {
|
||||||
OS::get_singleton()->print("Missing editor PID argument, aborting.\n");
|
OS::get_singleton()->print("Missing editor PID argument, aborting.\n");
|
||||||
|
@ -370,7 +370,7 @@ bool test_22() {
|
|||||||
static const int num[4] = { 1237461283, -22, 0, -1123412 };
|
static const int num[4] = { 1237461283, -22, 0, -1123412 };
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
OS::get_singleton()->print("\tString: \"%s\" as Int is %i\n", nums[i], String(nums[i]).to_int());
|
OS::get_singleton()->print("\tString: \"%s\" as Int is %lli\n", nums[i], (long long)(String(nums[i]).to_int()));
|
||||||
|
|
||||||
if (String(nums[i]).to_int() != num[i]) {
|
if (String(nums[i]).to_int() != num[i]) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -625,7 +625,7 @@ int64_t GDAPI godot_string_hex_to_int64_with_prefix(const godot_string *p_self)
|
|||||||
int64_t GDAPI godot_string_to_int64(const godot_string *p_self) {
|
int64_t GDAPI godot_string_to_int64(const godot_string *p_self) {
|
||||||
const String *self = (const String *)p_self;
|
const String *self = (const String *)p_self;
|
||||||
|
|
||||||
return self->to_int64();
|
return self->to_int();
|
||||||
}
|
}
|
||||||
|
|
||||||
double GDAPI godot_string_unicode_char_to_double(const wchar_t *p_str, const wchar_t **r_end) {
|
double GDAPI godot_string_unicode_char_to_double(const wchar_t *p_str, const wchar_t **r_end) {
|
||||||
|
@ -961,7 +961,7 @@ void GDScriptTokenizerText::_advance() {
|
|||||||
double val = str.to_double();
|
double val = str.to_double();
|
||||||
_make_constant(val);
|
_make_constant(val);
|
||||||
} else {
|
} else {
|
||||||
int64_t val = str.to_int64();
|
int64_t val = str.to_int();
|
||||||
_make_constant(val);
|
_make_constant(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user