From 25c978730bd6d09091ae0f148766f6833e6e1400 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Wed, 3 Jun 2020 00:04:04 -0400 Subject: [PATCH] Rename String bin_to_int64 to bin_to_int And also change String static to_int(const char *) to return int64_t --- core/ustring.cpp | 10 +++++----- core/ustring.h | 4 ++-- modules/gdscript/gdscript_tokenizer.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/ustring.cpp b/core/ustring.cpp index 698187cc293..884e7f25eb2 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -1660,7 +1660,7 @@ int64_t String::hex_to_int(bool p_with_prefix) const { return hex * sign; } -int64_t String::bin_to_int64(bool p_with_prefix) const { +int64_t String::bin_to_int(bool p_with_prefix) const { if (p_with_prefix && length() < 3) { return 0; } @@ -1725,7 +1725,7 @@ int64_t String::to_int() const { return integer * sign; } -int String::to_int(const char *p_str, int p_len) { +int64_t String::to_int(const char *p_str, int p_len) { int to = 0; if (p_len >= 0) { to = p_len; @@ -1735,13 +1735,13 @@ int String::to_int(const char *p_str, int p_len) { } } - int integer = 0; - int sign = 1; + int64_t integer = 0; + int64_t sign = 1; for (int i = 0; i < to; i++) { char c = p_str[i]; if (c >= '0' && c <= '9') { - ERR_FAIL_COND_V_MSG(integer > INT32_MAX / 10, sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + String(p_str).substr(0, to) + " as 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 " + String(p_str).substr(0, to) + " as an integer, provided value is " + (sign == 1 ? "too big." : "too small.")); integer *= 10; integer += c - '0'; diff --git a/core/ustring.h b/core/ustring.h index c48bca5552d..a86849b9325 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -247,9 +247,9 @@ public: float to_float() const; int64_t hex_to_int(bool p_with_prefix = true) const; - int64_t bin_to_int64(bool p_with_prefix = true) const; + int64_t bin_to_int(bool p_with_prefix = true) const; int64_t to_int() const; - static int to_int(const char *p_str, int p_len = -1); + static int64_t to_int(const char *p_str, int p_len = -1); static double to_double(const char *p_str); static double to_double(const CharType *p_str, const CharType **r_end = nullptr); static int64_t to_int(const CharType *p_str, int p_len = -1, bool p_clamp = false); diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp index f87b6367a47..82def3f877a 100644 --- a/modules/gdscript/gdscript_tokenizer.cpp +++ b/modules/gdscript/gdscript_tokenizer.cpp @@ -955,7 +955,7 @@ void GDScriptTokenizerText::_advance() { int64_t val = str.hex_to_int(); _make_constant(val); } else if (bin_found) { - int64_t val = str.bin_to_int64(); + int64_t val = str.bin_to_int(); _make_constant(val); } else if (period_found || exponent_found) { double val = str.to_double();