1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Refactored binding system for core types

Moved to a system using variadic templates, shared with CallableBind.

New code is cleaner, faster and allows for much better optimization of core
type functions from GDScript and GDNative.

Added Variant::InternalMethod function for direct call access.
This commit is contained in:
reduz
2020-10-13 15:59:37 -03:00
committed by Juan Linietsky
parent bc91e088e4
commit b8c64184c6
15 changed files with 2229 additions and 1611 deletions

View File

@@ -4732,6 +4732,69 @@ String String::unquote() const {
return substr(1, length() - 2);
}
Vector<uint8_t> String::to_ascii_buffer() const {
const String *s = this;
if (s->empty()) {
return Vector<uint8_t>();
}
CharString charstr = s->ascii();
Vector<uint8_t> retval;
size_t len = charstr.length();
retval.resize(len);
uint8_t *w = retval.ptrw();
copymem(w, charstr.ptr(), len);
return retval;
}
Vector<uint8_t> String::to_utf8_buffer() const {
const String *s = this;
if (s->empty()) {
return Vector<uint8_t>();
}
CharString charstr = s->utf8();
Vector<uint8_t> retval;
size_t len = charstr.length();
retval.resize(len);
uint8_t *w = retval.ptrw();
copymem(w, charstr.ptr(), len);
return retval;
}
Vector<uint8_t> String::to_utf16_buffer() const {
const String *s = this;
if (s->empty()) {
return Vector<uint8_t>();
}
Char16String charstr = s->utf16();
Vector<uint8_t> retval;
size_t len = charstr.length() * 2;
retval.resize(len);
uint8_t *w = retval.ptrw();
copymem(w, (const void *)charstr.ptr(), len);
return retval;
}
Vector<uint8_t> String::to_utf32_buffer() const {
const String *s = this;
if (s->empty()) {
return Vector<uint8_t>();
}
Vector<uint8_t> retval;
size_t len = s->length() * 4;
retval.resize(len);
uint8_t *w = retval.ptrw();
copymem(w, (const void *)s->ptr(), len);
return retval;
}
#ifdef TOOLS_ENABLED
String TTR(const String &p_text, const String &p_context) {
if (TranslationServer::get_singleton()) {