diff options
Diffstat (limited to 'modules')
47 files changed, 3289 insertions, 572 deletions
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index 2fca7fe633..9aac7ba9e4 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -445,11 +445,6 @@ void RigidBodyBullet::assert_no_constraints() { if (btBody->getNumConstraintRefs()) { WARN_PRINT("A body with a joints is destroyed. Please check the implementation in order to destroy the joint before the body."); } - /*for(int i = btBody->getNumConstraintRefs()-1; 0<=i; --i){ - btTypedConstraint* btConst = btBody->getConstraintRef(i); - JointBullet* joint = static_cast<JointBullet*>( btConst->getUserConstraintPtr() ); - space->removeConstraint(joint); - }*/ } void RigidBodyBullet::set_activation_state(bool p_active) { diff --git a/modules/camera/camera_win.cpp b/modules/camera/camera_win.cpp index 875f0b26bc..1646644be3 100644 --- a/modules/camera/camera_win.cpp +++ b/modules/camera/camera_win.cpp @@ -53,9 +53,9 @@ public: void deactivate_feed(); }; -CameraFeedWindows::CameraFeedWindows(){ +CameraFeedWindows::CameraFeedWindows() { ///@TODO implement this, should store information about our available camera -}; +} CameraFeedWindows::~CameraFeedWindows() { // make sure we stop recording if we are! @@ -75,16 +75,16 @@ bool CameraFeedWindows::activate_feed() { ///@TODO we should probably have a callback method here that is being called by the // camera API which provides frames and call back into the CameraServer to update our texture -void CameraFeedWindows::deactivate_feed(){ +void CameraFeedWindows::deactivate_feed() { ///@TODO this should deactivate our camera and stop the process of capturing frames -}; +} ////////////////////////////////////////////////////////////////////////// // CameraWindows - Subclass for our camera server on windows -void CameraWindows::add_active_cameras(){ +void CameraWindows::add_active_cameras() { ///@TODO scan through any active cameras and create CameraFeedWindows objects for them -}; +} CameraWindows::CameraWindows() { // Find cameras active right now @@ -92,7 +92,3 @@ CameraWindows::CameraWindows() { // need to add something that will react to devices being connected/removed... }; - -CameraWindows::~CameraWindows(){ - -}; diff --git a/modules/camera/camera_win.h b/modules/camera/camera_win.h index 39a1b0b86f..bbc8880c12 100644 --- a/modules/camera/camera_win.h +++ b/modules/camera/camera_win.h @@ -40,7 +40,7 @@ private: public: CameraWindows(); - ~CameraWindows(); + ~CameraWindows() {} }; #endif /* CAMERAWIN_H */ diff --git a/modules/gdnative/gdnative/aabb.cpp b/modules/gdnative/gdnative/aabb.cpp index 246e5d4e8d..7f22c7dfe3 100644 --- a/modules/gdnative/gdnative/aabb.cpp +++ b/modules/gdnative/gdnative/aabb.cpp @@ -37,6 +37,8 @@ extern "C" { #endif +static_assert(sizeof(godot_aabb) == sizeof(AABB), "AABB size mismatch"); + void GDAPI godot_aabb_new(godot_aabb *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size) { const Vector3 *pos = (const Vector3 *)p_pos; const Vector3 *size = (const Vector3 *)p_size; diff --git a/modules/gdnative/gdnative/array.cpp b/modules/gdnative/gdnative/array.cpp index 0c764ab8fd..59953f5182 100644 --- a/modules/gdnative/gdnative/array.cpp +++ b/modules/gdnative/gdnative/array.cpp @@ -41,6 +41,8 @@ extern "C" { #endif +static_assert(sizeof(godot_array) == sizeof(Array), "Array size mismatch"); + void GDAPI godot_array_new(godot_array *r_dest) { Array *dest = (Array *)r_dest; memnew_placement(dest, Array); @@ -100,9 +102,33 @@ void GDAPI godot_array_new_packed_string_array(godot_array *r_dest, const godot_ } } -void GDAPI godot_array_new_packed_real_array(godot_array *r_dest, const godot_packed_real_array *p_pra) { +void GDAPI godot_array_new_packed_float32_array(godot_array *r_dest, const godot_packed_float32_array *p_pra) { + Array *dest = (Array *)r_dest; + Vector<float> *pca = (Vector<float> *)p_pra; + memnew_placement(dest, Array); + dest->resize(pca->size()); + + for (int i = 0; i < dest->size(); i++) { + Variant v = pca->operator[](i); + dest->operator[](i) = v; + } +} + +void GDAPI godot_array_new_packed_float64_array(godot_array *r_dest, const godot_packed_float64_array *p_pra) { + Array *dest = (Array *)r_dest; + Vector<double> *pca = (Vector<double> *)p_pra; + memnew_placement(dest, Array); + dest->resize(pca->size()); + + for (int i = 0; i < dest->size(); i++) { + Variant v = pca->operator[](i); + dest->operator[](i) = v; + } +} + +void GDAPI godot_array_new_packed_int32_array(godot_array *r_dest, const godot_packed_int32_array *p_pia) { Array *dest = (Array *)r_dest; - Vector<godot_real> *pca = (Vector<godot_real> *)p_pra; + Vector<int32_t> *pca = (Vector<int32_t> *)p_pia; memnew_placement(dest, Array); dest->resize(pca->size()); @@ -112,9 +138,9 @@ void GDAPI godot_array_new_packed_real_array(godot_array *r_dest, const godot_pa } } -void GDAPI godot_array_new_packed_int_array(godot_array *r_dest, const godot_packed_int_array *p_pia) { +void GDAPI godot_array_new_packed_int64_array(godot_array *r_dest, const godot_packed_int64_array *p_pia) { Array *dest = (Array *)r_dest; - Vector<godot_int> *pca = (Vector<godot_int> *)p_pia; + Vector<int64_t> *pca = (Vector<int64_t> *)p_pia; memnew_placement(dest, Array); dest->resize(pca->size()); diff --git a/modules/gdnative/gdnative/basis.cpp b/modules/gdnative/gdnative/basis.cpp index 4f489287b9..990fd3795d 100644 --- a/modules/gdnative/gdnative/basis.cpp +++ b/modules/gdnative/gdnative/basis.cpp @@ -37,6 +37,8 @@ extern "C" { #endif +static_assert(sizeof(godot_basis) == sizeof(Basis), "Basis size mismatch"); + void GDAPI godot_basis_new_with_rows(godot_basis *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis) { const Vector3 *x_axis = (const Vector3 *)p_x_axis; const Vector3 *y_axis = (const Vector3 *)p_y_axis; diff --git a/modules/gdnative/gdnative/callable.cpp b/modules/gdnative/gdnative/callable.cpp new file mode 100644 index 0000000000..868b324227 --- /dev/null +++ b/modules/gdnative/gdnative/callable.cpp @@ -0,0 +1,252 @@ +/*************************************************************************/ +/* callable.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "gdnative/callable.h" + +#include "core/callable.h" +#include "core/resource.h" +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +static_assert(sizeof(godot_callable) == sizeof(Callable), "Callable size mismatch"); +static_assert(sizeof(godot_signal) == sizeof(Signal), "Signal size mismatch"); + +// Callable + +void GDAPI godot_callable_new_with_object(godot_callable *r_dest, const godot_object *p_object, const godot_string_name *p_method) { + Callable *dest = (Callable *)r_dest; + const Object *object = (const Object *)p_object; + const StringName *method = (const StringName *)p_method; + memnew_placement(dest, Callable(object, *method)); +} + +void GDAPI godot_callable_new_with_object_id(godot_callable *r_dest, uint64_t p_objectid, const godot_string_name *p_method) { + Callable *dest = (Callable *)r_dest; + const StringName *method = (const StringName *)p_method; + memnew_placement(dest, Callable(ObjectID(p_objectid), *method)); +} + +void GDAPI godot_callable_new_copy(godot_callable *r_dest, const godot_callable *p_src) { + Callable *dest = (Callable *)r_dest; + const Callable *src = (const Callable *)p_src; + memnew_placement(dest, Callable(*src)); +} + +void GDAPI godot_callable_destroy(godot_callable *p_self) { + Callable *self = (Callable *)p_self; + self->~Callable(); +} + +godot_int GDAPI godot_callable_call(const godot_callable *p_self, const godot_variant **p_arguments, godot_int p_argcount, godot_variant *r_return_value) { + const Callable *self = (const Callable *)p_self; + const Variant **arguments = (const Variant **)p_arguments; + Variant *return_value = (Variant *)r_return_value; + Variant ret; + Callable::CallError err; + self->call(arguments, p_argcount, ret, err); + if (return_value) + (*return_value) = ret; + return (godot_int)err.error; +} + +void GDAPI godot_callable_call_deferred(const godot_callable *p_self, const godot_variant **p_arguments, godot_int p_argcount) { + const Callable *self = (const Callable *)p_self; + const Variant **arguments = (const Variant **)p_arguments; + self->call_deferred(arguments, p_argcount); +} + +godot_bool GDAPI godot_callable_is_null(const godot_callable *p_self) { + const Callable *self = (const Callable *)p_self; + return self->is_null(); +} + +godot_bool GDAPI godot_callable_is_custom(const godot_callable *p_self) { + const Callable *self = (const Callable *)p_self; + return self->is_custom(); +} + +godot_bool GDAPI godot_callable_is_standard(const godot_callable *p_self) { + const Callable *self = (const Callable *)p_self; + return self->is_standard(); +} + +godot_object GDAPI *godot_callable_get_object(const godot_callable *p_self) { + const Callable *self = (const Callable *)p_self; + return (godot_object *)self->get_object(); +} + +uint64_t GDAPI godot_callable_get_object_id(const godot_callable *p_self) { + const Callable *self = (const Callable *)p_self; + return (uint64_t)self->get_object_id(); +} + +godot_string_name GDAPI godot_callable_get_method(const godot_callable *p_self) { + godot_string_name raw_dest; + const Callable *self = (const Callable *)p_self; + StringName *dest = (StringName *)&raw_dest; + memnew_placement(dest, StringName(self->get_method())); + return raw_dest; +} + +uint32_t GDAPI godot_callable_hash(const godot_callable *p_self) { + const Callable *self = (const Callable *)p_self; + return self->hash(); +} + +godot_string GDAPI godot_callable_as_string(const godot_callable *p_self) { + godot_string ret; + const Callable *self = (const Callable *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_bool GDAPI godot_callable_operator_equal(const godot_callable *p_self, const godot_callable *p_other) { + const Callable *self = (const Callable *)p_self; + const Callable *other = (const Callable *)p_other; + return *self == *other; +} + +godot_bool GDAPI godot_callable_operator_less(const godot_callable *p_self, const godot_callable *p_other) { + const Callable *self = (const Callable *)p_self; + const Callable *other = (const Callable *)p_other; + return *self < *other; +} + +// Signal + +void GDAPI godot_signal_new_with_object(godot_signal *r_dest, const godot_object *p_object, const godot_string_name *p_name) { + Signal *dest = (Signal *)r_dest; + const Object *object = (const Object *)p_object; + const StringName *name = (const StringName *)p_name; + memnew_placement(dest, Signal(object, *name)); +} + +void GDAPI godot_signal_new_with_object_id(godot_signal *r_dest, uint64_t p_objectid, const godot_string_name *p_name) { + Signal *dest = (Signal *)r_dest; + const StringName *name = (const StringName *)p_name; + memnew_placement(dest, Signal(ObjectID(p_objectid), *name)); +} + +void GDAPI godot_signal_new_copy(godot_signal *r_dest, const godot_signal *p_src) { + Signal *dest = (Signal *)r_dest; + const Signal *src = (const Signal *)p_src; + memnew_placement(dest, Signal(*src)); +} + +void GDAPI godot_signal_destroy(godot_signal *p_self) { + Signal *self = (Signal *)p_self; + self->~Signal(); +} + +godot_int GDAPI godot_signal_emit(const godot_signal *p_self, const godot_variant **p_arguments, godot_int p_argcount) { + const Signal *self = (const Signal *)p_self; + const Variant **arguments = (const Variant **)p_arguments; + return (godot_int)self->emit(arguments, p_argcount); +} + +godot_int GDAPI godot_signal_connect(godot_signal *p_self, const godot_callable *p_callable, const godot_array *p_binds, uint32_t p_flags) { + Signal *self = (Signal *)p_self; + const Callable *callable = (const Callable *)p_callable; + const Array *binds_ar = (const Array *)p_binds; + Vector<Variant> binds; + for (int i = 0; i < binds_ar->size(); i++) { + binds.push_back(binds_ar->get(i)); + } + return (godot_int)self->connect(*callable, binds, p_flags); +} + +void GDAPI godot_signal_disconnect(godot_signal *p_self, const godot_callable *p_callable) { + Signal *self = (Signal *)p_self; + const Callable *callable = (const Callable *)p_callable; + self->disconnect(*callable); +} + +godot_bool GDAPI godot_signal_is_null(const godot_signal *p_self) { + const Signal *self = (const Signal *)p_self; + return self->is_null(); +} + +godot_bool GDAPI godot_signal_is_connected(const godot_signal *p_self, const godot_callable *p_callable) { + const Signal *self = (const Signal *)p_self; + const Callable *callable = (const Callable *)p_callable; + return self->is_connected(*callable); +} + +godot_array GDAPI godot_signal_get_connections(const godot_signal *p_self) { + godot_array raw_dest; + const Signal *self = (const Signal *)p_self; + Array *dest = (Array *)&raw_dest; + memnew_placement(dest, Array(self->get_connections())); + return raw_dest; +} + +godot_object GDAPI *godot_signal_get_object(const godot_signal *p_self) { + const Signal *self = (const Signal *)p_self; + return (godot_object *)self->get_object(); +} + +uint64_t GDAPI godot_signal_get_object_id(const godot_signal *p_self) { + const Signal *self = (const Signal *)p_self; + return (uint64_t)self->get_object_id(); +} + +godot_string_name GDAPI godot_signal_get_name(const godot_signal *p_self) { + godot_string_name raw_dest; + const Signal *self = (const Signal *)p_self; + StringName *dest = (StringName *)&raw_dest; + memnew_placement(dest, StringName(self->get_name())); + return raw_dest; +} + +godot_string GDAPI godot_signal_as_string(const godot_signal *p_self) { + godot_string ret; + const Signal *self = (const Signal *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_bool GDAPI godot_signal_operator_equal(const godot_signal *p_self, const godot_signal *p_other) { + const Signal *self = (const Signal *)p_self; + const Signal *other = (const Signal *)p_other; + return *self == *other; +} + +godot_bool GDAPI godot_signal_operator_less(const godot_signal *p_self, const godot_signal *p_other) { + const Signal *self = (const Signal *)p_self; + const Signal *other = (const Signal *)p_other; + return *self < *other; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/color.cpp b/modules/gdnative/gdnative/color.cpp index d79170771a..c75e74daba 100644 --- a/modules/gdnative/gdnative/color.cpp +++ b/modules/gdnative/gdnative/color.cpp @@ -37,6 +37,8 @@ extern "C" { #endif +static_assert(sizeof(godot_color) == sizeof(Color), "Color size mismatch"); + void GDAPI godot_color_new_rgba(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b, const godot_real p_a) { Color *dest = (Color *)r_dest; *dest = Color(p_r, p_g, p_b, p_a); diff --git a/modules/gdnative/gdnative/dictionary.cpp b/modules/gdnative/gdnative/dictionary.cpp index b145b88934..a126974815 100644 --- a/modules/gdnative/gdnative/dictionary.cpp +++ b/modules/gdnative/gdnative/dictionary.cpp @@ -39,6 +39,8 @@ extern "C" { #endif +static_assert(sizeof(godot_dictionary) == sizeof(Dictionary), "Dictionary size mismatch"); + void GDAPI godot_dictionary_new(godot_dictionary *r_dest) { Dictionary *dest = (Dictionary *)r_dest; memnew_placement(dest, Dictionary); diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp index 6b2b5b80a4..e94190b07b 100644 --- a/modules/gdnative/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative/gdnative.cpp @@ -165,7 +165,7 @@ void _gdnative_report_loading_error(const godot_object *p_library, const char *p _err_print_error("gdnative_init", library->get_current_library_path().utf8().ptr(), 0, message.utf8().ptr()); } -godot_object GDAPI *godot_instance_from_id(godot_int p_instance_id) { +godot_object GDAPI *godot_instance_from_id(uint64_t p_instance_id) { return (godot_object *)ObjectDB::get_instance(ObjectID(p_instance_id)); } @@ -184,6 +184,11 @@ godot_object *godot_object_cast_to(const godot_object *p_object, void *p_class_t return o->is_class_ptr(p_class_tag) ? (godot_object *)o : nullptr; } +uint64_t GDAPI godot_object_get_instance_id(const godot_object *p_object) { + const Object *o = (const Object *)p_object; + return (uint64_t)o->get_instance_id(); +} + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/gdnative/node_path.cpp b/modules/gdnative/gdnative/node_path.cpp index 93f43835c8..88ed650ebe 100644 --- a/modules/gdnative/gdnative/node_path.cpp +++ b/modules/gdnative/gdnative/node_path.cpp @@ -37,6 +37,8 @@ extern "C" { #endif +static_assert(sizeof(godot_node_path) == sizeof(NodePath), "NodePath size mismatch"); + void GDAPI godot_node_path_new(godot_node_path *r_dest, const godot_string *p_from) { NodePath *dest = (NodePath *)r_dest; const String *from = (const String *)p_from; diff --git a/modules/gdnative/gdnative/pool_arrays.cpp b/modules/gdnative/gdnative/packed_arrays.cpp index 589b4d4dfe..675d66056a 100644 --- a/modules/gdnative/gdnative/pool_arrays.cpp +++ b/modules/gdnative/gdnative/packed_arrays.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* pool_arrays.cpp */ +/* packed_arrays.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "gdnative/pool_arrays.h" +#include "gdnative/packed_arrays.h" #include "core/array.h" @@ -42,6 +42,16 @@ extern "C" { #endif +static_assert(sizeof(godot_packed_byte_array) == sizeof(Vector<uint8_t>), "Vector<uint8_t> size mismatch"); +static_assert(sizeof(godot_packed_int32_array) == sizeof(Vector<int32_t>), "Vector<int32_t> size mismatch"); +static_assert(sizeof(godot_packed_int64_array) == sizeof(Vector<int64_t>), "Vector<int64_t> size mismatch"); +static_assert(sizeof(godot_packed_float32_array) == sizeof(Vector<float>), "Vector<float> size mismatch"); +static_assert(sizeof(godot_packed_float64_array) == sizeof(Vector<double>), "Vector<double> size mismatch"); +static_assert(sizeof(godot_packed_string_array) == sizeof(Vector<String>), "Vector<String> size mismatch"); +static_assert(sizeof(godot_packed_vector2_array) == sizeof(Vector<Vector2>), "Vector<Vector2> size mismatch"); +static_assert(sizeof(godot_packed_vector3_array) == sizeof(Vector<Vector3>), "Vector<Vector3> size mismatch"); +static_assert(sizeof(godot_packed_color_array) == sizeof(Vector<Color>), "Vector<Color> size mismatch"); + #define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr) // byte @@ -128,23 +138,191 @@ void GDAPI godot_packed_byte_array_destroy(godot_packed_byte_array *p_self) { ((Vector<uint8_t> *)p_self)->~Vector(); } -// int +// int32 + +void GDAPI godot_packed_int32_array_new(godot_packed_int32_array *r_dest) { + Vector<int32_t> *dest = (Vector<int32_t> *)r_dest; + memnew_placement(dest, Vector<int32_t>); +} + +void GDAPI godot_packed_int32_array_new_copy(godot_packed_int32_array *r_dest, const godot_packed_int32_array *p_src) { + Vector<int32_t> *dest = (Vector<int32_t> *)r_dest; + const Vector<int32_t> *src = (const Vector<int32_t> *)p_src; + memnew_placement(dest, Vector<int32_t>(*src)); +} + +void GDAPI godot_packed_int32_array_new_with_array(godot_packed_int32_array *r_dest, const godot_array *p_a) { + Vector<int32_t> *dest = (Vector<int32_t> *)r_dest; + Array *a = (Array *)p_a; + memnew_placement(dest, Vector<int32_t>); + + dest->resize(a->size()); + for (int i = 0; i < a->size(); i++) { + dest->set(i, (*a)[i]); + } +} + +void GDAPI godot_packed_int32_array_append(godot_packed_int32_array *p_self, const int32_t p_data) { + Vector<int32_t> *self = (Vector<int32_t> *)p_self; + self->push_back(p_data); +} + +void GDAPI godot_packed_int32_array_append_array(godot_packed_int32_array *p_self, const godot_packed_int32_array *p_array) { + Vector<int32_t> *self = (Vector<int32_t> *)p_self; + Vector<int32_t> *array = (Vector<int32_t> *)p_array; + self->append_array(*array); +} + +godot_error GDAPI godot_packed_int32_array_insert(godot_packed_int32_array *p_self, const godot_int p_idx, const int32_t p_data) { + Vector<int32_t> *self = (Vector<int32_t> *)p_self; + return (godot_error)self->insert(p_idx, p_data); +} + +void GDAPI godot_packed_int32_array_invert(godot_packed_int32_array *p_self) { + Vector<int32_t> *self = (Vector<int32_t> *)p_self; + self->invert(); +} + +void GDAPI godot_packed_int32_array_push_back(godot_packed_int32_array *p_self, const int32_t p_data) { + Vector<int32_t> *self = (Vector<int32_t> *)p_self; + self->push_back(p_data); +} + +void GDAPI godot_packed_int32_array_remove(godot_packed_int32_array *p_self, const godot_int p_idx) { + Vector<int32_t> *self = (Vector<int32_t> *)p_self; + self->remove(p_idx); +} + +void GDAPI godot_packed_int32_array_resize(godot_packed_int32_array *p_self, const godot_int p_size) { + Vector<int32_t> *self = (Vector<int32_t> *)p_self; + self->resize(p_size); +} + +void GDAPI godot_packed_int32_array_set(godot_packed_int32_array *p_self, const godot_int p_idx, const int32_t p_data) { + Vector<int32_t> *self = (Vector<int32_t> *)p_self; + self->set(p_idx, p_data); +} + +int32_t GDAPI godot_packed_int32_array_get(const godot_packed_int32_array *p_self, const godot_int p_idx) { + const Vector<int32_t> *self = (const Vector<int32_t> *)p_self; + return self->get(p_idx); +} + +godot_int GDAPI godot_packed_int32_array_size(const godot_packed_int32_array *p_self) { + const Vector<int32_t> *self = (const Vector<int32_t> *)p_self; + return self->size(); +} + +godot_bool GDAPI godot_packed_int32_array_empty(const godot_packed_int32_array *p_self) { + const Vector<int32_t> *self = (const Vector<int32_t> *)p_self; + return self->empty(); +} + +void GDAPI godot_packed_int32_array_destroy(godot_packed_int32_array *p_self) { + ((Vector<int32_t> *)p_self)->~Vector(); +} + +// int64 + +void GDAPI godot_packed_int64_array_new(godot_packed_int64_array *r_dest) { + Vector<int64_t> *dest = (Vector<int64_t> *)r_dest; + memnew_placement(dest, Vector<int64_t>); +} + +void GDAPI godot_packed_int64_array_new_copy(godot_packed_int64_array *r_dest, const godot_packed_int64_array *p_src) { + Vector<int64_t> *dest = (Vector<int64_t> *)r_dest; + const Vector<int64_t> *src = (const Vector<int64_t> *)p_src; + memnew_placement(dest, Vector<int64_t>(*src)); +} + +void GDAPI godot_packed_int64_array_new_with_array(godot_packed_int64_array *r_dest, const godot_array *p_a) { + Vector<int64_t> *dest = (Vector<int64_t> *)r_dest; + Array *a = (Array *)p_a; + memnew_placement(dest, Vector<int64_t>); + + dest->resize(a->size()); + for (int i = 0; i < a->size(); i++) { + dest->set(i, (*a)[i]); + } +} + +void GDAPI godot_packed_int64_array_append(godot_packed_int64_array *p_self, const int64_t p_data) { + Vector<int64_t> *self = (Vector<int64_t> *)p_self; + self->push_back(p_data); +} + +void GDAPI godot_packed_int64_array_append_array(godot_packed_int64_array *p_self, const godot_packed_int64_array *p_array) { + Vector<int64_t> *self = (Vector<int64_t> *)p_self; + Vector<int64_t> *array = (Vector<int64_t> *)p_array; + self->append_array(*array); +} + +godot_error GDAPI godot_packed_int64_array_insert(godot_packed_int64_array *p_self, const godot_int p_idx, const int64_t p_data) { + Vector<int64_t> *self = (Vector<int64_t> *)p_self; + return (godot_error)self->insert(p_idx, p_data); +} + +void GDAPI godot_packed_int64_array_invert(godot_packed_int64_array *p_self) { + Vector<int64_t> *self = (Vector<int64_t> *)p_self; + self->invert(); +} + +void GDAPI godot_packed_int64_array_push_back(godot_packed_int64_array *p_self, const int64_t p_data) { + Vector<int64_t> *self = (Vector<int64_t> *)p_self; + self->push_back(p_data); +} + +void GDAPI godot_packed_int64_array_remove(godot_packed_int64_array *p_self, const godot_int p_idx) { + Vector<int64_t> *self = (Vector<int64_t> *)p_self; + self->remove(p_idx); +} + +void GDAPI godot_packed_int64_array_resize(godot_packed_int64_array *p_self, const godot_int p_size) { + Vector<int64_t> *self = (Vector<int64_t> *)p_self; + self->resize(p_size); +} + +void GDAPI godot_packed_int64_array_set(godot_packed_int64_array *p_self, const godot_int p_idx, const int64_t p_data) { + Vector<int64_t> *self = (Vector<int64_t> *)p_self; + self->set(p_idx, p_data); +} + +int64_t GDAPI godot_packed_int64_array_get(const godot_packed_int64_array *p_self, const godot_int p_idx) { + const Vector<int64_t> *self = (const Vector<int64_t> *)p_self; + return self->get(p_idx); +} + +godot_int GDAPI godot_packed_int64_array_size(const godot_packed_int64_array *p_self) { + const Vector<int64_t> *self = (const Vector<int64_t> *)p_self; + return self->size(); +} + +godot_bool GDAPI godot_packed_int64_array_empty(const godot_packed_int64_array *p_self) { + const Vector<int64_t> *self = (const Vector<int64_t> *)p_self; + return self->empty(); +} + +void GDAPI godot_packed_int64_array_destroy(godot_packed_int64_array *p_self) { + ((Vector<int64_t> *)p_self)->~Vector(); +} + +// float32 -void GDAPI godot_packed_int_array_new(godot_packed_int_array *r_dest) { - Vector<godot_int> *dest = (Vector<godot_int> *)r_dest; - memnew_placement(dest, Vector<godot_int>); +void GDAPI godot_packed_float32_array_new(godot_packed_float32_array *r_dest) { + Vector<float> *dest = (Vector<float> *)r_dest; + memnew_placement(dest, Vector<float>); } -void GDAPI godot_packed_int_array_new_copy(godot_packed_int_array *r_dest, const godot_packed_int_array *p_src) { - Vector<godot_int> *dest = (Vector<godot_int> *)r_dest; - const Vector<godot_int> *src = (const Vector<godot_int> *)p_src; - memnew_placement(dest, Vector<godot_int>(*src)); +void GDAPI godot_packed_float32_array_new_copy(godot_packed_float32_array *r_dest, const godot_packed_float32_array *p_src) { + Vector<float> *dest = (Vector<float> *)r_dest; + const Vector<float> *src = (const Vector<float> *)p_src; + memnew_placement(dest, Vector<float>(*src)); } -void GDAPI godot_packed_int_array_new_with_array(godot_packed_int_array *r_dest, const godot_array *p_a) { - Vector<godot_int> *dest = (Vector<godot_int> *)r_dest; +void GDAPI godot_packed_float32_array_new_with_array(godot_packed_float32_array *r_dest, const godot_array *p_a) { + Vector<float> *dest = (Vector<float> *)r_dest; Array *a = (Array *)p_a; - memnew_placement(dest, Vector<godot_int>); + memnew_placement(dest, Vector<float>); dest->resize(a->size()); for (int i = 0; i < a->size(); i++) { @@ -152,83 +330,83 @@ void GDAPI godot_packed_int_array_new_with_array(godot_packed_int_array *r_dest, } } -void GDAPI godot_packed_int_array_append(godot_packed_int_array *p_self, const godot_int p_data) { - Vector<godot_int> *self = (Vector<godot_int> *)p_self; +void GDAPI godot_packed_float32_array_append(godot_packed_float32_array *p_self, const float p_data) { + Vector<float> *self = (Vector<float> *)p_self; self->push_back(p_data); } -void GDAPI godot_packed_int_array_append_array(godot_packed_int_array *p_self, const godot_packed_int_array *p_array) { - Vector<godot_int> *self = (Vector<godot_int> *)p_self; - Vector<godot_int> *array = (Vector<godot_int> *)p_array; +void GDAPI godot_packed_float32_array_append_array(godot_packed_float32_array *p_self, const godot_packed_float32_array *p_array) { + Vector<float> *self = (Vector<float> *)p_self; + Vector<float> *array = (Vector<float> *)p_array; self->append_array(*array); } -godot_error GDAPI godot_packed_int_array_insert(godot_packed_int_array *p_self, const godot_int p_idx, const godot_int p_data) { - Vector<godot_int> *self = (Vector<godot_int> *)p_self; +godot_error GDAPI godot_packed_float32_array_insert(godot_packed_float32_array *p_self, const godot_int p_idx, const float p_data) { + Vector<float> *self = (Vector<float> *)p_self; return (godot_error)self->insert(p_idx, p_data); } -void GDAPI godot_packed_int_array_invert(godot_packed_int_array *p_self) { - Vector<godot_int> *self = (Vector<godot_int> *)p_self; +void GDAPI godot_packed_float32_array_invert(godot_packed_float32_array *p_self) { + Vector<float> *self = (Vector<float> *)p_self; self->invert(); } -void GDAPI godot_packed_int_array_push_back(godot_packed_int_array *p_self, const godot_int p_data) { - Vector<godot_int> *self = (Vector<godot_int> *)p_self; +void GDAPI godot_packed_float32_array_push_back(godot_packed_float32_array *p_self, const float p_data) { + Vector<float> *self = (Vector<float> *)p_self; self->push_back(p_data); } -void GDAPI godot_packed_int_array_remove(godot_packed_int_array *p_self, const godot_int p_idx) { - Vector<godot_int> *self = (Vector<godot_int> *)p_self; +void GDAPI godot_packed_float32_array_remove(godot_packed_float32_array *p_self, const godot_int p_idx) { + Vector<float> *self = (Vector<float> *)p_self; self->remove(p_idx); } -void GDAPI godot_packed_int_array_resize(godot_packed_int_array *p_self, const godot_int p_size) { - Vector<godot_int> *self = (Vector<godot_int> *)p_self; +void GDAPI godot_packed_float32_array_resize(godot_packed_float32_array *p_self, const godot_int p_size) { + Vector<float> *self = (Vector<float> *)p_self; self->resize(p_size); } -void GDAPI godot_packed_int_array_set(godot_packed_int_array *p_self, const godot_int p_idx, const godot_int p_data) { - Vector<godot_int> *self = (Vector<godot_int> *)p_self; +void GDAPI godot_packed_float32_array_set(godot_packed_float32_array *p_self, const godot_int p_idx, const float p_data) { + Vector<float> *self = (Vector<float> *)p_self; self->set(p_idx, p_data); } -godot_int GDAPI godot_packed_int_array_get(const godot_packed_int_array *p_self, const godot_int p_idx) { - const Vector<godot_int> *self = (const Vector<godot_int> *)p_self; +float GDAPI godot_packed_float32_array_get(const godot_packed_float32_array *p_self, const godot_int p_idx) { + const Vector<float> *self = (const Vector<float> *)p_self; return self->get(p_idx); } -godot_int GDAPI godot_packed_int_array_size(const godot_packed_int_array *p_self) { - const Vector<godot_int> *self = (const Vector<godot_int> *)p_self; +godot_int GDAPI godot_packed_float32_array_size(const godot_packed_float32_array *p_self) { + const Vector<float> *self = (const Vector<float> *)p_self; return self->size(); } -godot_bool GDAPI godot_packed_int_array_empty(const godot_packed_int_array *p_self) { - const Vector<godot_int> *self = (const Vector<godot_int> *)p_self; +godot_bool GDAPI godot_packed_float32_array_empty(const godot_packed_float32_array *p_self) { + const Vector<float> *self = (const Vector<float> *)p_self; return self->empty(); } -void GDAPI godot_packed_int_array_destroy(godot_packed_int_array *p_self) { - ((Vector<godot_int> *)p_self)->~Vector(); +void GDAPI godot_packed_float32_array_destroy(godot_packed_float32_array *p_self) { + ((Vector<float> *)p_self)->~Vector(); } -// real +// float64 -void GDAPI godot_packed_real_array_new(godot_packed_real_array *r_dest) { - Vector<godot_real> *dest = (Vector<godot_real> *)r_dest; - memnew_placement(dest, Vector<godot_real>); +void GDAPI godot_packed_float64_array_new(godot_packed_float64_array *r_dest) { + Vector<double> *dest = (Vector<double> *)r_dest; + memnew_placement(dest, Vector<double>); } -void GDAPI godot_packed_real_array_new_copy(godot_packed_real_array *r_dest, const godot_packed_real_array *p_src) { - Vector<godot_real> *dest = (Vector<godot_real> *)r_dest; - const Vector<godot_real> *src = (const Vector<godot_real> *)p_src; - memnew_placement(dest, Vector<godot_real>(*src)); +void GDAPI godot_packed_float64_array_new_copy(godot_packed_float64_array *r_dest, const godot_packed_float64_array *p_src) { + Vector<double> *dest = (Vector<double> *)r_dest; + const Vector<double> *src = (const Vector<double> *)p_src; + memnew_placement(dest, Vector<double>(*src)); } -void GDAPI godot_packed_real_array_new_with_array(godot_packed_real_array *r_dest, const godot_array *p_a) { - Vector<godot_real> *dest = (Vector<godot_real> *)r_dest; +void GDAPI godot_packed_float64_array_new_with_array(godot_packed_float64_array *r_dest, const godot_array *p_a) { + Vector<double> *dest = (Vector<double> *)r_dest; Array *a = (Array *)p_a; - memnew_placement(dest, Vector<godot_real>); + memnew_placement(dest, Vector<double>); dest->resize(a->size()); for (int i = 0; i < a->size(); i++) { @@ -236,64 +414,64 @@ void GDAPI godot_packed_real_array_new_with_array(godot_packed_real_array *r_des } } -void GDAPI godot_packed_real_array_append(godot_packed_real_array *p_self, const godot_real p_data) { - Vector<godot_real> *self = (Vector<godot_real> *)p_self; +void GDAPI godot_packed_float64_array_append(godot_packed_float64_array *p_self, const double p_data) { + Vector<double> *self = (Vector<double> *)p_self; self->push_back(p_data); } -void GDAPI godot_packed_real_array_append_array(godot_packed_real_array *p_self, const godot_packed_real_array *p_array) { - Vector<godot_real> *self = (Vector<godot_real> *)p_self; - Vector<godot_real> *array = (Vector<godot_real> *)p_array; +void GDAPI godot_packed_float64_array_append_array(godot_packed_float64_array *p_self, const godot_packed_float64_array *p_array) { + Vector<double> *self = (Vector<double> *)p_self; + Vector<double> *array = (Vector<double> *)p_array; self->append_array(*array); } -godot_error GDAPI godot_packed_real_array_insert(godot_packed_real_array *p_self, const godot_int p_idx, const godot_real p_data) { - Vector<godot_real> *self = (Vector<godot_real> *)p_self; +godot_error GDAPI godot_packed_float64_array_insert(godot_packed_float64_array *p_self, const godot_int p_idx, const double p_data) { + Vector<double> *self = (Vector<double> *)p_self; return (godot_error)self->insert(p_idx, p_data); } -void GDAPI godot_packed_real_array_invert(godot_packed_real_array *p_self) { - Vector<godot_real> *self = (Vector<godot_real> *)p_self; +void GDAPI godot_packed_float64_array_invert(godot_packed_float64_array *p_self) { + Vector<double> *self = (Vector<double> *)p_self; self->invert(); } -void GDAPI godot_packed_real_array_push_back(godot_packed_real_array *p_self, const godot_real p_data) { - Vector<godot_real> *self = (Vector<godot_real> *)p_self; +void GDAPI godot_packed_float64_array_push_back(godot_packed_float64_array *p_self, const double p_data) { + Vector<double> *self = (Vector<double> *)p_self; self->push_back(p_data); } -void GDAPI godot_packed_real_array_remove(godot_packed_real_array *p_self, const godot_int p_idx) { - Vector<godot_real> *self = (Vector<godot_real> *)p_self; +void GDAPI godot_packed_float64_array_remove(godot_packed_float64_array *p_self, const godot_int p_idx) { + Vector<double> *self = (Vector<double> *)p_self; self->remove(p_idx); } -void GDAPI godot_packed_real_array_resize(godot_packed_real_array *p_self, const godot_int p_size) { - Vector<godot_real> *self = (Vector<godot_real> *)p_self; +void GDAPI godot_packed_float64_array_resize(godot_packed_float64_array *p_self, const godot_int p_size) { + Vector<double> *self = (Vector<double> *)p_self; self->resize(p_size); } -void GDAPI godot_packed_real_array_set(godot_packed_real_array *p_self, const godot_int p_idx, const godot_real p_data) { - Vector<godot_real> *self = (Vector<godot_real> *)p_self; +void GDAPI godot_packed_float64_array_set(godot_packed_float64_array *p_self, const godot_int p_idx, const double p_data) { + Vector<double> *self = (Vector<double> *)p_self; self->set(p_idx, p_data); } -godot_real GDAPI godot_packed_real_array_get(const godot_packed_real_array *p_self, const godot_int p_idx) { - const Vector<godot_real> *self = (const Vector<godot_real> *)p_self; +double GDAPI godot_packed_float64_array_get(const godot_packed_float64_array *p_self, const godot_int p_idx) { + const Vector<double> *self = (const Vector<double> *)p_self; return self->get(p_idx); } -godot_int GDAPI godot_packed_real_array_size(const godot_packed_real_array *p_self) { - const Vector<godot_real> *self = (const Vector<godot_real> *)p_self; +godot_int GDAPI godot_packed_float64_array_size(const godot_packed_float64_array *p_self) { + const Vector<double> *self = (const Vector<double> *)p_self; return self->size(); } -godot_bool GDAPI godot_packed_real_array_empty(const godot_packed_real_array *p_self) { - const Vector<godot_real> *self = (const Vector<godot_real> *)p_self; +godot_bool GDAPI godot_packed_float64_array_empty(const godot_packed_float64_array *p_self) { + const Vector<double> *self = (const Vector<double> *)p_self; return self->empty(); } -void GDAPI godot_packed_real_array_destroy(godot_packed_real_array *p_self) { - ((Vector<godot_real> *)p_self)->~Vector(); +void GDAPI godot_packed_float64_array_destroy(godot_packed_float64_array *p_self) { + ((Vector<double> *)p_self)->~Vector(); } // string diff --git a/modules/gdnative/gdnative/plane.cpp b/modules/gdnative/gdnative/plane.cpp index 923308dc34..663937f906 100644 --- a/modules/gdnative/gdnative/plane.cpp +++ b/modules/gdnative/gdnative/plane.cpp @@ -37,6 +37,8 @@ extern "C" { #endif +static_assert(sizeof(godot_plane) == sizeof(Plane), "Plane size mismatch"); + void GDAPI godot_plane_new_with_reals(godot_plane *r_dest, const godot_real p_a, const godot_real p_b, const godot_real p_c, const godot_real p_d) { Plane *dest = (Plane *)r_dest; *dest = Plane(p_a, p_b, p_c, p_d); diff --git a/modules/gdnative/gdnative/quat.cpp b/modules/gdnative/gdnative/quat.cpp index 15c04f7191..de6308ad2a 100644 --- a/modules/gdnative/gdnative/quat.cpp +++ b/modules/gdnative/gdnative/quat.cpp @@ -37,6 +37,8 @@ extern "C" { #endif +static_assert(sizeof(godot_quat) == sizeof(Quat), "Quat size mismatch"); + void GDAPI godot_quat_new(godot_quat *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z, const godot_real p_w) { Quat *dest = (Quat *)r_dest; *dest = Quat(p_x, p_y, p_z, p_w); diff --git a/modules/gdnative/gdnative/rect2.cpp b/modules/gdnative/gdnative/rect2.cpp index a2f735172f..516f4d75ce 100644 --- a/modules/gdnative/gdnative/rect2.cpp +++ b/modules/gdnative/gdnative/rect2.cpp @@ -37,6 +37,11 @@ extern "C" { #endif +static_assert(sizeof(godot_rect2) == sizeof(Rect2), "Rect2 size mismatch"); +static_assert(sizeof(godot_rect2i) == sizeof(Rect2i), "Rect2i size mismatch"); + +// Rect2 + void GDAPI godot_rect2_new_with_position_and_size(godot_rect2 *r_dest, const godot_vector2 *p_pos, const godot_vector2 *p_size) { const Vector2 *position = (const Vector2 *)p_pos; const Vector2 *size = (const Vector2 *)p_size; @@ -56,6 +61,13 @@ godot_string GDAPI godot_rect2_as_string(const godot_rect2 *p_self) { return ret; } +godot_rect2i GDAPI godot_rect2_as_rect2i(const godot_rect2 *p_self) { + godot_rect2i dest; + const Rect2 *self = (const Rect2 *)p_self; + *((Rect2i *)&dest) = Rect2i(*self); + return dest; +} + godot_real GDAPI godot_rect2_get_area(const godot_rect2 *p_self) { const Rect2 *self = (const Rect2 *)p_self; return self->get_area(); @@ -171,6 +183,149 @@ void GDAPI godot_rect2_set_size(godot_rect2 *p_self, const godot_vector2 *p_size self->set_size(*size); } +// Rect2i + +void GDAPI godot_rect2i_new_with_position_and_size(godot_rect2i *r_dest, const godot_vector2i *p_pos, const godot_vector2i *p_size) { + const Vector2i *position = (const Vector2i *)p_pos; + const Vector2i *size = (const Vector2i *)p_size; + Rect2i *dest = (Rect2i *)r_dest; + *dest = Rect2i(*position, *size); +} + +void GDAPI godot_rect2i_new(godot_rect2i *r_dest, const godot_int p_x, const godot_int p_y, const godot_int p_width, const godot_int p_height) { + Rect2i *dest = (Rect2i *)r_dest; + *dest = Rect2i(p_x, p_y, p_width, p_height); +} + +godot_string GDAPI godot_rect2i_as_string(const godot_rect2i *p_self) { + godot_string ret; + const Rect2i *self = (const Rect2i *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_rect2 GDAPI godot_rect2i_as_rect2(const godot_rect2i *p_self) { + godot_rect2 dest; + const Rect2i *self = (const Rect2i *)p_self; + *((Rect2 *)&dest) = Rect2(*self); + return dest; +} + +godot_int GDAPI godot_rect2i_get_area(const godot_rect2i *p_self) { + const Rect2i *self = (const Rect2i *)p_self; + return self->get_area(); +} + +godot_bool GDAPI godot_rect2i_intersects(const godot_rect2i *p_self, const godot_rect2i *p_b) { + const Rect2i *self = (const Rect2i *)p_self; + const Rect2i *b = (const Rect2i *)p_b; + return self->intersects(*b); +} + +godot_bool GDAPI godot_rect2i_encloses(const godot_rect2i *p_self, const godot_rect2i *p_b) { + const Rect2i *self = (const Rect2i *)p_self; + const Rect2i *b = (const Rect2i *)p_b; + return self->encloses(*b); +} + +godot_bool GDAPI godot_rect2i_has_no_area(const godot_rect2i *p_self) { + const Rect2i *self = (const Rect2i *)p_self; + return self->has_no_area(); +} + +godot_rect2i GDAPI godot_rect2i_clip(const godot_rect2i *p_self, const godot_rect2i *p_b) { + godot_rect2i dest; + const Rect2i *self = (const Rect2i *)p_self; + const Rect2i *b = (const Rect2i *)p_b; + *((Rect2i *)&dest) = self->clip(*b); + return dest; +} + +godot_rect2i GDAPI godot_rect2i_merge(const godot_rect2i *p_self, const godot_rect2i *p_b) { + godot_rect2i dest; + const Rect2i *self = (const Rect2i *)p_self; + const Rect2i *b = (const Rect2i *)p_b; + *((Rect2i *)&dest) = self->merge(*b); + return dest; +} + +godot_bool GDAPI godot_rect2i_has_point(const godot_rect2i *p_self, const godot_vector2i *p_point) { + const Rect2i *self = (const Rect2i *)p_self; + const Vector2i *point = (const Vector2i *)p_point; + return self->has_point(*point); +} + +godot_rect2i GDAPI godot_rect2i_grow(const godot_rect2i *p_self, const godot_int p_by) { + godot_rect2i dest; + const Rect2i *self = (const Rect2i *)p_self; + + *((Rect2i *)&dest) = self->grow(p_by); + return dest; +} + +godot_rect2i GDAPI godot_rect2i_grow_individual(const godot_rect2i *p_self, const godot_int p_left, const godot_int p_top, const godot_int p_right, const godot_int p_bottom) { + godot_rect2i dest; + const Rect2i *self = (const Rect2i *)p_self; + *((Rect2i *)&dest) = self->grow_individual(p_left, p_top, p_right, p_bottom); + return dest; +} + +godot_rect2i GDAPI godot_rect2i_grow_margin(const godot_rect2i *p_self, const godot_int p_margin, const godot_int p_by) { + godot_rect2i dest; + const Rect2i *self = (const Rect2i *)p_self; + *((Rect2i *)&dest) = self->grow_margin((Margin)p_margin, p_by); + return dest; +} + +godot_rect2i GDAPI godot_rect2i_abs(const godot_rect2i *p_self) { + godot_rect2i dest; + const Rect2i *self = (const Rect2i *)p_self; + *((Rect2i *)&dest) = self->abs(); + return dest; +} + +godot_rect2i GDAPI godot_rect2i_expand(const godot_rect2i *p_self, const godot_vector2i *p_to) { + godot_rect2i dest; + const Rect2i *self = (const Rect2i *)p_self; + const Vector2i *to = (const Vector2i *)p_to; + *((Rect2i *)&dest) = self->expand(*to); + return dest; +} + +godot_bool GDAPI godot_rect2i_operator_equal(const godot_rect2i *p_self, const godot_rect2i *p_b) { + const Rect2i *self = (const Rect2i *)p_self; + const Rect2i *b = (const Rect2i *)p_b; + return *self == *b; +} + +godot_vector2i GDAPI godot_rect2i_get_position(const godot_rect2i *p_self) { + godot_vector2i dest; + Vector2i *d = (Vector2i *)&dest; + const Rect2i *self = (const Rect2i *)p_self; + *d = self->get_position(); + return dest; +} + +godot_vector2i GDAPI godot_rect2i_get_size(const godot_rect2i *p_self) { + godot_vector2i dest; + Vector2i *d = (Vector2i *)&dest; + const Rect2i *self = (const Rect2i *)p_self; + *d = self->get_size(); + return dest; +} + +void GDAPI godot_rect2i_set_position(godot_rect2i *p_self, const godot_vector2i *p_pos) { + Rect2i *self = (Rect2i *)p_self; + const Vector2i *position = (const Vector2i *)p_pos; + self->set_position(*position); +} + +void GDAPI godot_rect2i_set_size(godot_rect2i *p_self, const godot_vector2i *p_size) { + Rect2i *self = (Rect2i *)p_self; + const Vector2i *size = (const Vector2i *)p_size; + self->set_size(*size); +} + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/gdnative/rid.cpp b/modules/gdnative/gdnative/rid.cpp index 7ea80123a3..d7a63f33a7 100644 --- a/modules/gdnative/gdnative/rid.cpp +++ b/modules/gdnative/gdnative/rid.cpp @@ -38,6 +38,8 @@ extern "C" { #endif +static_assert(sizeof(godot_rid) == sizeof(RID), "RID size mismatch"); + void GDAPI godot_rid_new(godot_rid *r_dest) { RID *dest = (RID *)r_dest; memnew_placement(dest, RID); diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp index a22af89edc..724a4b56cb 100644 --- a/modules/gdnative/gdnative/string.cpp +++ b/modules/gdnative/gdnative/string.cpp @@ -40,6 +40,10 @@ extern "C" { #endif +static_assert(sizeof(godot_char_string) == sizeof(CharString), "CharString size mismatch"); +static_assert(sizeof(godot_string) == sizeof(String), "String size mismatch"); +static_assert(sizeof(godot_char_type) == sizeof(CharType), "CharType size mismatch"); + godot_int GDAPI godot_char_string_length(const godot_char_string *p_cs) { const CharString *cs = (const CharString *)p_cs; diff --git a/modules/gdnative/gdnative/string_name.cpp b/modules/gdnative/gdnative/string_name.cpp index 1abb4486b1..7bbaaeeaa0 100644 --- a/modules/gdnative/gdnative/string_name.cpp +++ b/modules/gdnative/gdnative/string_name.cpp @@ -39,6 +39,8 @@ extern "C" { #endif +static_assert(sizeof(godot_string_name) == sizeof(StringName), "StringName size mismatch"); + void GDAPI godot_string_name_new(godot_string_name *r_dest, const godot_string *p_name) { StringName *dest = (StringName *)r_dest; const String *name = (const String *)p_name; diff --git a/modules/gdnative/gdnative/transform.cpp b/modules/gdnative/gdnative/transform.cpp index c9b3e37fb2..d19de93e9b 100644 --- a/modules/gdnative/gdnative/transform.cpp +++ b/modules/gdnative/gdnative/transform.cpp @@ -37,6 +37,8 @@ extern "C" { #endif +static_assert(sizeof(godot_transform) == sizeof(Transform), "Transform size mismatch"); + void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis, const godot_vector3 *p_origin) { const Vector3 *x_axis = (const Vector3 *)p_x_axis; const Vector3 *y_axis = (const Vector3 *)p_y_axis; diff --git a/modules/gdnative/gdnative/transform2d.cpp b/modules/gdnative/gdnative/transform2d.cpp index 26a71333b1..c0f7878eb0 100644 --- a/modules/gdnative/gdnative/transform2d.cpp +++ b/modules/gdnative/gdnative/transform2d.cpp @@ -37,6 +37,8 @@ extern "C" { #endif +static_assert(sizeof(godot_transform2d) == sizeof(Transform2D), "Transform2D size mismatch"); + void GDAPI godot_transform2d_new(godot_transform2d *r_dest, const godot_real p_rot, const godot_vector2 *p_pos) { const Vector2 *pos = (const Vector2 *)p_pos; Transform2D *dest = (Transform2D *)r_dest; diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp index f0fc44ae8a..dac4feb0e5 100644 --- a/modules/gdnative/gdnative/variant.cpp +++ b/modules/gdnative/gdnative/variant.cpp @@ -37,6 +37,8 @@ extern "C" { #endif +static_assert(sizeof(godot_variant) == sizeof(Variant), "Variant size mismatch"); + // Workaround GCC ICE on armv7hl which was affected GCC 6.0 up to 8.0 (GH-16100). // It was fixed upstream in 8.1, and a fix was backported to 7.4. // This can be removed once no supported distro ships with versions older than 7.4. @@ -97,24 +99,48 @@ void GDAPI godot_variant_new_string(godot_variant *r_dest, const godot_string *p memnew_placement_custom(dest, Variant, Variant(*s)); } +void GDAPI godot_variant_new_string_name(godot_variant *r_dest, const godot_string_name *p_s) { + Variant *dest = (Variant *)r_dest; + StringName *s = (StringName *)p_s; + memnew_placement_custom(dest, Variant, Variant(*s)); +} + void GDAPI godot_variant_new_vector2(godot_variant *r_dest, const godot_vector2 *p_v2) { Variant *dest = (Variant *)r_dest; Vector2 *v2 = (Vector2 *)p_v2; memnew_placement_custom(dest, Variant, Variant(*v2)); } +void GDAPI godot_variant_new_vector2i(godot_variant *r_dest, const godot_vector2i *p_v2) { + Variant *dest = (Variant *)r_dest; + Vector2i *v2 = (Vector2i *)p_v2; + memnew_placement_custom(dest, Variant, Variant(*v2)); +} + void GDAPI godot_variant_new_rect2(godot_variant *r_dest, const godot_rect2 *p_rect2) { Variant *dest = (Variant *)r_dest; Rect2 *rect2 = (Rect2 *)p_rect2; memnew_placement_custom(dest, Variant, Variant(*rect2)); } +void GDAPI godot_variant_new_rect2i(godot_variant *r_dest, const godot_rect2i *p_rect2) { + Variant *dest = (Variant *)r_dest; + Rect2i *rect2 = (Rect2i *)p_rect2; + memnew_placement_custom(dest, Variant, Variant(*rect2)); +} + void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3 *p_v3) { Variant *dest = (Variant *)r_dest; Vector3 *v3 = (Vector3 *)p_v3; memnew_placement_custom(dest, Variant, Variant(*v3)); } +void GDAPI godot_variant_new_vector3i(godot_variant *r_dest, const godot_vector3i *p_v3) { + Variant *dest = (Variant *)r_dest; + Vector3i *v3 = (Vector3i *)p_v3; + memnew_placement_custom(dest, Variant, Variant(*v3)); +} + void GDAPI godot_variant_new_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d) { Variant *dest = (Variant *)r_dest; Transform2D *t2d = (Transform2D *)p_t2d; @@ -169,6 +195,18 @@ void GDAPI godot_variant_new_rid(godot_variant *r_dest, const godot_rid *p_rid) memnew_placement_custom(dest, Variant, Variant(*rid)); } +void GDAPI godot_variant_new_callable(godot_variant *r_dest, const godot_callable *p_cb) { + Variant *dest = (Variant *)r_dest; + Callable *cb = (Callable *)p_cb; + memnew_placement_custom(dest, Variant, Variant(*cb)); +} + +void GDAPI godot_variant_new_signal(godot_variant *r_dest, const godot_signal *p_signal) { + Variant *dest = (Variant *)r_dest; + Signal *signal = (Signal *)p_signal; + memnew_placement_custom(dest, Variant, Variant(*signal)); +} + void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p_obj) { Variant *dest = (Variant *)r_dest; Object *obj = (Object *)p_obj; @@ -207,18 +245,30 @@ void GDAPI godot_variant_new_packed_byte_array(godot_variant *r_dest, const godo memnew_placement_custom(dest, Variant, Variant(*pba)); } -void GDAPI godot_variant_new_packed_int_array(godot_variant *r_dest, const godot_packed_int_array *p_pia) { +void GDAPI godot_variant_new_packed_int32_array(godot_variant *r_dest, const godot_packed_int32_array *p_pia) { Variant *dest = (Variant *)r_dest; PackedInt32Array *pia = (PackedInt32Array *)p_pia; memnew_placement_custom(dest, Variant, Variant(*pia)); } -void GDAPI godot_variant_new_packed_real_array(godot_variant *r_dest, const godot_packed_real_array *p_pra) { +void GDAPI godot_variant_new_packed_int64_array(godot_variant *r_dest, const godot_packed_int64_array *p_pia) { + Variant *dest = (Variant *)r_dest; + PackedInt64Array *pia = (PackedInt64Array *)p_pia; + memnew_placement_custom(dest, Variant, Variant(*pia)); +} + +void GDAPI godot_variant_new_packed_float32_array(godot_variant *r_dest, const godot_packed_float32_array *p_pra) { Variant *dest = (Variant *)r_dest; PackedFloat32Array *pra = (PackedFloat32Array *)p_pra; memnew_placement_custom(dest, Variant, Variant(*pra)); } +void GDAPI godot_variant_new_packed_float64_array(godot_variant *r_dest, const godot_packed_float64_array *p_pra) { + Variant *dest = (Variant *)r_dest; + PackedFloat64Array *pra = (PackedFloat64Array *)p_pra; + memnew_placement_custom(dest, Variant, Variant(*pra)); +} + void GDAPI godot_variant_new_packed_string_array(godot_variant *r_dest, const godot_packed_string_array *p_psa) { Variant *dest = (Variant *)r_dest; PackedStringArray *psa = (PackedStringArray *)p_psa; @@ -271,6 +321,14 @@ godot_string GDAPI godot_variant_as_string(const godot_variant *p_self) { return raw_dest; } +godot_string_name GDAPI godot_variant_as_string_name(const godot_variant *p_self) { + godot_string_name raw_dest; + const Variant *self = (const Variant *)p_self; + StringName *dest = (StringName *)&raw_dest; + memnew_placement(dest, StringName(self->operator StringName())); // operator = is overloaded by StringName + return raw_dest; +} + godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_self) { godot_vector2 raw_dest; const Variant *self = (const Variant *)p_self; @@ -279,6 +337,14 @@ godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_self) { return raw_dest; } +godot_vector2i GDAPI godot_variant_as_vector2i(const godot_variant *p_self) { + godot_vector2i raw_dest; + const Variant *self = (const Variant *)p_self; + Vector2i *dest = (Vector2i *)&raw_dest; + *dest = *self; + return raw_dest; +} + godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_self) { godot_rect2 raw_dest; const Variant *self = (const Variant *)p_self; @@ -287,6 +353,14 @@ godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_self) { return raw_dest; } +godot_rect2i GDAPI godot_variant_as_rect2i(const godot_variant *p_self) { + godot_rect2i raw_dest; + const Variant *self = (const Variant *)p_self; + Rect2i *dest = (Rect2i *)&raw_dest; + *dest = *self; + return raw_dest; +} + godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_self) { godot_vector3 raw_dest; const Variant *self = (const Variant *)p_self; @@ -295,6 +369,14 @@ godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_self) { return raw_dest; } +godot_vector3i GDAPI godot_variant_as_vector3i(const godot_variant *p_self) { + godot_vector3i raw_dest; + const Variant *self = (const Variant *)p_self; + Vector3i *dest = (Vector3i *)&raw_dest; + *dest = *self; + return raw_dest; +} + godot_transform2d GDAPI godot_variant_as_transform2d(const godot_variant *p_self) { godot_transform2d raw_dest; const Variant *self = (const Variant *)p_self; @@ -367,6 +449,22 @@ godot_rid GDAPI godot_variant_as_rid(const godot_variant *p_self) { return raw_dest; } +godot_callable GDAPI godot_variant_as_callable(const godot_variant *p_self) { + godot_callable raw_dest; + const Variant *self = (const Variant *)p_self; + Callable *dest = (Callable *)&raw_dest; + *dest = *self; + return raw_dest; +} + +godot_signal GDAPI godot_variant_as_signal(const godot_variant *p_self) { + godot_signal raw_dest; + const Variant *self = (const Variant *)p_self; + Signal *dest = (Signal *)&raw_dest; + *dest = *self; + return raw_dest; +} + godot_object GDAPI *godot_variant_as_object(const godot_variant *p_self) { const Variant *self = (const Variant *)p_self; Object *dest; @@ -399,8 +497,8 @@ godot_packed_byte_array GDAPI godot_variant_as_packed_byte_array(const godot_var return raw_dest; } -godot_packed_int_array GDAPI godot_variant_as_packed_int_array(const godot_variant *p_self) { - godot_packed_int_array raw_dest; +godot_packed_int32_array GDAPI godot_variant_as_packed_int32_array(const godot_variant *p_self) { + godot_packed_int32_array raw_dest; const Variant *self = (const Variant *)p_self; PackedInt32Array *dest = (PackedInt32Array *)&raw_dest; memnew_placement(dest, PackedInt32Array(self->operator PackedInt32Array())); // operator = is overloaded by PackedInt32Array @@ -408,8 +506,17 @@ godot_packed_int_array GDAPI godot_variant_as_packed_int_array(const godot_varia return raw_dest; } -godot_packed_real_array GDAPI godot_variant_as_packed_real_array(const godot_variant *p_self) { - godot_packed_real_array raw_dest; +godot_packed_int64_array GDAPI godot_variant_as_packed_int64_array(const godot_variant *p_self) { + godot_packed_int64_array raw_dest; + const Variant *self = (const Variant *)p_self; + PackedInt64Array *dest = (PackedInt64Array *)&raw_dest; + memnew_placement(dest, PackedInt64Array(self->operator PackedInt64Array())); // operator = is overloaded by PackedInt64Array + *dest = *self; + return raw_dest; +} + +godot_packed_float32_array GDAPI godot_variant_as_packed_float32_array(const godot_variant *p_self) { + godot_packed_float32_array raw_dest; const Variant *self = (const Variant *)p_self; PackedFloat32Array *dest = (PackedFloat32Array *)&raw_dest; memnew_placement(dest, PackedFloat32Array(self->operator PackedFloat32Array())); // operator = is overloaded by PackedFloat32Array @@ -417,6 +524,15 @@ godot_packed_real_array GDAPI godot_variant_as_packed_real_array(const godot_var return raw_dest; } +godot_packed_float64_array GDAPI godot_variant_as_packed_float64_array(const godot_variant *p_self) { + godot_packed_float64_array raw_dest; + const Variant *self = (const Variant *)p_self; + PackedFloat64Array *dest = (PackedFloat64Array *)&raw_dest; + memnew_placement(dest, PackedFloat64Array(self->operator PackedFloat64Array())); // operator = is overloaded by PackedFloat64Array + *dest = *self; + return raw_dest; +} + godot_packed_string_array GDAPI godot_variant_as_packed_string_array(const godot_variant *p_self) { godot_packed_string_array raw_dest; const Variant *self = (const Variant *)p_self; @@ -487,6 +603,11 @@ godot_bool GDAPI godot_variant_operator_less(const godot_variant *p_self, const return self->operator<(*other); } +uint32_t GDAPI godot_variant_hash(const godot_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->hash(); +} + godot_bool GDAPI godot_variant_hash_compare(const godot_variant *p_self, const godot_variant *p_other) { const Variant *self = (const Variant *)p_self; const Variant *other = (const Variant *)p_other; diff --git a/modules/gdnative/gdnative/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp index b6c3569f42..1ee716df86 100644 --- a/modules/gdnative/gdnative/vector2.cpp +++ b/modules/gdnative/gdnative/vector2.cpp @@ -37,6 +37,11 @@ extern "C" { #endif +static_assert(sizeof(godot_vector2) == sizeof(Vector2), "Vector2 size mismatch"); +static_assert(sizeof(godot_vector2i) == sizeof(Vector2i), "Vector2i size mismatch"); + +// Vector2 + void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y) { Vector2 *dest = (Vector2 *)r_dest; *dest = Vector2(p_x, p_y); @@ -49,6 +54,13 @@ godot_string GDAPI godot_vector2_as_string(const godot_vector2 *p_self) { return ret; } +godot_vector2i GDAPI godot_vector2_as_vector2i(const godot_vector2 *p_self) { + godot_vector2i dest; + const Vector2 *self = (const Vector2 *)p_self; + *((Vector2i *)&dest) = Vector2i(*self); + return dest; +} + godot_vector2 GDAPI godot_vector2_normalized(const godot_vector2 *p_self) { godot_vector2 dest; const Vector2 *self = (const Vector2 *)p_self; @@ -156,6 +168,13 @@ godot_vector2 GDAPI godot_vector2_floor(const godot_vector2 *p_self) { return dest; } +godot_vector2 GDAPI godot_vector2_sign(const godot_vector2 *p_self) { + godot_vector2 dest; + const Vector2 *self = (const Vector2 *)p_self; + *((Vector2 *)&dest) = self->sign(); + return dest; +} + godot_vector2 GDAPI godot_vector2_snapped(const godot_vector2 *p_self, const godot_vector2 *p_by) { godot_vector2 dest; const Vector2 *self = (const Vector2 *)p_self; @@ -306,6 +325,138 @@ godot_real GDAPI godot_vector2_get_y(const godot_vector2 *p_self) { return self->y; } +// Vector2i + +void GDAPI godot_vector2i_new(godot_vector2i *r_dest, const godot_int p_x, const godot_int p_y) { + Vector2i *dest = (Vector2i *)r_dest; + *dest = Vector2i(p_x, p_y); +} + +godot_string GDAPI godot_vector2i_as_string(const godot_vector2i *p_self) { + godot_string ret; + const Vector2i *self = (const Vector2i *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_vector2 GDAPI godot_vector2i_as_vector2(const godot_vector2i *p_self) { + godot_vector2 dest; + const Vector2i *self = (const Vector2i *)p_self; + *((Vector2 *)&dest) = Vector2(*self); + return dest; +} + +godot_real GDAPI godot_vector2i_aspect(const godot_vector2i *p_self) { + const Vector2i *self = (const Vector2i *)p_self; + return self->aspect(); +} + +godot_vector2i GDAPI godot_vector2i_abs(const godot_vector2i *p_self) { + godot_vector2i dest; + const Vector2i *self = (const Vector2i *)p_self; + *((Vector2i *)&dest) = self->abs(); + return dest; +} + +godot_vector2i GDAPI godot_vector2i_sign(const godot_vector2i *p_self) { + godot_vector2i dest; + const Vector2i *self = (const Vector2i *)p_self; + *((Vector2i *)&dest) = self->sign(); + return dest; +} + +godot_vector2i GDAPI godot_vector2i_operator_add(const godot_vector2i *p_self, const godot_vector2i *p_b) { + godot_vector2i raw_dest; + Vector2i *dest = (Vector2i *)&raw_dest; + const Vector2i *self = (const Vector2i *)p_self; + const Vector2i *b = (const Vector2i *)p_b; + *dest = *self + *b; + return raw_dest; +} + +godot_vector2i GDAPI godot_vector2i_operator_subtract(const godot_vector2i *p_self, const godot_vector2i *p_b) { + godot_vector2i raw_dest; + Vector2i *dest = (Vector2i *)&raw_dest; + const Vector2i *self = (const Vector2i *)p_self; + const Vector2i *b = (const Vector2i *)p_b; + *dest = *self - *b; + return raw_dest; +} + +godot_vector2i GDAPI godot_vector2i_operator_multiply_vector(const godot_vector2i *p_self, const godot_vector2i *p_b) { + godot_vector2i raw_dest; + Vector2i *dest = (Vector2i *)&raw_dest; + const Vector2i *self = (const Vector2i *)p_self; + const Vector2i *b = (const Vector2i *)p_b; + *dest = *self * *b; + return raw_dest; +} + +godot_vector2i GDAPI godot_vector2i_operator_multiply_scalar(const godot_vector2i *p_self, const godot_int p_b) { + godot_vector2i raw_dest; + Vector2i *dest = (Vector2i *)&raw_dest; + const Vector2i *self = (const Vector2i *)p_self; + *dest = *self * p_b; + return raw_dest; +} + +godot_vector2i GDAPI godot_vector2i_operator_divide_vector(const godot_vector2i *p_self, const godot_vector2i *p_b) { + godot_vector2i raw_dest; + Vector2i *dest = (Vector2i *)&raw_dest; + const Vector2i *self = (const Vector2i *)p_self; + const Vector2i *b = (const Vector2i *)p_b; + *dest = *self / *b; + return raw_dest; +} + +godot_vector2i GDAPI godot_vector2i_operator_divide_scalar(const godot_vector2i *p_self, const godot_int p_b) { + godot_vector2i raw_dest; + Vector2i *dest = (Vector2i *)&raw_dest; + const Vector2i *self = (const Vector2i *)p_self; + *dest = *self / p_b; + return raw_dest; +} + +godot_bool GDAPI godot_vector2i_operator_equal(const godot_vector2i *p_self, const godot_vector2i *p_b) { + const Vector2i *self = (const Vector2i *)p_self; + const Vector2i *b = (const Vector2i *)p_b; + return *self == *b; +} + +godot_bool GDAPI godot_vector2i_operator_less(const godot_vector2i *p_self, const godot_vector2i *p_b) { + const Vector2i *self = (const Vector2i *)p_self; + const Vector2i *b = (const Vector2i *)p_b; + return *self < *b; +} + +godot_vector2i GDAPI godot_vector2i_operator_neg(const godot_vector2i *p_self) { + godot_vector2i raw_dest; + Vector2i *dest = (Vector2i *)&raw_dest; + const Vector2i *self = (const Vector2i *)p_self; + *dest = -(*self); + return raw_dest; +} + +void GDAPI godot_vector2i_set_x(godot_vector2i *p_self, const godot_int p_x) { + Vector2i *self = (Vector2i *)p_self; + self->x = p_x; +} + +void GDAPI godot_vector2i_set_y(godot_vector2i *p_self, const godot_int p_y) { + Vector2i *self = (Vector2i *)p_self; + self->y = p_y; +} + +godot_int GDAPI godot_vector2i_get_x(const godot_vector2i *p_self) { + const Vector2i *self = (const Vector2i *)p_self; + return self->x; +} + +godot_int GDAPI godot_vector2i_get_y(const godot_vector2i *p_self) { + const Vector2i *self = (const Vector2i *)p_self; + return self->y; +} + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/gdnative/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp index 3e272ae9df..32cad30c17 100644 --- a/modules/gdnative/gdnative/vector3.cpp +++ b/modules/gdnative/gdnative/vector3.cpp @@ -37,6 +37,11 @@ extern "C" { #endif +static_assert(sizeof(godot_vector3) == sizeof(Vector3), "Vector3 size mismatch"); +static_assert(sizeof(godot_vector3i) == sizeof(Vector3i), "Vector3i size mismatch"); + +// Vector3 + void GDAPI godot_vector3_new(godot_vector3 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z) { Vector3 *dest = (Vector3 *)r_dest; *dest = Vector3(p_x, p_y, p_z); @@ -49,6 +54,13 @@ godot_string GDAPI godot_vector3_as_string(const godot_vector3 *p_self) { return ret; } +godot_vector3i GDAPI godot_vector3_as_vector3i(const godot_vector3 *p_self) { + godot_vector3i dest; + const Vector3 *self = (const Vector3 *)p_self; + *((Vector3i *)&dest) = Vector3i(*self); + return dest; +} + godot_int GDAPI godot_vector3_min_axis(const godot_vector3 *p_self) { const Vector3 *self = (const Vector3 *)p_self; return self->min_axis(); @@ -167,6 +179,13 @@ godot_vector3 GDAPI godot_vector3_abs(const godot_vector3 *p_self) { return dest; } +godot_vector3 GDAPI godot_vector3_sign(const godot_vector3 *p_self) { + godot_vector3 dest; + const Vector3 *self = (const Vector3 *)p_self; + *((Vector3 *)&dest) = self->sign(); + return dest; +} + godot_vector3 GDAPI godot_vector3_floor(const godot_vector3 *p_self) { godot_vector3 dest; const Vector3 *self = (const Vector3 *)p_self; @@ -313,6 +332,133 @@ godot_real GDAPI godot_vector3_get_axis(const godot_vector3 *p_self, const godot return self->get_axis(p_axis); } +// Vector3i + +void GDAPI godot_vector3i_new(godot_vector3i *r_dest, const godot_int p_x, const godot_int p_y, const godot_int p_z) { + Vector3i *dest = (Vector3i *)r_dest; + *dest = Vector3i(p_x, p_y, p_z); +} + +godot_string GDAPI godot_vector3i_as_string(const godot_vector3i *p_self) { + godot_string ret; + const Vector3i *self = (const Vector3i *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_vector3 GDAPI godot_vector3i_as_vector3(const godot_vector3i *p_self) { + godot_vector3 dest; + const Vector3i *self = (const Vector3i *)p_self; + *((Vector3 *)&dest) = Vector3(*self); + return dest; +} + +godot_int GDAPI godot_vector3i_min_axis(const godot_vector3i *p_self) { + const Vector3i *self = (const Vector3i *)p_self; + return self->min_axis(); +} + +godot_int GDAPI godot_vector3i_max_axis(const godot_vector3i *p_self) { + const Vector3i *self = (const Vector3i *)p_self; + return self->max_axis(); +} + +godot_vector3i GDAPI godot_vector3i_abs(const godot_vector3i *p_self) { + godot_vector3i dest; + const Vector3i *self = (const Vector3i *)p_self; + *((Vector3i *)&dest) = self->abs(); + return dest; +} + +godot_vector3i GDAPI godot_vector3i_sign(const godot_vector3i *p_self) { + godot_vector3i dest; + const Vector3i *self = (const Vector3i *)p_self; + *((Vector3i *)&dest) = self->sign(); + return dest; +} + +godot_vector3i GDAPI godot_vector3i_operator_add(const godot_vector3i *p_self, const godot_vector3i *p_b) { + godot_vector3i raw_dest; + Vector3i *dest = (Vector3i *)&raw_dest; + Vector3i *self = (Vector3i *)p_self; + const Vector3i *b = (const Vector3i *)p_b; + *dest = *self + *b; + return raw_dest; +} + +godot_vector3i GDAPI godot_vector3i_operator_subtract(const godot_vector3i *p_self, const godot_vector3i *p_b) { + godot_vector3i raw_dest; + Vector3i *dest = (Vector3i *)&raw_dest; + Vector3i *self = (Vector3i *)p_self; + const Vector3i *b = (const Vector3i *)p_b; + *dest = *self - *b; + return raw_dest; +} + +godot_vector3i GDAPI godot_vector3i_operator_multiply_vector(const godot_vector3i *p_self, const godot_vector3i *p_b) { + godot_vector3i raw_dest; + Vector3i *dest = (Vector3i *)&raw_dest; + Vector3i *self = (Vector3i *)p_self; + const Vector3i *b = (const Vector3i *)p_b; + *dest = *self * *b; + return raw_dest; +} + +godot_vector3i GDAPI godot_vector3i_operator_multiply_scalar(const godot_vector3i *p_self, const godot_int p_b) { + godot_vector3i raw_dest; + Vector3i *dest = (Vector3i *)&raw_dest; + Vector3i *self = (Vector3i *)p_self; + *dest = *self * p_b; + return raw_dest; +} + +godot_vector3i GDAPI godot_vector3i_operator_divide_vector(const godot_vector3i *p_self, const godot_vector3i *p_b) { + godot_vector3i raw_dest; + Vector3i *dest = (Vector3i *)&raw_dest; + Vector3i *self = (Vector3i *)p_self; + const Vector3i *b = (const Vector3i *)p_b; + *dest = *self / *b; + return raw_dest; +} + +godot_vector3i GDAPI godot_vector3i_operator_divide_scalar(const godot_vector3i *p_self, const godot_int p_b) { + godot_vector3i raw_dest; + Vector3i *dest = (Vector3i *)&raw_dest; + Vector3i *self = (Vector3i *)p_self; + *dest = *self / p_b; + return raw_dest; +} + +godot_bool GDAPI godot_vector3i_operator_equal(const godot_vector3i *p_self, const godot_vector3i *p_b) { + Vector3i *self = (Vector3i *)p_self; + const Vector3i *b = (const Vector3i *)p_b; + return *self == *b; +} + +godot_bool GDAPI godot_vector3i_operator_less(const godot_vector3i *p_self, const godot_vector3i *p_b) { + Vector3i *self = (Vector3i *)p_self; + const Vector3i *b = (const Vector3i *)p_b; + return *self < *b; +} + +godot_vector3i GDAPI godot_vector3i_operator_neg(const godot_vector3i *p_self) { + godot_vector3i raw_dest; + Vector3i *dest = (Vector3i *)&raw_dest; + const Vector3i *self = (const Vector3i *)p_self; + *dest = -(*self); + return raw_dest; +} + +void GDAPI godot_vector3i_set_axis(godot_vector3i *p_self, const godot_vector3_axis p_axis, const godot_int p_val) { + Vector3i *self = (Vector3i *)p_self; + self->set_axis(p_axis, p_val); +} + +godot_int GDAPI godot_vector3i_get_axis(const godot_vector3i *p_self, const godot_vector3_axis p_axis) { + const Vector3i *self = (const Vector3i *)p_self; + return self->get_axis(p_axis); +} + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index d5ab62dc61..9c38c8b58d 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -17,7 +17,1125 @@ "major": 1, "minor": 2 }, - "next": null, + "next": { + "type": "CORE", + "version": { + "major": 1, + "minor": 3 + }, + "next": null, + "api": [ + { + "name": "godot_object_get_instance_id", + "return_type": "uint64_t", + "arguments": [ + ["const godot_object *", "p_object"] + ] + }, + { + "name": "godot_array_new_packed_float64_array", + "return_type": "void", + "arguments": [ + ["godot_array *", "r_dest"], + ["const godot_packed_float64_array *", "p_pra"] + ] + }, + { + "name": "godot_array_new_packed_int64_array", + "return_type": "void", + "arguments": [ + ["godot_array *", "r_dest"], + ["const godot_packed_int64_array *", "p_pia"] + ] + }, + { + "name": "godot_callable_new_with_object", + "return_type": "void", + "arguments": [ + ["godot_callable *", "r_dest"], + ["const godot_object *", "p_object"], + ["const godot_string_name *", "p_method"] + ] + }, + { + "name": "godot_callable_new_with_object_id", + "return_type": "void", + "arguments": [ + ["godot_callable *", "r_dest"], + ["uint64_t", "p_objectid"], + ["const godot_string_name *", "p_method"] + ] + }, + { + "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", + "arguments": [ + ["godot_callable *", "p_self"] + ] + }, + { + "name": "godot_callable_call", + "return_type": "godot_int", + "arguments": [ + ["const godot_callable *", "p_self"], + ["const godot_variant **", "p_arguments"], + ["godot_int", "p_argcount"], + ["godot_variant *", "r_return_value"] + ] + }, + { + "name": "godot_callable_call_deferred", + "return_type": "void", + "arguments": [ + ["const godot_callable *", "p_self"], + ["const godot_variant **", "p_arguments"], + ["godot_int", "p_argcount"] + ] + }, + { + "name": "godot_callable_is_null", + "return_type": "godot_bool", + "arguments": [ + ["const godot_callable *", "p_self"] + ] + }, + { + "name": "godot_callable_is_custom", + "return_type": "godot_bool", + "arguments": [ + ["const godot_callable *", "p_self"] + ] + }, + { + "name": "godot_callable_is_standard", + "return_type": "godot_bool", + "arguments": [ + ["const godot_callable *", "p_self"] + ] + }, + { + "name": "godot_callable_get_object", + "return_type": "godot_object *", + "arguments": [ + ["const godot_callable *", "p_self"] + ] + }, + { + "name": "godot_callable_get_object_id", + "return_type": "uint64_t", + "arguments": [ + ["const godot_callable *", "p_self"] + ] + }, + { + "name": "godot_callable_get_method", + "return_type": "godot_string_name", + "arguments": [ + ["const godot_callable *", "p_self"] + ] + }, + { + "name": "godot_callable_hash", + "return_type": "uint32_t", + "arguments": [ + ["const godot_callable *", "p_self"] + ] + }, + { + "name": "godot_callable_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_callable *", "p_self"] + ] + }, + { + "name": "godot_callable_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_callable *", "p_self"], + ["const godot_callable *", "p_other"] + ] + }, + { + "name": "godot_callable_operator_less", + "return_type": "godot_bool", + "arguments": [ + ["const godot_callable *", "p_self"], + ["const godot_callable *", "p_other"] + ] + }, + { + "name": "godot_signal_new_with_object", + "return_type": "void", + "arguments": [ + ["godot_signal *", "r_dest"], + ["const godot_object *", "p_object"], + ["const godot_string_name *", "p_method"] + ] + }, + { + "name": "godot_signal_new_with_object_id", + "return_type": "void", + "arguments": [ + ["godot_signal *", "r_dest"], + ["uint64_t", "p_objectid"], + ["const godot_string_name *", "p_method"] + ] + }, + { + "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", + "arguments": [ + ["godot_signal *", "p_self"] + ] + }, + { + "name": "godot_signal_emit", + "return_type": "godot_int", + "arguments": [ + ["const godot_signal *", "p_self"], + ["const godot_variant **", "p_arguments"], + ["godot_int", "p_argcount"] + ] + }, + { + "name": "godot_signal_connect", + "return_type": "godot_int", + "arguments": [ + ["godot_signal *", "p_self"], + ["const godot_callable *", "p_callable"], + ["const godot_array *", "p_binds"], + ["uint32_t", "p_flags"] + ] + }, + { + "name": "godot_signal_disconnect", + "return_type": "void", + "arguments": [ + ["godot_signal *", "p_self"], + ["const godot_callable *", "p_callable"] + ] + }, + { + "name": "godot_signal_is_null", + "return_type": "godot_bool", + "arguments": [ + ["const godot_signal *", "p_self"] + ] + }, + { + "name": "godot_signal_is_connected", + "return_type": "godot_bool", + "arguments": [ + ["const godot_signal *", "p_self"], + ["const godot_callable *", "p_callable"] + ] + }, + { + "name": "godot_signal_get_connections", + "return_type": "godot_array", + "arguments": [ + ["const godot_signal *", "p_self"] + ] + }, + { + "name": "godot_signal_get_object", + "return_type": "godot_object *", + "arguments": [ + ["const godot_signal *", "p_self"] + ] + }, + { + "name": "godot_signal_get_object_id", + "return_type": "uint64_t", + "arguments": [ + ["const godot_signal *", "p_self"] + ] + }, + { + "name": "godot_signal_get_name", + "return_type": "godot_string_name", + "arguments": [ + ["const godot_signal *", "p_self"] + ] + }, + { + "name": "godot_signal_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_signal *", "p_self"] + ] + }, + { + "name": "godot_signal_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_signal *", "p_self"], + ["const godot_signal *", "p_other"] + ] + }, + { + "name": "godot_signal_operator_less", + "return_type": "godot_bool", + "arguments": [ + ["const godot_signal *", "p_self"], + ["const godot_signal *", "p_other"] + ] + }, + { + "name": "godot_packed_int64_array_new", + "return_type": "void", + "arguments": [ + ["godot_packed_int64_array *", "r_dest"] + ] + }, + { + "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_new_with_array", + "return_type": "void", + "arguments": [ + ["godot_packed_int64_array *", "r_dest"], + ["const godot_array *", "p_a"] + ] + }, + { + "name": "godot_packed_int64_array_append", + "return_type": "void", + "arguments": [ + ["godot_packed_int64_array *", "p_self"], + ["const int64_t", "p_data"] + ] + }, + { + "name": "godot_packed_int64_array_append_array", + "return_type": "void", + "arguments": [ + ["godot_packed_int64_array *", "p_self"], + ["const godot_packed_int64_array *", "p_array"] + ] + }, + { + "name": "godot_packed_int64_array_insert", + "return_type": "godot_error", + "arguments": [ + ["godot_packed_int64_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const int64_t", "p_data"] + ] + }, + { + "name": "godot_packed_int64_array_invert", + "return_type": "void", + "arguments": [ + ["godot_packed_int64_array *", "p_self"] + ] + }, + { + "name": "godot_packed_int64_array_push_back", + "return_type": "void", + "arguments": [ + ["godot_packed_int64_array *", "p_self"], + ["const int64_t", "p_data"] + ] + }, + { + "name": "godot_packed_int64_array_remove", + "return_type": "void", + "arguments": [ + ["godot_packed_int64_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_packed_int64_array_resize", + "return_type": "void", + "arguments": [ + ["godot_packed_int64_array *", "p_self"], + ["const godot_int", "p_size"] + ] + }, + { + "name": "godot_packed_int64_array_set", + "return_type": "void", + "arguments": [ + ["godot_packed_int64_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const int64_t", "p_data"] + ] + }, + { + "name": "godot_packed_int64_array_get", + "return_type": "int64_t", + "arguments": [ + ["const godot_packed_int64_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_packed_int64_array_size", + "return_type": "godot_int", + "arguments": [ + ["const godot_packed_int64_array *", "p_self"] + ] + }, + { + "name": "godot_packed_int64_array_destroy", + "return_type": "void", + "arguments": [ + ["godot_packed_int64_array *", "p_self"] + ] + }, + { + "name": "godot_packed_float64_array_new", + "return_type": "void", + "arguments": [ + ["godot_packed_float64_array *", "r_dest"] + ] + }, + { + "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_new_with_array", + "return_type": "void", + "arguments": [ + ["godot_packed_float64_array *", "r_dest"], + ["const godot_array *", "p_a"] + ] + }, + { + "name": "godot_packed_float64_array_append", + "return_type": "void", + "arguments": [ + ["godot_packed_float64_array *", "p_self"], + ["const double", "p_data"] + ] + }, + { + "name": "godot_packed_float64_array_append_array", + "return_type": "void", + "arguments": [ + ["godot_packed_float64_array *", "p_self"], + ["const godot_packed_float64_array *", "p_array"] + ] + }, + { + "name": "godot_packed_float64_array_insert", + "return_type": "godot_error", + "arguments": [ + ["godot_packed_float64_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const double", "p_data"] + ] + }, + { + "name": "godot_packed_float64_array_invert", + "return_type": "void", + "arguments": [ + ["godot_packed_float64_array *", "p_self"] + ] + }, + { + "name": "godot_packed_float64_array_push_back", + "return_type": "void", + "arguments": [ + ["godot_packed_float64_array *", "p_self"], + ["const double", "p_data"] + ] + }, + { + "name": "godot_packed_float64_array_remove", + "return_type": "void", + "arguments": [ + ["godot_packed_float64_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_packed_float64_array_resize", + "return_type": "void", + "arguments": [ + ["godot_packed_float64_array *", "p_self"], + ["const godot_int", "p_size"] + ] + }, + { + "name": "godot_packed_float64_array_set", + "return_type": "void", + "arguments": [ + ["godot_packed_float64_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const double", "p_data"] + ] + }, + { + "name": "godot_packed_float64_array_get", + "return_type": "double", + "arguments": [ + ["const godot_packed_float64_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_packed_float64_array_size", + "return_type": "godot_int", + "arguments": [ + ["const godot_packed_float64_array *", "p_self"] + ] + }, + { + "name": "godot_packed_float64_array_destroy", + "return_type": "void", + "arguments": [ + ["godot_packed_float64_array *", "p_self"] + ] + }, + { + "name": "godot_rect2_as_rect2i", + "return_type": "godot_rect2i", + "arguments": [ + ["const godot_rect2 *", "p_self"] + ] + }, + { + "name": "godot_rect2i_new_with_position_and_size", + "return_type": "void", + "arguments": [ + ["godot_rect2i *", "r_dest"], + ["const godot_vector2i *", "p_pos"], + ["const godot_vector2i *", "p_size"] + ] + }, + { + "name": "godot_rect2i_new", + "return_type": "void", + "arguments": [ + ["godot_rect2i *", "r_dest"], + ["const godot_int", "p_x"], + ["const godot_int", "p_y"], + ["const godot_int", "p_width"], + ["const godot_int", "p_height"] + ] + }, + { + "name": "godot_rect2i_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_rect2i *", "p_self"] + ] + }, + { + "name": "godot_rect2i_as_rect2", + "return_type": "godot_rect2", + "arguments": [ + ["const godot_rect2i *", "p_self"] + ] + }, + { + "name": "godot_rect2i_get_area", + "return_type": "godot_int", + "arguments": [ + ["const godot_rect2i *", "p_self"] + ] + }, + { + "name": "godot_rect2i_intersects", + "return_type": "godot_bool", + "arguments": [ + ["const godot_rect2i *", "p_self"], + ["const godot_rect2i *", "p_b"] + ] + }, + { + "name": "godot_rect2i_encloses", + "return_type": "godot_bool", + "arguments": [ + ["const godot_rect2i *", "p_self"], + ["const godot_rect2i *", "p_b"] + ] + }, + { + "name": "godot_rect2i_has_no_area", + "return_type": "godot_bool", + "arguments": [ + ["const godot_rect2i *", "p_self"] + ] + }, + { + "name": "godot_rect2i_clip", + "return_type": "godot_rect2i", + "arguments": [ + ["const godot_rect2i *", "p_self"], + ["const godot_rect2i *", "p_b"] + ] + }, + { + "name": "godot_rect2i_merge", + "return_type": "godot_rect2i", + "arguments": [ + ["const godot_rect2i *", "p_self"], + ["const godot_rect2i *", "p_b"] + ] + }, + { + "name": "godot_rect2i_has_point", + "return_type": "godot_bool", + "arguments": [ + ["const godot_rect2i *", "p_self"], + ["const godot_vector2i *", "p_point"] + ] + }, + { + "name": "godot_rect2i_grow", + "return_type": "godot_rect2i", + "arguments": [ + ["const godot_rect2i *", "p_self"], + ["const godot_int", "p_by"] + ] + }, + { + "name": "godot_rect2i_grow_individual", + "return_type": "godot_rect2i", + "arguments": [ + ["const godot_rect2i *", "p_self"], + ["const godot_int", "p_left"], + ["const godot_int", "p_top"], + ["const godot_int", "p_right"], + ["const godot_int", "p_bottom"] + ] + }, + { + "name": "godot_rect2i_grow_margin", + "return_type": "godot_rect2i", + "arguments": [ + ["const godot_rect2i *", "p_self"], + ["const godot_int", "p_margin"], + ["const godot_int", "p_by"] + ] + }, + { + "name": "godot_rect2i_abs", + "return_type": "godot_rect2i", + "arguments": [ + ["const godot_rect2i *", "p_self"] + ] + }, + { + "name": "godot_rect2i_expand", + "return_type": "godot_rect2i", + "arguments": [ + ["const godot_rect2i *", "p_self"], + ["const godot_vector2i *", "p_to"] + ] + }, + { + "name": "godot_rect2i_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_rect2i *", "p_self"], + ["const godot_rect2i *", "p_b"] + ] + }, + { + "name": "godot_rect2i_get_position", + "return_type": "godot_vector2i", + "arguments": [ + ["const godot_rect2i *", "p_self"] + ] + }, + { + "name": "godot_rect2i_get_size", + "return_type": "godot_vector2i", + "arguments": [ + ["const godot_rect2i *", "p_self"] + ] + }, + { + "name": "godot_rect2i_set_position", + "return_type": "void", + "arguments": [ + ["godot_rect2i *", "p_self"], + ["const godot_vector2i *", "p_pos"] + ] + }, + { + "name": "godot_rect2i_set_size", + "return_type": "void", + "arguments": [ + ["godot_rect2i *", "p_self"], + ["const godot_vector2i *", "p_size"] + ] + }, + { + "name": "godot_variant_new_string_name", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_string_name *", "p_s"] + ] + }, + { + "name": "godot_variant_new_vector2i", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_vector2i *", "p_v2"] + ] + }, + { + "name": "godot_variant_new_rect2i", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_rect2i *", "p_rect2"] + ] + }, + { + "name": "godot_variant_new_vector3i", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_vector3i *", "p_v3"] + ] + }, + { + "name": "godot_variant_new_callable", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_callable *", "p_cb"] + ] + }, + { + "name": "godot_variant_new_signal", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_signal *", "p_signal"] + ] + }, + { + "name": "godot_variant_new_packed_int64_array", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_packed_int64_array *", "p_pia"] + ] + }, + { + "name": "godot_variant_new_packed_float64_array", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_packed_float64_array *", "p_pra"] + ] + }, + { + "name": "godot_variant_as_string_name", + "return_type": "godot_string_name", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_vector2i", + "return_type": "godot_vector2i", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_rect2i", + "return_type": "godot_rect2i", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_vector3i", + "return_type": "godot_vector3i", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_callable", + "return_type": "godot_callable", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_signal", + "return_type": "godot_signal", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_packed_int64_array", + "return_type": "godot_packed_int64_array", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_packed_float64_array", + "return_type": "godot_packed_float64_array", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_hash", + "return_type": "uint32_t", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_vector2_as_vector2i", + "return_type": "godot_vector2i", + "arguments": [ + ["const godot_vector2 *", "p_self"] + ] + }, + { + "name": "godot_vector2_sign", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"] + ] + }, + { + "name": "godot_vector2i_new", + "return_type": "void", + "arguments": [ + ["godot_vector2i *", "r_dest"], + ["const godot_int", "p_x"], + ["const godot_int", "p_y"] + ] + }, + { + "name": "godot_vector2i_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_vector2i *", "p_self"] + ] + }, + { + "name": "godot_vector2i_as_vector2", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2i *", "p_self"] + ] + }, + { + "name": "godot_vector2i_aspect", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector2i *", "p_self"] + ] + }, + { + "name": "godot_vector2i_abs", + "return_type": "godot_vector2i", + "arguments": [ + ["const godot_vector2i *", "p_self"] + ] + }, + { + "name": "godot_vector2i_sign", + "return_type": "godot_vector2i", + "arguments": [ + ["const godot_vector2i *", "p_self"] + ] + }, + { + "name": "godot_vector2i_operator_add", + "return_type": "godot_vector2i", + "arguments": [ + ["const godot_vector2i *", "p_self"], + ["const godot_vector2i *", "p_b"] + ] + }, + { + "name": "godot_vector2i_operator_subtract", + "return_type": "godot_vector2i", + "arguments": [ + ["const godot_vector2i *", "p_self"], + ["const godot_vector2i *", "p_b"] + ] + }, + { + "name": "godot_vector2i_operator_multiply_vector", + "return_type": "godot_vector2i", + "arguments": [ + ["const godot_vector2i *", "p_self"], + ["const godot_vector2i *", "p_b"] + ] + }, + { + "name": "godot_vector2i_operator_multiply_scalar", + "return_type": "godot_vector2i", + "arguments": [ + ["const godot_vector2i *", "p_self"], + ["const godot_int", "p_b"] + ] + }, + { + "name": "godot_vector2i_operator_divide_vector", + "return_type": "godot_vector2i", + "arguments": [ + ["const godot_vector2i *", "p_self"], + ["const godot_vector2i *", "p_b"] + ] + }, + { + "name": "godot_vector2i_operator_divide_scalar", + "return_type": "godot_vector2i", + "arguments": [ + ["const godot_vector2i *", "p_self"], + ["const godot_int", "p_b"] + ] + }, + { + "name": "godot_vector2i_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_vector2i *", "p_self"], + ["const godot_vector2i *", "p_b"] + ] + }, + { + "name": "godot_vector2i_operator_less", + "return_type": "godot_bool", + "arguments": [ + ["const godot_vector2i *", "p_self"], + ["const godot_vector2i *", "p_b"] + ] + }, + { + "name": "godot_vector2i_operator_neg", + "return_type": "godot_vector2i", + "arguments": [ + ["const godot_vector2i *", "p_self"] + ] + }, + { + "name": "godot_vector2i_set_x", + "return_type": "void", + "arguments": [ + ["godot_vector2i *", "p_self"], + ["const godot_int", "p_x"] + ] + }, + { + "name": "godot_vector2i_set_y", + "return_type": "void", + "arguments": [ + ["godot_vector2i *", "p_self"], + ["const godot_int", "p_y"] + ] + }, + { + "name": "godot_vector2i_get_x", + "return_type": "godot_int", + "arguments": [ + ["const godot_vector2i *", "p_self"] + ] + }, + { + "name": "godot_vector2i_get_y", + "return_type": "godot_int", + "arguments": [ + ["const godot_vector2i *", "p_self"] + ] + }, + { + "name": "godot_vector3_as_vector3i", + "return_type": "godot_vector3i", + "arguments": [ + ["const godot_vector3 *", "p_self"] + ] + }, + { + "name": "godot_vector3_sign", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"] + ] + }, + { + "name": "godot_vector3i_new", + "return_type": "void", + "arguments": [ + ["godot_vector3i *", "r_dest"], + ["const godot_int", "p_x"], + ["const godot_int", "p_y"], + ["const godot_int", "p_z"] + ] + }, + { + "name": "godot_vector3i_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_vector3i *", "p_self"] + ] + }, + { + "name": "godot_vector3i_as_vector3", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3i *", "p_self"] + ] + }, + { + "name": "godot_vector3i_min_axis", + "return_type": "godot_int", + "arguments": [ + ["const godot_vector3i *", "p_self"] + ] + }, + { + "name": "godot_vector3i_max_axis", + "return_type": "godot_int", + "arguments": [ + ["const godot_vector3i *", "p_self"] + ] + }, + { + "name": "godot_vector3i_abs", + "return_type": "godot_vector3i", + "arguments": [ + ["const godot_vector3i *", "p_self"] + ] + }, + { + "name": "godot_vector3i_sign", + "return_type": "godot_vector3i", + "arguments": [ + ["const godot_vector3i *", "p_self"] + ] + }, + { + "name": "godot_vector3i_operator_add", + "return_type": "godot_vector3i", + "arguments": [ + ["const godot_vector3i *", "p_self"], + ["const godot_vector3i *", "p_b"] + ] + }, + { + "name": "godot_vector3i_operator_subtract", + "return_type": "godot_vector3i", + "arguments": [ + ["const godot_vector3i *", "p_self"], + ["const godot_vector3i *", "p_b"] + ] + }, + { + "name": "godot_vector3i_operator_multiply_vector", + "return_type": "godot_vector3i", + "arguments": [ + ["const godot_vector3i *", "p_self"], + ["const godot_vector3i *", "p_b"] + ] + }, + { + "name": "godot_vector3i_operator_multiply_scalar", + "return_type": "godot_vector3i", + "arguments": [ + ["const godot_vector3i *", "p_self"], + ["const godot_int", "p_b"] + ] + }, + { + "name": "godot_vector3i_operator_divide_vector", + "return_type": "godot_vector3i", + "arguments": [ + ["const godot_vector3i *", "p_self"], + ["const godot_vector3i *", "p_b"] + ] + }, + { + "name": "godot_vector3i_operator_divide_scalar", + "return_type": "godot_vector3i", + "arguments": [ + ["const godot_vector3i *", "p_self"], + ["const godot_int", "p_b"] + ] + }, + { + "name": "godot_vector3i_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_vector3i *", "p_self"], + ["const godot_vector3i *", "p_b"] + ] + }, + { + "name": "godot_vector3i_operator_less", + "return_type": "godot_bool", + "arguments": [ + ["const godot_vector3i *", "p_self"], + ["const godot_vector3i *", "p_b"] + ] + }, + { + "name": "godot_vector3i_operator_neg", + "return_type": "godot_vector3i", + "arguments": [ + ["const godot_vector3i *", "p_self"] + ] + }, + { + "name": "godot_vector3i_set_axis", + "return_type": "void", + "arguments": [ + ["godot_vector3i *", "p_self"], + ["const godot_vector3_axis", "p_axis"], + ["const godot_int", "p_val"] + ] + }, + { + "name": "godot_vector3i_get_axis", + "return_type": "godot_int", + "arguments": [ + ["const godot_vector3i *", "p_self"], + ["const godot_vector3_axis", "p_axis"] + ] + } + ] + }, "api": [ { "name": "godot_dictionary_duplicate", @@ -100,17 +1218,17 @@ ] }, { - "name": "godot_packed_int_array_empty", + "name": "godot_packed_int32_array_empty", "return_type": "godot_bool", "arguments": [ - ["const godot_packed_int_array *", "p_self"] + ["const godot_packed_int32_array *", "p_self"] ] }, { - "name": "godot_packed_real_array_empty", + "name": "godot_packed_float32_array_empty", "return_type": "godot_bool", "arguments": [ - ["const godot_packed_real_array *", "p_self"] + ["const godot_packed_float32_array *", "p_self"] ] }, { @@ -160,7 +1278,7 @@ "name": "godot_instance_from_id", "return_type": "godot_object *", "arguments": [ - ["godot_int", "p_instance_id"] + ["uint64_t", "p_instance_id"] ] } ] @@ -1767,223 +2885,223 @@ ] }, { - "name": "godot_packed_int_array_new", + "name": "godot_packed_int32_array_new", "return_type": "void", "arguments": [ - ["godot_packed_int_array *", "r_dest"] + ["godot_packed_int32_array *", "r_dest"] ] }, { - "name": "godot_packed_int_array_new_copy", + "name": "godot_packed_int32_array_new_copy", "return_type": "void", "arguments": [ - ["godot_packed_int_array *", "r_dest"], - ["const godot_packed_int_array *", "p_src"] + ["godot_packed_int32_array *", "r_dest"], + ["const godot_packed_int32_array *", "p_src"] ] }, { - "name": "godot_packed_int_array_new_with_array", + "name": "godot_packed_int32_array_new_with_array", "return_type": "void", "arguments": [ - ["godot_packed_int_array *", "r_dest"], + ["godot_packed_int32_array *", "r_dest"], ["const godot_array *", "p_a"] ] }, { - "name": "godot_packed_int_array_append", + "name": "godot_packed_int32_array_append", "return_type": "void", "arguments": [ - ["godot_packed_int_array *", "p_self"], - ["const godot_int", "p_data"] + ["godot_packed_int32_array *", "p_self"], + ["const int32_t", "p_data"] ] }, { - "name": "godot_packed_int_array_append_array", + "name": "godot_packed_int32_array_append_array", "return_type": "void", "arguments": [ - ["godot_packed_int_array *", "p_self"], - ["const godot_packed_int_array *", "p_array"] + ["godot_packed_int32_array *", "p_self"], + ["const godot_packed_int32_array *", "p_array"] ] }, { - "name": "godot_packed_int_array_insert", + "name": "godot_packed_int32_array_insert", "return_type": "godot_error", "arguments": [ - ["godot_packed_int_array *", "p_self"], + ["godot_packed_int32_array *", "p_self"], ["const godot_int", "p_idx"], - ["const godot_int", "p_data"] + ["const int32_t", "p_data"] ] }, { - "name": "godot_packed_int_array_invert", + "name": "godot_packed_int32_array_invert", "return_type": "void", "arguments": [ - ["godot_packed_int_array *", "p_self"] + ["godot_packed_int32_array *", "p_self"] ] }, { - "name": "godot_packed_int_array_push_back", + "name": "godot_packed_int32_array_push_back", "return_type": "void", "arguments": [ - ["godot_packed_int_array *", "p_self"], - ["const godot_int", "p_data"] + ["godot_packed_int32_array *", "p_self"], + ["const int32_t", "p_data"] ] }, { - "name": "godot_packed_int_array_remove", + "name": "godot_packed_int32_array_remove", "return_type": "void", "arguments": [ - ["godot_packed_int_array *", "p_self"], + ["godot_packed_int32_array *", "p_self"], ["const godot_int", "p_idx"] ] }, { - "name": "godot_packed_int_array_resize", + "name": "godot_packed_int32_array_resize", "return_type": "void", "arguments": [ - ["godot_packed_int_array *", "p_self"], + ["godot_packed_int32_array *", "p_self"], ["const godot_int", "p_size"] ] }, { - "name": "godot_packed_int_array_set", + "name": "godot_packed_int32_array_set", "return_type": "void", "arguments": [ - ["godot_packed_int_array *", "p_self"], + ["godot_packed_int32_array *", "p_self"], ["const godot_int", "p_idx"], - ["const godot_int", "p_data"] + ["const int32_t", "p_data"] ] }, { - "name": "godot_packed_int_array_get", - "return_type": "godot_int", + "name": "godot_packed_int32_array_get", + "return_type": "int32_t", "arguments": [ - ["const godot_packed_int_array *", "p_self"], + ["const godot_packed_int32_array *", "p_self"], ["const godot_int", "p_idx"] ] }, { - "name": "godot_packed_int_array_size", + "name": "godot_packed_int32_array_size", "return_type": "godot_int", "arguments": [ - ["const godot_packed_int_array *", "p_self"] + ["const godot_packed_int32_array *", "p_self"] ] }, { - "name": "godot_packed_int_array_destroy", + "name": "godot_packed_int32_array_destroy", "return_type": "void", "arguments": [ - ["godot_packed_int_array *", "p_self"] + ["godot_packed_int32_array *", "p_self"] ] }, { - "name": "godot_packed_real_array_new", + "name": "godot_packed_float32_array_new", "return_type": "void", "arguments": [ - ["godot_packed_real_array *", "r_dest"] + ["godot_packed_float32_array *", "r_dest"] ] }, { - "name": "godot_packed_real_array_new_copy", + "name": "godot_packed_float32_array_new_copy", "return_type": "void", "arguments": [ - ["godot_packed_real_array *", "r_dest"], - ["const godot_packed_real_array *", "p_src"] + ["godot_packed_float32_array *", "r_dest"], + ["const godot_packed_float32_array *", "p_src"] ] }, { - "name": "godot_packed_real_array_new_with_array", + "name": "godot_packed_float32_array_new_with_array", "return_type": "void", "arguments": [ - ["godot_packed_real_array *", "r_dest"], + ["godot_packed_float32_array *", "r_dest"], ["const godot_array *", "p_a"] ] }, { - "name": "godot_packed_real_array_append", + "name": "godot_packed_float32_array_append", "return_type": "void", "arguments": [ - ["godot_packed_real_array *", "p_self"], - ["const godot_real", "p_data"] + ["godot_packed_float32_array *", "p_self"], + ["const float", "p_data"] ] }, { - "name": "godot_packed_real_array_append_array", + "name": "godot_packed_float32_array_append_array", "return_type": "void", "arguments": [ - ["godot_packed_real_array *", "p_self"], - ["const godot_packed_real_array *", "p_array"] + ["godot_packed_float32_array *", "p_self"], + ["const godot_packed_float32_array *", "p_array"] ] }, { - "name": "godot_packed_real_array_insert", + "name": "godot_packed_float32_array_insert", "return_type": "godot_error", "arguments": [ - ["godot_packed_real_array *", "p_self"], + ["godot_packed_float32_array *", "p_self"], ["const godot_int", "p_idx"], - ["const godot_real", "p_data"] + ["const float", "p_data"] ] }, { - "name": "godot_packed_real_array_invert", + "name": "godot_packed_float32_array_invert", "return_type": "void", "arguments": [ - ["godot_packed_real_array *", "p_self"] + ["godot_packed_float32_array *", "p_self"] ] }, { - "name": "godot_packed_real_array_push_back", + "name": "godot_packed_float32_array_push_back", "return_type": "void", "arguments": [ - ["godot_packed_real_array *", "p_self"], - ["const godot_real", "p_data"] + ["godot_packed_float32_array *", "p_self"], + ["const float", "p_data"] ] }, { - "name": "godot_packed_real_array_remove", + "name": "godot_packed_float32_array_remove", "return_type": "void", "arguments": [ - ["godot_packed_real_array *", "p_self"], + ["godot_packed_float32_array *", "p_self"], ["const godot_int", "p_idx"] ] }, { - "name": "godot_packed_real_array_resize", + "name": "godot_packed_float32_array_resize", "return_type": "void", "arguments": [ - ["godot_packed_real_array *", "p_self"], + ["godot_packed_float32_array *", "p_self"], ["const godot_int", "p_size"] ] }, { - "name": "godot_packed_real_array_set", + "name": "godot_packed_float32_array_set", "return_type": "void", "arguments": [ - ["godot_packed_real_array *", "p_self"], + ["godot_packed_float32_array *", "p_self"], ["const godot_int", "p_idx"], - ["const godot_real", "p_data"] + ["const float", "p_data"] ] }, { - "name": "godot_packed_real_array_get", - "return_type": "godot_real", + "name": "godot_packed_float32_array_get", + "return_type": "float", "arguments": [ - ["const godot_packed_real_array *", "p_self"], + ["const godot_packed_float32_array *", "p_self"], ["const godot_int", "p_idx"] ] }, { - "name": "godot_packed_real_array_size", + "name": "godot_packed_float32_array_size", "return_type": "godot_int", "arguments": [ - ["const godot_packed_real_array *", "p_self"] + ["const godot_packed_float32_array *", "p_self"] ] }, { - "name": "godot_packed_real_array_destroy", + "name": "godot_packed_float32_array_destroy", "return_type": "void", "arguments": [ - ["godot_packed_real_array *", "p_self"] + ["godot_packed_float32_array *", "p_self"] ] }, { @@ -2474,19 +3592,19 @@ ] }, { - "name": "godot_array_new_packed_real_array", + "name": "godot_array_new_packed_float32_array", "return_type": "void", "arguments": [ ["godot_array *", "r_dest"], - ["const godot_packed_real_array *", "p_pra"] + ["const godot_packed_float32_array *", "p_pra"] ] }, { - "name": "godot_array_new_packed_int_array", + "name": "godot_array_new_packed_int32_array", "return_type": "void", "arguments": [ ["godot_array *", "r_dest"], - ["const godot_packed_int_array *", "p_pia"] + ["const godot_packed_int32_array *", "p_pia"] ] }, { @@ -4059,19 +5177,19 @@ ] }, { - "name": "godot_variant_new_packed_int_array", + "name": "godot_variant_new_packed_int32_array", "return_type": "void", "arguments": [ ["godot_variant *", "r_dest"], - ["const godot_packed_int_array *", "p_pia"] + ["const godot_packed_int32_array *", "p_pia"] ] }, { - "name": "godot_variant_new_packed_real_array", + "name": "godot_variant_new_packed_float32_array", "return_type": "void", "arguments": [ ["godot_variant *", "r_dest"], - ["const godot_packed_real_array *", "p_pra"] + ["const godot_packed_float32_array *", "p_pra"] ] }, { @@ -4254,15 +5372,15 @@ ] }, { - "name": "godot_variant_as_packed_int_array", - "return_type": "godot_packed_int_array", + "name": "godot_variant_as_packed_int32_array", + "return_type": "godot_packed_int32_array", "arguments": [ ["const godot_variant *", "p_self"] ] }, { - "name": "godot_variant_as_packed_real_array", - "return_type": "godot_packed_real_array", + "name": "godot_variant_as_packed_float32_array", + "return_type": "godot_packed_float32_array", "arguments": [ ["const godot_variant *", "p_self"] ] @@ -5869,7 +6987,7 @@ "arguments": [ ["void *", "p_gdnative_handle"], ["const char *", "p_name"], - ["const godot_signal *", "p_signal"] + ["const godot_nativescript_signal *", "p_signal"] ] }, { diff --git a/modules/gdnative/include/gdnative/array.h b/modules/gdnative/include/gdnative/array.h index e3114e9348..4db685873f 100644 --- a/modules/gdnative/include/gdnative/array.h +++ b/modules/gdnative/include/gdnative/array.h @@ -51,7 +51,7 @@ typedef struct { } #endif -#include <gdnative/pool_arrays.h> +#include <gdnative/packed_arrays.h> #include <gdnative/variant.h> #include <gdnative/gdnative.h> @@ -66,8 +66,10 @@ void GDAPI godot_array_new_packed_color_array(godot_array *r_dest, const godot_p void GDAPI godot_array_new_packed_vector3_array(godot_array *r_dest, const godot_packed_vector3_array *p_pv3a); void GDAPI godot_array_new_packed_vector2_array(godot_array *r_dest, const godot_packed_vector2_array *p_pv2a); void GDAPI godot_array_new_packed_string_array(godot_array *r_dest, const godot_packed_string_array *p_psa); -void GDAPI godot_array_new_packed_real_array(godot_array *r_dest, const godot_packed_real_array *p_pra); -void GDAPI godot_array_new_packed_int_array(godot_array *r_dest, const godot_packed_int_array *p_pia); +void GDAPI godot_array_new_packed_float32_array(godot_array *r_dest, const godot_packed_float32_array *p_pra); +void GDAPI godot_array_new_packed_float64_array(godot_array *r_dest, const godot_packed_float64_array *p_pra); +void GDAPI godot_array_new_packed_int32_array(godot_array *r_dest, const godot_packed_int32_array *p_pia); +void GDAPI godot_array_new_packed_int64_array(godot_array *r_dest, const godot_packed_int64_array *p_pia); void GDAPI godot_array_new_packed_byte_array(godot_array *r_dest, const godot_packed_byte_array *p_pba); void GDAPI godot_array_set(godot_array *p_self, const godot_int p_idx, const godot_variant *p_value); diff --git a/modules/gdnative/include/gdnative/callable.h b/modules/gdnative/include/gdnative/callable.h new file mode 100644 index 0000000000..dbb5d02590 --- /dev/null +++ b/modules/gdnative/include/gdnative/callable.h @@ -0,0 +1,126 @@ +/*************************************************************************/ +/* callable.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef GODOT_CALLABLE_H +#define GODOT_CALLABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#define GODOT_CALLABLE_SIZE (16) + +#ifndef GODOT_CORE_API_GODOT_CALLABLE_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_CALLABLE_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_CALLABLE_SIZE]; +} godot_callable; +#endif + +#define GODOT_SIGNAL_SIZE (16) + +#ifndef GODOT_CORE_API_GODOT_SIGNAL_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_SIGNAL_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_SIGNAL_SIZE]; +} godot_signal; +#endif + +#ifdef __cplusplus +} +#endif + +#include <gdnative/gdnative.h> +#include <gdnative/string_name.h> + +#ifdef __cplusplus +extern "C" { +#endif + +// Callable + +void GDAPI godot_callable_new_with_object(godot_callable *r_dest, const godot_object *p_object, const godot_string_name *p_method); +void GDAPI godot_callable_new_with_object_id(godot_callable *r_dest, uint64_t p_objectid, const godot_string_name *p_method); +void GDAPI godot_callable_new_copy(godot_callable *r_dest, const godot_callable *p_src); + +void GDAPI godot_callable_destroy(godot_callable *p_self); + +godot_int GDAPI godot_callable_call(const godot_callable *p_self, const godot_variant **p_arguments, godot_int p_argcount, godot_variant *r_return_value); +void GDAPI godot_callable_call_deferred(const godot_callable *p_self, const godot_variant **p_arguments, godot_int p_argcount); + +godot_bool GDAPI godot_callable_is_null(const godot_callable *p_self); +godot_bool GDAPI godot_callable_is_custom(const godot_callable *p_self); +godot_bool GDAPI godot_callable_is_standard(const godot_callable *p_self); + +godot_object GDAPI *godot_callable_get_object(const godot_callable *p_self); +uint64_t GDAPI godot_callable_get_object_id(const godot_callable *p_self); +godot_string_name GDAPI godot_callable_get_method(const godot_callable *p_self); + +uint32_t GDAPI godot_callable_hash(const godot_callable *p_self); + +godot_string GDAPI godot_callable_as_string(const godot_callable *p_self); + +godot_bool GDAPI godot_callable_operator_equal(const godot_callable *p_self, const godot_callable *p_other); +godot_bool GDAPI godot_callable_operator_less(const godot_callable *p_self, const godot_callable *p_other); + +// Signal + +void GDAPI godot_signal_new_with_object(godot_signal *r_dest, const godot_object *p_object, const godot_string_name *p_name); +void GDAPI godot_signal_new_with_object_id(godot_signal *r_dest, uint64_t p_objectid, const godot_string_name *p_name); +void GDAPI godot_signal_new_copy(godot_signal *r_dest, const godot_signal *p_src); + +void GDAPI godot_signal_destroy(godot_signal *p_self); + +godot_int GDAPI godot_signal_emit(const godot_signal *p_self, const godot_variant **p_arguments, godot_int p_argcount); + +godot_int GDAPI godot_signal_connect(godot_signal *p_self, const godot_callable *p_callable, const godot_array *p_binds, uint32_t p_flags); +void GDAPI godot_signal_disconnect(godot_signal *p_self, const godot_callable *p_callable); + +godot_bool GDAPI godot_signal_is_null(const godot_signal *p_self); +godot_bool GDAPI godot_signal_is_connected(const godot_signal *p_self, const godot_callable *p_callable); + +godot_array GDAPI godot_signal_get_connections(const godot_signal *p_self); + +godot_object GDAPI *godot_signal_get_object(const godot_signal *p_self); +uint64_t GDAPI godot_signal_get_object_id(const godot_signal *p_self); +godot_string_name GDAPI godot_signal_get_name(const godot_signal *p_self); + +godot_string GDAPI godot_signal_as_string(const godot_signal *p_self); + +godot_bool GDAPI godot_signal_operator_equal(const godot_signal *p_self, const godot_signal *p_other); +godot_bool GDAPI godot_signal_operator_less(const godot_signal *p_self, const godot_signal *p_other); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h index 6fdca30122..6a0a375da8 100644 --- a/modules/gdnative/include/gdnative/gdnative.h +++ b/modules/gdnative/include/gdnative/gdnative.h @@ -144,15 +144,15 @@ typedef void godot_object; #include <gdnative/string_name.h> -////// Vector2 +////// Vector2 & Vector2i #include <gdnative/vector2.h> -////// Rect2 +////// Rect2 & Rect2i #include <gdnative/rect2.h> -////// Vector3 +////// Vector3 & Vector3i #include <gdnative/vector3.h> @@ -192,6 +192,10 @@ typedef void godot_object; #include <gdnative/rid.h> +/////// Callable & Signal + +#include <gdnative/callable.h> + /////// Dictionary #include <gdnative/dictionary.h> @@ -200,8 +204,8 @@ typedef void godot_object; #include <gdnative/array.h> -// single API file for Pool*Array -#include <gdnative/pool_arrays.h> +// single API file for Packed*Array +#include <gdnative/packed_arrays.h> void GDAPI godot_object_destroy(godot_object *p_o); @@ -289,7 +293,9 @@ void GDAPI *godot_get_class_tag(const godot_string_name *p_class); godot_object GDAPI *godot_object_cast_to(const godot_object *p_object, void *p_class_tag); // equivalent of GDScript's instance_from_id -godot_object GDAPI *godot_instance_from_id(godot_int p_instance_id); +godot_object GDAPI *godot_instance_from_id(uint64_t p_instance_id); + +uint64_t GDAPI godot_object_get_instance_id(const godot_object *p_object); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/pool_arrays.h b/modules/gdnative/include/gdnative/packed_arrays.h index c610377f54..d5bad70bdc 100644 --- a/modules/gdnative/include/gdnative/pool_arrays.h +++ b/modules/gdnative/include/gdnative/packed_arrays.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* pool_arrays.h */ +/* packed_arrays.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GODOT_POOL_ARRAYS_H -#define GODOT_POOL_ARRAYS_H +#ifndef GODOT_PACKED_ARRAYS_H +#define GODOT_PACKED_ARRAYS_H #ifdef __cplusplus extern "C" { @@ -39,7 +39,7 @@ extern "C" { /////// PackedByteArray -#define GODOT_PACKED_BYTE_ARRAY_SIZE sizeof(void *) +#define GODOT_PACKED_BYTE_ARRAY_SIZE (2 * sizeof(void *)) #ifndef GODOT_CORE_API_GODOT_PACKED_BYTE_ARRAY_TYPE_DEFINED #define GODOT_CORE_API_GODOT_PACKED_BYTE_ARRAY_TYPE_DEFINED @@ -50,29 +50,51 @@ typedef struct { /////// PackedInt32Array -#define GODOT_PACKED_INT_ARRAY_SIZE sizeof(void *) +#define GODOT_PACKED_INT32_ARRAY_SIZE (2 * sizeof(void *)) -#ifndef GODOT_CORE_API_GODOT_PACKED_INT_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_PACKED_INT_ARRAY_TYPE_DEFINED +#ifndef GODOT_CORE_API_GODOT_PACKED_INT32_ARRAY_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_PACKED_INT32_ARRAY_TYPE_DEFINED typedef struct { - uint8_t _dont_touch_that[GODOT_PACKED_INT_ARRAY_SIZE]; -} godot_packed_int_array; + uint8_t _dont_touch_that[GODOT_PACKED_INT32_ARRAY_SIZE]; +} godot_packed_int32_array; +#endif + +/////// PackedInt64Array + +#define GODOT_PACKED_INT64_ARRAY_SIZE (2 * sizeof(void *)) + +#ifndef GODOT_CORE_API_GODOT_PACKED_INT64_ARRAY_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_PACKED_INT64_ARRAY_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_PACKED_INT64_ARRAY_SIZE]; +} godot_packed_int64_array; #endif /////// PackedFloat32Array -#define GODOT_PACKED_REAL_ARRAY_SIZE sizeof(void *) +#define GODOT_PACKED_FLOAT32_ARRAY_SIZE (2 * sizeof(void *)) + +#ifndef GODOT_CORE_API_GODOT_PACKED_FLOAT32_ARRAY_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_PACKED_FLOAT32_ARRAY_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_PACKED_FLOAT32_ARRAY_SIZE]; +} godot_packed_float32_array; +#endif + +/////// PackedFloat64Array -#ifndef GODOT_CORE_API_GODOT_PACKED_REAL_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_PACKED_REAL_ARRAY_TYPE_DEFINED +#define GODOT_PACKED_FLOAT64_ARRAY_SIZE (2 * sizeof(void *)) + +#ifndef GODOT_CORE_API_GODOT_PACKED_FLOAT64_ARRAY_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_PACKED_FLOAT64_ARRAY_TYPE_DEFINED typedef struct { - uint8_t _dont_touch_that[GODOT_PACKED_REAL_ARRAY_SIZE]; -} godot_packed_real_array; + uint8_t _dont_touch_that[GODOT_PACKED_FLOAT64_ARRAY_SIZE]; +} godot_packed_float64_array; #endif /////// PackedStringArray -#define GODOT_PACKED_STRING_ARRAY_SIZE sizeof(void *) +#define GODOT_PACKED_STRING_ARRAY_SIZE (2 * sizeof(void *)) #ifndef GODOT_CORE_API_GODOT_PACKED_STRING_ARRAY_TYPE_DEFINED #define GODOT_CORE_API_GODOT_PACKED_STRING_ARRAY_TYPE_DEFINED @@ -83,7 +105,7 @@ typedef struct { /////// PackedVector2Array -#define GODOT_PACKED_VECTOR2_ARRAY_SIZE sizeof(void *) +#define GODOT_PACKED_VECTOR2_ARRAY_SIZE (2 * sizeof(void *)) #ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR2_ARRAY_TYPE_DEFINED #define GODOT_CORE_API_GODOT_PACKED_VECTOR2_ARRAY_TYPE_DEFINED @@ -94,7 +116,7 @@ typedef struct { /////// PackedVector3Array -#define GODOT_PACKED_VECTOR3_ARRAY_SIZE sizeof(void *) +#define GODOT_PACKED_VECTOR3_ARRAY_SIZE (2 * sizeof(void *)) #ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR3_ARRAY_TYPE_DEFINED #define GODOT_CORE_API_GODOT_PACKED_VECTOR3_ARRAY_TYPE_DEFINED @@ -105,7 +127,7 @@ typedef struct { /////// PackedColorArray -#define GODOT_PACKED_COLOR_ARRAY_SIZE sizeof(void *) +#define GODOT_PACKED_COLOR_ARRAY_SIZE (2 * sizeof(void *)) #ifndef GODOT_CORE_API_GODOT_PACKED_COLOR_ARRAY_TYPE_DEFINED #define GODOT_CORE_API_GODOT_PACKED_COLOR_ARRAY_TYPE_DEFINED @@ -159,63 +181,121 @@ godot_bool GDAPI godot_packed_byte_array_empty(const godot_packed_byte_array *p_ void GDAPI godot_packed_byte_array_destroy(godot_packed_byte_array *p_self); -// int +// int32 + +void GDAPI godot_packed_int32_array_new(godot_packed_int32_array *r_dest); +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_new_with_array(godot_packed_int32_array *r_dest, const godot_array *p_a); + +void GDAPI godot_packed_int32_array_append(godot_packed_int32_array *p_self, const int32_t p_data); + +void GDAPI godot_packed_int32_array_append_array(godot_packed_int32_array *p_self, const godot_packed_int32_array *p_array); + +godot_error GDAPI godot_packed_int32_array_insert(godot_packed_int32_array *p_self, const godot_int p_idx, const int32_t p_data); + +void GDAPI godot_packed_int32_array_invert(godot_packed_int32_array *p_self); + +void GDAPI godot_packed_int32_array_push_back(godot_packed_int32_array *p_self, const int32_t p_data); + +void GDAPI godot_packed_int32_array_remove(godot_packed_int32_array *p_self, const godot_int p_idx); + +void GDAPI godot_packed_int32_array_resize(godot_packed_int32_array *p_self, const godot_int p_size); + +void GDAPI godot_packed_int32_array_set(godot_packed_int32_array *p_self, const godot_int p_idx, const int32_t p_data); +int32_t GDAPI godot_packed_int32_array_get(const godot_packed_int32_array *p_self, const godot_int p_idx); + +godot_int GDAPI godot_packed_int32_array_size(const godot_packed_int32_array *p_self); + +godot_bool GDAPI godot_packed_int32_array_empty(const godot_packed_int32_array *p_self); + +void GDAPI godot_packed_int32_array_destroy(godot_packed_int32_array *p_self); + +// int64 + +void GDAPI godot_packed_int64_array_new(godot_packed_int64_array *r_dest); +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_new_with_array(godot_packed_int64_array *r_dest, const godot_array *p_a); + +void GDAPI godot_packed_int64_array_append(godot_packed_int64_array *p_self, const int64_t p_data); + +void GDAPI godot_packed_int64_array_append_array(godot_packed_int64_array *p_self, const godot_packed_int64_array *p_array); + +godot_error GDAPI godot_packed_int64_array_insert(godot_packed_int64_array *p_self, const godot_int p_idx, const int64_t p_data); + +void GDAPI godot_packed_int64_array_invert(godot_packed_int64_array *p_self); + +void GDAPI godot_packed_int64_array_push_back(godot_packed_int64_array *p_self, const int64_t p_data); + +void GDAPI godot_packed_int64_array_remove(godot_packed_int64_array *p_self, const godot_int p_idx); + +void GDAPI godot_packed_int64_array_resize(godot_packed_int64_array *p_self, const godot_int p_size); + +void GDAPI godot_packed_int64_array_set(godot_packed_int64_array *p_self, const godot_int p_idx, const int64_t p_data); +int64_t GDAPI godot_packed_int64_array_get(const godot_packed_int64_array *p_self, const godot_int p_idx); + +godot_int GDAPI godot_packed_int64_array_size(const godot_packed_int64_array *p_self); + +godot_bool GDAPI godot_packed_int64_array_empty(const godot_packed_int64_array *p_self); + +void GDAPI godot_packed_int64_array_destroy(godot_packed_int64_array *p_self); + +// float32 -void GDAPI godot_packed_int_array_new(godot_packed_int_array *r_dest); -void GDAPI godot_packed_int_array_new_copy(godot_packed_int_array *r_dest, const godot_packed_int_array *p_src); -void GDAPI godot_packed_int_array_new_with_array(godot_packed_int_array *r_dest, const godot_array *p_a); +void GDAPI godot_packed_float32_array_new(godot_packed_float32_array *r_dest); +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_new_with_array(godot_packed_float32_array *r_dest, const godot_array *p_a); -void GDAPI godot_packed_int_array_append(godot_packed_int_array *p_self, const godot_int p_data); +void GDAPI godot_packed_float32_array_append(godot_packed_float32_array *p_self, const float p_data); -void GDAPI godot_packed_int_array_append_array(godot_packed_int_array *p_self, const godot_packed_int_array *p_array); +void GDAPI godot_packed_float32_array_append_array(godot_packed_float32_array *p_self, const godot_packed_float32_array *p_array); -godot_error GDAPI godot_packed_int_array_insert(godot_packed_int_array *p_self, const godot_int p_idx, const godot_int p_data); +godot_error GDAPI godot_packed_float32_array_insert(godot_packed_float32_array *p_self, const godot_int p_idx, const float p_data); -void GDAPI godot_packed_int_array_invert(godot_packed_int_array *p_self); +void GDAPI godot_packed_float32_array_invert(godot_packed_float32_array *p_self); -void GDAPI godot_packed_int_array_push_back(godot_packed_int_array *p_self, const godot_int p_data); +void GDAPI godot_packed_float32_array_push_back(godot_packed_float32_array *p_self, const float p_data); -void GDAPI godot_packed_int_array_remove(godot_packed_int_array *p_self, const godot_int p_idx); +void GDAPI godot_packed_float32_array_remove(godot_packed_float32_array *p_self, const godot_int p_idx); -void GDAPI godot_packed_int_array_resize(godot_packed_int_array *p_self, const godot_int p_size); +void GDAPI godot_packed_float32_array_resize(godot_packed_float32_array *p_self, const godot_int p_size); -void GDAPI godot_packed_int_array_set(godot_packed_int_array *p_self, const godot_int p_idx, const godot_int p_data); -godot_int GDAPI godot_packed_int_array_get(const godot_packed_int_array *p_self, const godot_int p_idx); +void GDAPI godot_packed_float32_array_set(godot_packed_float32_array *p_self, const godot_int p_idx, const float p_data); +float GDAPI godot_packed_float32_array_get(const godot_packed_float32_array *p_self, const godot_int p_idx); -godot_int GDAPI godot_packed_int_array_size(const godot_packed_int_array *p_self); +godot_int GDAPI godot_packed_float32_array_size(const godot_packed_float32_array *p_self); -godot_bool GDAPI godot_packed_int_array_empty(const godot_packed_int_array *p_self); +godot_bool GDAPI godot_packed_float32_array_empty(const godot_packed_float32_array *p_self); -void GDAPI godot_packed_int_array_destroy(godot_packed_int_array *p_self); +void GDAPI godot_packed_float32_array_destroy(godot_packed_float32_array *p_self); -// real +// float64 -void GDAPI godot_packed_real_array_new(godot_packed_real_array *r_dest); -void GDAPI godot_packed_real_array_new_copy(godot_packed_real_array *r_dest, const godot_packed_real_array *p_src); -void GDAPI godot_packed_real_array_new_with_array(godot_packed_real_array *r_dest, const godot_array *p_a); +void GDAPI godot_packed_float64_array_new(godot_packed_float64_array *r_dest); +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_new_with_array(godot_packed_float64_array *r_dest, const godot_array *p_a); -void GDAPI godot_packed_real_array_append(godot_packed_real_array *p_self, const godot_real p_data); +void GDAPI godot_packed_float64_array_append(godot_packed_float64_array *p_self, const double p_data); -void GDAPI godot_packed_real_array_append_array(godot_packed_real_array *p_self, const godot_packed_real_array *p_array); +void GDAPI godot_packed_float64_array_append_array(godot_packed_float64_array *p_self, const godot_packed_float64_array *p_array); -godot_error GDAPI godot_packed_real_array_insert(godot_packed_real_array *p_self, const godot_int p_idx, const godot_real p_data); +godot_error GDAPI godot_packed_float64_array_insert(godot_packed_float64_array *p_self, const godot_int p_idx, const double p_data); -void GDAPI godot_packed_real_array_invert(godot_packed_real_array *p_self); +void GDAPI godot_packed_float64_array_invert(godot_packed_float64_array *p_self); -void GDAPI godot_packed_real_array_push_back(godot_packed_real_array *p_self, const godot_real p_data); +void GDAPI godot_packed_float64_array_push_back(godot_packed_float64_array *p_self, const double p_data); -void GDAPI godot_packed_real_array_remove(godot_packed_real_array *p_self, const godot_int p_idx); +void GDAPI godot_packed_float64_array_remove(godot_packed_float64_array *p_self, const godot_int p_idx); -void GDAPI godot_packed_real_array_resize(godot_packed_real_array *p_self, const godot_int p_size); +void GDAPI godot_packed_float64_array_resize(godot_packed_float64_array *p_self, const godot_int p_size); -void GDAPI godot_packed_real_array_set(godot_packed_real_array *p_self, const godot_int p_idx, const godot_real p_data); -godot_real GDAPI godot_packed_real_array_get(const godot_packed_real_array *p_self, const godot_int p_idx); +void GDAPI godot_packed_float64_array_set(godot_packed_float64_array *p_self, const godot_int p_idx, const double p_data); +double GDAPI godot_packed_float64_array_get(const godot_packed_float64_array *p_self, const godot_int p_idx); -godot_int GDAPI godot_packed_real_array_size(const godot_packed_real_array *p_self); +godot_int GDAPI godot_packed_float64_array_size(const godot_packed_float64_array *p_self); -godot_bool GDAPI godot_packed_real_array_empty(const godot_packed_real_array *p_self); +godot_bool GDAPI godot_packed_float64_array_empty(const godot_packed_float64_array *p_self); -void GDAPI godot_packed_real_array_destroy(godot_packed_real_array *p_self); +void GDAPI godot_packed_float64_array_destroy(godot_packed_float64_array *p_self); // string diff --git a/modules/gdnative/include/gdnative/rect2.h b/modules/gdnative/include/gdnative/rect2.h index 0ecf072471..f317afc9da 100644 --- a/modules/gdnative/include/gdnative/rect2.h +++ b/modules/gdnative/include/gdnative/rect2.h @@ -44,6 +44,13 @@ typedef struct godot_rect2 { } godot_rect2; #endif +#ifndef GODOT_CORE_API_GODOT_RECT2I_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_RECT2I_TYPE_DEFINED +typedef struct godot_rect2i { + uint8_t _dont_touch_that[16]; +} godot_rect2i; +#endif + // reduce extern "C" nesting for VS2013 #ifdef __cplusplus } @@ -56,11 +63,15 @@ typedef struct godot_rect2 { extern "C" { #endif +// Rect2 + void GDAPI godot_rect2_new_with_position_and_size(godot_rect2 *r_dest, const godot_vector2 *p_pos, const godot_vector2 *p_size); void GDAPI godot_rect2_new(godot_rect2 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_width, const godot_real p_height); godot_string GDAPI godot_rect2_as_string(const godot_rect2 *p_self); +godot_rect2i GDAPI godot_rect2_as_rect2i(const godot_rect2 *p_self); + godot_real GDAPI godot_rect2_get_area(const godot_rect2 *p_self); godot_bool GDAPI godot_rect2_intersects(const godot_rect2 *p_self, const godot_rect2 *p_b); @@ -95,6 +106,49 @@ void GDAPI godot_rect2_set_position(godot_rect2 *p_self, const godot_vector2 *p_ void GDAPI godot_rect2_set_size(godot_rect2 *p_self, const godot_vector2 *p_size); +// Rect2I + +void GDAPI godot_rect2i_new_with_position_and_size(godot_rect2i *r_dest, const godot_vector2i *p_pos, const godot_vector2i *p_size); +void GDAPI godot_rect2i_new(godot_rect2i *r_dest, const godot_int p_x, const godot_int p_y, const godot_int p_width, const godot_int p_height); + +godot_string GDAPI godot_rect2i_as_string(const godot_rect2i *p_self); + +godot_rect2 GDAPI godot_rect2i_as_rect2(const godot_rect2i *p_self); + +godot_int GDAPI godot_rect2i_get_area(const godot_rect2i *p_self); + +godot_bool GDAPI godot_rect2i_intersects(const godot_rect2i *p_self, const godot_rect2i *p_b); + +godot_bool GDAPI godot_rect2i_encloses(const godot_rect2i *p_self, const godot_rect2i *p_b); + +godot_bool GDAPI godot_rect2i_has_no_area(const godot_rect2i *p_self); + +godot_rect2i GDAPI godot_rect2i_clip(const godot_rect2i *p_self, const godot_rect2i *p_b); + +godot_rect2i GDAPI godot_rect2i_merge(const godot_rect2i *p_self, const godot_rect2i *p_b); + +godot_bool GDAPI godot_rect2i_has_point(const godot_rect2i *p_self, const godot_vector2i *p_point); + +godot_rect2i GDAPI godot_rect2i_grow(const godot_rect2i *p_self, const godot_int p_by); + +godot_rect2i GDAPI godot_rect2i_grow_individual(const godot_rect2i *p_self, const godot_int p_left, const godot_int p_top, const godot_int p_right, const godot_int p_bottom); + +godot_rect2i GDAPI godot_rect2i_grow_margin(const godot_rect2i *p_self, const godot_int p_margin, const godot_int p_by); + +godot_rect2i GDAPI godot_rect2i_abs(const godot_rect2i *p_self); + +godot_rect2i GDAPI godot_rect2i_expand(const godot_rect2i *p_self, const godot_vector2i *p_to); + +godot_bool GDAPI godot_rect2i_operator_equal(const godot_rect2i *p_self, const godot_rect2i *p_b); + +godot_vector2i GDAPI godot_rect2i_get_position(const godot_rect2i *p_self); + +godot_vector2i GDAPI godot_rect2i_get_size(const godot_rect2i *p_self); + +void GDAPI godot_rect2i_set_position(godot_rect2i *p_self, const godot_vector2i *p_pos); + +void GDAPI godot_rect2i_set_size(godot_rect2i *p_self, const godot_vector2i *p_size); + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/include/gdnative/rid.h b/modules/gdnative/include/gdnative/rid.h index 04661cedc8..73b601dc04 100644 --- a/modules/gdnative/include/gdnative/rid.h +++ b/modules/gdnative/include/gdnative/rid.h @@ -37,7 +37,7 @@ extern "C" { #include <stdint.h> -#define GODOT_RID_SIZE sizeof(void *) +#define GODOT_RID_SIZE sizeof(uint64_t) #ifndef GODOT_CORE_API_GODOT_RID_TYPE_DEFINED #define GODOT_CORE_API_GODOT_RID_TYPE_DEFINED diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h index 934e856fbf..0a611b76e9 100644 --- a/modules/gdnative/include/gdnative/variant.h +++ b/modules/gdnative/include/gdnative/variant.h @@ -37,7 +37,7 @@ extern "C" { #include <stdint.h> -#define GODOT_VARIANT_SIZE (16 + sizeof(void *)) +#define GODOT_VARIANT_SIZE (16 + sizeof(int64_t)) #ifndef GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED #define GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED @@ -71,16 +71,21 @@ typedef enum godot_variant_type { // misc types GODOT_VARIANT_TYPE_COLOR, + GODOT_VARIANT_TYPE_STRING_NAME, GODOT_VARIANT_TYPE_NODE_PATH, GODOT_VARIANT_TYPE_RID, GODOT_VARIANT_TYPE_OBJECT, + GODOT_VARIANT_TYPE_CALLABLE, + GODOT_VARIANT_TYPE_SIGNAL, GODOT_VARIANT_TYPE_DICTIONARY, GODOT_VARIANT_TYPE_ARRAY, // arrays GODOT_VARIANT_TYPE_PACKED_BYTE_ARRAY, - GODOT_VARIANT_TYPE_PACKED_INT_ARRAY, - GODOT_VARIANT_TYPE_PACKED_REAL_ARRAY, + GODOT_VARIANT_TYPE_PACKED_INT32_ARRAY, + GODOT_VARIANT_TYPE_PACKED_INT64_ARRAY, + GODOT_VARIANT_TYPE_PACKED_FLOAT32_ARRAY, + GODOT_VARIANT_TYPE_PACKED_FLOAT64_ARRAY, GODOT_VARIANT_TYPE_PACKED_STRING_ARRAY, GODOT_VARIANT_TYPE_PACKED_VECTOR2_ARRAY, GODOT_VARIANT_TYPE_PACKED_VECTOR3_ARRAY, @@ -149,15 +154,17 @@ typedef enum godot_variant_operator { #include <gdnative/aabb.h> #include <gdnative/array.h> #include <gdnative/basis.h> +#include <gdnative/callable.h> #include <gdnative/color.h> #include <gdnative/dictionary.h> #include <gdnative/node_path.h> +#include <gdnative/packed_arrays.h> #include <gdnative/plane.h> -#include <gdnative/pool_arrays.h> #include <gdnative/quat.h> #include <gdnative/rect2.h> #include <gdnative/rid.h> #include <gdnative/string.h> +#include <gdnative/string_name.h> #include <gdnative/transform.h> #include <gdnative/transform2d.h> #include <gdnative/variant.h> @@ -181,9 +188,13 @@ void GDAPI godot_variant_new_uint(godot_variant *r_dest, const uint64_t p_i); void GDAPI godot_variant_new_int(godot_variant *r_dest, const int64_t p_i); void GDAPI godot_variant_new_real(godot_variant *r_dest, const double p_r); void GDAPI godot_variant_new_string(godot_variant *r_dest, const godot_string *p_s); +void GDAPI godot_variant_new_string_name(godot_variant *r_dest, const godot_string_name *p_s); void GDAPI godot_variant_new_vector2(godot_variant *r_dest, const godot_vector2 *p_v2); +void GDAPI godot_variant_new_vector2i(godot_variant *r_dest, const godot_vector2i *p_v2); void GDAPI godot_variant_new_rect2(godot_variant *r_dest, const godot_rect2 *p_rect2); +void GDAPI godot_variant_new_rect2i(godot_variant *r_dest, const godot_rect2i *p_rect2); void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3 *p_v3); +void GDAPI godot_variant_new_vector3i(godot_variant *r_dest, const godot_vector3i *p_v3); void GDAPI godot_variant_new_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d); void GDAPI godot_variant_new_plane(godot_variant *r_dest, const godot_plane *p_plane); void GDAPI godot_variant_new_quat(godot_variant *r_dest, const godot_quat *p_quat); @@ -193,12 +204,16 @@ void GDAPI godot_variant_new_transform(godot_variant *r_dest, const godot_transf void GDAPI godot_variant_new_color(godot_variant *r_dest, const godot_color *p_color); void GDAPI godot_variant_new_node_path(godot_variant *r_dest, const godot_node_path *p_np); void GDAPI godot_variant_new_rid(godot_variant *r_dest, const godot_rid *p_rid); +void GDAPI godot_variant_new_callable(godot_variant *r_dest, const godot_callable *p_callable); +void GDAPI godot_variant_new_signal(godot_variant *r_dest, const godot_signal *p_signal); void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p_obj); void GDAPI godot_variant_new_dictionary(godot_variant *r_dest, const godot_dictionary *p_dict); void GDAPI godot_variant_new_array(godot_variant *r_dest, const godot_array *p_arr); void GDAPI godot_variant_new_packed_byte_array(godot_variant *r_dest, const godot_packed_byte_array *p_pba); -void GDAPI godot_variant_new_packed_int_array(godot_variant *r_dest, const godot_packed_int_array *p_pia); -void GDAPI godot_variant_new_packed_real_array(godot_variant *r_dest, const godot_packed_real_array *p_pra); +void GDAPI godot_variant_new_packed_int32_array(godot_variant *r_dest, const godot_packed_int32_array *p_pia); +void GDAPI godot_variant_new_packed_int64_array(godot_variant *r_dest, const godot_packed_int64_array *p_pia); +void GDAPI godot_variant_new_packed_float32_array(godot_variant *r_dest, const godot_packed_float32_array *p_pra); +void GDAPI godot_variant_new_packed_float64_array(godot_variant *r_dest, const godot_packed_float64_array *p_pra); void GDAPI godot_variant_new_packed_string_array(godot_variant *r_dest, const godot_packed_string_array *p_psa); void GDAPI godot_variant_new_packed_vector2_array(godot_variant *r_dest, const godot_packed_vector2_array *p_pv2a); void GDAPI godot_variant_new_packed_vector3_array(godot_variant *r_dest, const godot_packed_vector3_array *p_pv3a); @@ -209,9 +224,13 @@ uint64_t GDAPI godot_variant_as_uint(const godot_variant *p_self); int64_t GDAPI godot_variant_as_int(const godot_variant *p_self); double GDAPI godot_variant_as_real(const godot_variant *p_self); godot_string GDAPI godot_variant_as_string(const godot_variant *p_self); +godot_string_name GDAPI godot_variant_as_string_name(const godot_variant *p_self); godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_self); +godot_vector2i GDAPI godot_variant_as_vector2i(const godot_variant *p_self); godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_self); +godot_rect2i GDAPI godot_variant_as_rect2i(const godot_variant *p_self); godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_self); +godot_vector3i GDAPI godot_variant_as_vector3i(const godot_variant *p_self); godot_transform2d GDAPI godot_variant_as_transform2d(const godot_variant *p_self); godot_plane GDAPI godot_variant_as_plane(const godot_variant *p_self); godot_quat GDAPI godot_variant_as_quat(const godot_variant *p_self); @@ -221,12 +240,16 @@ godot_transform GDAPI godot_variant_as_transform(const godot_variant *p_self); godot_color GDAPI godot_variant_as_color(const godot_variant *p_self); godot_node_path GDAPI godot_variant_as_node_path(const godot_variant *p_self); godot_rid GDAPI godot_variant_as_rid(const godot_variant *p_self); +godot_callable GDAPI godot_variant_as_callable(const godot_variant *p_self); +godot_signal GDAPI godot_variant_as_signal(const godot_variant *p_self); godot_object GDAPI *godot_variant_as_object(const godot_variant *p_self); godot_dictionary GDAPI godot_variant_as_dictionary(const godot_variant *p_self); godot_array GDAPI godot_variant_as_array(const godot_variant *p_self); godot_packed_byte_array GDAPI godot_variant_as_packed_byte_array(const godot_variant *p_self); -godot_packed_int_array GDAPI godot_variant_as_packed_int_array(const godot_variant *p_self); -godot_packed_real_array GDAPI godot_variant_as_packed_real_array(const godot_variant *p_self); +godot_packed_int32_array GDAPI godot_variant_as_packed_int32_array(const godot_variant *p_self); +godot_packed_int64_array GDAPI godot_variant_as_packed_int64_array(const godot_variant *p_self); +godot_packed_float32_array GDAPI godot_variant_as_packed_float32_array(const godot_variant *p_self); +godot_packed_float64_array GDAPI godot_variant_as_packed_float64_array(const godot_variant *p_self); godot_packed_string_array GDAPI godot_variant_as_packed_string_array(const godot_variant *p_self); godot_packed_vector2_array GDAPI godot_variant_as_packed_vector2_array(const godot_variant *p_self); godot_packed_vector3_array GDAPI godot_variant_as_packed_vector3_array(const godot_variant *p_self); @@ -239,6 +262,7 @@ godot_bool GDAPI godot_variant_has_method(const godot_variant *p_self, const god godot_bool GDAPI godot_variant_operator_equal(const godot_variant *p_self, const godot_variant *p_other); godot_bool GDAPI godot_variant_operator_less(const godot_variant *p_self, const godot_variant *p_other); +uint32_t GDAPI godot_variant_hash(const godot_variant *p_self); godot_bool GDAPI godot_variant_hash_compare(const godot_variant *p_self, const godot_variant *p_other); godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self); diff --git a/modules/gdnative/include/gdnative/vector2.h b/modules/gdnative/include/gdnative/vector2.h index c11e23a586..35b02c5a75 100644 --- a/modules/gdnative/include/gdnative/vector2.h +++ b/modules/gdnative/include/gdnative/vector2.h @@ -46,6 +46,15 @@ typedef struct { } godot_vector2; #endif +#define GODOT_VECTOR2I_SIZE 8 + +#ifndef GODOT_CORE_API_GODOT_VECTOR2I_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_VECTOR2I_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_VECTOR2I_SIZE]; +} godot_vector2i; +#endif + // reduce extern "C" nesting for VS2013 #ifdef __cplusplus } @@ -57,10 +66,14 @@ typedef struct { extern "C" { #endif +// Vector2 + void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y); godot_string GDAPI godot_vector2_as_string(const godot_vector2 *p_self); +godot_vector2i GDAPI godot_vector2_as_vector2i(const godot_vector2 *p_self); + godot_vector2 GDAPI godot_vector2_normalized(const godot_vector2 *p_self); godot_real GDAPI godot_vector2_length(const godot_vector2 *p_self); @@ -93,6 +106,8 @@ godot_vector2 GDAPI godot_vector2_tangent(const godot_vector2 *p_self); godot_vector2 GDAPI godot_vector2_floor(const godot_vector2 *p_self); +godot_vector2 GDAPI godot_vector2_sign(const godot_vector2 *p_self); + godot_vector2 GDAPI godot_vector2_snapped(const godot_vector2 *p_self, const godot_vector2 *p_by); godot_real GDAPI godot_vector2_aspect(const godot_vector2 *p_self); @@ -135,6 +150,46 @@ godot_real GDAPI godot_vector2_get_x(const godot_vector2 *p_self); godot_real GDAPI godot_vector2_get_y(const godot_vector2 *p_self); +// Vector2i + +void GDAPI godot_vector2i_new(godot_vector2i *r_dest, const godot_int p_x, const godot_int p_y); + +godot_string GDAPI godot_vector2i_as_string(const godot_vector2i *p_self); + +godot_vector2 GDAPI godot_vector2i_as_vector2(const godot_vector2i *p_self); + +godot_real GDAPI godot_vector2i_aspect(const godot_vector2i *p_self); + +godot_vector2i GDAPI godot_vector2i_abs(const godot_vector2i *p_self); + +godot_vector2i GDAPI godot_vector2i_sign(const godot_vector2i *p_self); + +godot_vector2i GDAPI godot_vector2i_operator_add(const godot_vector2i *p_self, const godot_vector2i *p_b); + +godot_vector2i GDAPI godot_vector2i_operator_subtract(const godot_vector2i *p_self, const godot_vector2i *p_b); + +godot_vector2i GDAPI godot_vector2i_operator_multiply_vector(const godot_vector2i *p_self, const godot_vector2i *p_b); + +godot_vector2i GDAPI godot_vector2i_operator_multiply_scalar(const godot_vector2i *p_self, const godot_int p_b); + +godot_vector2i GDAPI godot_vector2i_operator_divide_vector(const godot_vector2i *p_self, const godot_vector2i *p_b); + +godot_vector2i GDAPI godot_vector2i_operator_divide_scalar(const godot_vector2i *p_self, const godot_int p_b); + +godot_bool GDAPI godot_vector2i_operator_equal(const godot_vector2i *p_self, const godot_vector2i *p_b); + +godot_bool GDAPI godot_vector2i_operator_less(const godot_vector2i *p_self, const godot_vector2i *p_b); + +godot_vector2i GDAPI godot_vector2i_operator_neg(const godot_vector2i *p_self); + +void GDAPI godot_vector2i_set_x(godot_vector2i *p_self, const godot_int p_x); + +void GDAPI godot_vector2i_set_y(godot_vector2i *p_self, const godot_int p_y); + +godot_int GDAPI godot_vector2i_get_x(const godot_vector2i *p_self); + +godot_int GDAPI godot_vector2i_get_y(const godot_vector2i *p_self); + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/include/gdnative/vector3.h b/modules/gdnative/include/gdnative/vector3.h index 8ebf15b724..5127b8789b 100644 --- a/modules/gdnative/include/gdnative/vector3.h +++ b/modules/gdnative/include/gdnative/vector3.h @@ -46,6 +46,15 @@ typedef struct { } godot_vector3; #endif +#define GODOT_VECTOR3I_SIZE 12 + +#ifndef GODOT_CORE_API_GODOT_VECTOR3I_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_VECTOR3I_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_VECTOR3I_SIZE]; +} godot_vector3i; +#endif + // reduce extern "C" nesting for VS2013 #ifdef __cplusplus } @@ -64,10 +73,14 @@ typedef enum { GODOT_VECTOR3_AXIS_Z, } godot_vector3_axis; +// Vector3 + void GDAPI godot_vector3_new(godot_vector3 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z); godot_string GDAPI godot_vector3_as_string(const godot_vector3 *p_self); +godot_vector3i GDAPI godot_vector3_as_vector3i(const godot_vector3 *p_self); + godot_int GDAPI godot_vector3_min_axis(const godot_vector3 *p_self); godot_int GDAPI godot_vector3_max_axis(const godot_vector3 *p_self); @@ -102,6 +115,8 @@ godot_basis GDAPI godot_vector3_to_diagonal_matrix(const godot_vector3 *p_self); godot_vector3 GDAPI godot_vector3_abs(const godot_vector3 *p_self); +godot_vector3 GDAPI godot_vector3_sign(const godot_vector3 *p_self); + godot_vector3 GDAPI godot_vector3_floor(const godot_vector3 *p_self); godot_vector3 GDAPI godot_vector3_ceil(const godot_vector3 *p_self); @@ -142,6 +157,44 @@ void GDAPI godot_vector3_set_axis(godot_vector3 *p_self, const godot_vector3_axi godot_real GDAPI godot_vector3_get_axis(const godot_vector3 *p_self, const godot_vector3_axis p_axis); +// Vector3i + +void GDAPI godot_vector3i_new(godot_vector3i *r_dest, const godot_int p_x, const godot_int p_y, const godot_int p_z); + +godot_string GDAPI godot_vector3i_as_string(const godot_vector3i *p_self); + +godot_vector3 GDAPI godot_vector3i_as_vector3(const godot_vector3i *p_self); + +godot_int GDAPI godot_vector3i_min_axis(const godot_vector3i *p_self); + +godot_int GDAPI godot_vector3i_max_axis(const godot_vector3i *p_self); + +godot_vector3i GDAPI godot_vector3i_abs(const godot_vector3i *p_self); + +godot_vector3i GDAPI godot_vector3i_sign(const godot_vector3i *p_self); + +godot_vector3i GDAPI godot_vector3i_operator_add(const godot_vector3i *p_self, const godot_vector3i *p_b); + +godot_vector3i GDAPI godot_vector3i_operator_subtract(const godot_vector3i *p_self, const godot_vector3i *p_b); + +godot_vector3i GDAPI godot_vector3i_operator_multiply_vector(const godot_vector3i *p_self, const godot_vector3i *p_b); + +godot_vector3i GDAPI godot_vector3i_operator_multiply_scalar(const godot_vector3i *p_self, const godot_int p_b); + +godot_vector3i GDAPI godot_vector3i_operator_divide_vector(const godot_vector3i *p_self, const godot_vector3i *p_b); + +godot_vector3i GDAPI godot_vector3i_operator_divide_scalar(const godot_vector3i *p_self, const godot_int p_b); + +godot_bool GDAPI godot_vector3i_operator_equal(const godot_vector3i *p_self, const godot_vector3i *p_b); + +godot_bool GDAPI godot_vector3i_operator_less(const godot_vector3i *p_self, const godot_vector3i *p_b); + +godot_vector3i GDAPI godot_vector3i_operator_neg(const godot_vector3i *p_self); + +void GDAPI godot_vector3i_set_axis(godot_vector3i *p_self, const godot_vector3_axis p_axis, const godot_int p_val); + +godot_int GDAPI godot_vector3i_get_axis(const godot_vector3i *p_self, const godot_vector3_axis p_axis); + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h index 0fb5180103..d65b3f91f4 100644 --- a/modules/gdnative/include/nativescript/godot_nativescript.h +++ b/modules/gdnative/include/nativescript/godot_nativescript.h @@ -172,17 +172,17 @@ typedef struct { godot_string hint_string; godot_property_usage_flags usage; godot_variant default_value; -} godot_signal_argument; +} godot_nativescript_signal_argument; typedef struct { godot_string name; int num_args; - godot_signal_argument *args; + godot_nativescript_signal_argument *args; int num_default_args; godot_variant *default_args; -} godot_signal; +} godot_nativescript_signal; -void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_signal *p_signal); +void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_nativescript_signal *p_signal); void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance); diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp index 1bdac0dcb2..1aea8ad160 100644 --- a/modules/gdnative/nativescript/godot_nativescript.cpp +++ b/modules/gdnative/nativescript/godot_nativescript.cpp @@ -159,7 +159,7 @@ void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const c E->get().properties.insert(p_path, property); } -void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_signal *p_signal) { +void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_nativescript_signal *p_signal) { String *s = (String *)p_gdnative_handle; Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); @@ -171,7 +171,7 @@ void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const cha for (int i = 0; i < p_signal->num_args; i++) { PropertyInfo info; - godot_signal_argument arg = p_signal->args[i]; + godot_nativescript_signal_argument arg = p_signal->args[i]; info.hint = (PropertyHint)arg.hint; info.hint_string = *(String *)&arg.hint_string; @@ -184,7 +184,7 @@ void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const cha for (int i = 0; i < p_signal->num_default_args; i++) { Variant *v; - godot_signal_argument attrib = p_signal->args[i]; + godot_nativescript_signal_argument attrib = p_signal->args[i]; v = (Variant *)&attrib.default_value; diff --git a/modules/gdnavigation/nav_map.cpp b/modules/gdnavigation/nav_map.cpp index c7df6dc1fb..4bea007104 100644 --- a/modules/gdnavigation/nav_map.cpp +++ b/modules/gdnavigation/nav_map.cpp @@ -299,7 +299,6 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p left = p->poly->points[prev].pos; right = p->poly->points[prev_n].pos; - //if (CLOCK_TANGENT(apex_point,left,(left+right)*0.5).dot(up) < 0){ if (p->poly->clockwise) { SWAP(left, right); } diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index 92e07ab874..fc0c4b3138 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -1818,8 +1818,6 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) { state.result = Variant(); if (completed) { - _clear_stack(); - if (first_state.is_valid()) { first_state->emit_signal("completed", ret); } else { diff --git a/modules/lightmapper_rd/lm_blendseams.glsl b/modules/lightmapper_rd/lm_blendseams.glsl index 8a9ea91311..e47e5fcc51 100644 --- a/modules/lightmapper_rd/lm_blendseams.glsl +++ b/modules/lightmapper_rd/lm_blendseams.glsl @@ -1,10 +1,9 @@ -/* clang-format off */ -[versions] +#[versions] -lines = "#define MODE_LINES" -triangles = "#define MODE_TRIANGLES" +lines = "#define MODE_LINES"; +triangles = "#define MODE_TRIANGLES"; -[vertex] +#[vertex] #version 450 @@ -12,22 +11,20 @@ VERSION_DEFINES #include "lm_common_inc.glsl" - /* clang-format on */ - - layout(push_constant, binding = 0, std430) uniform Params { - uint base_index; - uint slice; - vec2 uv_offset; - bool debug; - float blend; - uint pad[2]; - } params; +layout(push_constant, binding = 0, std430) uniform Params { + uint base_index; + uint slice; + vec2 uv_offset; + bool debug; + float blend; + uint pad[2]; +} +params; layout(location = 0) out vec3 uv_interp; void main() { #ifdef MODE_TRIANGLES - uint triangle_idx = params.base_index + gl_VertexIndex / 3; uint triangle_subidx = gl_VertexIndex % 3; @@ -42,7 +39,6 @@ void main() { uv_interp = vec3(uv, float(params.slice)); gl_Position = vec4((uv + params.uv_offset) * 2.0 - 1.0, 0.0001, 1.0); - #endif #ifdef MODE_LINES @@ -71,12 +67,10 @@ void main() { uv_interp = vec3(src_uv, float(params.slice)); gl_Position = vec4(dst_uv * 2.0 - 1.0, 0.0001, 1.0); - ; #endif } -/* clang-format off */ -[fragment] +#[fragment] #version 450 @@ -84,16 +78,15 @@ VERSION_DEFINES #include "lm_common_inc.glsl" - /* clang-format on */ - - layout(push_constant, binding = 0, std430) uniform Params { - uint base_index; - uint slice; - vec2 uv_offset; - bool debug; - float blend; - uint pad[2]; - } params; +layout(push_constant, binding = 0, std430) uniform Params { + uint base_index; + uint slice; + vec2 uv_offset; + bool debug; + float blend; + uint pad[2]; +} +params; layout(location = 0) in vec3 uv_interp; diff --git a/modules/lightmapper_rd/lm_common_inc.glsl b/modules/lightmapper_rd/lm_common_inc.glsl index 15946d5327..0ff455936e 100644 --- a/modules/lightmapper_rd/lm_common_inc.glsl +++ b/modules/lightmapper_rd/lm_common_inc.glsl @@ -11,7 +11,6 @@ struct Vertex { layout(set = 0, binding = 1, std430) restrict readonly buffer Vertices { Vertex data[]; } - vertices; struct Triangle { @@ -22,7 +21,6 @@ struct Triangle { layout(set = 0, binding = 2, std430) restrict readonly buffer Triangles { Triangle data[]; } - triangles; struct Box { @@ -35,13 +33,11 @@ struct Box { layout(set = 0, binding = 3, std430) restrict readonly buffer Boxes { Box data[]; } - boxes; layout(set = 0, binding = 4, std430) restrict readonly buffer GridIndices { uint data[]; } - grid_indices; #define LIGHT_TYPE_DIRECTIONAL 0 @@ -70,7 +66,6 @@ struct Light { layout(set = 0, binding = 5, std430) restrict readonly buffer Lights { Light data[]; } - lights; struct Seam { @@ -81,13 +76,11 @@ struct Seam { layout(set = 0, binding = 6, std430) restrict readonly buffer Seams { Seam data[]; } - seams; layout(set = 0, binding = 7, std430) restrict readonly buffer Probes { vec4 data[]; } - probe_positions; layout(set = 0, binding = 8) uniform utexture3D grid; diff --git a/modules/lightmapper_rd/lm_compute.glsl b/modules/lightmapper_rd/lm_compute.glsl index a442016969..56976bd623 100644 --- a/modules/lightmapper_rd/lm_compute.glsl +++ b/modules/lightmapper_rd/lm_compute.glsl @@ -1,13 +1,12 @@ -/* clang-format off */ -[versions] +#[versions] -primary = "#define MODE_DIRECT_LIGHT" -secondary = "#define MODE_BOUNCE_LIGHT" -dilate = "#define MODE_DILATE" -unocclude = "#define MODE_UNOCCLUDE" -light_probes = "#define MODE_LIGHT_PROBES" +primary = "#define MODE_DIRECT_LIGHT"; +secondary = "#define MODE_BOUNCE_LIGHT"; +dilate = "#define MODE_DILATE"; +unocclude = "#define MODE_UNOCCLUDE"; +light_probes = "#define MODE_LIGHT_PROBES"; -[compute] +#[compute] #version 450 @@ -29,14 +28,11 @@ layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; #include "lm_common_inc.glsl" -/* clang-format on */ - #ifdef MODE_LIGHT_PROBES layout(set = 1, binding = 0, std430) restrict buffer LightProbeData { vec4 data[]; } - light_probes; layout(set = 1, binding = 1) uniform texture2DArray source_light; @@ -94,7 +90,6 @@ layout(push_constant, binding = 0, std430) uniform Params { mat3x4 env_transform; } - params; //check it, but also return distance and barycentric coords (for uv lookup) @@ -123,7 +118,6 @@ bool trace_ray(vec3 p_from, vec3 p_to out float r_distance, out vec3 r_normal #endif ) { - /* world coords */ vec3 rel = p_to - p_from; @@ -149,7 +143,6 @@ bool trace_ray(vec3 p_from, vec3 p_to while (all(greaterThanEqual(icell, ivec3(0))) && all(lessThan(icell, ivec3(params.grid_size))) && iters < 1000) { uvec2 cell_data = texelFetch(usampler3D(grid, linear_sampler), icell, 0).xy; if (cell_data.x > 0) { //triangles here - bool hit = false; #if defined(MODE_UNOCCLUDE) bool hit_backface = false; @@ -211,7 +204,6 @@ bool trace_ray(vec3 p_from, vec3 p_to r_triangle = tidx; r_barycentric = barycentric; } - #endif } } diff --git a/modules/lightmapper_rd/lm_raster.glsl b/modules/lightmapper_rd/lm_raster.glsl index 36b706bcd5..6c2904192b 100644 --- a/modules/lightmapper_rd/lm_raster.glsl +++ b/modules/lightmapper_rd/lm_raster.glsl @@ -1,5 +1,4 @@ -/* clang-format off */ -[vertex] +#[vertex] #version 450 @@ -7,9 +6,7 @@ VERSION_DEFINES #include "lm_common_inc.glsl" - /* clang-format on */ - - layout(location = 0) out vec3 vertex_interp; +layout(location = 0) out vec3 vertex_interp; layout(location = 1) out vec3 normal_interp; layout(location = 2) out vec2 uv_interp; layout(location = 3) out vec3 barycentric; @@ -26,11 +23,8 @@ layout(push_constant, binding = 0, std430) uniform Params { ivec3 grid_size; uint pad2; } - params; -/* clang-format on */ - void main() { uint triangle_idx = params.base_triangle + gl_VertexIndex / 3; uint triangle_subidx = gl_VertexIndex % 3; @@ -56,12 +50,9 @@ void main() { face_normal = -normalize(cross((vertices.data[vertex_indices.x].position - vertices.data[vertex_indices.y].position), (vertices.data[vertex_indices.x].position - vertices.data[vertex_indices.z].position))); gl_Position = vec4((uv_interp + params.uv_offset) * 2.0 - 1.0, 0.0001, 1.0); - ; } -/* clang-format off */ - -[fragment] +#[fragment] #version 450 @@ -69,7 +60,6 @@ VERSION_DEFINES #include "lm_common_inc.glsl" - layout(push_constant, binding = 0, std430) uniform Params { vec2 atlas_size; vec2 uv_offset; @@ -79,9 +69,8 @@ layout(push_constant, binding = 0, std430) uniform Params { float bias; ivec3 grid_size; uint pad2; -} params; - -/* clang-format on */ +} +params; layout(location = 0) in vec3 vertex_interp; layout(location = 1) in vec3 normal_interp; @@ -100,7 +89,6 @@ void main() { { // smooth out vertex position by interpolating its projection in the 3 normal planes (normal plane is created by vertex pos and normal) // because we don't want to interpolate inwards, normals found pointing inwards are pushed out. - vec3 pos_a = vertices.data[vertex_indices.x].position; vec3 pos_b = vertices.data[vertex_indices.y].position; vec3 pos_c = vertices.data[vertex_indices.z].position; diff --git a/modules/mobile_vr/mobile_vr_interface.cpp b/modules/mobile_vr/mobile_vr_interface.cpp index eebb3af709..a2fb443ef0 100644 --- a/modules/mobile_vr/mobile_vr_interface.cpp +++ b/modules/mobile_vr/mobile_vr_interface.cpp @@ -448,12 +448,6 @@ void MobileVRInterface::process() { }; }; -void MobileVRInterface::notification(int p_what){ - _THREAD_SAFE_METHOD_ - - // nothing to do here, I guess we could pauze our sensors... -} - MobileVRInterface::MobileVRInterface() { initialized = false; diff --git a/modules/mobile_vr/mobile_vr_interface.h b/modules/mobile_vr/mobile_vr_interface.h index 3a9ed1314a..e986a4a3de 100644 --- a/modules/mobile_vr/mobile_vr_interface.h +++ b/modules/mobile_vr/mobile_vr_interface.h @@ -142,7 +142,7 @@ public: virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect); virtual void process(); - virtual void notification(int p_what); + virtual void notification(int p_what) {} MobileVRInterface(); ~MobileVRInterface(); diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index a5aae5175b..6e3bdf8e41 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -3240,9 +3240,7 @@ Error CSharpScript::reload(bool p_keep_state) { ERR_FAIL_NULL_V(namespace_, ERR_BUG); ERR_FAIL_NULL_V(class_name, ERR_BUG); GDMonoClass *klass = project_assembly->get_class(namespace_->operator String(), class_name->operator String()); - if (klass) { - bool obj_type = CACHED_CLASS(GodotObject)->is_assignable_from(klass); - ERR_FAIL_COND_V(!obj_type, ERR_BUG); + if (klass && CACHED_CLASS(GodotObject)->is_assignable_from(klass)) { script_class = klass; } } else { diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 0218773105..730ffcb945 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -123,8 +123,9 @@ static String snake_to_pascal_case(const String &p_identifier, bool p_input_is_u if (part.length()) { part[0] = _find_upper(part[0]); if (p_input_is_upper) { - for (int j = 1; j < part.length(); j++) + for (int j = 1; j < part.length(); j++) { part[j] = _find_lower(part[j]); + } } ret += part; } else { @@ -157,8 +158,9 @@ static String snake_to_camel_case(const String &p_identifier, bool p_input_is_up part[0] = _find_upper(part[0]); } if (p_input_is_upper) { - for (int j = i != 0 ? 1 : 0; j < part.length(); j++) + for (int j = i != 0 ? 1 : 0; j < part.length(); j++) { part[j] = _find_lower(part[j]); + } } ret += part; } else { @@ -182,8 +184,9 @@ static String snake_to_camel_case(const String &p_identifier, bool p_input_is_up String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterface *p_itype) { // Based on the version in EditorHelp - if (p_bbcode.empty()) + if (p_bbcode.empty()) { return String(); + } DocData *doc = EditorHelp::get_doc_data(); @@ -200,8 +203,9 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf while (pos < bbcode.length()) { int brk_pos = bbcode.find("[", pos); - if (brk_pos < 0) + if (brk_pos < 0) { brk_pos = bbcode.length(); + } if (brk_pos > pos) { String text = bbcode.substr(pos, brk_pos - pos); @@ -210,19 +214,22 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf } else { Vector<String> lines = text.split("\n"); for (int i = 0; i < lines.size(); i++) { - if (i != 0) + if (i != 0) { xml_output.append("<para>"); + } xml_output.append(lines[i].xml_escape()); - if (i != lines.size() - 1) + if (i != lines.size() - 1) { xml_output.append("</para>\n"); + } } } } - if (brk_pos == bbcode.length()) + if (brk_pos == bbcode.length()) { break; // nothing else to add + } int brk_end = bbcode.find("]", brk_pos + 1); @@ -233,13 +240,15 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf } else { Vector<String> lines = text.split("\n"); for (int i = 0; i < lines.size(); i++) { - if (i != 0) + if (i != 0) { xml_output.append("<para>"); + } xml_output.append(lines[i].xml_escape()); - if (i != lines.size() - 1) + if (i != lines.size() - 1) { xml_output.append("</para>\n"); + } } } @@ -412,8 +421,9 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf for (const List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) { target_ienum = &E->get(); target_iconst = find_constant_by_name(target_name, target_ienum->constants); - if (target_iconst) + if (target_iconst) { break; + } } if (target_iconst) { @@ -450,8 +460,9 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf for (const List<EnumInterface>::Element *E = target_itype->enums.front(); E; E = E->next()) { target_ienum = &E->get(); target_iconst = find_constant_by_name(target_name, target_ienum->constants); - if (target_iconst) + if (target_iconst) { break; + } } if (target_iconst) { @@ -583,8 +594,9 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf tag_stack.push_front(tag); } else if (tag == "url") { int end = bbcode.find("[", brk_end); - if (end == -1) + if (end == -1) { end = bbcode.length(); + } String url = bbcode.substr(brk_end + 1, end - brk_end - 1); xml_output.append("<a href=\""); xml_output.append(url); @@ -603,8 +615,9 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf tag_stack.push_front("url"); } else if (tag == "img") { int end = bbcode.find("[", brk_end); - if (end == -1) + if (end == -1) { end = bbcode.length(); + } String image = bbcode.substr(brk_end + 1, end - brk_end - 1); // Not supported. Just append the bbcode. @@ -640,8 +653,9 @@ int BindingsGenerator::_determine_enum_prefix(const EnumInterface &p_ienum) { Vector<String> front_parts = front_iconstant.name.split("_", /* p_allow_empty: */ true); int candidate_len = front_parts.size() - 1; - if (candidate_len == 0) + if (candidate_len == 0) { return 0; + } for (const List<ConstantInterface>::Element *E = p_ienum.constants.front()->next(); E; E = E->next()) { const ConstantInterface &iconstant = E->get(); @@ -653,14 +667,16 @@ int BindingsGenerator::_determine_enum_prefix(const EnumInterface &p_ienum) { if (front_parts[i] != parts[i]) { // HARDCODED: Some Flag enums have the prefix 'FLAG_' for everything except 'FLAGS_DEFAULT' (same for 'METHOD_FLAG_' and'METHOD_FLAGS_DEFAULT'). bool hardcoded_exc = (i == candidate_len - 1 && ((front_parts[i] == "FLAGS" && parts[i] == "FLAG") || (front_parts[i] == "FLAG" && parts[i] == "FLAGS"))); - if (!hardcoded_exc) + if (!hardcoded_exc) { break; + } } } candidate_len = i; - if (candidate_len == 0) + if (candidate_len == 0) { return 0; + } } return candidate_len; @@ -677,22 +693,25 @@ void BindingsGenerator::_apply_prefix_to_enum_constants(BindingsGenerator::EnumI Vector<String> parts = constant_name.split("_", /* p_allow_empty: */ true); - if (parts.size() <= curr_prefix_length) + if (parts.size() <= curr_prefix_length) { continue; + } if (parts[curr_prefix_length][0] >= '0' && parts[curr_prefix_length][0] <= '9') { // The name of enum constants may begin with a numeric digit when strip from the enum prefix, // so we make the prefix for this constant one word shorter in those cases. for (curr_prefix_length = curr_prefix_length - 1; curr_prefix_length > 0; curr_prefix_length--) { - if (parts[curr_prefix_length][0] < '0' || parts[curr_prefix_length][0] > '9') + if (parts[curr_prefix_length][0] < '0' || parts[curr_prefix_length][0] > '9') { break; + } } } constant_name = ""; for (int i = curr_prefix_length; i < parts.size(); i++) { - if (i > curr_prefix_length) + if (i > curr_prefix_length) { constant_name += "_"; + } constant_name += parts[i]; } @@ -705,8 +724,9 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) { for (const List<MethodInterface>::Element *E = p_itype.methods.front(); E; E = E->next()) { const MethodInterface &imethod = E->get(); - if (imethod.is_virtual) + if (imethod.is_virtual) { continue; + } const TypeInterface *return_type = _get_type_or_placeholder(imethod.return_type); @@ -755,8 +775,9 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) { List<InternalCall>::Element *match = method_icalls.find(im_icall); if (match) { - if (p_itype.api_type != ClassDB::API_EDITOR) + if (p_itype.api_type != ClassDB::API_EDITOR) { match->get().editor_only = false; + } method_icalls_map.insert(&E->get(), &match->get()); } else { List<InternalCall>::Element *added = method_icalls.push_back(im_icall); @@ -801,8 +822,9 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { p_output.append(";"); } - if (!global_constants.empty()) + if (!global_constants.empty()) { p_output.append("\n"); + } p_output.append(INDENT1 CLOSE_BLOCK); // end of GD class @@ -864,8 +886,9 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { p_output.append(INDENT1 CLOSE_BLOCK); - if (enum_in_static_class) + if (enum_in_static_class) { p_output.append(INDENT1 CLOSE_BLOCK); + } } p_output.append(CLOSE_BLOCK); // end of namespace @@ -899,8 +922,9 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) { _generate_global_constants(constants_source); String output_file = path::join(base_gen_dir, BINDINGS_GLOBAL_SCOPE_CLASS "_constants.cs"); Error save_err = _save_file(output_file, constants_source); - if (save_err != OK) + if (save_err != OK) { return save_err; + } compile_items.push_back(output_file); } @@ -908,17 +932,20 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) { for (OrderedHashMap<StringName, TypeInterface>::Element E = obj_types.front(); E; E = E.next()) { const TypeInterface &itype = E.get(); - if (itype.api_type == ClassDB::API_EDITOR) + if (itype.api_type == ClassDB::API_EDITOR) { continue; + } String output_file = path::join(godot_objects_gen_dir, itype.proxy_name + ".cs"); Error err = _generate_cs_type(itype, output_file); - if (err == ERR_SKIP) + if (err == ERR_SKIP) { continue; + } - if (err != OK) + if (err != OK) { return err; + } compile_items.push_back(output_file); } @@ -949,10 +976,12 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) { cs_icalls_content.append(m_icall.im_sig + ");\n"); \ } - for (const List<InternalCall>::Element *E = core_custom_icalls.front(); E; E = E->next()) + for (const List<InternalCall>::Element *E = core_custom_icalls.front(); E; E = E->next()) { ADD_INTERNAL_CALL(E->get()); - for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next()) + } + for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next()) { ADD_INTERNAL_CALL(E->get()); + } #undef ADD_INTERNAL_CALL @@ -961,8 +990,9 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) { String internal_methods_file = path::join(base_gen_dir, BINDINGS_CLASS_NATIVECALLS ".cs"); Error err = _save_file(internal_methods_file, cs_icalls_content); - if (err != OK) + if (err != OK) { return err; + } compile_items.push_back(internal_methods_file); @@ -981,8 +1011,9 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) { String includes_props_file = path::join(base_gen_dir, "GeneratedIncludes.props"); err = _save_file(includes_props_file, includes_props_content); - if (err != OK) + if (err != OK) { return err; + } return OK; } @@ -1010,17 +1041,20 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) { for (OrderedHashMap<StringName, TypeInterface>::Element E = obj_types.front(); E; E = E.next()) { const TypeInterface &itype = E.get(); - if (itype.api_type != ClassDB::API_EDITOR) + if (itype.api_type != ClassDB::API_EDITOR) { continue; + } String output_file = path::join(godot_objects_gen_dir, itype.proxy_name + ".cs"); Error err = _generate_cs_type(itype, output_file); - if (err == ERR_SKIP) + if (err == ERR_SKIP) { continue; + } - if (err != OK) + if (err != OK) { return err; + } compile_items.push_back(output_file); } @@ -1050,10 +1084,12 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) { cs_icalls_content.append(m_icall.im_sig + ");\n"); \ } - for (const List<InternalCall>::Element *E = editor_custom_icalls.front(); E; E = E->next()) + for (const List<InternalCall>::Element *E = editor_custom_icalls.front(); E; E = E->next()) { ADD_INTERNAL_CALL(E->get()); - for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next()) + } + for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next()) { ADD_INTERNAL_CALL(E->get()); + } #undef ADD_INTERNAL_CALL @@ -1062,8 +1098,9 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) { String internal_methods_file = path::join(base_gen_dir, BINDINGS_CLASS_NATIVECALLS_EDITOR ".cs"); Error err = _save_file(internal_methods_file, cs_icalls_content); - if (err != OK) + if (err != OK) { return err; + } compile_items.push_back(internal_methods_file); @@ -1082,8 +1119,9 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) { String includes_props_file = path::join(base_gen_dir, "GeneratedIncludes.props"); err = _save_file(includes_props_file, includes_props_content); - if (err != OK) + if (err != OK) { return err; + } return OK; } @@ -1210,92 +1248,89 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str output.append(INDENT1 "{"); - if (class_doc) { - // Add constants - - for (const List<ConstantInterface>::Element *E = itype.constants.front(); E; E = E->next()) { - const ConstantInterface &iconstant = E->get(); + // Add constants - if (iconstant.const_doc && iconstant.const_doc->description.size()) { - String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), &itype); - Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); + for (const List<ConstantInterface>::Element *E = itype.constants.front(); E; E = E->next()) { + const ConstantInterface &iconstant = E->get(); - if (summary_lines.size()) { - output.append(MEMBER_BEGIN "/// <summary>\n"); + if (iconstant.const_doc && iconstant.const_doc->description.size()) { + String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), &itype); + Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); - for (int i = 0; i < summary_lines.size(); i++) { - output.append(INDENT2 "/// "); - output.append(summary_lines[i]); - output.append("\n"); - } + if (summary_lines.size()) { + output.append(MEMBER_BEGIN "/// <summary>\n"); - output.append(INDENT2 "/// </summary>"); + for (int i = 0; i < summary_lines.size(); i++) { + output.append(INDENT2 "/// "); + output.append(summary_lines[i]); + output.append("\n"); } - } - output.append(MEMBER_BEGIN "public const int "); - output.append(iconstant.proxy_name); - output.append(" = "); - output.append(itos(iconstant.value)); - output.append(";"); + output.append(INDENT2 "/// </summary>"); + } } - if (itype.constants.size()) - output.append("\n"); + output.append(MEMBER_BEGIN "public const int "); + output.append(iconstant.proxy_name); + output.append(" = "); + output.append(itos(iconstant.value)); + output.append(";"); + } - // Add enums + if (itype.constants.size()) { + output.append("\n"); + } - for (const List<EnumInterface>::Element *E = itype.enums.front(); E; E = E->next()) { - const EnumInterface &ienum = E->get(); + // Add enums - ERR_FAIL_COND_V(ienum.constants.empty(), ERR_BUG); + for (const List<EnumInterface>::Element *E = itype.enums.front(); E; E = E->next()) { + const EnumInterface &ienum = E->get(); - output.append(MEMBER_BEGIN "public enum "); - output.append(ienum.cname.operator String()); - output.append(MEMBER_BEGIN OPEN_BLOCK); + ERR_FAIL_COND_V(ienum.constants.empty(), ERR_BUG); - for (const List<ConstantInterface>::Element *F = ienum.constants.front(); F; F = F->next()) { - const ConstantInterface &iconstant = F->get(); + output.append(MEMBER_BEGIN "public enum "); + output.append(ienum.cname.operator String()); + output.append(MEMBER_BEGIN OPEN_BLOCK); - if (iconstant.const_doc && iconstant.const_doc->description.size()) { - String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), &itype); - Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); + for (const List<ConstantInterface>::Element *F = ienum.constants.front(); F; F = F->next()) { + const ConstantInterface &iconstant = F->get(); - if (summary_lines.size()) { - output.append(INDENT3 "/// <summary>\n"); + if (iconstant.const_doc && iconstant.const_doc->description.size()) { + String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), &itype); + Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); - for (int i = 0; i < summary_lines.size(); i++) { - output.append(INDENT3 "/// "); - output.append(summary_lines[i]); - output.append("\n"); - } + if (summary_lines.size()) { + output.append(INDENT3 "/// <summary>\n"); - output.append(INDENT3 "/// </summary>\n"); + for (int i = 0; i < summary_lines.size(); i++) { + output.append(INDENT3 "/// "); + output.append(summary_lines[i]); + output.append("\n"); } - } - output.append(INDENT3); - output.append(iconstant.proxy_name); - output.append(" = "); - output.append(itos(iconstant.value)); - output.append(F != ienum.constants.back() ? ",\n" : "\n"); + output.append(INDENT3 "/// </summary>\n"); + } } - output.append(INDENT2 CLOSE_BLOCK); + output.append(INDENT3); + output.append(iconstant.proxy_name); + output.append(" = "); + output.append(itos(iconstant.value)); + output.append(F != ienum.constants.back() ? ",\n" : "\n"); } - // Add properties - - for (const List<PropertyInterface>::Element *E = itype.properties.front(); E; E = E->next()) { - const PropertyInterface &iprop = E->get(); - Error prop_err = _generate_cs_property(itype, iprop, output); - ERR_FAIL_COND_V_MSG(prop_err != OK, prop_err, - "Failed to generate property '" + iprop.cname.operator String() + - "' for class '" + itype.name + "'."); - } + output.append(INDENT2 CLOSE_BLOCK); } - // TODO: BINDINGS_NATIVE_NAME_FIELD should be StringName, once we support it in C# + // Add properties + + for (const List<PropertyInterface>::Element *E = itype.properties.front(); E; E = E->next()) { + const PropertyInterface &iprop = E->get(); + Error prop_err = _generate_cs_property(itype, iprop, output); + ERR_FAIL_COND_V_MSG(prop_err != OK, prop_err, + "Failed to generate property '" + iprop.cname.operator String() + + "' for class '" + itype.name + "'."); + } if (itype.is_singleton) { // Add the type name and the singleton pointer as static fields @@ -1368,15 +1403,17 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str if (itype.is_singleton) { InternalCall singleton_icall = InternalCall(itype.api_type, ICALL_PREFIX + itype.name + SINGLETON_ICALL_SUFFIX, "IntPtr"); - if (!find_icall_by_name(singleton_icall.name, custom_icalls)) + if (!find_icall_by_name(singleton_icall.name, custom_icalls)) { custom_icalls.push_back(singleton_icall); + } } if (is_derived_type && itype.is_instantiable) { InternalCall ctor_icall = InternalCall(itype.api_type, ctor_method, "IntPtr", itype.proxy_name + " obj"); - if (!find_icall_by_name(ctor_icall.name, custom_icalls)) + if (!find_icall_by_name(ctor_icall.name, custom_icalls)) { custom_icalls.push_back(ctor_icall); + } } output.append(INDENT1 CLOSE_BLOCK /* class */ @@ -1442,6 +1479,9 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte const TypeInterface *prop_itype = _get_type_or_null(proptype_name); ERR_FAIL_NULL_V(prop_itype, ERR_BUG); // Property type not found + ERR_FAIL_COND_V_MSG(prop_itype->is_singleton, ERR_BUG, + "Property type is a singleton: '" + p_itype.name + "." + String(p_iprop.cname) + "'."); + if (p_iprop.prop_doc && p_iprop.prop_doc->description.size()) { String xml_summary = bbcode_to_xml(fix_doc_description(p_iprop.prop_doc->description), &p_itype); Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); @@ -1461,8 +1501,9 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte p_output.append(MEMBER_BEGIN "public "); - if (p_itype.is_singleton) + if (p_itype.is_singleton) { p_output.append("static "); + } p_output.append(prop_itype->cs_type); p_output.append(" "); @@ -1534,6 +1575,9 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterface &p_itype, const BindingsGenerator::MethodInterface &p_imethod, int &p_method_bind_count, StringBuilder &p_output) { const TypeInterface *return_type = _get_type_or_placeholder(p_imethod.return_type); + ERR_FAIL_COND_V_MSG(return_type->is_singleton, ERR_BUG, + "Method return type is a singleton: '" + p_itype.name + "." + p_imethod.name + "'."); + String method_bind_field = "__method_bind_" + itos(p_method_bind_count); String arguments_sig; @@ -1549,29 +1593,41 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf const ArgumentInterface &iarg = F->get(); const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type); + ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG, + "Argument type is a singleton: '" + iarg.name + "' of method '" + p_itype.name + "." + p_imethod.name + "'."); + + if (iarg.default_argument.size()) { + CRASH_COND_MSG(!_arg_default_value_is_assignable_to_type(iarg.def_param_value, *arg_type), + "Invalid default value for parameter '" + iarg.name + "' of method '" + p_itype.name + "." + p_imethod.name + "'."); + } + // Add the current arguments to the signature // If the argument has a default value which is not a constant, we will make it Nullable { - if (F != p_imethod.arguments.front()) + if (F != p_imethod.arguments.front()) { arguments_sig += ", "; + } - if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL) + if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL) { arguments_sig += "Nullable<"; + } arguments_sig += arg_type->cs_type; - if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL) + if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL) { arguments_sig += "> "; - else + } else { arguments_sig += " "; + } arguments_sig += iarg.name; if (iarg.default_argument.size()) { - if (iarg.def_param_mode != ArgumentInterface::CONSTANT) + if (iarg.def_param_mode != ArgumentInterface::CONSTANT) { arguments_sig += " = null"; - else + } else { arguments_sig += " = " + sformat(iarg.default_argument, arg_type->cs_type); + } } } @@ -1589,17 +1645,19 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf cs_in_statements += " = "; cs_in_statements += iarg.name; - if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL) + if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL) { cs_in_statements += ".HasValue ? "; - else + } else { cs_in_statements += " != null ? "; + } cs_in_statements += iarg.name; - if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL) + if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL) { cs_in_statements += ".Value : "; - else + } else { cs_in_statements += " : "; + } String def_arg = sformat(iarg.default_argument, arg_type->cs_type); @@ -1659,8 +1717,9 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf } if (p_imethod.is_deprecated) { - if (p_imethod.deprecation_message.empty()) + if (p_imethod.deprecation_message.empty()) { WARN_PRINT("An empty deprecation message is discouraged. Method: '" + p_imethod.proxy_name + "'."); + } p_output.append(MEMBER_BEGIN "[Obsolete(\""); p_output.append(p_imethod.deprecation_message); @@ -1720,8 +1779,9 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf im_call += "."; im_call += im_icall->name; - if (p_imethod.arguments.size()) + if (p_imethod.arguments.size()) { p_output.append(cs_in_statements); + } if (return_type->cname == name_cache.type_void) { p_output.append(im_call + "(" + icall_params + ");\n"); @@ -1748,10 +1808,14 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf const ArgumentInterface &iarg = F->get(); const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type); + ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG, + "Argument type is a singleton: '" + iarg.name + "' of signal" + p_itype.name + "." + p_isignal.name + "'."); + // Add the current arguments to the signature - if (F != p_isignal.arguments.front()) + if (F != p_isignal.arguments.front()) { arguments_sig += ", "; + } arguments_sig += arg_type->cs_type; arguments_sig += " "; @@ -1778,8 +1842,9 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf } if (p_isignal.is_deprecated) { - if (p_isignal.deprecation_message.empty()) + if (p_isignal.deprecation_message.empty()) { WARN_PRINT("An empty deprecation message is discouraged. Signal: '" + p_isignal.proxy_name + "'."); + } p_output.append(MEMBER_BEGIN "[Obsolete(\""); p_output.append(p_isignal.deprecation_message); @@ -1810,8 +1875,9 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf // Generate event p_output.append(MEMBER_BEGIN "[Signal]" MEMBER_BEGIN "public "); - if (p_itype.is_singleton) + if (p_itype.is_singleton) { p_output.append("static "); + } p_output.append("event "); p_output.append(delegate_name); @@ -1819,18 +1885,20 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf p_output.append(p_isignal.proxy_name); p_output.append("\n" OPEN_BLOCK_L2); - if (p_itype.is_singleton) + if (p_itype.is_singleton) { p_output.append("add => Singleton.Connect(__signal_name_"); - else + } else { p_output.append("add => Connect(__signal_name_"); + } p_output.append(p_isignal.name); p_output.append(", new Callable(value));\n"); - if (p_itype.is_singleton) + if (p_itype.is_singleton) { p_output.append(INDENT3 "remove => Singleton.Disconnect(__signal_name_"); - else + } else { p_output.append(INDENT3 "remove => Disconnect(__signal_name_"); + } p_output.append(p_isignal.name); p_output.append(", new Callable(value));\n"); @@ -1864,7 +1932,6 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { CRASH_COND(itype.cname != name_cache.type_Object); CRASH_COND(!itype.is_instantiable); CRASH_COND(itype.api_type != ClassDB::API_CORE); - CRASH_COND(itype.is_reference); CRASH_COND(itype.is_singleton); } @@ -1885,8 +1952,9 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { String singleton_icall_name = ICALL_PREFIX + itype.name + SINGLETON_ICALL_SUFFIX; InternalCall singleton_icall = InternalCall(itype.api_type, singleton_icall_name, "IntPtr"); - if (!find_icall_by_name(singleton_icall.name, custom_icalls)) + if (!find_icall_by_name(singleton_icall.name, custom_icalls)) { custom_icalls.push_back(singleton_icall); + } output.append("Object* "); output.append(singleton_icall_name); @@ -1898,8 +1966,9 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { if (is_derived_type && itype.is_instantiable) { InternalCall ctor_icall = InternalCall(itype.api_type, ctor_method, "IntPtr", itype.proxy_name + " obj"); - if (!find_icall_by_name(ctor_icall.name, custom_icalls)) + if (!find_icall_by_name(ctor_icall.name, custom_icalls)) { custom_icalls.push_back(ctor_icall); + } output.append("Object* "); output.append(ctor_method); @@ -1998,8 +2067,9 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { output.append("\n#endif // MONO_GLUE_ENABLED\n"); Error save_err = _save_file(path::join(p_output_dir, "mono_glue.gen.cpp"), output); - if (save_err != OK) + if (save_err != OK) { return save_err; + } OS::get_singleton()->print("Mono glue generated successfully\n"); @@ -2022,8 +2092,9 @@ Error BindingsGenerator::_save_file(const String &p_path, const StringBuilder &p } Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInterface &p_itype, const BindingsGenerator::MethodInterface &p_imethod, StringBuilder &p_output) { - if (p_imethod.is_virtual) + if (p_imethod.is_virtual) { return OK; // Ignore + } bool ret_void = p_imethod.return_type.cname == name_cache.type_void; @@ -2051,10 +2122,12 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte c_in_statements += sformat(", &%s_in);\n", c_param_name); } } else { - if (i > 0) + if (i > 0) { c_args_var_content += ", "; - if (arg_type->c_in.size()) + } + if (arg_type->c_in.size()) { c_in_statements += sformat(arg_type->c_in, arg_type->c_type, c_param_name); + } c_args_var_content += sformat(arg_type->c_arg_in, c_param_name); } @@ -2084,8 +2157,9 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte if (!generated_icall_funcs.find(im_icall)) { generated_icall_funcs.push_back(im_icall); - if (im_icall->editor_only) + if (im_icall->editor_only) { p_output.append("#ifdef TOOLS_ENABLED\n"); + } // Generate icall function @@ -2203,8 +2277,9 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte p_output.append(CLOSE_BLOCK "\n"); - if (im_icall->editor_only) + if (im_icall->editor_only) { p_output.append("#endif // TOOLS_ENABLED\n"); + } } return OK; @@ -2213,19 +2288,22 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_null(const TypeReference &p_typeref) { const Map<StringName, TypeInterface>::Element *builtin_type_match = builtin_types.find(p_typeref.cname); - if (builtin_type_match) + if (builtin_type_match) { return &builtin_type_match->get(); + } const OrderedHashMap<StringName, TypeInterface>::Element obj_type_match = obj_types.find(p_typeref.cname); - if (obj_type_match) + if (obj_type_match) { return &obj_type_match.get(); + } if (p_typeref.is_enum) { const Map<StringName, TypeInterface>::Element *enum_match = enum_types.find(p_typeref.cname); - if (enum_match) + if (enum_match) { return &enum_match->get(); + } // Enum not found. Most likely because none of its constants were bound, so it's empty. That's fine. Use int instead. const Map<StringName, TypeInterface>::Element *int_match = builtin_types.find(name_cache.type_int); @@ -2239,15 +2317,17 @@ const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_null(con const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_placeholder(const TypeReference &p_typeref) { const TypeInterface *found = _get_type_or_null(p_typeref); - if (found) + if (found) { return found; + } ERR_PRINT(String() + "Type not found. Creating placeholder: '" + p_typeref.cname.operator String() + "'."); const Map<StringName, TypeInterface>::Element *match = placeholder_types.find(p_typeref.cname); - if (match) + if (match) { return &match->get(); + } TypeInterface placeholder; TypeInterface::create_placeholder_type(placeholder, p_typeref.cname); @@ -2305,6 +2385,84 @@ StringName BindingsGenerator::_get_float_type_name_from_meta(GodotTypeInfo::Meta } } +bool BindingsGenerator::_arg_default_value_is_assignable_to_type(const Variant &p_val, const TypeInterface &p_arg_type) { + if (p_arg_type.name == name_cache.type_Variant) { + // Variant can take anything + return true; + } + + switch (p_val.get_type()) { + case Variant::NIL: + return p_arg_type.is_object_type || + name_cache.is_nullable_type(p_arg_type.name); + case Variant::BOOL: + return p_arg_type.name == name_cache.type_bool; + case Variant::INT: + return p_arg_type.name == name_cache.type_sbyte || + p_arg_type.name == name_cache.type_short || + p_arg_type.name == name_cache.type_int || + p_arg_type.name == name_cache.type_byte || + p_arg_type.name == name_cache.type_ushort || + p_arg_type.name == name_cache.type_uint || + p_arg_type.name == name_cache.type_long || + p_arg_type.name == name_cache.type_ulong || + p_arg_type.name == name_cache.type_float || + p_arg_type.name == name_cache.type_double || + p_arg_type.is_enum; + case Variant::FLOAT: + return p_arg_type.name == name_cache.type_float || + p_arg_type.name == name_cache.type_double; + case Variant::STRING: + case Variant::STRING_NAME: + return p_arg_type.name == name_cache.type_String || + p_arg_type.name == name_cache.type_StringName || + p_arg_type.name == name_cache.type_NodePath; + case Variant::NODE_PATH: + return p_arg_type.name == name_cache.type_NodePath; + case Variant::TRANSFORM: + case Variant::TRANSFORM2D: + case Variant::BASIS: + case Variant::QUAT: + case Variant::PLANE: + case Variant::AABB: + case Variant::COLOR: + case Variant::VECTOR2: + case Variant::RECT2: + case Variant::VECTOR3: + case Variant::_RID: + case Variant::ARRAY: + case Variant::DICTIONARY: + case Variant::PACKED_BYTE_ARRAY: + case Variant::PACKED_INT32_ARRAY: + case Variant::PACKED_INT64_ARRAY: + case Variant::PACKED_FLOAT32_ARRAY: + case Variant::PACKED_FLOAT64_ARRAY: + case Variant::PACKED_STRING_ARRAY: + case Variant::PACKED_VECTOR2_ARRAY: + case Variant::PACKED_VECTOR3_ARRAY: + case Variant::PACKED_COLOR_ARRAY: + case Variant::CALLABLE: + case Variant::SIGNAL: + return p_arg_type.name == Variant::get_type_name(p_val.get_type()); + case Variant::OBJECT: + return p_arg_type.is_object_type; + case Variant::VECTOR2I: + return p_arg_type.name == name_cache.type_Vector2 || + p_arg_type.name == Variant::get_type_name(p_val.get_type()); + case Variant::RECT2I: + return p_arg_type.name == name_cache.type_Rect2 || + p_arg_type.name == Variant::get_type_name(p_val.get_type()); + case Variant::VECTOR3I: + return p_arg_type.name == name_cache.type_Vector3 || + p_arg_type.name == Variant::get_type_name(p_val.get_type()); + default: + CRASH_NOW_MSG("Unexpected Variant type: " + itos(p_val.get_type())); + break; + } + + return false; +} + bool BindingsGenerator::_populate_object_type_interfaces() { obj_types.clear(); @@ -2367,8 +2525,9 @@ bool BindingsGenerator::_populate_object_type_interfaces() { for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { const PropertyInfo &property = E->get(); - if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_SUBGROUP || property.usage & PROPERTY_USAGE_CATEGORY) + if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_SUBGROUP || property.usage & PROPERTY_USAGE_CATEGORY) { continue; + } if (property.name.find("/") >= 0) { // Ignore properties with '/' (slash) in the name. These are only meant for use in the inspector. @@ -2380,10 +2539,12 @@ bool BindingsGenerator::_populate_object_type_interfaces() { iprop.setter = ClassDB::get_property_setter(type_cname, iprop.cname); iprop.getter = ClassDB::get_property_getter(type_cname, iprop.cname); - if (iprop.setter != StringName()) + if (iprop.setter != StringName()) { accessor_methods[iprop.setter] = iprop.cname; - if (iprop.getter != StringName()) + } + if (iprop.getter != StringName()) { accessor_methods[iprop.getter] = iprop.cname; + } bool valid = false; iprop.index = ClassDB::get_property_index(type_cname, iprop.cname, &valid); @@ -2427,20 +2588,23 @@ bool BindingsGenerator::_populate_object_type_interfaces() { int argc = method_info.arguments.size(); - if (method_info.name.empty()) + if (method_info.name.empty()) { continue; + } String cname = method_info.name; - if (blacklisted_methods.find(itype.cname) && blacklisted_methods[itype.cname].find(cname)) + if (blacklisted_methods.find(itype.cname) && blacklisted_methods[itype.cname].find(cname)) { continue; + } MethodInterface imethod; imethod.name = method_info.name; imethod.cname = cname; - if (method_info.flags & METHOD_FLAG_VIRTUAL) + if (method_info.flags & METHOD_FLAG_VIRTUAL) { imethod.is_virtual = true; + } PropertyInfo return_info = method_info.return_val; @@ -2462,9 +2626,8 @@ bool BindingsGenerator::_populate_object_type_interfaces() { // We assume the return type is void. imethod.return_type.cname = name_cache.type_void; - // Actually, more methods like this may be added in the future, - // which could actually will return something different. - // Let's put this to notify us if that ever happens. + // Actually, more methods like this may be added in the future, which could return + // something different. Let's put this check to notify us if that ever happens. if (itype.cname != name_cache.type_Object || imethod.name != "free") { WARN_PRINT("Notification: New unexpected virtual non-overridable method found." " We only expected Object.free, but found '" + @@ -2475,13 +2638,12 @@ bool BindingsGenerator::_populate_object_type_interfaces() { imethod.return_type.is_enum = true; } else if (return_info.class_name != StringName()) { imethod.return_type.cname = return_info.class_name; - if (!imethod.is_virtual && ClassDB::is_parent_class(return_info.class_name, name_cache.type_Reference) && return_info.hint != PROPERTY_HINT_RESOURCE_TYPE) { - /* clang-format off */ - ERR_PRINT("Return type is reference but hint is not '" _STR(PROPERTY_HINT_RESOURCE_TYPE) "'." - " Are you returning a reference type by pointer? Method: '" + itype.name + "." + imethod.name + "'."); - /* clang-format on */ - ERR_FAIL_V(false); - } + + bool bad_reference_hint = !imethod.is_virtual && return_info.hint != PROPERTY_HINT_RESOURCE_TYPE && + ClassDB::is_parent_class(return_info.class_name, name_cache.type_Reference); + ERR_FAIL_COND_V_MSG(bad_reference_hint, false, + String() + "Return type is reference but hint is not '" _STR(PROPERTY_HINT_RESOURCE_TYPE) "'." + + " Are you returning a reference type by pointer? Method: '" + itype.name + "." + imethod.name + "'."); } else if (return_info.hint == PROPERTY_HINT_RESOURCE_TYPE) { imethod.return_type.cname = return_info.hint_string; } else if (return_info.type == Variant::NIL && return_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT) { @@ -2572,6 +2734,10 @@ bool BindingsGenerator::_populate_object_type_interfaces() { } } + ERR_FAIL_COND_V_MSG(itype.find_property_by_name(imethod.cname), false, + "Method name conflicts with property: '" + itype.name + "." + imethod.name + "'."); + + // Classes starting with an underscore are ignored unless they're used as a property setter or getter if (!imethod.is_virtual && imethod.name[0] == '_') { for (const List<PropertyInterface>::Element *F = itype.properties.front(); F; F = F->next()) { const PropertyInterface &iprop = F->get(); @@ -2751,7 +2917,8 @@ bool BindingsGenerator::_populate_object_type_interfaces() { } bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, ArgumentInterface &r_iarg) { - r_iarg.default_argument = p_val; + r_iarg.def_param_value = p_val; + r_iarg.default_argument = p_val.operator String(); switch (p_val.get_type()) { case Variant::NIL: @@ -2784,8 +2951,9 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar } break; case Variant::TRANSFORM: - if (p_val.operator Transform() == Transform()) + if (p_val.operator Transform() == Transform()) { r_iarg.default_argument.clear(); + } r_iarg.default_argument = "new %s(" + r_iarg.default_argument + ")"; r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL; break; @@ -2851,8 +3019,9 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar break; } - if (r_iarg.def_param_mode == ArgumentInterface::CONSTANT && r_iarg.type.cname == name_cache.type_Variant && r_iarg.default_argument != "null") + if (r_iarg.def_param_mode == ArgumentInterface::CONSTANT && r_iarg.type.cname == name_cache.type_Variant && r_iarg.default_argument != "null") { r_iarg.def_param_mode = ArgumentInterface::NULLABLE_REF; + } return true; } @@ -3357,8 +3526,9 @@ void BindingsGenerator::_initialize() { core_custom_icalls.clear(); editor_custom_icalls.clear(); - for (OrderedHashMap<StringName, TypeInterface>::Element E = obj_types.front(); E; E = E.next()) + for (OrderedHashMap<StringName, TypeInterface>::Element E = obj_types.front(); E; E = E.next()) { _generate_method_icalls(E.get()); + } initialized = true; } @@ -3426,21 +3596,25 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args) } if (glue_dir_path.length()) { - if (bindings_generator.generate_glue(glue_dir_path) != OK) + if (bindings_generator.generate_glue(glue_dir_path) != OK) { ERR_PRINT(generate_all_glue_option + ": Failed to generate the C++ glue."); + } - if (bindings_generator.generate_cs_api(glue_dir_path.plus_file(API_SOLUTION_NAME)) != OK) + if (bindings_generator.generate_cs_api(glue_dir_path.plus_file(API_SOLUTION_NAME)) != OK) { ERR_PRINT(generate_all_glue_option + ": Failed to generate the C# API."); + } } if (cs_dir_path.length()) { - if (bindings_generator.generate_cs_api(cs_dir_path) != OK) + if (bindings_generator.generate_cs_api(cs_dir_path) != OK) { ERR_PRINT(generate_cs_glue_option + ": Failed to generate the C# API."); + } } if (cpp_dir_path.length()) { - if (bindings_generator.generate_glue(cpp_dir_path) != OK) + if (bindings_generator.generate_glue(cpp_dir_path) != OK) { ERR_PRINT(generate_cpp_glue_option + ": Failed to generate the C++ glue."); + } } // Exit once done diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index aad109e03c..90c1c9f3ee 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -102,6 +102,8 @@ class BindingsGenerator { TypeReference type; String name; + + Variant def_param_value; DefaultParamMode def_param_mode = CONSTANT; /** @@ -355,8 +357,9 @@ class BindingsGenerator { const MethodInterface *find_method_by_name(const StringName &p_cname) const { for (const List<MethodInterface>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().cname == p_cname) + if (E->get().cname == p_cname) { return &E->get(); + } } return nullptr; @@ -364,8 +367,9 @@ class BindingsGenerator { const PropertyInterface *find_property_by_name(const StringName &p_cname) const { for (const List<PropertyInterface>::Element *E = properties.front(); E; E = E->next()) { - if (E->get().cname == p_cname) + if (E->get().cname == p_cname) { return &E->get(); + } } return nullptr; @@ -373,8 +377,9 @@ class BindingsGenerator { const PropertyInterface *find_property_by_proxy_name(const String &p_proxy_name) const { for (const List<PropertyInterface>::Element *E = properties.front(); E; E = E->next()) { - if (E->get().proxy_name == p_proxy_name) + if (E->get().proxy_name == p_proxy_name) { return &E->get(); + } } return nullptr; @@ -382,8 +387,9 @@ class BindingsGenerator { const MethodInterface *find_method_by_proxy_name(const String &p_proxy_name) const { for (const List<MethodInterface>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().proxy_name == p_proxy_name) + if (E->get().proxy_name == p_proxy_name) { return &E->get(); + } } return nullptr; @@ -523,58 +529,70 @@ class BindingsGenerator { void _initialize_blacklisted_methods(); struct NameCache { - StringName type_void; - StringName type_Array; - StringName type_Dictionary; - StringName type_Variant; - StringName type_VarArg; - StringName type_Object; - StringName type_Reference; - StringName type_RID; - StringName type_String; - StringName type_StringName; - StringName type_NodePath; - StringName type_at_GlobalScope; - StringName enum_Error; - - StringName type_sbyte; - StringName type_short; - StringName type_int; - StringName type_long; - StringName type_byte; - StringName type_ushort; - StringName type_uint; - StringName type_ulong; - StringName type_float; - StringName type_double; - - NameCache() { - type_void = StaticCString::create("void"); - type_Array = StaticCString::create("Array"); - type_Dictionary = StaticCString::create("Dictionary"); - type_Variant = StaticCString::create("Variant"); - type_VarArg = StaticCString::create("VarArg"); - type_Object = StaticCString::create("Object"); - type_Reference = StaticCString::create("Reference"); - type_RID = StaticCString::create("RID"); - type_String = StaticCString::create("String"); - type_StringName = StaticCString::create("StringName"); - type_NodePath = StaticCString::create("NodePath"); - type_at_GlobalScope = StaticCString::create("@GlobalScope"); - enum_Error = StaticCString::create("Error"); - - type_sbyte = StaticCString::create("sbyte"); - type_short = StaticCString::create("short"); - type_int = StaticCString::create("int"); - type_long = StaticCString::create("long"); - type_byte = StaticCString::create("byte"); - type_ushort = StaticCString::create("ushort"); - type_uint = StaticCString::create("uint"); - type_ulong = StaticCString::create("ulong"); - type_float = StaticCString::create("float"); - type_double = StaticCString::create("double"); + StringName type_void = StaticCString::create("void"); + StringName type_Variant = StaticCString::create("Variant"); + StringName type_VarArg = StaticCString::create("VarArg"); + StringName type_Object = StaticCString::create("Object"); + StringName type_Reference = StaticCString::create("Reference"); + StringName type_RID = StaticCString::create("RID"); + StringName type_String = StaticCString::create("String"); + StringName type_StringName = StaticCString::create("StringName"); + StringName type_NodePath = StaticCString::create("NodePath"); + StringName type_at_GlobalScope = StaticCString::create("@GlobalScope"); + StringName enum_Error = StaticCString::create("Error"); + + StringName type_sbyte = StaticCString::create("sbyte"); + StringName type_short = StaticCString::create("short"); + StringName type_int = StaticCString::create("int"); + StringName type_byte = StaticCString::create("byte"); + StringName type_ushort = StaticCString::create("ushort"); + StringName type_uint = StaticCString::create("uint"); + StringName type_long = StaticCString::create("long"); + StringName type_ulong = StaticCString::create("ulong"); + + StringName type_bool = StaticCString::create("bool"); + StringName type_float = StaticCString::create("float"); + StringName type_double = StaticCString::create("double"); + + StringName type_Vector2 = StaticCString::create("Vector2"); + StringName type_Rect2 = StaticCString::create("Rect2"); + StringName type_Vector3 = StaticCString::create("Vector3"); + + // Object not included as it must be checked for all derived classes + static constexpr int nullable_types_count = 17; + StringName nullable_types[nullable_types_count] = { + type_String, + type_StringName, + type_NodePath, + + StaticCString::create(_STR(Array)), + StaticCString::create(_STR(Dictionary)), + StaticCString::create(_STR(Callable)), + StaticCString::create(_STR(Signal)), + + StaticCString::create(_STR(PackedByteArray)), + StaticCString::create(_STR(PackedInt32Array)), + StaticCString::create(_STR(PackedInt64rray)), + StaticCString::create(_STR(PackedFloat32Array)), + StaticCString::create(_STR(PackedFloat64Array)), + StaticCString::create(_STR(PackedStringArray)), + StaticCString::create(_STR(PackedVector2Array)), + StaticCString::create(_STR(PackedVector3Array)), + StaticCString::create(_STR(PackedColorArray)), + }; + + bool is_nullable_type(const StringName &p_type) const { + for (int i = 0; i < nullable_types_count; i++) { + if (p_type == nullable_types[i]) { + return true; + } + } + + return false; } + NameCache() {} + private: NameCache(const NameCache &); NameCache &operator=(const NameCache &); @@ -585,8 +603,9 @@ class BindingsGenerator { const List<InternalCall>::Element *find_icall_by_name(const String &p_name, const List<InternalCall> &p_list) { const List<InternalCall>::Element *it = p_list.front(); while (it) { - if (it->get().name == p_name) + if (it->get().name == p_name) { return it; + } it = it->next(); } return nullptr; @@ -594,20 +613,22 @@ class BindingsGenerator { const ConstantInterface *find_constant_by_name(const String &p_name, const List<ConstantInterface> &p_constants) const { for (const List<ConstantInterface>::Element *E = p_constants.front(); E; E = E->next()) { - if (E->get().name == p_name) + if (E->get().name == p_name) { return &E->get(); + } } return nullptr; } inline String get_unique_sig(const TypeInterface &p_type) { - if (p_type.is_reference) + if (p_type.is_reference) { return "Ref"; - else if (p_type.is_object_type) + } else if (p_type.is_object_type) { return "Obj"; - else if (p_type.is_enum) + } else if (p_type.is_enum) { return "int"; + } return p_type.name; } @@ -626,6 +647,7 @@ class BindingsGenerator { StringName _get_float_type_name_from_meta(GodotTypeInfo::Metadata p_meta); bool _arg_default_value_from_variant(const Variant &p_val, ArgumentInterface &r_iarg); + bool _arg_default_value_is_assignable_to_type(const Variant &p_val, const TypeInterface &p_arg_type); bool _populate_object_type_interfaces(); void _populate_builtin_type_interfaces(); diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index 4d83e6a4a5..498391e44a 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -581,9 +581,8 @@ bool VideoStreamPlaybackTheora::is_paused() const { return paused; }; -void VideoStreamPlaybackTheora::set_loop(bool p_enable){ - -}; +void VideoStreamPlaybackTheora::set_loop(bool p_enable) { +} bool VideoStreamPlaybackTheora::has_loop() const { return false; @@ -605,10 +604,8 @@ float VideoStreamPlaybackTheora::get_playback_position() const { return get_time(); }; -void VideoStreamPlaybackTheora::seek(float p_time){ - - // no -}; +void VideoStreamPlaybackTheora::seek(float p_time) { +} void VideoStreamPlaybackTheora::set_mix_callback(AudioMixCallback p_callback, void *p_userdata) { mix_callback = p_callback; |