Rename String bin_to_int64 to bin_to_int

And also change String static to_int(const char *) to return int64_t
This commit is contained in:
Aaron Franke 2020-06-03 00:04:04 -04:00
parent e5ae89775a
commit 25c978730b
No known key found for this signature in database
GPG key ID: 40A1750B977E56BF
3 changed files with 8 additions and 8 deletions

View file

@ -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';

View file

@ -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);

View file

@ -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();