diff options
author | Karroffel <therzog@mail.de> | 2017-04-11 14:58:59 +0200 |
---|---|---|
committer | Karroffel <therzog@mail.de> | 2017-04-11 14:58:59 +0200 |
commit | be2ad4f155de085716cf98c629b44583b6896492 (patch) | |
tree | 71f7a4bd6d1e387cf6d78720627819b7d993b2df /modules | |
parent | 09ed1113fa78d31c72341c2b3550e554e728b1f3 (diff) |
[GDNative] made string functions more C-friendly
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdnative/godot/godot_string.cpp | 10 | ||||
-rw-r--r-- | modules/gdnative/godot/godot_string.h | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/modules/gdnative/godot/godot_string.cpp b/modules/gdnative/godot/godot_string.cpp index 2a78b2c96f..757b8510cf 100644 --- a/modules/gdnative/godot/godot_string.cpp +++ b/modules/gdnative/godot/godot_string.cpp @@ -53,13 +53,13 @@ void GDAPI godot_string_new_data(godot_string *p_str, const char *p_contents, co *p = String::utf8(p_contents, p_size); } -void GDAPI godot_string_get_data(const godot_string *p_str, wchar_t *p_dest, int *p_size) { +void GDAPI godot_string_get_data(const godot_string *p_str, char *p_dest, int *p_size) { String *p = (String *)p_str; if (p_size != NULL) { - *p_size = p->length(); + *p_size = p->utf8().length(); } if (p_dest != NULL) { - memcpy(p_dest, p->ptr(), *p_size * sizeof(CharType)); + memcpy(p_dest, p->utf8().get_data(), *p_size); } } @@ -75,9 +75,9 @@ wchar_t GDAPI *godot_string_operator_index(godot_string *p_str, const godot_int return &(s->operator[](p_idx)); } -const wchar_t GDAPI *godot_string_c_str(const godot_string *p_str) { +const char GDAPI *godot_string_c_str(const godot_string *p_str) { const String *s = (const String *)p_str; - return s->c_str(); + return s->utf8().get_data(); } godot_bool GDAPI godot_string_operator_equal(const godot_string *p_a, const godot_string *p_b) { diff --git a/modules/gdnative/godot/godot_string.h b/modules/gdnative/godot/godot_string.h index 7cde482cce..9289531c5e 100644 --- a/modules/gdnative/godot/godot_string.h +++ b/modules/gdnative/godot/godot_string.h @@ -47,12 +47,12 @@ typedef struct godot_string { void GDAPI godot_string_new(godot_string *p_str); void GDAPI godot_string_new_data(godot_string *p_str, const char *p_contents, const int p_size); -void GDAPI godot_string_get_data(const godot_string *p_str, wchar_t *p_dest, int *p_size); +void GDAPI godot_string_get_data(const godot_string *p_str, char *p_dest, int *p_size); void GDAPI godot_string_copy_string(const godot_string *p_dest, const godot_string *p_src); wchar_t GDAPI *godot_string_operator_index(godot_string *p_str, const godot_int p_idx); -const wchar_t GDAPI *godot_string_c_str(const godot_string *p_str); +const char GDAPI *godot_string_c_str(const godot_string *p_str); godot_bool GDAPI godot_string_operator_equal(const godot_string *p_a, const godot_string *p_b); godot_bool GDAPI godot_string_operator_less(const godot_string *p_a, const godot_string *p_b); |