diff options
| author | Ignacio Etcheverry | 2018-02-22 13:13:51 +0100 |
|---|---|---|
| committer | Hein-Pieter van Braam | 2018-02-26 22:36:03 +0100 |
| commit | dde14e15c667d59f931bb8050b113fb564b578e4 (patch) | |
| tree | 115be9e387d582a136dd916b87494e83aa1f3cba /core | |
| parent | 1ea805a4aa47eac9d4bcc672b02f210416e86fe7 (diff) | |
| download | godot-dde14e15c667d59f931bb8050b113fb564b578e4.tar.gz godot-dde14e15c667d59f931bb8050b113fb564b578e4.tar.zst godot-dde14e15c667d59f931bb8050b113fb564b578e4.zip | |
Mono: Better versioning and gracefully unloading of Godot API assemblies
(cherry picked from commit f37090ccf4f699800a43878273b8b94b5906f4bc)
Diffstat (limited to 'core')
| -rw-r--r-- | core/ustring.cpp | 30 | ||||
| -rw-r--r-- | core/ustring.h | 1 |
2 files changed, 31 insertions, 0 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp index d445e4ed4..a7a781083 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -1135,6 +1135,36 @@ String String::num_int64(int64_t p_num, int base, bool capitalize_hex) { return s; } +String String::num_uint64(uint64_t p_num, int base, bool capitalize_hex) { + + uint64_t n = p_num; + + int chars = 0; + do { + n /= base; + chars++; + } while (n); + + String s; + s.resize(chars + 1); + CharType *c = s.ptrw(); + c[chars] = 0; + n = p_num; + do { + int mod = ABS(n % base); + if (mod >= 10) { + char a = (capitalize_hex ? 'A' : 'a'); + c[--chars] = a + (mod - 10); + } else { + c[--chars] = '0' + mod; + } + + n /= base; + } while (n); + + return s; +} + String String::num_real(double p_num) { String s; diff --git a/core/ustring.h b/core/ustring.h index 90496b71b..bb676ce62 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -146,6 +146,7 @@ public: static String num_scientific(double p_num); static String num_real(double p_num); static String num_int64(int64_t p_num, int base = 10, bool capitalize_hex = false); + static String num_uint64(uint64_t p_num, int base = 10, bool capitalize_hex = false); static String chr(CharType p_char); static String md5(const uint8_t *p_md5); static String hex_encode_buffer(const uint8_t *p_buffer, int p_len); |
