Merge pull request #12610 from karroffel/gdnative-api-fixes

[GDNative] small API bug fixes
This commit is contained in:
Rémi Verschelde 2017-11-03 21:02:58 +01:00 committed by GitHub
commit acd193b62e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 8 deletions

View File

@ -172,7 +172,7 @@ void GDAPI godot_basis_new_with_euler_quat(godot_basis *r_dest, const godot_quat
} }
// p_elements is a pointer to an array of 3 (!!) vector3 // p_elements is a pointer to an array of 3 (!!) vector3
void GDAPI godot_basis_get_elements(godot_basis *p_self, godot_vector3 *p_elements) { void GDAPI godot_basis_get_elements(const godot_basis *p_self, godot_vector3 *p_elements) {
const Basis *self = (const Basis *)p_self; const Basis *self = (const Basis *)p_self;
Vector3 *elements = (Vector3 *)p_elements; Vector3 *elements = (Vector3 *)p_elements;
elements[0] = self->elements[0]; elements[0] = self->elements[0];

View File

@ -65,11 +65,20 @@ void GDAPI godot_string_new_unicode_data(godot_string *r_dest, const wchar_t *p_
void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *p_size) { void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *p_size) {
String *self = (String *)p_self; String *self = (String *)p_self;
if (p_size != NULL) {
*p_size = self->utf8().length(); if (p_size) {
} // we have a length pointer, that means we either want to know
if (p_dest != NULL) { // the length or want to write *p_size bytes into a buffer
memcpy(p_dest, self->utf8().get_data(), *p_size);
CharString utf8_string = self->utf8();
int len = utf8_string.length();
if (p_dest) {
memcpy(p_dest, utf8_string.get_data(), *p_size);
} else {
*p_size = len;
}
} }
} }
@ -78,6 +87,11 @@ wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int
return &(self->operator[](p_idx)); return &(self->operator[](p_idx));
} }
wchar_t GDAPI godot_string_operator_index_const(const godot_string *p_self, const godot_int p_idx) {
const String *self = (const String *)p_self;
return self->operator[](p_idx);
}
const char GDAPI *godot_string_c_str(const godot_string *p_self) { const char GDAPI *godot_string_c_str(const godot_string *p_self) {
const String *self = (const String *)p_self; const String *self = (const String *)p_self;
return self->utf8().get_data(); return self->utf8().get_data();

View File

@ -847,7 +847,7 @@
"name": "godot_basis_get_elements", "name": "godot_basis_get_elements",
"return_type": "void", "return_type": "void",
"arguments": [ "arguments": [
["godot_basis *", "p_self"], ["const godot_basis *", "p_self"],
["godot_vector3 *", "p_elements"] ["godot_vector3 *", "p_elements"]
] ]
}, },
@ -3926,6 +3926,14 @@
["const godot_int", "p_idx"] ["const godot_int", "p_idx"]
] ]
}, },
{
"name": "godot_string_operator_index_const",
"return_type": "wchar_t",
"arguments": [
["const godot_string *", "p_self"],
["const godot_int", "p_idx"]
]
},
{ {
"name": "godot_string_c_str", "name": "godot_string_c_str",
"return_type": "const char *", "return_type": "const char *",

View File

@ -97,7 +97,7 @@ void GDAPI godot_basis_new(godot_basis *r_dest);
void GDAPI godot_basis_new_with_euler_quat(godot_basis *r_dest, const godot_quat *p_euler); void GDAPI godot_basis_new_with_euler_quat(godot_basis *r_dest, const godot_quat *p_euler);
// p_elements is a pointer to an array of 3 (!!) vector3 // p_elements is a pointer to an array of 3 (!!) vector3
void GDAPI godot_basis_get_elements(godot_basis *p_self, godot_vector3 *p_elements); void GDAPI godot_basis_get_elements(const godot_basis *p_self, godot_vector3 *p_elements);
godot_vector3 GDAPI godot_basis_get_axis(const godot_basis *p_self, const godot_int p_axis); godot_vector3 GDAPI godot_basis_get_axis(const godot_basis *p_self, const godot_int p_axis);

View File

@ -66,6 +66,7 @@ void GDAPI godot_string_new_unicode_data(godot_string *r_dest, const wchar_t *p_
void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *p_size); void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *p_size);
wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx); wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx);
wchar_t GDAPI godot_string_operator_index_const(const godot_string *p_self, const godot_int p_idx);
const char GDAPI *godot_string_c_str(const godot_string *p_self); const char GDAPI *godot_string_c_str(const godot_string *p_self);
const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_self); const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_self);