From 8fddab9209e0c68fac3cd9da1ebf7c3ebd7ad9d5 Mon Sep 17 00:00:00 2001 From: George Marques Date: Thu, 25 Feb 2021 19:50:56 -0300 Subject: [PATCH 1/2] Further changes in GDNative API - Added new_copy to all types, since trivial copy won't work for all types. - Added functions to convert from String to char array types, which is not provided by the methods bound in Variant. - Added operator index to String. - Added missing cstring version of some Variant functions. They existed in the header but didn't have the implementation and were missing from the gdnative_api.json file. - Added support for static calls on Variant types. --- modules/gdnative/gdnative/aabb.cpp | 4 + modules/gdnative/gdnative/array.cpp | 4 + modules/gdnative/gdnative/basis.cpp | 4 + modules/gdnative/gdnative/callable.cpp | 4 + modules/gdnative/gdnative/color.cpp | 4 + modules/gdnative/gdnative/dictionary.cpp | 4 + modules/gdnative/gdnative/node_path.cpp | 4 + modules/gdnative/gdnative/packed_arrays.cpp | 44 ++ modules/gdnative/gdnative/plane.cpp | 4 + modules/gdnative/gdnative/quat.cpp | 4 + modules/gdnative/gdnative/rect2.cpp | 8 + modules/gdnative/gdnative/rid.cpp | 4 + modules/gdnative/gdnative/signal.cpp | 4 + modules/gdnative/gdnative/string.cpp | 44 +- modules/gdnative/gdnative/string_name.cpp | 4 +- modules/gdnative/gdnative/transform.cpp | 4 + modules/gdnative/gdnative/transform2d.cpp | 4 + modules/gdnative/gdnative/variant.cpp | 81 ++- modules/gdnative/gdnative/vector2.cpp | 8 + modules/gdnative/gdnative/vector3.cpp | 8 + modules/gdnative/gdnative_api.json | 598 +++++++++++++++++- modules/gdnative/include/gdnative/aabb.h | 1 + modules/gdnative/include/gdnative/array.h | 1 + modules/gdnative/include/gdnative/basis.h | 1 + modules/gdnative/include/gdnative/callable.h | 1 + modules/gdnative/include/gdnative/color.h | 1 + .../gdnative/include/gdnative/dictionary.h | 1 + modules/gdnative/include/gdnative/node_path.h | 1 + .../gdnative/include/gdnative/packed_arrays.h | 11 + modules/gdnative/include/gdnative/plane.h | 1 + modules/gdnative/include/gdnative/quat.h | 1 + modules/gdnative/include/gdnative/rect2.h | 2 + modules/gdnative/include/gdnative/rid.h | 1 + modules/gdnative/include/gdnative/signal.h | 1 + modules/gdnative/include/gdnative/string.h | 10 + modules/gdnative/include/gdnative/transform.h | 1 + .../gdnative/include/gdnative/transform2d.h | 1 + modules/gdnative/include/gdnative/variant.h | 4 + modules/gdnative/include/gdnative/vector2.h | 2 + modules/gdnative/include/gdnative/vector3.h | 2 + 40 files changed, 880 insertions(+), 11 deletions(-) diff --git a/modules/gdnative/gdnative/aabb.cpp b/modules/gdnative/gdnative/aabb.cpp index 5d3f224adcc..c42b874b4b2 100644 --- a/modules/gdnative/gdnative/aabb.cpp +++ b/modules/gdnative/gdnative/aabb.cpp @@ -42,6 +42,10 @@ void GDAPI godot_aabb_new(godot_aabb *p_self) { memnew_placement(p_self, AABB); } +void GDAPI godot_aabb_new_copy(godot_aabb *r_dest, const godot_aabb *p_src) { + memnew_placement(r_dest, AABB(*(AABB *)p_src)); +} + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/gdnative/array.cpp b/modules/gdnative/gdnative/array.cpp index e68b60c5e66..76e131dc06e 100644 --- a/modules/gdnative/gdnative/array.cpp +++ b/modules/gdnative/gdnative/array.cpp @@ -43,6 +43,10 @@ void GDAPI godot_array_new(godot_array *p_self) { memnew_placement(p_self, Array); } +void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src) { + memnew_placement(r_dest, Array(*(Array *)p_src)); +} + void GDAPI godot_array_destroy(godot_array *p_self) { ((Array *)p_self)->~Array(); } diff --git a/modules/gdnative/gdnative/basis.cpp b/modules/gdnative/gdnative/basis.cpp index df3e1255ac0..4641f0bacce 100644 --- a/modules/gdnative/gdnative/basis.cpp +++ b/modules/gdnative/gdnative/basis.cpp @@ -42,6 +42,10 @@ void GDAPI godot_basis_new(godot_basis *p_self) { memnew_placement(p_self, Basis); } +void GDAPI godot_basis_new_copy(godot_basis *r_dest, const godot_basis *p_src) { + memnew_placement(r_dest, Basis(*(Basis *)p_src)); +} + godot_vector3 GDAPI *godot_basis_operator_index(godot_basis *p_self, godot_int p_index) { Basis *self = (Basis *)p_self; return (godot_vector3 *)&self->operator[](p_index); diff --git a/modules/gdnative/gdnative/callable.cpp b/modules/gdnative/gdnative/callable.cpp index 7c62b5928ff..85274e5e22b 100644 --- a/modules/gdnative/gdnative/callable.cpp +++ b/modules/gdnative/gdnative/callable.cpp @@ -43,6 +43,10 @@ void GDAPI godot_callable_new(godot_callable *p_self) { memnew_placement(p_self, Callable); } +void GDAPI godot_callable_new_copy(godot_callable *r_dest, const godot_callable *p_src) { + memnew_placement(r_dest, Callable(*(Callable *)p_src)); +} + void GDAPI godot_callable_destroy(godot_callable *p_self) { Callable *self = (Callable *)p_self; self->~Callable(); diff --git a/modules/gdnative/gdnative/color.cpp b/modules/gdnative/gdnative/color.cpp index 12a800d333e..502f89c027b 100644 --- a/modules/gdnative/gdnative/color.cpp +++ b/modules/gdnative/gdnative/color.cpp @@ -42,6 +42,10 @@ void GDAPI godot_color_new(godot_color *p_self) { memnew_placement(p_self, Color); } +void GDAPI godot_color_new_copy(godot_color *r_dest, const godot_color *p_src) { + memnew_placement(r_dest, Color(*(Color *)p_src)); +} + float GDAPI *godot_color_operator_index(godot_color *p_self, godot_int p_index) { Color *self = (Color *)p_self; return (float *)&self->operator[](p_index); diff --git a/modules/gdnative/gdnative/dictionary.cpp b/modules/gdnative/gdnative/dictionary.cpp index 9fa4a27a839..2bfad6e6955 100644 --- a/modules/gdnative/gdnative/dictionary.cpp +++ b/modules/gdnative/gdnative/dictionary.cpp @@ -43,6 +43,10 @@ void GDAPI godot_dictionary_new(godot_dictionary *p_self) { memnew_placement(p_self, Dictionary); } +void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src) { + memnew_placement(r_dest, Dictionary(*(Dictionary *)p_src)); +} + void GDAPI godot_dictionary_destroy(godot_dictionary *p_self) { Dictionary *self = (Dictionary *)p_self; self->~Dictionary(); diff --git a/modules/gdnative/gdnative/node_path.cpp b/modules/gdnative/gdnative/node_path.cpp index 02c2f9b22b9..57d67b9abbf 100644 --- a/modules/gdnative/gdnative/node_path.cpp +++ b/modules/gdnative/gdnative/node_path.cpp @@ -42,6 +42,10 @@ void GDAPI godot_node_path_new(godot_node_path *p_self) { memnew_placement(p_self, NodePath); } +void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src) { + memnew_placement(r_dest, NodePath(*(NodePath *)p_src)); +} + void GDAPI godot_node_path_destroy(godot_node_path *p_self) { NodePath *self = (NodePath *)p_self; self->~NodePath(); diff --git a/modules/gdnative/gdnative/packed_arrays.cpp b/modules/gdnative/gdnative/packed_arrays.cpp index 63a2425b877..396109e5763 100644 --- a/modules/gdnative/gdnative/packed_arrays.cpp +++ b/modules/gdnative/gdnative/packed_arrays.cpp @@ -59,6 +59,10 @@ void GDAPI godot_packed_byte_array_new(godot_packed_byte_array *p_self) { memnew_placement(p_self, PackedByteArray); } +void GDAPI godot_packed_byte_array_new_copy(godot_packed_byte_array *r_dest, const godot_packed_byte_array *p_src) { + memnew_placement(r_dest, PackedByteArray(*(PackedByteArray *)p_src)); +} + void GDAPI godot_packed_byte_array_destroy(godot_packed_byte_array *p_self) { ((PackedByteArray *)p_self)->~PackedByteArray(); } @@ -79,6 +83,10 @@ void GDAPI godot_packed_int32_array_new(godot_packed_int32_array *p_self) { memnew_placement(p_self, PackedInt32Array); } +void GDAPI godot_packed_int32_array_new_copy(godot_packed_int32_array *r_dest, const godot_packed_int32_array *p_src) { + memnew_placement(r_dest, PackedInt32Array(*(PackedInt32Array *)p_src)); +} + void GDAPI godot_packed_int32_array_destroy(godot_packed_int32_array *p_self) { ((PackedInt32Array *)p_self)->~PackedInt32Array(); } @@ -99,6 +107,10 @@ void GDAPI godot_packed_int64_array_new(godot_packed_int64_array *p_self) { memnew_placement(p_self, PackedInt64Array); } +void GDAPI godot_packed_int64_array_new_copy(godot_packed_int64_array *r_dest, const godot_packed_int64_array *p_src) { + memnew_placement(r_dest, PackedInt64Array(*(PackedInt64Array *)p_src)); +} + void GDAPI godot_packed_int64_array_destroy(godot_packed_int64_array *p_self) { ((PackedInt64Array *)p_self)->~PackedInt64Array(); } @@ -119,6 +131,10 @@ void GDAPI godot_packed_float32_array_new(godot_packed_float32_array *p_self) { memnew_placement(p_self, PackedFloat32Array); } +void GDAPI godot_packed_float32_array_new_copy(godot_packed_float32_array *r_dest, const godot_packed_float32_array *p_src) { + memnew_placement(r_dest, PackedFloat32Array(*(PackedFloat32Array *)p_src)); +} + void GDAPI godot_packed_float32_array_destroy(godot_packed_float32_array *p_self) { ((PackedFloat32Array *)p_self)->~PackedFloat32Array(); } @@ -139,6 +155,10 @@ void GDAPI godot_packed_float64_array_new(godot_packed_float64_array *p_self) { memnew_placement(p_self, PackedFloat64Array); } +void GDAPI godot_packed_float64_array_new_copy(godot_packed_float64_array *r_dest, const godot_packed_float64_array *p_src) { + memnew_placement(r_dest, PackedFloat64Array(*(PackedFloat64Array *)p_src)); +} + void GDAPI godot_packed_float64_array_destroy(godot_packed_float64_array *p_self) { ((PackedFloat64Array *)p_self)->~PackedFloat64Array(); } @@ -159,6 +179,10 @@ void GDAPI godot_packed_string_array_new(godot_packed_string_array *p_self) { memnew_placement(p_self, PackedStringArray); } +void GDAPI godot_packed_string_array_new_copy(godot_packed_string_array *r_dest, const godot_packed_string_array *p_src) { + memnew_placement(r_dest, PackedStringArray(*(PackedStringArray *)p_src)); +} + void GDAPI godot_packed_string_array_destroy(godot_packed_string_array *p_self) { ((PackedStringArray *)p_self)->~PackedStringArray(); } @@ -179,6 +203,10 @@ void GDAPI godot_packed_vector2_array_new(godot_packed_vector2_array *p_self) { memnew_placement(p_self, PackedVector2Array); } +void GDAPI godot_packed_vector2_array_new_copy(godot_packed_vector2_array *r_dest, const godot_packed_vector2_array *p_src) { + memnew_placement(r_dest, PackedVector2Array(*(PackedVector2Array *)p_src)); +} + void GDAPI godot_packed_vector2_array_destroy(godot_packed_vector2_array *p_self) { ((PackedVector2Array *)p_self)->~PackedVector2Array(); } @@ -199,6 +227,10 @@ void GDAPI godot_packed_vector2i_array_new(godot_packed_vector2i_array *p_self) memnew_placement(p_self, Vector); } +void GDAPI godot_packed_vector2i_array_new_copy(godot_packed_vector2i_array *r_dest, const godot_packed_vector2i_array *p_src) { + memnew_placement(r_dest, Vector(*(Vector *)p_src)); +} + void GDAPI godot_packed_vector2i_array_destroy(godot_packed_vector2i_array *p_self) { ((Vector *)p_self)->~Vector(); } @@ -219,6 +251,10 @@ void GDAPI godot_packed_vector3_array_new(godot_packed_vector3_array *p_self) { memnew_placement(p_self, PackedVector3Array); } +void GDAPI godot_packed_vector3_array_new_copy(godot_packed_vector3_array *r_dest, const godot_packed_vector3_array *p_src) { + memnew_placement(r_dest, PackedVector3Array(*(PackedVector3Array *)p_src)); +} + void GDAPI godot_packed_vector3_array_destroy(godot_packed_vector3_array *p_self) { ((PackedVector3Array *)p_self)->~PackedVector3Array(); } @@ -239,6 +275,10 @@ void GDAPI godot_packed_vector3i_array_new(godot_packed_vector3i_array *p_self) memnew_placement(p_self, Vector); } +void GDAPI godot_packed_vector3i_array_new_copy(godot_packed_vector3i_array *r_dest, const godot_packed_vector3i_array *p_src) { + memnew_placement(r_dest, Vector(*(Vector *)p_src)); +} + void GDAPI godot_packed_vector3i_array_destroy(godot_packed_vector3i_array *p_self) { ((Vector *)p_self)->~Vector(); } @@ -259,6 +299,10 @@ void GDAPI godot_packed_color_array_new(godot_packed_color_array *p_self) { memnew_placement(p_self, PackedColorArray); } +void GDAPI godot_packed_color_array_new_copy(godot_packed_color_array *r_dest, const godot_packed_color_array *p_src) { + memnew_placement(r_dest, PackedColorArray(*(PackedColorArray *)p_src)); +} + void GDAPI godot_packed_color_array_destroy(godot_packed_color_array *p_self) { ((PackedColorArray *)p_self)->~PackedColorArray(); } diff --git a/modules/gdnative/gdnative/plane.cpp b/modules/gdnative/gdnative/plane.cpp index 61d5e09fad1..8b8e84e3c11 100644 --- a/modules/gdnative/gdnative/plane.cpp +++ b/modules/gdnative/gdnative/plane.cpp @@ -42,6 +42,10 @@ void GDAPI godot_plane_new(godot_plane *p_self) { memnew_placement(p_self, Plane); } +void GDAPI godot_plane_new_copy(godot_plane *r_dest, const godot_plane *p_src) { + memnew_placement(r_dest, Plane(*(Plane *)p_src)); +} + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/gdnative/quat.cpp b/modules/gdnative/gdnative/quat.cpp index 836d6390d6b..8ebcf7c91f0 100644 --- a/modules/gdnative/gdnative/quat.cpp +++ b/modules/gdnative/gdnative/quat.cpp @@ -42,6 +42,10 @@ void GDAPI godot_quat_new(godot_quat *p_self) { memnew_placement(p_self, Quat); } +void GDAPI godot_quat_new_copy(godot_quat *r_dest, const godot_quat *p_src) { + memnew_placement(r_dest, Quat(*(Quat *)p_src)); +} + godot_real_t GDAPI *godot_quat_operator_index(godot_quat *p_self, godot_int p_index) { Quat *self = (Quat *)p_self; return (godot_real_t *)&self->operator[](p_index); diff --git a/modules/gdnative/gdnative/rect2.cpp b/modules/gdnative/gdnative/rect2.cpp index 086592ec225..a196a63188b 100644 --- a/modules/gdnative/gdnative/rect2.cpp +++ b/modules/gdnative/gdnative/rect2.cpp @@ -43,10 +43,18 @@ void GDAPI godot_rect2_new(godot_rect2 *p_self) { memnew_placement(p_self, Rect2); } +void GDAPI godot_rect2_new_copy(godot_rect2 *r_dest, const godot_rect2 *p_src) { + memnew_placement(r_dest, Rect2(*(Rect2 *)p_src)); +} + void GDAPI godot_rect2i_new(godot_rect2i *p_self) { memnew_placement(p_self, Rect2i); } +void GDAPI godot_rect2i_new_copy(godot_rect2i *r_dest, const godot_rect2i *p_src) { + memnew_placement(r_dest, Rect2i(*(Rect2i *)p_src)); +} + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/gdnative/rid.cpp b/modules/gdnative/gdnative/rid.cpp index 5cab9a21ed5..f8599afcf99 100644 --- a/modules/gdnative/gdnative/rid.cpp +++ b/modules/gdnative/gdnative/rid.cpp @@ -43,6 +43,10 @@ void GDAPI godot_rid_new(godot_rid *p_self) { memnew_placement(p_self, RID); } +void GDAPI godot_rid_new_copy(godot_rid *r_dest, const godot_rid *p_src) { + memnew_placement(r_dest, RID(*(RID *)p_src)); +} + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/gdnative/signal.cpp b/modules/gdnative/gdnative/signal.cpp index bcb4c93b626..5963c0e6c69 100644 --- a/modules/gdnative/gdnative/signal.cpp +++ b/modules/gdnative/gdnative/signal.cpp @@ -43,6 +43,10 @@ void GDAPI godot_signal_new(godot_signal *p_self) { memnew_placement(p_self, Signal); } +void GDAPI godot_signal_new_copy(godot_signal *r_dest, const godot_signal *p_src) { + memnew_placement(r_dest, Signal(*(Signal *)p_src)); +} + void GDAPI godot_signal_destroy(godot_signal *p_self) { Signal *self = (Signal *)p_self; self->~Signal(); diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp index 19d95f20489..1ad1ea8bdf7 100644 --- a/modules/gdnative/gdnative/string.cpp +++ b/modules/gdnative/gdnative/string.cpp @@ -45,10 +45,7 @@ void GDAPI godot_string_new(godot_string *r_dest) { } void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src) { - String *dest = (String *)r_dest; - const String *src = (const String *)p_src; - memnew_placement(dest, String); - *dest = String(*src); + memnew_placement(r_dest, String(*(String *)p_src)); } void GDAPI godot_string_new_with_latin1_chars(godot_string *r_dest, const char *p_contents) { @@ -125,6 +122,45 @@ void GDAPI godot_string_new_with_wide_chars_and_len(godot_string *r_dest, const } } +const char GDAPI *godot_string_to_latin1_chars(const godot_string *p_self) { + String *self = (String *)p_self; + return self->ascii(true).get_data(); +} + +const char GDAPI *godot_string_to_utf8_chars(const godot_string *p_self) { + String *self = (String *)p_self; + return self->utf8().get_data(); +} + +const char16_t GDAPI *godot_string_to_utf16_chars(const godot_string *p_self) { + String *self = (String *)p_self; + return self->utf16().get_data(); +} + +const char32_t GDAPI *godot_string_to_utf32_chars(const godot_string *p_self) { + String *self = (String *)p_self; + return self->get_data(); +} + +const wchar_t GDAPI *godot_string_to_wide_chars(const godot_string *p_self) { + String *self = (String *)p_self; + if (sizeof(wchar_t) == 2) { + return (const wchar_t *)self->utf16().get_data(); + } else { + return (const wchar_t *)self->get_data(); + } +} + +char32_t GDAPI *godot_string_operator_index(godot_string *p_self, godot_int p_index) { + String *self = (String *)p_self; + return self->ptrw(); +} + +const char32_t GDAPI *godot_string_operator_index_const(const godot_string *p_self, godot_int p_index) { + const String *self = (const String *)p_self; + return self->ptr(); +} + void GDAPI godot_string_destroy(godot_string *p_self) { String *self = (String *)p_self; self->~String(); diff --git a/modules/gdnative/gdnative/string_name.cpp b/modules/gdnative/gdnative/string_name.cpp index c9d2dd5bc3c..bd8f69674e1 100644 --- a/modules/gdnative/gdnative/string_name.cpp +++ b/modules/gdnative/gdnative/string_name.cpp @@ -44,9 +44,7 @@ void GDAPI godot_string_name_new(godot_string_name *r_dest) { } void GDAPI godot_string_name_new_copy(godot_string_name *r_dest, const godot_string_name *p_src) { - StringName *dest = (StringName *)r_dest; - const StringName *src = (const StringName *)p_src; - memnew_placement(dest, StringName(*src)); + memnew_placement(r_dest, StringName(*(StringName *)p_src)); } void GDAPI godot_string_name_new_with_latin1_chars(godot_string_name *r_dest, const char *p_contents) { diff --git a/modules/gdnative/gdnative/transform.cpp b/modules/gdnative/gdnative/transform.cpp index eae981bd07b..bfaaa13db2b 100644 --- a/modules/gdnative/gdnative/transform.cpp +++ b/modules/gdnative/gdnative/transform.cpp @@ -42,6 +42,10 @@ void GDAPI godot_transform_new(godot_transform *p_self) { memnew_placement(p_self, Transform); } +void GDAPI godot_transform_new_copy(godot_transform *r_dest, const godot_transform *p_src) { + memnew_placement(r_dest, Transform(*(Transform *)p_src)); +} + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/gdnative/transform2d.cpp b/modules/gdnative/gdnative/transform2d.cpp index 679174d5a50..2864818831b 100644 --- a/modules/gdnative/gdnative/transform2d.cpp +++ b/modules/gdnative/gdnative/transform2d.cpp @@ -42,6 +42,10 @@ void GDAPI godot_transform2d_new(godot_transform2d *p_self) { memnew_placement(p_self, Transform2D); } +void GDAPI godot_transform2d_new_copy(godot_transform2d *r_dest, const godot_transform2d *p_src) { + memnew_placement(r_dest, Transform2D(*(Transform2D *)p_src)); +} + godot_vector2 GDAPI *godot_transform2d_operator_index(godot_transform2d *p_self, godot_int p_index) { Transform2D *self = (Transform2D *)p_self; return (godot_vector2 *)&self->operator[](p_index); diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp index ee4353bb48a..1dc3c905bdb 100644 --- a/modules/gdnative/gdnative/variant.cpp +++ b/modules/gdnative/gdnative/variant.cpp @@ -577,6 +577,54 @@ void GDAPI godot_variant_call(godot_variant *p_self, const godot_string_name *p_ } } +void GDAPI godot_variant_call_with_cstring(godot_variant *p_self, const char *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant *r_return, godot_variant_call_error *r_error) { + Variant *self = (Variant *)p_self; + const StringName method(p_method); + const Variant **args = (const Variant **)p_args; + Variant ret; + Callable::CallError error; + self->call(method, args, p_argcount, ret, error); + memnew_placement_custom(r_return, Variant, Variant(ret)); + + if (r_error) { + r_error->error = (godot_variant_call_error_error)error.error; + r_error->argument = error.argument; + r_error->expected = (godot_variant_type)error.expected; + } +} + +void GDAPI godot_variant_call_static(godot_variant_type p_type, const godot_string_name *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant *r_return, godot_variant_call_error *r_error) { + Variant::Type type = (Variant::Type)p_type; + const StringName *method = (const StringName *)p_method; + const Variant **args = (const Variant **)p_args; + Variant ret; + Callable::CallError error; + Variant().call_static(type, *method, args, p_argcount, ret, error); + memnew_placement_custom(r_return, Variant, Variant(ret)); + + if (r_error) { + r_error->error = (godot_variant_call_error_error)error.error; + r_error->argument = error.argument; + r_error->expected = (godot_variant_type)error.expected; + } +} + +void GDAPI godot_variant_call_static_with_cstring(godot_variant_type p_type, const char *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant *r_return, godot_variant_call_error *r_error) { + Variant::Type type = (Variant::Type)p_type; + const StringName method(p_method); + const Variant **args = (const Variant **)p_args; + Variant ret; + Callable::CallError error; + Variant().call_static(type, method, args, p_argcount, ret, error); + memnew_placement_custom(r_return, Variant, Variant(ret)); + + if (r_error) { + r_error->error = (godot_variant_call_error_error)error.error; + r_error->argument = error.argument; + r_error->expected = (godot_variant_type)error.expected; + } +} + void GDAPI godot_variant_evaluate(godot_variant_operator p_op, const godot_variant *p_a, const godot_variant *p_b, godot_variant *r_return, bool *r_valid) { Variant::Operator op = (Variant::Operator)p_op; const Variant *a = (const Variant *)p_a; @@ -593,12 +641,20 @@ void GDAPI godot_variant_set(godot_variant *p_self, const godot_variant *p_key, self->set(*key, *value, r_valid); } -void GDAPI godot_variant_set_named(godot_variant *p_self, const godot_string_name *p_name, const godot_variant *p_value, bool *r_valid) { +void GDAPI godot_variant_set_named(godot_variant *p_self, const godot_string_name *p_key, const godot_variant *p_value, bool *r_valid) { Variant *self = (Variant *)p_self; - const StringName *name = (const StringName *)p_name; + const StringName *key = (const StringName *)p_key; const Variant *value = (const Variant *)p_value; - self->set_named(*name, *value, *r_valid); + self->set_named(*key, *value, *r_valid); +} + +void GDAPI godot_variant_set_named_with_cstring(godot_variant *p_self, const char *p_key, const godot_variant *p_value, bool *r_valid) { + Variant *self = (Variant *)p_self; + const StringName key(p_key); + const Variant *value = (const Variant *)p_value; + + self->set_named(key, *value, *r_valid); } void GDAPI godot_variant_set_keyed(godot_variant *p_self, const godot_variant *p_key, const godot_variant *p_value, bool *r_valid) { @@ -638,6 +694,17 @@ godot_variant GDAPI godot_variant_get_named(const godot_variant *p_self, const g return result; } +godot_variant GDAPI godot_variant_get_named_with_cstring(const godot_variant *p_self, const char *p_key, bool *r_valid) { + const Variant *self = (const Variant *)p_self; + const StringName *key = (const StringName *)p_key; + Variant ret; + + ret = self->get_named(*key, *r_valid); + godot_variant result; + memnew_placement_custom(&result, Variant, Variant(ret)); + return result; +} + godot_variant GDAPI godot_variant_get_keyed(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid) { const Variant *self = (const Variant *)p_self; const Variant *key = (const Variant *)p_key; @@ -824,6 +891,14 @@ bool GDAPI godot_variant_is_builtin_method_const_with_cstring(godot_variant_type return Variant::is_builtin_method_const((Variant::Type)p_type, StringName(p_method)); } +bool GDAPI godot_variant_is_builtin_method_static(godot_variant_type p_type, const godot_string_name *p_method) { + return Variant::is_builtin_method_static((Variant::Type)p_type, *((const StringName *)p_method)); +} + +bool GDAPI godot_variant_is_builtin_method_static_with_cstring(godot_variant_type p_type, const char *p_method) { + return Variant::is_builtin_method_static((Variant::Type)p_type, StringName(p_method)); +} + bool GDAPI godot_variant_is_builtin_method_vararg(godot_variant_type p_type, const godot_string_name *p_method) { return Variant::is_builtin_method_vararg((Variant::Type)p_type, *((const StringName *)p_method)); } diff --git a/modules/gdnative/gdnative/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp index ebb19966496..6a01a7ad596 100644 --- a/modules/gdnative/gdnative/vector2.cpp +++ b/modules/gdnative/gdnative/vector2.cpp @@ -43,10 +43,18 @@ void GDAPI godot_vector2_new(godot_vector2 *p_self) { memnew_placement(p_self, Vector2); } +void GDAPI godot_vector2_new_copy(godot_vector2 *r_dest, const godot_vector2 *p_src) { + memnew_placement(r_dest, Vector2(*(Vector2 *)p_src)); +} + void GDAPI godot_vector2i_new(godot_vector2i *p_self) { memnew_placement(p_self, Vector2i); } +void GDAPI godot_vector2i_new_copy(godot_vector2i *r_dest, const godot_vector2i *p_src) { + memnew_placement(r_dest, Vector2i(*(Vector2i *)p_src)); +} + godot_real_t GDAPI *godot_vector2_operator_index(godot_vector2 *p_self, godot_int p_index) { Vector2 *self = (Vector2 *)p_self; return (godot_real_t *)&self->operator[](p_index); diff --git a/modules/gdnative/gdnative/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp index 0fe1b292a73..fb426c8ac4f 100644 --- a/modules/gdnative/gdnative/vector3.cpp +++ b/modules/gdnative/gdnative/vector3.cpp @@ -43,10 +43,18 @@ void GDAPI godot_vector3_new(godot_vector3 *p_self) { memnew_placement(p_self, Vector3); } +void GDAPI godot_vector3_new_copy(godot_vector3 *r_dest, const godot_vector3 *p_src) { + memnew_placement(r_dest, Vector3(*(Vector3 *)p_src)); +} + void GDAPI godot_vector3i_new(godot_vector3i *p_self) { memnew_placement(p_self, Vector3i); } +void GDAPI godot_vector3i_new_copy(godot_vector3i *r_dest, const godot_vector3i *p_src) { + memnew_placement(r_dest, Vector3i(*(Vector3i *)p_src)); +} + godot_real_t GDAPI *godot_vector3_operator_index(godot_vector3 *p_self, godot_int p_index) { Vector3 *self = (Vector3 *)p_self; return (godot_real_t *)&self->operator[](p_index); diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index c163fbbc1b4..59b078f2b69 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -1142,6 +1142,36 @@ ] ] }, + { + "name": "godot_variant_call_with_cstring", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "p_self" + ], + [ + "const char *", + "p_method" + ], + [ + "const godot_variant **", + "p_args" + ], + [ + "const godot_int", + "p_argument_count" + ], + [ + "godot_variant *", + "r_return" + ], + [ + "godot_variant_call_error *", + "r_error" + ] + ] + }, { "name": "godot_variant_evaluate", "return_type": "void", @@ -1200,7 +1230,29 @@ ], [ "const godot_string_name *", - "p_name" + "p_key" + ], + [ + "const godot_variant *", + "p_value" + ], + [ + "bool *", + "r_valid" + ] + ] + }, + { + "name": "godot_variant_set_named_with_cstring", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "p_self" + ], + [ + "const char *", + "p_key" ], [ "const godot_variant *", @@ -1296,6 +1348,24 @@ ] ] }, + { + "name": "godot_variant_get_named_with_cstring", + "return_type": "godot_variant", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ], + [ + "const char *", + "p_key" + ], + [ + "bool *", + "r_valid" + ] + ] + }, { "name": "godot_variant_get_keyed", "return_type": "godot_variant", @@ -1814,6 +1884,34 @@ ] ] }, + { + "name": "godot_variant_is_builtin_method_static", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_is_builtin_method_static_with_cstring", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_method" + ] + ] + }, { "name": "godot_variant_is_builtin_method_vararg", "return_type": "bool", @@ -2751,6 +2849,20 @@ ] ] }, + { + "name": "godot_aabb_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_aabb *", + "r_dest" + ], + [ + "const godot_aabb *", + "p_src" + ] + ] + }, { "name": "godot_array_new", "return_type": "void", @@ -2761,6 +2873,20 @@ ] ] }, + { + "name": "godot_array_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_array *", + "r_dest" + ], + [ + "const godot_array *", + "p_src" + ] + ] + }, { "name": "godot_array_destroy", "return_type": "void", @@ -2809,6 +2935,20 @@ ] ] }, + { + "name": "godot_basis_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_basis *", + "r_dest" + ], + [ + "const godot_basis *", + "p_src" + ] + ] + }, { "name": "godot_basis_operator_index", "return_type": "godot_vector3 *", @@ -2847,6 +2987,20 @@ ] ] }, + { + "name": "godot_callable_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_callable *", + "r_dest" + ], + [ + "const godot_callable *", + "p_src" + ] + ] + }, { "name": "godot_callable_destroy", "return_type": "void", @@ -2867,6 +3021,20 @@ ] ] }, + { + "name": "godot_color_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_color *", + "r_dest" + ], + [ + "const godot_color *", + "p_src" + ] + ] + }, { "name": "godot_color_operator_index", "return_type": "float *", @@ -2905,6 +3073,20 @@ ] ] }, + { + "name": "godot_dictionary_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_dictionary *", + "r_dest" + ], + [ + "const godot_dictionary *", + "p_src" + ] + ] + }, { "name": "godot_dictionary_destroy", "return_type": "void", @@ -2953,6 +3135,20 @@ ] ] }, + { + "name": "godot_node_path_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_node_path *", + "r_dest" + ], + [ + "const godot_node_path *", + "p_src" + ] + ] + }, { "name": "godot_node_path_destroy", "return_type": "void", @@ -2973,6 +3169,20 @@ ] ] }, + { + "name": "godot_packed_byte_array_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_byte_array *", + "r_dest" + ], + [ + "const godot_packed_byte_array *", + "p_src" + ] + ] + }, { "name": "godot_packed_byte_array_destroy", "return_type": "void", @@ -3021,6 +3231,20 @@ ] ] }, + { + "name": "godot_packed_int32_array_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_int32_array *", + "r_dest" + ], + [ + "const godot_packed_int32_array *", + "p_src" + ] + ] + }, { "name": "godot_packed_int32_array_destroy", "return_type": "void", @@ -3069,6 +3293,20 @@ ] ] }, + { + "name": "godot_packed_int64_array_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_int64_array *", + "r_dest" + ], + [ + "const godot_packed_int64_array *", + "p_src" + ] + ] + }, { "name": "godot_packed_int64_array_destroy", "return_type": "void", @@ -3117,6 +3355,20 @@ ] ] }, + { + "name": "godot_packed_float32_array_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_float32_array *", + "r_dest" + ], + [ + "const godot_packed_float32_array *", + "p_src" + ] + ] + }, { "name": "godot_packed_float32_array_destroy", "return_type": "void", @@ -3165,6 +3417,20 @@ ] ] }, + { + "name": "godot_packed_float64_array_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_float64_array *", + "r_dest" + ], + [ + "const godot_packed_float64_array *", + "p_src" + ] + ] + }, { "name": "godot_packed_float64_array_destroy", "return_type": "void", @@ -3213,6 +3479,20 @@ ] ] }, + { + "name": "godot_packed_string_array_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_string_array *", + "r_dest" + ], + [ + "const godot_packed_string_array *", + "p_src" + ] + ] + }, { "name": "godot_packed_string_array_destroy", "return_type": "void", @@ -3261,6 +3541,20 @@ ] ] }, + { + "name": "godot_packed_vector2_array_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_vector2_array *", + "r_dest" + ], + [ + "const godot_packed_vector2_array *", + "p_src" + ] + ] + }, { "name": "godot_packed_vector2_array_destroy", "return_type": "void", @@ -3309,6 +3603,20 @@ ] ] }, + { + "name": "godot_packed_vector2i_array_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_vector2i_array *", + "r_dest" + ], + [ + "const godot_packed_vector2i_array *", + "p_src" + ] + ] + }, { "name": "godot_packed_vector2i_array_destroy", "return_type": "void", @@ -3357,6 +3665,20 @@ ] ] }, + { + "name": "godot_packed_vector3_array_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_vector3_array *", + "r_dest" + ], + [ + "const godot_packed_vector3_array *", + "p_src" + ] + ] + }, { "name": "godot_packed_vector3_array_destroy", "return_type": "void", @@ -3405,6 +3727,20 @@ ] ] }, + { + "name": "godot_packed_vector3i_array_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_vector3i_array *", + "r_dest" + ], + [ + "const godot_packed_vector3i_array *", + "p_src" + ] + ] + }, { "name": "godot_packed_vector3i_array_destroy", "return_type": "void", @@ -3453,6 +3789,20 @@ ] ] }, + { + "name": "godot_packed_color_array_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_color_array *", + "r_dest" + ], + [ + "const godot_packed_color_array *", + "p_src" + ] + ] + }, { "name": "godot_packed_color_array_destroy", "return_type": "void", @@ -3501,6 +3851,20 @@ ] ] }, + { + "name": "godot_plane_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_plane *", + "r_dest" + ], + [ + "const godot_plane *", + "p_src" + ] + ] + }, { "name": "godot_quat_new", "return_type": "void", @@ -3511,6 +3875,20 @@ ] ] }, + { + "name": "godot_quat_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_quat *", + "r_dest" + ], + [ + "const godot_quat *", + "p_src" + ] + ] + }, { "name": "godot_quat_operator_index", "return_type": "godot_real_t *", @@ -3549,6 +3927,20 @@ ] ] }, + { + "name": "godot_rect2_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_rect2 *", + "r_dest" + ], + [ + "const godot_rect2 *", + "p_src" + ] + ] + }, { "name": "godot_rect2i_new", "return_type": "void", @@ -3559,6 +3951,20 @@ ] ] }, + { + "name": "godot_rect2i_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_rect2i *", + "r_dest" + ], + [ + "const godot_rect2i *", + "p_src" + ] + ] + }, { "name": "godot_rid_new", "return_type": "void", @@ -3569,6 +3975,20 @@ ] ] }, + { + "name": "godot_rid_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_rid *", + "r_dest" + ], + [ + "const godot_rid *", + "p_src" + ] + ] + }, { "name": "godot_signal_new", "return_type": "void", @@ -3579,6 +3999,20 @@ ] ] }, + { + "name": "godot_signal_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_signal *", + "r_dest" + ], + [ + "const godot_signal *", + "p_src" + ] + ] + }, { "name": "godot_signal_destroy", "return_type": "void", @@ -3783,6 +4217,84 @@ ] ] }, + { + "name": "godot_string_to_latin1_chars", + "return_type": "const char *", + "arguments": [ + [ + "const godot_string *", + "p_self" + ] + ] + }, + { + "name": "godot_string_to_utf8_chars", + "return_type": "const char *", + "arguments": [ + [ + "const godot_string *", + "p_self" + ] + ] + }, + { + "name": "godot_string_to_utf16_chars", + "return_type": "const char16_t *", + "arguments": [ + [ + "const godot_string *", + "p_self" + ] + ] + }, + { + "name": "godot_string_to_utf32_chars", + "return_type": "const char32_t *", + "arguments": [ + [ + "const godot_string *", + "p_self" + ] + ] + }, + { + "name": "godot_string_to_wide_chars", + "return_type": "const wchar_t *", + "arguments": [ + [ + "const godot_string *", + "p_self" + ] + ] + }, + { + "name": "godot_string_operator_index", + "return_type": "char32_t *", + "arguments": [ + [ + "godot_string *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_string_operator_index_const", + "return_type": "const char32_t *", + "arguments": [ + [ + "const godot_string *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, { "name": "godot_string_name_new", "return_type": "void", @@ -3841,6 +4353,20 @@ ] ] }, + { + "name": "godot_transform_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_transform *", + "r_dest" + ], + [ + "const godot_transform *", + "p_src" + ] + ] + }, { "name": "godot_transform2d_new", "return_type": "void", @@ -3851,6 +4377,20 @@ ] ] }, + { + "name": "godot_transform2d_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_transform2d *", + "r_dest" + ], + [ + "const godot_transform2d *", + "p_src" + ] + ] + }, { "name": "godot_transform2d_operator_index", "return_type": "godot_vector2 *", @@ -3889,6 +4429,20 @@ ] ] }, + { + "name": "godot_vector2_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_vector2 *", + "r_dest" + ], + [ + "const godot_vector2 *", + "p_src" + ] + ] + }, { "name": "godot_vector2_operator_index", "return_type": "godot_real_t *", @@ -3927,6 +4481,20 @@ ] ] }, + { + "name": "godot_vector2i_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_vector2i *", + "r_dest" + ], + [ + "const godot_vector2i *", + "p_src" + ] + ] + }, { "name": "godot_vector2i_operator_index", "return_type": "int32_t *", @@ -3965,6 +4533,20 @@ ] ] }, + { + "name": "godot_vector3_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_vector3 *", + "r_dest" + ], + [ + "const godot_vector3 *", + "p_src" + ] + ] + }, { "name": "godot_vector3_operator_index", "return_type": "godot_real_t *", @@ -4003,6 +4585,20 @@ ] ] }, + { + "name": "godot_vector3i_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_vector3i *", + "r_dest" + ], + [ + "const godot_vector3i *", + "p_src" + ] + ] + }, { "name": "godot_vector3i_operator_index", "return_type": "int32_t *", diff --git a/modules/gdnative/include/gdnative/aabb.h b/modules/gdnative/include/gdnative/aabb.h index be0235221f8..860675065d3 100644 --- a/modules/gdnative/include/gdnative/aabb.h +++ b/modules/gdnative/include/gdnative/aabb.h @@ -49,6 +49,7 @@ typedef struct { #include void GDAPI godot_aabb_new(godot_aabb *p_self); +void GDAPI godot_aabb_new_copy(godot_aabb *r_dest, const godot_aabb *p_src); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/array.h b/modules/gdnative/include/gdnative/array.h index 7603edaa739..bf4b852449c 100644 --- a/modules/gdnative/include/gdnative/array.h +++ b/modules/gdnative/include/gdnative/array.h @@ -50,6 +50,7 @@ typedef struct { #include void GDAPI godot_array_new(godot_array *p_self); +void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src); void GDAPI godot_array_destroy(godot_array *p_self); godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, godot_int p_index); const godot_variant GDAPI *godot_array_operator_index_const(const godot_array *p_self, godot_int p_index); diff --git a/modules/gdnative/include/gdnative/basis.h b/modules/gdnative/include/gdnative/basis.h index af8d7cbdd3b..5477dbf8111 100644 --- a/modules/gdnative/include/gdnative/basis.h +++ b/modules/gdnative/include/gdnative/basis.h @@ -49,6 +49,7 @@ typedef struct { #include void GDAPI godot_basis_new(godot_basis *p_self); +void GDAPI godot_basis_new_copy(godot_basis *r_dest, const godot_basis *p_src); godot_vector3 GDAPI *godot_basis_operator_index(godot_basis *p_self, godot_int p_index); const godot_vector3 GDAPI *godot_basis_operator_index_const(const godot_basis *p_self, godot_int p_index); diff --git a/modules/gdnative/include/gdnative/callable.h b/modules/gdnative/include/gdnative/callable.h index 6f359ada5e8..b84b0c1f1f4 100644 --- a/modules/gdnative/include/gdnative/callable.h +++ b/modules/gdnative/include/gdnative/callable.h @@ -49,6 +49,7 @@ typedef struct { #include void GDAPI godot_callable_new(godot_callable *p_self); +void GDAPI godot_callable_new_copy(godot_callable *r_dest, const godot_callable *p_src); void GDAPI godot_callable_destroy(godot_callable *p_self); #ifdef __cplusplus diff --git a/modules/gdnative/include/gdnative/color.h b/modules/gdnative/include/gdnative/color.h index 17a021e6ea3..33340131476 100644 --- a/modules/gdnative/include/gdnative/color.h +++ b/modules/gdnative/include/gdnative/color.h @@ -50,6 +50,7 @@ typedef struct { #include void GDAPI godot_color_new(godot_color *p_self); +void GDAPI godot_color_new_copy(godot_color *r_dest, const godot_color *p_src); float GDAPI *godot_color_operator_index(godot_color *p_self, godot_int p_index); const float GDAPI *godot_color_operator_index_const(const godot_color *p_self, godot_int p_index); diff --git a/modules/gdnative/include/gdnative/dictionary.h b/modules/gdnative/include/gdnative/dictionary.h index d2afbc4c940..b9525fb5e6d 100644 --- a/modules/gdnative/include/gdnative/dictionary.h +++ b/modules/gdnative/include/gdnative/dictionary.h @@ -50,6 +50,7 @@ typedef struct { #include void GDAPI godot_dictionary_new(godot_dictionary *p_self); +void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src); void GDAPI godot_dictionary_destroy(godot_dictionary *p_self); godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key); const godot_variant GDAPI *godot_dictionary_operator_index_const(const godot_dictionary *p_self, const godot_variant *p_key); diff --git a/modules/gdnative/include/gdnative/node_path.h b/modules/gdnative/include/gdnative/node_path.h index 3c31b9a98fc..a4607c0152d 100644 --- a/modules/gdnative/include/gdnative/node_path.h +++ b/modules/gdnative/include/gdnative/node_path.h @@ -49,6 +49,7 @@ typedef struct { #include void GDAPI godot_node_path_new(godot_node_path *p_self); +void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src); void GDAPI godot_node_path_destroy(godot_node_path *p_self); #ifdef __cplusplus diff --git a/modules/gdnative/include/gdnative/packed_arrays.h b/modules/gdnative/include/gdnative/packed_arrays.h index 621ed60cdfa..f9e4ba3a8de 100644 --- a/modules/gdnative/include/gdnative/packed_arrays.h +++ b/modules/gdnative/include/gdnative/packed_arrays.h @@ -163,6 +163,7 @@ typedef struct { // Byte. void GDAPI godot_packed_byte_array_new(godot_packed_byte_array *p_self); +void GDAPI godot_packed_byte_array_new_copy(godot_packed_byte_array *r_dest, const godot_packed_byte_array *p_src); void GDAPI godot_packed_byte_array_destroy(godot_packed_byte_array *p_self); uint8_t GDAPI *godot_packed_byte_array_operator_index(godot_packed_byte_array *p_self, godot_int p_index); const uint8_t GDAPI *godot_packed_byte_array_operator_index_const(const godot_packed_byte_array *p_self, godot_int p_index); @@ -170,6 +171,7 @@ const uint8_t GDAPI *godot_packed_byte_array_operator_index_const(const godot_pa // Int32. void GDAPI godot_packed_int32_array_new(godot_packed_int32_array *p_self); +void GDAPI godot_packed_int32_array_new_copy(godot_packed_int32_array *r_dest, const godot_packed_int32_array *p_src); void GDAPI godot_packed_int32_array_destroy(godot_packed_int32_array *p_self); int32_t GDAPI *godot_packed_int32_array_operator_index(godot_packed_int32_array *p_self, godot_int p_index); const int32_t GDAPI *godot_packed_int32_array_operator_index_const(const godot_packed_int32_array *p_self, godot_int p_index); @@ -177,6 +179,7 @@ const int32_t GDAPI *godot_packed_int32_array_operator_index_const(const godot_p // Int64. void GDAPI godot_packed_int64_array_new(godot_packed_int64_array *p_self); +void GDAPI godot_packed_int64_array_new_copy(godot_packed_int64_array *r_dest, const godot_packed_int64_array *p_src); void GDAPI godot_packed_int64_array_destroy(godot_packed_int64_array *p_self); int64_t GDAPI *godot_packed_int64_array_operator_index(godot_packed_int64_array *p_self, godot_int p_index); const int64_t GDAPI *godot_packed_int64_array_operator_index_const(const godot_packed_int64_array *p_self, godot_int p_index); @@ -184,6 +187,7 @@ const int64_t GDAPI *godot_packed_int64_array_operator_index_const(const godot_p // Float32. void GDAPI godot_packed_float32_array_new(godot_packed_float32_array *p_self); +void GDAPI godot_packed_float32_array_new_copy(godot_packed_float32_array *r_dest, const godot_packed_float32_array *p_src); void GDAPI godot_packed_float32_array_destroy(godot_packed_float32_array *p_self); float GDAPI *godot_packed_float32_array_operator_index(godot_packed_float32_array *p_self, godot_int p_index); const float GDAPI *godot_packed_float32_array_operator_index_const(const godot_packed_float32_array *p_self, godot_int p_index); @@ -191,6 +195,7 @@ const float GDAPI *godot_packed_float32_array_operator_index_const(const godot_p // Float64. void GDAPI godot_packed_float64_array_new(godot_packed_float64_array *p_self); +void GDAPI godot_packed_float64_array_new_copy(godot_packed_float64_array *r_dest, const godot_packed_float64_array *p_src); void GDAPI godot_packed_float64_array_destroy(godot_packed_float64_array *p_self); double GDAPI *godot_packed_float64_array_operator_index(godot_packed_float64_array *p_self, godot_int p_index); const double GDAPI *godot_packed_float64_array_operator_index_const(const godot_packed_float64_array *p_self, godot_int p_index); @@ -198,6 +203,7 @@ const double GDAPI *godot_packed_float64_array_operator_index_const(const godot_ // String. void GDAPI godot_packed_string_array_new(godot_packed_string_array *p_self); +void GDAPI godot_packed_string_array_new_copy(godot_packed_string_array *r_dest, const godot_packed_string_array *p_src); void GDAPI godot_packed_string_array_destroy(godot_packed_string_array *p_self); godot_string GDAPI *godot_packed_string_array_operator_index(godot_packed_string_array *p_self, godot_int p_index); const godot_string GDAPI *godot_packed_string_array_operator_index_const(const godot_packed_string_array *p_self, godot_int p_index); @@ -205,6 +211,7 @@ const godot_string GDAPI *godot_packed_string_array_operator_index_const(const g // Vector2. void GDAPI godot_packed_vector2_array_new(godot_packed_vector2_array *p_self); +void GDAPI godot_packed_vector2_array_new_copy(godot_packed_vector2_array *r_dest, const godot_packed_vector2_array *p_src); void GDAPI godot_packed_vector2_array_destroy(godot_packed_vector2_array *p_self); godot_vector2 GDAPI *godot_packed_vector2_array_operator_index(godot_packed_vector2_array *p_self, godot_int p_index); const godot_vector2 GDAPI *godot_packed_vector2_array_operator_index_const(const godot_packed_vector2_array *p_self, godot_int p_index); @@ -212,6 +219,7 @@ const godot_vector2 GDAPI *godot_packed_vector2_array_operator_index_const(const // Vector2i. void GDAPI godot_packed_vector2i_array_new(godot_packed_vector2i_array *p_self); +void GDAPI godot_packed_vector2i_array_new_copy(godot_packed_vector2i_array *r_dest, const godot_packed_vector2i_array *p_src); void GDAPI godot_packed_vector2i_array_destroy(godot_packed_vector2i_array *p_self); godot_vector2i GDAPI *godot_packed_vector2i_array_operator_index(godot_packed_vector2i_array *p_self, godot_int p_index); const godot_vector2i GDAPI *godot_packed_vector2i_array_operator_index_const(const godot_packed_vector2i_array *p_self, godot_int p_index); @@ -219,6 +227,7 @@ const godot_vector2i GDAPI *godot_packed_vector2i_array_operator_index_const(con // Vector3. void GDAPI godot_packed_vector3_array_new(godot_packed_vector3_array *p_self); +void GDAPI godot_packed_vector3_array_new_copy(godot_packed_vector3_array *r_dest, const godot_packed_vector3_array *p_src); void GDAPI godot_packed_vector3_array_destroy(godot_packed_vector3_array *p_self); godot_vector3 GDAPI *godot_packed_vector3_array_operator_index(godot_packed_vector3_array *p_self, godot_int p_index); const godot_vector3 GDAPI *godot_packed_vector3_array_operator_index_const(const godot_packed_vector3_array *p_self, godot_int p_index); @@ -226,6 +235,7 @@ const godot_vector3 GDAPI *godot_packed_vector3_array_operator_index_const(const // Vector3i. void GDAPI godot_packed_vector3i_array_new(godot_packed_vector3i_array *p_self); +void GDAPI godot_packed_vector3i_array_new_copy(godot_packed_vector3i_array *r_dest, const godot_packed_vector3i_array *p_src); void GDAPI godot_packed_vector3i_array_destroy(godot_packed_vector3i_array *p_self); godot_vector3i GDAPI *godot_packed_vector3i_array_operator_index(godot_packed_vector3i_array *p_self, godot_int p_index); const godot_vector3i GDAPI *godot_packed_vector3i_array_operator_index_const(const godot_packed_vector3i_array *p_self, godot_int p_index); @@ -233,6 +243,7 @@ const godot_vector3i GDAPI *godot_packed_vector3i_array_operator_index_const(con // Color. void GDAPI godot_packed_color_array_new(godot_packed_color_array *p_self); +void GDAPI godot_packed_color_array_new_copy(godot_packed_color_array *r_dest, const godot_packed_color_array *p_src); void GDAPI godot_packed_color_array_destroy(godot_packed_color_array *p_self); godot_color GDAPI *godot_packed_color_array_operator_index(godot_packed_color_array *p_self, godot_int p_index); const godot_color GDAPI *godot_packed_color_array_operator_index_const(const godot_packed_color_array *p_self, godot_int p_index); diff --git a/modules/gdnative/include/gdnative/plane.h b/modules/gdnative/include/gdnative/plane.h index ed10955e5fa..6cd0ed6307c 100644 --- a/modules/gdnative/include/gdnative/plane.h +++ b/modules/gdnative/include/gdnative/plane.h @@ -49,6 +49,7 @@ typedef struct { #include void GDAPI godot_plane_new(godot_plane *p_self); +void GDAPI godot_plane_new_copy(godot_plane *r_dest, const godot_plane *p_src); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/quat.h b/modules/gdnative/include/gdnative/quat.h index 69bf4276116..00abdb4404f 100644 --- a/modules/gdnative/include/gdnative/quat.h +++ b/modules/gdnative/include/gdnative/quat.h @@ -49,6 +49,7 @@ typedef struct { #include void GDAPI godot_quat_new(godot_quat *p_self); +void GDAPI godot_quat_new_copy(godot_quat *r_dest, const godot_quat *p_src); godot_real_t GDAPI *godot_quat_operator_index(godot_quat *p_self, godot_int p_index); const godot_real_t GDAPI *godot_quat_operator_index_const(const godot_quat *p_self, godot_int p_index); diff --git a/modules/gdnative/include/gdnative/rect2.h b/modules/gdnative/include/gdnative/rect2.h index 9e51254cfe5..326462be43a 100644 --- a/modules/gdnative/include/gdnative/rect2.h +++ b/modules/gdnative/include/gdnative/rect2.h @@ -58,7 +58,9 @@ typedef struct godot_rect2i { #include void GDAPI godot_rect2_new(godot_rect2 *p_self); +void GDAPI godot_rect2_new_copy(godot_rect2 *r_dest, const godot_rect2 *p_src); void GDAPI godot_rect2i_new(godot_rect2i *p_self); +void GDAPI godot_rect2i_new_copy(godot_rect2i *r_dest, const godot_rect2i *p_src); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/rid.h b/modules/gdnative/include/gdnative/rid.h index 7ea8cfd174c..bc832fbeb97 100644 --- a/modules/gdnative/include/gdnative/rid.h +++ b/modules/gdnative/include/gdnative/rid.h @@ -49,6 +49,7 @@ typedef struct { #include void GDAPI godot_rid_new(godot_rid *p_self); +void GDAPI godot_rid_new_copy(godot_rid *r_dest, const godot_rid *p_src); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/signal.h b/modules/gdnative/include/gdnative/signal.h index ad845426771..f4dc17e0898 100644 --- a/modules/gdnative/include/gdnative/signal.h +++ b/modules/gdnative/include/gdnative/signal.h @@ -49,6 +49,7 @@ typedef struct { #include void GDAPI godot_signal_new(godot_signal *p_self); +void GDAPI godot_signal_new_copy(godot_signal *r_dest, const godot_signal *p_src); void GDAPI godot_signal_destroy(godot_signal *p_self); #ifdef __cplusplus diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h index 10fbb2c0784..79de52c80f8 100644 --- a/modules/gdnative/include/gdnative/string.h +++ b/modules/gdnative/include/gdnative/string.h @@ -55,6 +55,7 @@ typedef struct { #endif #include +#include void GDAPI godot_string_new(godot_string *r_dest); void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src); @@ -72,6 +73,15 @@ void GDAPI godot_string_new_with_utf16_chars_and_len(godot_string *r_dest, const void GDAPI godot_string_new_with_utf32_chars_and_len(godot_string *r_dest, const char32_t *p_contents, const int p_size); void GDAPI godot_string_new_with_wide_chars_and_len(godot_string *r_dest, const wchar_t *p_contents, const int p_size); +const char GDAPI *godot_string_to_latin1_chars(const godot_string *p_self); +const char GDAPI *godot_string_to_utf8_chars(const godot_string *p_self); +const char16_t GDAPI *godot_string_to_utf16_chars(const godot_string *p_self); +const char32_t GDAPI *godot_string_to_utf32_chars(const godot_string *p_self); +const wchar_t GDAPI *godot_string_to_wide_chars(const godot_string *p_self); + +char32_t GDAPI *godot_string_operator_index(godot_string *p_self, godot_int p_index); +const char32_t GDAPI *godot_string_operator_index_const(const godot_string *p_self, godot_int p_index); + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/include/gdnative/transform.h b/modules/gdnative/include/gdnative/transform.h index e67862d140d..3861b5683af 100644 --- a/modules/gdnative/include/gdnative/transform.h +++ b/modules/gdnative/include/gdnative/transform.h @@ -49,6 +49,7 @@ typedef struct { #include void GDAPI godot_transform_new(godot_transform *p_self); +void GDAPI godot_transform_new_copy(godot_transform *r_dest, const godot_transform *p_src); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/transform2d.h b/modules/gdnative/include/gdnative/transform2d.h index 4a2bca7cfc0..5acb172081c 100644 --- a/modules/gdnative/include/gdnative/transform2d.h +++ b/modules/gdnative/include/gdnative/transform2d.h @@ -49,6 +49,7 @@ typedef struct { #include void GDAPI godot_transform2d_new(godot_transform2d *p_self); +void GDAPI godot_transform2d_new_copy(godot_transform2d *r_dest, const godot_transform2d *p_src); godot_vector2 GDAPI *godot_transform2d_operator_index(godot_transform2d *p_self, godot_int p_index); const godot_vector2 GDAPI *godot_transform2d_operator_index_const(const godot_transform2d *p_self, godot_int p_index); diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h index 329a6faf516..3e06ed9aa49 100644 --- a/modules/gdnative/include/gdnative/variant.h +++ b/modules/gdnative/include/gdnative/variant.h @@ -272,6 +272,8 @@ void GDAPI godot_variant_destroy(godot_variant *p_self); void GDAPI godot_variant_call(godot_variant *p_self, const godot_string_name *p_method, const godot_variant **p_args, const godot_int p_argument_count, godot_variant *r_return, godot_variant_call_error *r_error); void GDAPI godot_variant_call_with_cstring(godot_variant *p_self, const char *p_method, const godot_variant **p_args, const godot_int p_argument_count, godot_variant *r_return, godot_variant_call_error *r_error); +void GDAPI godot_variant_call_static(godot_variant_type p_type, const godot_string_name *p_method, const godot_variant **p_args, const godot_int p_argument_count, godot_variant *r_return, godot_variant_call_error *r_error); +void GDAPI godot_variant_call_static_with_cstring(godot_variant_type p_type, const char *p_method, const godot_variant **p_args, const godot_int p_argument_count, godot_variant *r_return, godot_variant_call_error *r_error); void GDAPI godot_variant_evaluate(godot_variant_operator p_op, const godot_variant *p_a, const godot_variant *p_b, godot_variant *r_return, bool *r_valid); void GDAPI godot_variant_set(godot_variant *p_self, const godot_variant *p_key, const godot_variant *p_value, bool *r_valid); void GDAPI godot_variant_set_named(godot_variant *p_self, const godot_string_name *p_name, const godot_variant *p_value, bool *r_valid); @@ -323,6 +325,8 @@ godot_variant_type GDAPI godot_variant_get_builtin_method_return_type(godot_vari godot_variant_type GDAPI godot_variant_get_builtin_method_return_type_with_cstring(godot_variant_type p_type, const char *p_method); bool GDAPI godot_variant_is_builtin_method_const(godot_variant_type p_type, const godot_string_name *p_method); bool GDAPI godot_variant_is_builtin_method_const_with_cstring(godot_variant_type p_type, const char *p_method); +bool GDAPI godot_variant_is_builtin_method_static(godot_variant_type p_type, const godot_string_name *p_method); +bool GDAPI godot_variant_is_builtin_method_static_with_cstring(godot_variant_type p_type, const char *p_method); bool GDAPI godot_variant_is_builtin_method_vararg(godot_variant_type p_type, const godot_string_name *p_method); bool GDAPI godot_variant_is_builtin_method_vararg_with_cstring(godot_variant_type p_type, const char *p_method); int GDAPI godot_variant_get_builtin_method_count(godot_variant_type p_type); diff --git a/modules/gdnative/include/gdnative/vector2.h b/modules/gdnative/include/gdnative/vector2.h index 5ebb705ba42..00faffbad7e 100644 --- a/modules/gdnative/include/gdnative/vector2.h +++ b/modules/gdnative/include/gdnative/vector2.h @@ -58,7 +58,9 @@ typedef struct { #include void GDAPI godot_vector2_new(godot_vector2 *p_self); +void GDAPI godot_vector2_new_copy(godot_vector2 *r_dest, const godot_vector2 *p_src); void GDAPI godot_vector2i_new(godot_vector2i *p_self); +void GDAPI godot_vector2i_new_copy(godot_vector2i *r_dest, const godot_vector2i *p_src); godot_real_t GDAPI *godot_vector2_operator_index(godot_vector2 *p_self, godot_int p_index); const godot_real_t GDAPI *godot_vector2_operator_index_const(const godot_vector2 *p_self, godot_int p_index); int32_t GDAPI *godot_vector2i_operator_index(godot_vector2i *p_self, godot_int p_index); diff --git a/modules/gdnative/include/gdnative/vector3.h b/modules/gdnative/include/gdnative/vector3.h index d37ebd3cc90..7db093ce526 100644 --- a/modules/gdnative/include/gdnative/vector3.h +++ b/modules/gdnative/include/gdnative/vector3.h @@ -58,7 +58,9 @@ typedef struct { #include void GDAPI godot_vector3_new(godot_vector3 *p_self); +void GDAPI godot_vector3_new_copy(godot_vector3 *r_dest, const godot_vector3 *p_src); void GDAPI godot_vector3i_new(godot_vector3i *p_self); +void GDAPI godot_vector3i_new_copy(godot_vector3i *r_dest, const godot_vector3i *p_src); godot_real_t GDAPI *godot_vector3_operator_index(godot_vector3 *p_self, godot_int p_index); const godot_real_t GDAPI *godot_vector3_operator_index_const(const godot_vector3 *p_self, godot_int p_index); int32_t GDAPI *godot_vector3i_operator_index(godot_vector3i *p_self, godot_int p_index); From ec806c5c5bc0abc2e1d01a96f7f7ea1b6da189fb Mon Sep 17 00:00:00 2001 From: George Marques Date: Sun, 28 Feb 2021 14:17:05 -0300 Subject: [PATCH 2/2] Added static method information the generated builtin API JSON --- modules/gdnative/gdnative/variant.cpp | 4 ++-- modules/gdnative/nativescript/api_generator.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp index 1dc3c905bdb..7801e21ab2c 100644 --- a/modules/gdnative/gdnative/variant.cpp +++ b/modules/gdnative/gdnative/variant.cpp @@ -599,7 +599,7 @@ void GDAPI godot_variant_call_static(godot_variant_type p_type, const godot_stri const Variant **args = (const Variant **)p_args; Variant ret; Callable::CallError error; - Variant().call_static(type, *method, args, p_argcount, ret, error); + Variant::call_static(type, *method, args, p_argcount, ret, error); memnew_placement_custom(r_return, Variant, Variant(ret)); if (r_error) { @@ -615,7 +615,7 @@ void GDAPI godot_variant_call_static_with_cstring(godot_variant_type p_type, con const Variant **args = (const Variant **)p_args; Variant ret; Callable::CallError error; - Variant().call_static(type, method, args, p_argcount, ret, error); + Variant::call_static(type, method, args, p_argcount, ret, error); memnew_placement_custom(r_return, Variant, Variant(ret)); if (r_error) { diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 3e75478cd81..f184c846150 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -71,6 +71,7 @@ struct MethodAPI { bool is_editor = false; bool is_noscript = false; bool is_const = false; + bool is_static = false; // For builtin types. bool is_reverse = false; bool is_virtual = false; bool is_from_script = false; @@ -528,6 +529,7 @@ List generate_c_builtin_api_types() { method_api.argument_count = Variant::get_builtin_method_argument_count(type, method_name); method_api.has_varargs = Variant::is_builtin_method_vararg(type, method_name); method_api.is_const = Variant::is_builtin_method_const(type, method_name); + method_api.is_static = Variant::is_builtin_method_static(type, method_name); for (int i = 0; i < method_api.argument_count; i++) { method_api.argument_names.push_back(Variant::get_builtin_method_argument_name(type, method_name, i)); @@ -757,6 +759,7 @@ static void write_builtin_method(StringBuilder &p_source, const MethodAPI &p_met append_indented(p_source, vformat(R"("name": "%s",)", p_method.method_name)); append_indented(p_source, vformat(R"("return_type": "%s",)", p_method.return_type)); append_indented(p_source, vformat(R"("is_const": %s,)", p_method.is_const ? "true" : "false")); + append_indented(p_source, vformat(R"("is_static": %s,)", p_method.is_static ? "true" : "false")); append_indented(p_source, vformat(R"("has_varargs": %s,)", p_method.has_varargs ? "true" : "false")); append_indented(p_source, R"("arguments": [)");