From 7878329e6fc828dc7ca0a8300ebdbaa0674a769c Mon Sep 17 00:00:00 2001 From: Karroffel Date: Sun, 3 Sep 2017 12:40:41 +0200 Subject: merged gdnative and nativescript module --- modules/gdnative/SCsub | 12 +- modules/gdnative/gdnative.h | 2 +- modules/gdnative/gdnative/array.cpp | 309 +++++ modules/gdnative/gdnative/basis.cpp | 254 ++++ modules/gdnative/gdnative/color.cpp | 182 +++ modules/gdnative/gdnative/dictionary.cpp | 155 +++ modules/gdnative/gdnative/gdnative.cpp | 189 +++ modules/gdnative/gdnative/node_path.cpp | 116 ++ modules/gdnative/gdnative/plane.cpp | 178 +++ modules/gdnative/gdnative/pool_arrays.cpp | 633 ++++++++++ modules/gdnative/gdnative/quat.cpp | 219 ++++ modules/gdnative/gdnative/rect2.cpp | 157 +++ modules/gdnative/gdnative/rect3.cpp | 219 ++++ modules/gdnative/gdnative/rid.cpp | 75 ++ modules/gdnative/gdnative/string.cpp | 1267 ++++++++++++++++++++ modules/gdnative/gdnative/transform.cpp | 223 ++++ modules/gdnative/gdnative/transform2d.cpp | 210 ++++ modules/gdnative/gdnative/variant.cpp | 481 ++++++++ modules/gdnative/gdnative/vector2.cpp | 297 +++++ modules/gdnative/gdnative/vector3.cpp | 304 +++++ modules/gdnative/godot/array.cpp | 309 ----- modules/gdnative/godot/array.h | 122 -- modules/gdnative/godot/basis.cpp | 254 ---- modules/gdnative/godot/basis.h | 115 -- modules/gdnative/godot/color.cpp | 182 --- modules/gdnative/godot/color.h | 96 -- modules/gdnative/godot/dictionary.cpp | 155 --- modules/gdnative/godot/dictionary.h | 89 -- modules/gdnative/godot/gdnative.cpp | 190 --- modules/gdnative/godot/gdnative.h | 303 ----- modules/gdnative/godot/icon.png.import | 23 - modules/gdnative/godot/node_path.cpp | 116 -- modules/gdnative/godot/node_path.h | 77 -- modules/gdnative/godot/plane.cpp | 178 --- modules/gdnative/godot/plane.h | 93 -- modules/gdnative/godot/pool_arrays.cpp | 633 ---------- modules/gdnative/godot/pool_arrays.h | 316 ----- modules/gdnative/godot/quat.cpp | 219 ---- modules/gdnative/godot/quat.h | 104 -- modules/gdnative/godot/rect2.cpp | 157 --- modules/gdnative/godot/rect2.h | 86 -- modules/gdnative/godot/rect3.cpp | 219 ---- modules/gdnative/godot/rect3.h | 108 -- modules/gdnative/godot/rid.cpp | 75 -- modules/gdnative/godot/rid.h | 64 - modules/gdnative/godot/string.cpp | 1267 -------------------- modules/gdnative/godot/string.h | 228 ---- modules/gdnative/godot/transform.cpp | 223 ---- modules/gdnative/godot/transform.h | 100 -- modules/gdnative/godot/transform2d.cpp | 210 ---- modules/gdnative/godot/transform2d.h | 99 -- modules/gdnative/godot/variant.cpp | 481 -------- modules/gdnative/godot/variant.h | 201 ---- modules/gdnative/godot/vector2.cpp | 297 ----- modules/gdnative/godot/vector2.h | 128 -- modules/gdnative/godot/vector3.cpp | 304 ----- modules/gdnative/godot/vector3.h | 135 --- modules/gdnative/include/gdnative/array.h | 122 ++ modules/gdnative/include/gdnative/basis.h | 115 ++ modules/gdnative/include/gdnative/color.h | 96 ++ modules/gdnative/include/gdnative/dictionary.h | 89 ++ modules/gdnative/include/gdnative/gdnative.h | 277 +++++ modules/gdnative/include/gdnative/node_path.h | 77 ++ modules/gdnative/include/gdnative/plane.h | 93 ++ modules/gdnative/include/gdnative/pool_arrays.h | 316 +++++ modules/gdnative/include/gdnative/quat.h | 104 ++ modules/gdnative/include/gdnative/rect2.h | 86 ++ modules/gdnative/include/gdnative/rect3.h | 108 ++ modules/gdnative/include/gdnative/rid.h | 64 + modules/gdnative/include/gdnative/string.h | 228 ++++ modules/gdnative/include/gdnative/transform.h | 100 ++ modules/gdnative/include/gdnative/transform2d.h | 99 ++ modules/gdnative/include/gdnative/variant.h | 201 ++++ modules/gdnative/include/gdnative/vector2.h | 128 ++ modules/gdnative/include/gdnative/vector3.h | 135 +++ .../include/nativescript/godot_nativescript.h | 227 ++++ modules/gdnative/nativescript/SCsub | 10 + modules/gdnative/nativescript/api_generator.cpp | 487 ++++++++ modules/gdnative/nativescript/api_generator.h | 38 + .../gdnative/nativescript/godot_nativescript.cpp | 205 ++++ modules/gdnative/nativescript/nativescript.cpp | 1215 +++++++++++++++++++ modules/gdnative/nativescript/nativescript.h | 325 +++++ modules/gdnative/nativescript/register_types.cpp | 118 ++ modules/gdnative/nativescript/register_types.h | 31 + modules/gdnative/register_types.cpp | 9 + modules/nativescript/SCsub | 10 - modules/nativescript/api_generator.cpp | 487 -------- modules/nativescript/api_generator.h | 38 - modules/nativescript/config.py | 8 - modules/nativescript/godot_nativescript.cpp | 205 ---- modules/nativescript/godot_nativescript.h | 227 ---- modules/nativescript/nativescript.cpp | 1215 ------------------- modules/nativescript/nativescript.h | 325 ----- modules/nativescript/register_types.cpp | 118 -- modules/nativescript/register_types.h | 31 - 95 files changed, 10580 insertions(+), 10625 deletions(-) create mode 100644 modules/gdnative/gdnative/array.cpp create mode 100644 modules/gdnative/gdnative/basis.cpp create mode 100644 modules/gdnative/gdnative/color.cpp create mode 100644 modules/gdnative/gdnative/dictionary.cpp create mode 100644 modules/gdnative/gdnative/gdnative.cpp create mode 100644 modules/gdnative/gdnative/node_path.cpp create mode 100644 modules/gdnative/gdnative/plane.cpp create mode 100644 modules/gdnative/gdnative/pool_arrays.cpp create mode 100644 modules/gdnative/gdnative/quat.cpp create mode 100644 modules/gdnative/gdnative/rect2.cpp create mode 100644 modules/gdnative/gdnative/rect3.cpp create mode 100644 modules/gdnative/gdnative/rid.cpp create mode 100644 modules/gdnative/gdnative/string.cpp create mode 100644 modules/gdnative/gdnative/transform.cpp create mode 100644 modules/gdnative/gdnative/transform2d.cpp create mode 100644 modules/gdnative/gdnative/variant.cpp create mode 100644 modules/gdnative/gdnative/vector2.cpp create mode 100644 modules/gdnative/gdnative/vector3.cpp delete mode 100644 modules/gdnative/godot/array.cpp delete mode 100644 modules/gdnative/godot/array.h delete mode 100644 modules/gdnative/godot/basis.cpp delete mode 100644 modules/gdnative/godot/basis.h delete mode 100644 modules/gdnative/godot/color.cpp delete mode 100644 modules/gdnative/godot/color.h delete mode 100644 modules/gdnative/godot/dictionary.cpp delete mode 100644 modules/gdnative/godot/dictionary.h delete mode 100644 modules/gdnative/godot/gdnative.cpp delete mode 100644 modules/gdnative/godot/gdnative.h delete mode 100644 modules/gdnative/godot/icon.png.import delete mode 100644 modules/gdnative/godot/node_path.cpp delete mode 100644 modules/gdnative/godot/node_path.h delete mode 100644 modules/gdnative/godot/plane.cpp delete mode 100644 modules/gdnative/godot/plane.h delete mode 100644 modules/gdnative/godot/pool_arrays.cpp delete mode 100644 modules/gdnative/godot/pool_arrays.h delete mode 100644 modules/gdnative/godot/quat.cpp delete mode 100644 modules/gdnative/godot/quat.h delete mode 100644 modules/gdnative/godot/rect2.cpp delete mode 100644 modules/gdnative/godot/rect2.h delete mode 100644 modules/gdnative/godot/rect3.cpp delete mode 100644 modules/gdnative/godot/rect3.h delete mode 100644 modules/gdnative/godot/rid.cpp delete mode 100644 modules/gdnative/godot/rid.h delete mode 100644 modules/gdnative/godot/string.cpp delete mode 100644 modules/gdnative/godot/string.h delete mode 100644 modules/gdnative/godot/transform.cpp delete mode 100644 modules/gdnative/godot/transform.h delete mode 100644 modules/gdnative/godot/transform2d.cpp delete mode 100644 modules/gdnative/godot/transform2d.h delete mode 100644 modules/gdnative/godot/variant.cpp delete mode 100644 modules/gdnative/godot/variant.h delete mode 100644 modules/gdnative/godot/vector2.cpp delete mode 100644 modules/gdnative/godot/vector2.h delete mode 100644 modules/gdnative/godot/vector3.cpp delete mode 100644 modules/gdnative/godot/vector3.h create mode 100644 modules/gdnative/include/gdnative/array.h create mode 100644 modules/gdnative/include/gdnative/basis.h create mode 100644 modules/gdnative/include/gdnative/color.h create mode 100644 modules/gdnative/include/gdnative/dictionary.h create mode 100644 modules/gdnative/include/gdnative/gdnative.h create mode 100644 modules/gdnative/include/gdnative/node_path.h create mode 100644 modules/gdnative/include/gdnative/plane.h create mode 100644 modules/gdnative/include/gdnative/pool_arrays.h create mode 100644 modules/gdnative/include/gdnative/quat.h create mode 100644 modules/gdnative/include/gdnative/rect2.h create mode 100644 modules/gdnative/include/gdnative/rect3.h create mode 100644 modules/gdnative/include/gdnative/rid.h create mode 100644 modules/gdnative/include/gdnative/string.h create mode 100644 modules/gdnative/include/gdnative/transform.h create mode 100644 modules/gdnative/include/gdnative/transform2d.h create mode 100644 modules/gdnative/include/gdnative/variant.h create mode 100644 modules/gdnative/include/gdnative/vector2.h create mode 100644 modules/gdnative/include/gdnative/vector3.h create mode 100644 modules/gdnative/include/nativescript/godot_nativescript.h create mode 100644 modules/gdnative/nativescript/SCsub create mode 100644 modules/gdnative/nativescript/api_generator.cpp create mode 100644 modules/gdnative/nativescript/api_generator.h create mode 100644 modules/gdnative/nativescript/godot_nativescript.cpp create mode 100644 modules/gdnative/nativescript/nativescript.cpp create mode 100644 modules/gdnative/nativescript/nativescript.h create mode 100644 modules/gdnative/nativescript/register_types.cpp create mode 100644 modules/gdnative/nativescript/register_types.h delete mode 100644 modules/nativescript/SCsub delete mode 100644 modules/nativescript/api_generator.cpp delete mode 100644 modules/nativescript/api_generator.h delete mode 100644 modules/nativescript/config.py delete mode 100644 modules/nativescript/godot_nativescript.cpp delete mode 100644 modules/nativescript/godot_nativescript.h delete mode 100644 modules/nativescript/nativescript.cpp delete mode 100644 modules/nativescript/nativescript.h delete mode 100644 modules/nativescript/register_types.cpp delete mode 100644 modules/nativescript/register_types.h diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub index 65970d48c1..f386f2b542 100644 --- a/modules/gdnative/SCsub +++ b/modules/gdnative/SCsub @@ -2,12 +2,16 @@ Import('env') -env.add_source_files(env.modules_sources, "*.cpp") -env.add_source_files(env.modules_sources, "godot/*.cpp") +gdn_env = env.Clone() -env.Append(CPPFLAGS=['-DGDAPI_BUILT_IN']) -env.Append(CPPPATH=['#modules/gdnative/']) +gdn_env.add_source_files(env.modules_sources, "*.cpp") +gdn_env.add_source_files(env.modules_sources, "gdnative/*.cpp") +gdn_env.add_source_files(env.modules_sources, "nativescript/*.cpp") + +gdn_env.Append(CPPFLAGS=['-DGDAPI_BUILT_IN']) +gdn_env.Append(CPPPATH=['#modules/gdnative/include/']) if "platform" in env and env["platform"] == "x11": # there has to be a better solution? env.Append(LINKFLAGS=["-rdynamic"]) + env.use_ptrcall = True diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h index dc1c3507ec..38a480925b 100644 --- a/modules/gdnative/gdnative.h +++ b/modules/gdnative/gdnative.h @@ -35,7 +35,7 @@ #include "os/thread_safe.h" #include "resource.h" -#include +#include "gdnative/gdnative.h" class GDNativeLibrary : public Resource { GDCLASS(GDNativeLibrary, Resource) diff --git a/modules/gdnative/gdnative/array.cpp b/modules/gdnative/gdnative/array.cpp new file mode 100644 index 0000000000..51c023981f --- /dev/null +++ b/modules/gdnative/gdnative/array.cpp @@ -0,0 +1,309 @@ +/*************************************************************************/ +/* array.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/array.h" + +#include "core/array.h" +#include "core/os/memory.h" + +#include "core/color.h" +#include "core/dvector.h" + +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _array_api_anchor() { +} + +void GDAPI godot_array_new(godot_array *r_dest) { + Array *dest = (Array *)r_dest; + memnew_placement(dest, Array); +} + +void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src) { + Array *dest = (Array *)r_dest; + const Array *src = (const Array *)p_src; + memnew_placement(dest, Array(*src)); +} + +void GDAPI godot_array_new_pool_color_array(godot_array *r_dest, const godot_pool_color_array *p_pca) { + Array *dest = (Array *)r_dest; + PoolVector *pca = (PoolVector *)p_pca; + 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_pool_vector3_array(godot_array *r_dest, const godot_pool_vector3_array *p_pv3a) { + Array *dest = (Array *)r_dest; + PoolVector *pca = (PoolVector *)p_pv3a; + 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_pool_vector2_array(godot_array *r_dest, const godot_pool_vector2_array *p_pv2a) { + Array *dest = (Array *)r_dest; + PoolVector *pca = (PoolVector *)p_pv2a; + 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_pool_string_array(godot_array *r_dest, const godot_pool_string_array *p_psa) { + Array *dest = (Array *)r_dest; + PoolVector *pca = (PoolVector *)p_psa; + 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_pool_real_array(godot_array *r_dest, const godot_pool_real_array *p_pra) { + Array *dest = (Array *)r_dest; + PoolVector *pca = (PoolVector *)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_pool_int_array(godot_array *r_dest, const godot_pool_int_array *p_pia) { + Array *dest = (Array *)r_dest; + PoolVector *pca = (PoolVector *)p_pia; + 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_pool_byte_array(godot_array *r_dest, const godot_pool_byte_array *p_pba) { + Array *dest = (Array *)r_dest; + PoolVector *pca = (PoolVector *)p_pba; + 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_set(godot_array *p_self, const godot_int p_idx, const godot_variant *p_value) { + Array *self = (Array *)p_self; + Variant *val = (Variant *)p_value; + self->operator[](p_idx) = *val; +} + +godot_variant GDAPI godot_array_get(const godot_array *p_self, const godot_int p_idx) { + godot_variant raw_dest; + Variant *dest = (Variant *)&raw_dest; + const Array *self = (const Array *)p_self; + memnew_placement(dest, Variant(self->operator[](p_idx))); + return raw_dest; +} + +godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, const godot_int p_idx) { + Array *self = (Array *)p_self; + return (godot_variant *)&self->operator[](p_idx); +} + +void GDAPI godot_array_append(godot_array *p_self, const godot_variant *p_value) { + Array *self = (Array *)p_self; + Variant *val = (Variant *)p_value; + self->append(*val); +} + +void GDAPI godot_array_clear(godot_array *p_self) { + Array *self = (Array *)p_self; + self->clear(); +} + +godot_int GDAPI godot_array_count(const godot_array *p_self, const godot_variant *p_value) { + const Array *self = (const Array *)p_self; + const Variant *val = (const Variant *)p_value; + return self->count(*val); +} + +godot_bool GDAPI godot_array_empty(const godot_array *p_self) { + const Array *self = (const Array *)p_self; + return self->empty(); +} + +void GDAPI godot_array_erase(godot_array *p_self, const godot_variant *p_value) { + Array *self = (Array *)p_self; + const Variant *val = (const Variant *)p_value; + self->erase(*val); +} + +godot_variant GDAPI godot_array_front(const godot_array *p_self) { + const Array *self = (const Array *)p_self; + godot_variant v; + Variant *val = (Variant *)&v; + memnew_placement(val, Variant); + *val = self->front(); + return v; +} + +godot_variant GDAPI godot_array_back(const godot_array *p_self) { + const Array *self = (const Array *)p_self; + godot_variant v; + Variant *val = (Variant *)&v; + memnew_placement(val, Variant); + *val = self->back(); + return v; +} + +godot_int GDAPI godot_array_find(const godot_array *p_self, const godot_variant *p_what, const godot_int p_from) { + const Array *self = (const Array *)p_self; + const Variant *val = (const Variant *)p_what; + return self->find(*val, p_from); +} + +godot_int GDAPI godot_array_find_last(const godot_array *p_self, const godot_variant *p_what) { + const Array *self = (const Array *)p_self; + const Variant *val = (const Variant *)p_what; + return self->find_last(*val); +} + +godot_bool GDAPI godot_array_has(const godot_array *p_self, const godot_variant *p_value) { + const Array *self = (const Array *)p_self; + const Variant *val = (const Variant *)p_value; + return self->has(*val); +} + +godot_int GDAPI godot_array_hash(const godot_array *p_self) { + const Array *self = (const Array *)p_self; + return self->hash(); +} + +void GDAPI godot_array_insert(godot_array *p_self, const godot_int p_pos, const godot_variant *p_value) { + Array *self = (Array *)p_self; + const Variant *val = (const Variant *)p_value; + self->insert(p_pos, *val); +} + +void GDAPI godot_array_invert(godot_array *p_self) { + Array *self = (Array *)p_self; + self->invert(); +} + +godot_variant GDAPI godot_array_pop_back(godot_array *p_self) { + Array *self = (Array *)p_self; + godot_variant v; + Variant *val = (Variant *)&v; + memnew_placement(val, Variant); + *val = self->pop_back(); + return v; +} + +godot_variant GDAPI godot_array_pop_front(godot_array *p_self) { + Array *self = (Array *)p_self; + godot_variant v; + Variant *val = (Variant *)&v; + memnew_placement(val, Variant); + *val = self->pop_front(); + return v; +} + +void GDAPI godot_array_push_back(godot_array *p_self, const godot_variant *p_value) { + Array *self = (Array *)p_self; + const Variant *val = (const Variant *)p_value; + self->push_back(*val); +} + +void GDAPI godot_array_push_front(godot_array *p_self, const godot_variant *p_value) { + Array *self = (Array *)p_self; + const Variant *val = (const Variant *)p_value; + self->push_front(*val); +} + +void GDAPI godot_array_remove(godot_array *p_self, const godot_int p_idx) { + Array *self = (Array *)p_self; + self->remove(p_idx); +} + +void GDAPI godot_array_resize(godot_array *p_self, const godot_int p_size) { + Array *self = (Array *)p_self; + self->resize(p_size); +} + +godot_int GDAPI godot_array_rfind(const godot_array *p_self, const godot_variant *p_what, const godot_int p_from) { + const Array *self = (const Array *)p_self; + const Variant *val = (const Variant *)p_what; + return self->rfind(*val, p_from); +} + +godot_int GDAPI godot_array_size(const godot_array *p_self) { + const Array *self = (const Array *)p_self; + return self->size(); +} + +void GDAPI godot_array_sort(godot_array *p_self) { + Array *self = (Array *)p_self; + self->sort(); +} + +void GDAPI godot_array_sort_custom(godot_array *p_self, godot_object *p_obj, const godot_string *p_func) { + Array *self = (Array *)p_self; + const String *func = (const String *)p_func; + self->sort_custom((Object *)p_obj, *func); +} + +void GDAPI godot_array_destroy(godot_array *p_self) { + ((Array *)p_self)->~Array(); +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/basis.cpp b/modules/gdnative/gdnative/basis.cpp new file mode 100644 index 0000000000..b1327cdaef --- /dev/null +++ b/modules/gdnative/gdnative/basis.cpp @@ -0,0 +1,254 @@ +/*************************************************************************/ +/* basis.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/basis.h" + +#include "core/math/matrix3.h" +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _basis_api_anchor() {} + +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; + const Vector3 *z_axis = (const Vector3 *)p_z_axis; + Basis *dest = (Basis *)r_dest; + *dest = Basis(*x_axis, *y_axis, *z_axis); +} + +void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *r_dest, const godot_vector3 *p_axis, const godot_real p_phi) { + const Vector3 *axis = (const Vector3 *)p_axis; + Basis *dest = (Basis *)r_dest; + *dest = Basis(*axis, p_phi); +} + +void GDAPI godot_basis_new_with_euler(godot_basis *r_dest, const godot_vector3 *p_euler) { + const Vector3 *euler = (const Vector3 *)p_euler; + Basis *dest = (Basis *)r_dest; + *dest = Basis(*euler); +} + +godot_string GDAPI godot_basis_as_string(const godot_basis *p_self) { + godot_string ret; + const Basis *self = (const Basis *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_basis GDAPI godot_basis_inverse(const godot_basis *p_self) { + godot_basis dest; + const Basis *self = (const Basis *)p_self; + *((Basis *)&dest) = self->inverse(); + return dest; +} + +godot_basis GDAPI godot_basis_transposed(const godot_basis *p_self) { + godot_basis dest; + const Basis *self = (const Basis *)p_self; + *((Basis *)&dest) = self->transposed(); + return dest; +} + +godot_basis GDAPI godot_basis_orthonormalized(const godot_basis *p_self) { + godot_basis dest; + const Basis *self = (const Basis *)p_self; + *((Basis *)&dest) = self->orthonormalized(); + return dest; +} + +godot_real GDAPI godot_basis_determinant(const godot_basis *p_self) { + const Basis *self = (const Basis *)p_self; + return self->determinant(); +} + +godot_basis GDAPI godot_basis_rotated(const godot_basis *p_self, const godot_vector3 *p_axis, const godot_real p_phi) { + godot_basis dest; + const Basis *self = (const Basis *)p_self; + const Vector3 *axis = (const Vector3 *)p_axis; + *((Basis *)&dest) = self->rotated(*axis, p_phi); + return dest; +} + +godot_basis GDAPI godot_basis_scaled(const godot_basis *p_self, const godot_vector3 *p_scale) { + godot_basis dest; + const Basis *self = (const Basis *)p_self; + const Vector3 *scale = (const Vector3 *)p_scale; + *((Basis *)&dest) = self->scaled(*scale); + return dest; +} + +godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self) { + godot_vector3 dest; + const Basis *self = (const Basis *)p_self; + *((Vector3 *)&dest) = self->get_scale(); + return dest; +} + +godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_self) { + godot_vector3 dest; + const Basis *self = (const Basis *)p_self; + *((Vector3 *)&dest) = self->get_euler(); + return dest; +} + +godot_real GDAPI godot_basis_tdotx(const godot_basis *p_self, const godot_vector3 *p_with) { + const Basis *self = (const Basis *)p_self; + const Vector3 *with = (const Vector3 *)p_with; + return self->tdotx(*with); +} + +godot_real GDAPI godot_basis_tdoty(const godot_basis *p_self, const godot_vector3 *p_with) { + const Basis *self = (const Basis *)p_self; + const Vector3 *with = (const Vector3 *)p_with; + return self->tdoty(*with); +} + +godot_real GDAPI godot_basis_tdotz(const godot_basis *p_self, const godot_vector3 *p_with) { + const Basis *self = (const Basis *)p_self; + const Vector3 *with = (const Vector3 *)p_with; + return self->tdotz(*with); +} + +godot_vector3 GDAPI godot_basis_xform(const godot_basis *p_self, const godot_vector3 *p_v) { + godot_vector3 dest; + const Basis *self = (const Basis *)p_self; + const Vector3 *v = (const Vector3 *)p_v; + *((Vector3 *)&dest) = self->xform(*v); + return dest; +} + +godot_vector3 GDAPI godot_basis_xform_inv(const godot_basis *p_self, const godot_vector3 *p_v) { + godot_vector3 dest; + const Basis *self = (const Basis *)p_self; + const Vector3 *v = (const Vector3 *)p_v; + *((Vector3 *)&dest) = self->xform_inv(*v); + return dest; +} + +godot_int GDAPI godot_basis_get_orthogonal_index(const godot_basis *p_self) { + const Basis *self = (const Basis *)p_self; + return self->get_orthogonal_index(); +} + +void GDAPI godot_basis_new(godot_basis *r_dest) { + Basis *dest = (Basis *)r_dest; + *dest = Basis(); +} + +void GDAPI godot_basis_new_with_euler_quat(godot_basis *r_dest, const godot_quat *p_euler) { + Basis *dest = (Basis *)r_dest; + const Quat *euler = (const Quat *)p_euler; + *dest = Basis(*euler); +} + +// p_elements is a pointer to an array of 3 (!!) vector3 +void GDAPI godot_basis_get_elements(godot_basis *p_self, godot_vector3 *p_elements) { + const Basis *self = (const Basis *)p_self; + Vector3 *elements = (Vector3 *)p_elements; + elements[0] = self->elements[0]; + elements[1] = self->elements[1]; + elements[2] = self->elements[2]; +} + +godot_vector3 GDAPI godot_basis_get_axis(const godot_basis *p_self, const godot_int p_axis) { + godot_vector3 dest; + Vector3 *d = (Vector3 *)&dest; + const Basis *self = (const Basis *)p_self; + *d = self->get_axis(p_axis); + return dest; +} + +void GDAPI godot_basis_set_axis(godot_basis *p_self, const godot_int p_axis, const godot_vector3 *p_value) { + Basis *self = (Basis *)p_self; + const Vector3 *value = (const Vector3 *)p_value; + self->set_axis(p_axis, *value); +} + +godot_vector3 GDAPI godot_basis_get_row(const godot_basis *p_self, const godot_int p_row) { + godot_vector3 dest; + Vector3 *d = (Vector3 *)&dest; + const Basis *self = (const Basis *)p_self; + *d = self->get_row(p_row); + return dest; +} + +void GDAPI godot_basis_set_row(godot_basis *p_self, const godot_int p_row, const godot_vector3 *p_value) { + Basis *self = (Basis *)p_self; + const Vector3 *value = (const Vector3 *)p_value; + self->set_row(p_row, *value); +} + +godot_bool GDAPI godot_basis_operator_equal(const godot_basis *p_self, const godot_basis *p_b) { + const Basis *self = (const Basis *)p_self; + const Basis *b = (const Basis *)p_b; + return *self == *b; +} + +godot_basis GDAPI godot_basis_operator_add(const godot_basis *p_self, const godot_basis *p_b) { + godot_basis raw_dest; + Basis *dest = (Basis *)&raw_dest; + const Basis *self = (const Basis *)p_self; + const Basis *b = (const Basis *)p_b; + *dest = *self + *b; + return raw_dest; +} + +godot_basis GDAPI godot_basis_operator_substract(const godot_basis *p_self, const godot_basis *p_b) { + godot_basis raw_dest; + Basis *dest = (Basis *)&raw_dest; + const Basis *self = (const Basis *)p_self; + const Basis *b = (const Basis *)p_b; + *dest = *self - *b; + return raw_dest; +} + +godot_basis GDAPI godot_basis_operator_multiply_vector(const godot_basis *p_self, const godot_basis *p_b) { + godot_basis raw_dest; + Basis *dest = (Basis *)&raw_dest; + const Basis *self = (const Basis *)p_self; + const Basis *b = (const Basis *)p_b; + *dest = *self * *b; + return raw_dest; +} + +godot_basis GDAPI godot_basis_operator_multiply_scalar(const godot_basis *p_self, const godot_real p_b) { + godot_basis raw_dest; + Basis *dest = (Basis *)&raw_dest; + const Basis *self = (const Basis *)p_self; + *dest = *self * p_b; + return raw_dest; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/color.cpp b/modules/gdnative/gdnative/color.cpp new file mode 100644 index 0000000000..3f8912d896 --- /dev/null +++ b/modules/gdnative/gdnative/color.cpp @@ -0,0 +1,182 @@ +/*************************************************************************/ +/* color.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/color.h" + +#include "core/color.h" +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _color_api_anchor() {} + +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); +} + +void GDAPI godot_color_new_rgb(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b) { + + Color *dest = (Color *)r_dest; + *dest = Color(p_r, p_g, p_b); +} + +godot_real godot_color_get_r(const godot_color *p_self) { + const Color *self = (const Color *)p_self; + return self->r; +} + +void godot_color_set_r(godot_color *p_self, const godot_real val) { + Color *self = (Color *)p_self; + self->r = val; +} + +godot_real godot_color_get_g(const godot_color *p_self) { + const Color *self = (const Color *)p_self; + return self->g; +} + +void godot_color_set_g(godot_color *p_self, const godot_real val) { + Color *self = (Color *)p_self; + self->g = val; +} + +godot_real godot_color_get_b(const godot_color *p_self) { + const Color *self = (const Color *)p_self; + return self->b; +} + +void godot_color_set_b(godot_color *p_self, const godot_real val) { + Color *self = (Color *)p_self; + self->b = val; +} + +godot_real godot_color_get_a(const godot_color *p_self) { + const Color *self = (const Color *)p_self; + return self->a; +} + +void godot_color_set_a(godot_color *p_self, const godot_real val) { + Color *self = (Color *)p_self; + self->a = val; +} + +godot_real godot_color_get_h(const godot_color *p_self) { + const Color *self = (const Color *)p_self; + return self->get_h(); +} + +godot_real godot_color_get_s(const godot_color *p_self) { + const Color *self = (const Color *)p_self; + return self->get_s(); +} + +godot_real godot_color_get_v(const godot_color *p_self) { + const Color *self = (const Color *)p_self; + return self->get_v(); +} + +godot_string GDAPI godot_color_as_string(const godot_color *p_self) { + godot_string ret; + const Color *self = (const Color *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_int GDAPI godot_color_to_32(const godot_color *p_self) { + const Color *self = (const Color *)p_self; + return self->to_32(); +} + +godot_int GDAPI godot_color_to_ARGB32(const godot_color *p_self) { + const Color *self = (const Color *)p_self; + return self->to_ARGB32(); +} + +godot_real GDAPI godot_color_gray(const godot_color *p_self) { + const Color *self = (const Color *)p_self; + return self->gray(); +} + +godot_color GDAPI godot_color_inverted(const godot_color *p_self) { + godot_color dest; + const Color *self = (const Color *)p_self; + *((Color *)&dest) = self->inverted(); + return dest; +} + +godot_color GDAPI godot_color_contrasted(const godot_color *p_self) { + godot_color dest; + const Color *self = (const Color *)p_self; + *((Color *)&dest) = self->contrasted(); + return dest; +} + +godot_color GDAPI godot_color_linear_interpolate(const godot_color *p_self, const godot_color *p_b, const godot_real p_t) { + godot_color dest; + const Color *self = (const Color *)p_self; + const Color *b = (const Color *)p_b; + *((Color *)&dest) = self->linear_interpolate(*b, p_t); + return dest; +} + +godot_color GDAPI godot_color_blend(const godot_color *p_self, const godot_color *p_over) { + godot_color dest; + const Color *self = (const Color *)p_self; + const Color *over = (const Color *)p_over; + *((Color *)&dest) = self->blend(*over); + return dest; +} + +godot_string GDAPI godot_color_to_html(const godot_color *p_self, const godot_bool p_with_alpha) { + godot_string dest; + const Color *self = (const Color *)p_self; + + memnew_placement(&dest, String(self->to_html(p_with_alpha))); + return dest; +} + +godot_bool GDAPI godot_color_operator_equal(const godot_color *p_self, const godot_color *p_b) { + const Color *self = (const Color *)p_self; + const Color *b = (const Color *)p_b; + return *self == *b; +} + +godot_bool GDAPI godot_color_operator_less(const godot_color *p_self, const godot_color *p_b) { + const Color *self = (const Color *)p_self; + const Color *b = (const Color *)p_b; + return *self < *b; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/dictionary.cpp b/modules/gdnative/gdnative/dictionary.cpp new file mode 100644 index 0000000000..ed98cdbb00 --- /dev/null +++ b/modules/gdnative/gdnative/dictionary.cpp @@ -0,0 +1,155 @@ +/*************************************************************************/ +/* dictionary.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/dictionary.h" + +#include "core/variant.h" +// core/variant.h before to avoid compile errors with MSVC +#include "core/dictionary.h" +#include "core/io/json.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _dictionary_api_anchor() {} + +void GDAPI godot_dictionary_new(godot_dictionary *r_dest) { + Dictionary *dest = (Dictionary *)r_dest; + memnew_placement(dest, Dictionary); +} + +void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src) { + Dictionary *dest = (Dictionary *)r_dest; + const Dictionary *src = (const Dictionary *)p_src; + memnew_placement(dest, Dictionary(*src)); +} + +void GDAPI godot_dictionary_destroy(godot_dictionary *p_self) { + Dictionary *self = (Dictionary *)p_self; + self->~Dictionary(); +} + +godot_int GDAPI godot_dictionary_size(const godot_dictionary *p_self) { + const Dictionary *self = (const Dictionary *)p_self; + return self->size(); +} + +godot_bool GDAPI godot_dictionary_empty(const godot_dictionary *p_self) { + const Dictionary *self = (const Dictionary *)p_self; + return self->empty(); +} + +void GDAPI godot_dictionary_clear(godot_dictionary *p_self) { + Dictionary *self = (Dictionary *)p_self; + self->clear(); +} + +godot_bool GDAPI godot_dictionary_has(const godot_dictionary *p_self, const godot_variant *p_key) { + const Dictionary *self = (const Dictionary *)p_self; + const Variant *key = (const Variant *)p_key; + return self->has(*key); +} + +godot_bool GDAPI godot_dictionary_has_all(const godot_dictionary *p_self, const godot_array *p_keys) { + const Dictionary *self = (const Dictionary *)p_self; + const Array *keys = (const Array *)p_keys; + return self->has_all(*keys); +} + +void GDAPI godot_dictionary_erase(godot_dictionary *p_self, const godot_variant *p_key) { + Dictionary *self = (Dictionary *)p_self; + const Variant *key = (const Variant *)p_key; + self->erase(*key); +} + +godot_int GDAPI godot_dictionary_hash(const godot_dictionary *p_self) { + const Dictionary *self = (const Dictionary *)p_self; + return self->hash(); +} + +godot_array GDAPI godot_dictionary_keys(const godot_dictionary *p_self) { + godot_array dest; + const Dictionary *self = (const Dictionary *)p_self; + memnew_placement(&dest, Array(self->keys())); + return dest; +} + +godot_array GDAPI godot_dictionary_values(const godot_dictionary *p_self) { + godot_array dest; + const Dictionary *self = (const Dictionary *)p_self; + memnew_placement(&dest, Array(self->values())); + return dest; +} + +godot_variant GDAPI godot_dictionary_get(const godot_dictionary *p_self, const godot_variant *p_key) { + godot_variant raw_dest; + Variant *dest = (Variant *)&raw_dest; + const Dictionary *self = (const Dictionary *)p_self; + const Variant *key = (const Variant *)p_key; + memnew_placement(dest, Variant(self->operator[](*key))); + return raw_dest; +} + +void GDAPI godot_dictionary_set(godot_dictionary *p_self, const godot_variant *p_key, const godot_variant *p_value) { + Dictionary *self = (Dictionary *)p_self; + const Variant *key = (const Variant *)p_key; + const Variant *value = (const Variant *)p_value; + self->operator[](*key) = *value; +} + +godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key) { + Dictionary *self = (Dictionary *)p_self; + const Variant *key = (const Variant *)p_key; + return (godot_variant *)&self->operator[](*key); +} + +godot_variant GDAPI *godot_dictionary_next(const godot_dictionary *p_self, const godot_variant *p_key) { + Dictionary *self = (Dictionary *)p_self; + const Variant *key = (const Variant *)p_key; + return (godot_variant *)self->next(key); +} + +godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self, const godot_dictionary *p_b) { + const Dictionary *self = (const Dictionary *)p_self; + const Dictionary *b = (const Dictionary *)p_b; + return *self == *b; +} + +godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self) { + godot_string raw_dest; + String *dest = (String *)&raw_dest; + const Dictionary *self = (const Dictionary *)p_self; + memnew_placement(dest, String(JSON::print(Variant(*self)))); + return raw_dest; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp new file mode 100644 index 0000000000..cf1f6a4f16 --- /dev/null +++ b/modules/gdnative/gdnative/gdnative.cpp @@ -0,0 +1,189 @@ +/*************************************************************************/ +/* gdnative.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/gdnative.h" + +#include "class_db.h" +#include "error_macros.h" +#include "global_constants.h" +#include "os/os.h" +#include "project_settings.h" +#include "variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern "C" void _string_api_anchor(); +extern "C" void _vector2_api_anchor(); +extern "C" void _rect2_api_anchor(); +extern "C" void _vector3_api_anchor(); +extern "C" void _transform2d_api_anchor(); +extern "C" void _plane_api_anchor(); +extern "C" void _quat_api_anchor(); +extern "C" void _basis_api_anchor(); +extern "C" void _rect3_api_anchor(); +extern "C" void _transform_api_anchor(); +extern "C" void _color_api_anchor(); +extern "C" void _node_path_api_anchor(); +extern "C" void _rid_api_anchor(); +extern "C" void _dictionary_api_anchor(); +extern "C" void _array_api_anchor(); +extern "C" void _pool_arrays_api_anchor(); +extern "C" void _variant_api_anchor(); + +void _api_anchor() { + + _string_api_anchor(); + _vector2_api_anchor(); + _rect2_api_anchor(); + _vector3_api_anchor(); + _transform2d_api_anchor(); + _plane_api_anchor(); + _quat_api_anchor(); + _rect3_api_anchor(); + _basis_api_anchor(); + _transform_api_anchor(); + _color_api_anchor(); + _node_path_api_anchor(); + _rid_api_anchor(); + _dictionary_api_anchor(); + _array_api_anchor(); + _pool_arrays_api_anchor(); + _variant_api_anchor(); +} + +void GDAPI godot_object_destroy(godot_object *p_o) { + memdelete((Object *)p_o); +} + +// Singleton API + +godot_object GDAPI *godot_global_get_singleton(char *p_name) { + return (godot_object *)ProjectSettings::get_singleton()->get_singleton_object(String(p_name)); +} // result shouldn't be freed + +void GDAPI *godot_get_stack_bottom() { + return OS::get_singleton()->get_stack_bottom(); +} + +// MethodBind API + +godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname) { + + MethodBind *mb = ClassDB::get_method(StringName(p_classname), StringName(p_methodname)); + // MethodBind *mb = ClassDB::get_method("Node", "get_name"); + return (godot_method_bind *)mb; +} + +void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_object *p_instance, const void **p_args, void *p_ret) { + + MethodBind *mb = (MethodBind *)p_method_bind; + Object *o = (Object *)p_instance; + mb->ptrcall(o, p_args, p_ret); +} + +godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, godot_object *p_instance, const godot_variant **p_args, const int p_arg_count, godot_variant_call_error *p_call_error) { + MethodBind *mb = (MethodBind *)p_method_bind; + Object *o = (Object *)p_instance; + const Variant **args = (const Variant **)p_args; + + godot_variant ret; + godot_variant_new_nil(&ret); + + Variant *ret_val = (Variant *)&ret; + + Variant::CallError r_error; + *ret_val = mb->call(o, args, p_arg_count, r_error); + + if (p_call_error) { + p_call_error->error = (godot_variant_call_error_error)r_error.error; + p_call_error->argument = r_error.argument; + p_call_error->expected = (godot_variant_type)r_error.expected; + } + + return ret; +} + +// @Todo +/* +void GDAPI godot_method_bind_varcall(godot_method_bind *p_method_bind) +{ + +} +*/ + +godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname) { + ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname)); + if (class_info) + return (godot_class_constructor)class_info->creation_func; + return NULL; +} + +godot_dictionary GDAPI godot_get_global_constants() { + godot_dictionary constants; + godot_dictionary_new(&constants); + Dictionary *p_constants = (Dictionary *)&constants; + const int constants_count = GlobalConstants::get_global_constant_count(); + for (int i = 0; i < constants_count; ++i) { + const char *name = GlobalConstants::get_global_constant_name(i); + int value = GlobalConstants::get_global_constant_value(i); + (*p_constants)[name] = value; + } + return constants; +} + +// System functions +void GDAPI *godot_alloc(int p_bytes) { + return memalloc(p_bytes); +} + +void GDAPI *godot_realloc(void *p_ptr, int p_bytes) { + return memrealloc(p_ptr, p_bytes); +} + +void GDAPI godot_free(void *p_ptr) { + memfree(p_ptr); +} + +void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line) { + _err_print_error(p_function, p_file, p_line, p_description, ERR_HANDLER_ERROR); +} + +void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line) { + _err_print_error(p_function, p_file, p_line, p_description, ERR_HANDLER_WARNING); +} + +void GDAPI godot_print(const godot_string *p_message) { + print_line(*(String *)p_message); +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/node_path.cpp b/modules/gdnative/gdnative/node_path.cpp new file mode 100644 index 0000000000..50fade5b94 --- /dev/null +++ b/modules/gdnative/gdnative/node_path.cpp @@ -0,0 +1,116 @@ +/*************************************************************************/ +/* node_path.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/node_path.h" + +#include "core/node_path.h" +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _node_path_api_anchor() {} + +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; + memnew_placement(dest, NodePath(*from)); +} + +void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src) { + NodePath *dest = (NodePath *)r_dest; + const NodePath *src = (const NodePath *)p_src; + memnew_placement(dest, NodePath(*src)); +} + +void GDAPI godot_node_path_destroy(godot_node_path *p_self) { + NodePath *self = (NodePath *)p_self; + self->~NodePath(); +} + +godot_string GDAPI godot_node_path_as_string(const godot_node_path *p_self) { + godot_string ret; + const NodePath *self = (const NodePath *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_bool GDAPI godot_node_path_is_absolute(const godot_node_path *p_self) { + const NodePath *self = (const NodePath *)p_self; + return self->is_absolute(); +} + +godot_int GDAPI godot_node_path_get_name_count(const godot_node_path *p_self) { + const NodePath *self = (const NodePath *)p_self; + return self->get_name_count(); +} + +godot_string GDAPI godot_node_path_get_name(const godot_node_path *p_self, const godot_int p_idx) { + godot_string dest; + const NodePath *self = (const NodePath *)p_self; + + memnew_placement(&dest, String(self->get_name(p_idx))); + return dest; +} + +godot_int GDAPI godot_node_path_get_subname_count(const godot_node_path *p_self) { + const NodePath *self = (const NodePath *)p_self; + return self->get_subname_count(); +} + +godot_string GDAPI godot_node_path_get_subname(const godot_node_path *p_self, const godot_int p_idx) { + godot_string dest; + const NodePath *self = (const NodePath *)p_self; + + memnew_placement(&dest, String(self->get_subname(p_idx))); + return dest; +} + +godot_string GDAPI godot_node_path_get_property(const godot_node_path *p_self) { + godot_string dest; + const NodePath *self = (const NodePath *)p_self; + memnew_placement(&dest, String(self->get_property())); + return dest; +} + +godot_bool GDAPI godot_node_path_is_empty(const godot_node_path *p_self) { + const NodePath *self = (const NodePath *)p_self; + return self->is_empty(); +} + +godot_bool GDAPI godot_node_path_operator_equal(const godot_node_path *p_self, const godot_node_path *p_b) { + const NodePath *self = (const NodePath *)p_self; + const NodePath *b = (const NodePath *)p_b; + return *self == *b; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/plane.cpp b/modules/gdnative/gdnative/plane.cpp new file mode 100644 index 0000000000..a5e05ffa6b --- /dev/null +++ b/modules/gdnative/gdnative/plane.cpp @@ -0,0 +1,178 @@ +/*************************************************************************/ +/* plane.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/plane.h" + +#include "core/math/plane.h" +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _plane_api_anchor() {} + +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); +} + +void GDAPI godot_plane_new_with_vectors(godot_plane *r_dest, const godot_vector3 *p_v1, const godot_vector3 *p_v2, const godot_vector3 *p_v3) { + const Vector3 *v1 = (const Vector3 *)p_v1; + const Vector3 *v2 = (const Vector3 *)p_v2; + const Vector3 *v3 = (const Vector3 *)p_v3; + Plane *dest = (Plane *)r_dest; + *dest = Plane(*v1, *v2, *v3); +} + +void GDAPI godot_plane_new_with_normal(godot_plane *r_dest, const godot_vector3 *p_normal, const godot_real p_d) { + const Vector3 *normal = (const Vector3 *)p_normal; + Plane *dest = (Plane *)r_dest; + *dest = Plane(*normal, p_d); +} + +godot_string GDAPI godot_plane_as_string(const godot_plane *p_self) { + godot_string ret; + const Plane *self = (const Plane *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_plane GDAPI godot_plane_normalized(const godot_plane *p_self) { + godot_plane dest; + const Plane *self = (const Plane *)p_self; + *((Plane *)&dest) = self->normalized(); + return dest; +} + +godot_vector3 GDAPI godot_plane_center(const godot_plane *p_self) { + godot_vector3 dest; + const Plane *self = (const Plane *)p_self; + *((Vector3 *)&dest) = self->center(); + return dest; +} + +godot_vector3 GDAPI godot_plane_get_any_point(const godot_plane *p_self) { + godot_vector3 dest; + const Plane *self = (const Plane *)p_self; + *((Vector3 *)&dest) = self->get_any_point(); + return dest; +} + +godot_bool GDAPI godot_plane_is_point_over(const godot_plane *p_self, const godot_vector3 *p_point) { + const Plane *self = (const Plane *)p_self; + const Vector3 *point = (const Vector3 *)p_point; + return self->is_point_over(*point); +} + +godot_real GDAPI godot_plane_distance_to(const godot_plane *p_self, const godot_vector3 *p_point) { + const Plane *self = (const Plane *)p_self; + const Vector3 *point = (const Vector3 *)p_point; + return self->distance_to(*point); +} + +godot_bool GDAPI godot_plane_has_point(const godot_plane *p_self, const godot_vector3 *p_point, const godot_real p_epsilon) { + const Plane *self = (const Plane *)p_self; + const Vector3 *point = (const Vector3 *)p_point; + return self->has_point(*point, p_epsilon); +} + +godot_vector3 GDAPI godot_plane_project(const godot_plane *p_self, const godot_vector3 *p_point) { + godot_vector3 dest; + const Plane *self = (const Plane *)p_self; + const Vector3 *point = (const Vector3 *)p_point; + *((Vector3 *)&dest) = self->project(*point); + return dest; +} + +godot_bool GDAPI godot_plane_intersect_3(const godot_plane *p_self, godot_vector3 *r_dest, const godot_plane *p_b, const godot_plane *p_c) { + const Plane *self = (const Plane *)p_self; + const Plane *b = (const Plane *)p_b; + const Plane *c = (const Plane *)p_c; + Vector3 *dest = (Vector3 *)r_dest; + return self->intersect_3(*b, *c, dest); +} + +godot_bool GDAPI godot_plane_intersects_ray(const godot_plane *p_self, godot_vector3 *r_dest, const godot_vector3 *p_from, const godot_vector3 *p_dir) { + const Plane *self = (const Plane *)p_self; + const Vector3 *from = (const Vector3 *)p_from; + const Vector3 *dir = (const Vector3 *)p_dir; + Vector3 *dest = (Vector3 *)r_dest; + return self->intersects_ray(*from, *dir, dest); +} + +godot_bool GDAPI godot_plane_intersects_segment(const godot_plane *p_self, godot_vector3 *r_dest, const godot_vector3 *p_begin, const godot_vector3 *p_end) { + const Plane *self = (const Plane *)p_self; + const Vector3 *begin = (const Vector3 *)p_begin; + const Vector3 *end = (const Vector3 *)p_end; + Vector3 *dest = (Vector3 *)r_dest; + return self->intersects_segment(*begin, *end, dest); +} + +godot_plane GDAPI godot_plane_operator_neg(const godot_plane *p_self) { + godot_plane raw_dest; + Plane *dest = (Plane *)&raw_dest; + const Plane *self = (const Plane *)p_self; + *dest = -(*self); + return raw_dest; +} + +godot_bool GDAPI godot_plane_operator_equal(const godot_plane *p_self, const godot_plane *p_b) { + const Plane *self = (const Plane *)p_self; + const Plane *b = (const Plane *)p_b; + return *self == *b; +} + +void GDAPI godot_plane_set_normal(godot_plane *p_self, const godot_vector3 *p_normal) { + Plane *self = (Plane *)p_self; + const Vector3 *normal = (const Vector3 *)p_normal; + self->set_normal(*normal); +} + +godot_vector3 GDAPI godot_plane_get_normal(const godot_plane *p_self) { + const Plane *self = (const Plane *)p_self; + const Vector3 normal = self->get_normal(); + godot_vector3 *v3 = (godot_vector3 *)&normal; + return *v3; +} + +godot_real GDAPI godot_plane_get_d(const godot_plane *p_self) { + const Plane *self = (const Plane *)p_self; + return self->d; +} + +void GDAPI godot_plane_set_d(godot_plane *p_self, const godot_real p_d) { + Plane *self = (Plane *)p_self; + self->d = p_d; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/pool_arrays.cpp b/modules/gdnative/gdnative/pool_arrays.cpp new file mode 100644 index 0000000000..1393374da2 --- /dev/null +++ b/modules/gdnative/gdnative/pool_arrays.cpp @@ -0,0 +1,633 @@ +/*************************************************************************/ +/* pool_arrays.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/pool_arrays.h" + +#include "array.h" +#include "core/variant.h" +#include "dvector.h" + +#include "core/color.h" +#include "core/math/math_2d.h" +#include "core/math/vector3.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _pool_arrays_api_anchor() { +} + +#define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr) + +// byte + +void GDAPI godot_pool_byte_array_new(godot_pool_byte_array *r_dest) { + PoolVector *dest = (PoolVector *)r_dest; + memnew_placement(dest, PoolVector); +} + +void GDAPI godot_pool_byte_array_new_copy(godot_pool_byte_array *r_dest, const godot_pool_byte_array *p_src) { + PoolVector *dest = (PoolVector *)r_dest; + const PoolVector *src = (const PoolVector *)p_src; + memnew_placement(dest, PoolVector(*src)); +} + +void GDAPI godot_pool_byte_array_new_with_array(godot_pool_byte_array *r_dest, const godot_array *p_a) { + PoolVector *dest = (PoolVector *)r_dest; + Array *a = (Array *)p_a; + memnew_placement(dest, PoolVector); + + dest->resize(a->size()); + for (int i = 0; i < a->size(); i++) { + dest->set(i, (*a)[i]); + } +} + +void GDAPI godot_pool_byte_array_append(godot_pool_byte_array *p_self, const uint8_t p_data) { + PoolVector *self = (PoolVector *)p_self; + self->append(p_data); +} + +void GDAPI godot_pool_byte_array_append_array(godot_pool_byte_array *p_self, const godot_pool_byte_array *p_array) { + PoolVector *self = (PoolVector *)p_self; + PoolVector *array = (PoolVector *)p_array; + self->append_array(*array); +} + +godot_error GDAPI godot_pool_byte_array_insert(godot_pool_byte_array *p_self, const godot_int p_idx, const uint8_t p_data) { + PoolVector *self = (PoolVector *)p_self; + return (godot_error)self->insert(p_idx, p_data); +} + +void GDAPI godot_pool_byte_array_invert(godot_pool_byte_array *p_self) { + PoolVector *self = (PoolVector *)p_self; + self->invert(); +} + +void GDAPI godot_pool_byte_array_push_back(godot_pool_byte_array *p_self, const uint8_t p_data) { + PoolVector *self = (PoolVector *)p_self; + self->push_back(p_data); +} + +void GDAPI godot_pool_byte_array_remove(godot_pool_byte_array *p_self, const godot_int p_idx) { + PoolVector *self = (PoolVector *)p_self; + self->remove(p_idx); +} + +void GDAPI godot_pool_byte_array_resize(godot_pool_byte_array *p_self, const godot_int p_size) { + PoolVector *self = (PoolVector *)p_self; + self->resize(p_size); +} + +void GDAPI godot_pool_byte_array_set(godot_pool_byte_array *p_self, const godot_int p_idx, const uint8_t p_data) { + PoolVector *self = (PoolVector *)p_self; + self->set(p_idx, p_data); +} + +uint8_t GDAPI godot_pool_byte_array_get(const godot_pool_byte_array *p_self, const godot_int p_idx) { + const PoolVector *self = (const PoolVector *)p_self; + return self->get(p_idx); +} + +godot_int GDAPI godot_pool_byte_array_size(const godot_pool_byte_array *p_self) { + const PoolVector *self = (const PoolVector *)p_self; + return self->size(); +} + +void GDAPI godot_pool_byte_array_destroy(godot_pool_byte_array *p_self) { + ((PoolVector *)p_self)->~PoolVector(); +} + +// int + +void GDAPI godot_pool_int_array_new(godot_pool_int_array *r_dest) { + PoolVector *dest = (PoolVector *)r_dest; + memnew_placement(dest, PoolVector); +} + +void GDAPI godot_pool_int_array_new_copy(godot_pool_int_array *r_dest, const godot_pool_int_array *p_src) { + PoolVector *dest = (PoolVector *)r_dest; + const PoolVector *src = (const PoolVector *)p_src; + memnew_placement(dest, PoolVector(*src)); +} + +void GDAPI godot_pool_int_array_new_with_array(godot_pool_int_array *r_dest, const godot_array *p_a) { + PoolVector *dest = (PoolVector *)r_dest; + Array *a = (Array *)p_a; + memnew_placement(dest, PoolVector); + + dest->resize(a->size()); + for (int i = 0; i < a->size(); i++) { + dest->set(i, (*a)[i]); + } +} + +void GDAPI godot_pool_int_array_append(godot_pool_int_array *p_self, const godot_int p_data) { + PoolVector *self = (PoolVector *)p_self; + self->append(p_data); +} + +void GDAPI godot_pool_int_array_append_array(godot_pool_int_array *p_self, const godot_pool_int_array *p_array) { + PoolVector *self = (PoolVector *)p_self; + PoolVector *array = (PoolVector *)p_array; + self->append_array(*array); +} + +godot_error GDAPI godot_pool_int_array_insert(godot_pool_int_array *p_self, const godot_int p_idx, const godot_int p_data) { + PoolVector *self = (PoolVector *)p_self; + return (godot_error)self->insert(p_idx, p_data); +} + +void GDAPI godot_pool_int_array_invert(godot_pool_int_array *p_self) { + PoolVector *self = (PoolVector *)p_self; + self->invert(); +} + +void GDAPI godot_pool_int_array_push_back(godot_pool_int_array *p_self, const godot_int p_data) { + PoolVector *self = (PoolVector *)p_self; + self->push_back(p_data); +} + +void GDAPI godot_pool_int_array_remove(godot_pool_int_array *p_self, const godot_int p_idx) { + PoolVector *self = (PoolVector *)p_self; + self->remove(p_idx); +} + +void GDAPI godot_pool_int_array_resize(godot_pool_int_array *p_self, const godot_int p_size) { + PoolVector *self = (PoolVector *)p_self; + self->resize(p_size); +} + +void GDAPI godot_pool_int_array_set(godot_pool_int_array *p_self, const godot_int p_idx, const godot_int p_data) { + PoolVector *self = (PoolVector *)p_self; + self->set(p_idx, p_data); +} + +godot_int GDAPI godot_pool_int_array_get(const godot_pool_int_array *p_self, const godot_int p_idx) { + const PoolVector *self = (const PoolVector *)p_self; + return self->get(p_idx); +} + +godot_int GDAPI godot_pool_int_array_size(const godot_pool_int_array *p_self) { + const PoolVector *self = (const PoolVector *)p_self; + return self->size(); +} + +void GDAPI godot_pool_int_array_destroy(godot_pool_int_array *p_self) { + ((PoolVector *)p_self)->~PoolVector(); +} + +// real + +void GDAPI godot_pool_real_array_new(godot_pool_real_array *r_dest) { + PoolVector *dest = (PoolVector *)r_dest; + memnew_placement(dest, PoolVector); +} + +void GDAPI godot_pool_real_array_new_copy(godot_pool_real_array *r_dest, const godot_pool_real_array *p_src) { + PoolVector *dest = (PoolVector *)r_dest; + const PoolVector *src = (const PoolVector *)p_src; + memnew_placement(dest, PoolVector(*src)); +} + +void GDAPI godot_pool_real_array_new_with_array(godot_pool_real_array *r_dest, const godot_array *p_a) { + PoolVector *dest = (PoolVector *)r_dest; + Array *a = (Array *)p_a; + memnew_placement(dest, PoolVector); + + dest->resize(a->size()); + for (int i = 0; i < a->size(); i++) { + dest->set(i, (*a)[i]); + } +} + +void GDAPI godot_pool_real_array_append(godot_pool_real_array *p_self, const godot_real p_data) { + PoolVector *self = (PoolVector *)p_self; + self->append(p_data); +} + +void GDAPI godot_pool_real_array_append_array(godot_pool_real_array *p_self, const godot_pool_real_array *p_array) { + PoolVector *self = (PoolVector *)p_self; + PoolVector *array = (PoolVector *)p_array; + self->append_array(*array); +} + +godot_error GDAPI godot_pool_real_array_insert(godot_pool_real_array *p_self, const godot_int p_idx, const godot_real p_data) { + PoolVector *self = (PoolVector *)p_self; + return (godot_error)self->insert(p_idx, p_data); +} + +void GDAPI godot_pool_real_array_invert(godot_pool_real_array *p_self) { + PoolVector *self = (PoolVector *)p_self; + self->invert(); +} + +void GDAPI godot_pool_real_array_push_back(godot_pool_real_array *p_self, const godot_real p_data) { + PoolVector *self = (PoolVector *)p_self; + self->push_back(p_data); +} + +void GDAPI godot_pool_real_array_remove(godot_pool_real_array *p_self, const godot_int p_idx) { + PoolVector *self = (PoolVector *)p_self; + self->remove(p_idx); +} + +void GDAPI godot_pool_real_array_resize(godot_pool_real_array *p_self, const godot_int p_size) { + PoolVector *self = (PoolVector *)p_self; + self->resize(p_size); +} + +void GDAPI godot_pool_real_array_set(godot_pool_real_array *p_self, const godot_int p_idx, const godot_real p_data) { + PoolVector *self = (PoolVector *)p_self; + self->set(p_idx, p_data); +} + +godot_real GDAPI godot_pool_real_array_get(const godot_pool_real_array *p_self, const godot_int p_idx) { + const PoolVector *self = (const PoolVector *)p_self; + return self->get(p_idx); +} + +godot_int GDAPI godot_pool_real_array_size(const godot_pool_real_array *p_self) { + const PoolVector *self = (const PoolVector *)p_self; + return self->size(); +} + +void GDAPI godot_pool_real_array_destroy(godot_pool_real_array *p_self) { + ((PoolVector *)p_self)->~PoolVector(); +} + +// string + +void GDAPI godot_pool_string_array_new(godot_pool_string_array *r_dest) { + PoolVector *dest = (PoolVector *)r_dest; + memnew_placement(dest, PoolVector); +} + +void GDAPI godot_pool_string_array_new_copy(godot_pool_string_array *r_dest, const godot_pool_string_array *p_src) { + PoolVector *dest = (PoolVector *)r_dest; + const PoolVector *src = (const PoolVector *)p_src; + memnew_placement(dest, PoolVector(*src)); +} + +void GDAPI godot_pool_string_array_new_with_array(godot_pool_string_array *r_dest, const godot_array *p_a) { + PoolVector *dest = (PoolVector *)r_dest; + Array *a = (Array *)p_a; + memnew_placement(dest, PoolVector); + + dest->resize(a->size()); + for (int i = 0; i < a->size(); i++) { + dest->set(i, (*a)[i]); + } +} + +void GDAPI godot_pool_string_array_append(godot_pool_string_array *p_self, const godot_string *p_data) { + PoolVector *self = (PoolVector *)p_self; + String &s = *(String *)p_data; + self->append(s); +} + +void GDAPI godot_pool_string_array_append_array(godot_pool_string_array *p_self, const godot_pool_string_array *p_array) { + PoolVector *self = (PoolVector *)p_self; + PoolVector *array = (PoolVector *)p_array; + self->append_array(*array); +} + +godot_error GDAPI godot_pool_string_array_insert(godot_pool_string_array *p_self, const godot_int p_idx, const godot_string *p_data) { + PoolVector *self = (PoolVector *)p_self; + String &s = *(String *)p_data; + return (godot_error)self->insert(p_idx, s); +} + +void GDAPI godot_pool_string_array_invert(godot_pool_string_array *p_self) { + PoolVector *self = (PoolVector *)p_self; + self->invert(); +} + +void GDAPI godot_pool_string_array_push_back(godot_pool_string_array *p_self, const godot_string *p_data) { + PoolVector *self = (PoolVector *)p_self; + String &s = *(String *)p_data; + self->push_back(s); +} + +void GDAPI godot_pool_string_array_remove(godot_pool_string_array *p_self, const godot_int p_idx) { + PoolVector *self = (PoolVector *)p_self; + self->remove(p_idx); +} + +void GDAPI godot_pool_string_array_resize(godot_pool_string_array *p_self, const godot_int p_size) { + PoolVector *self = (PoolVector *)p_self; + self->resize(p_size); +} + +void GDAPI godot_pool_string_array_set(godot_pool_string_array *p_self, const godot_int p_idx, const godot_string *p_data) { + PoolVector *self = (PoolVector *)p_self; + String &s = *(String *)p_data; + self->set(p_idx, s); +} + +godot_string GDAPI godot_pool_string_array_get(const godot_pool_string_array *p_self, const godot_int p_idx) { + const PoolVector *self = (const PoolVector *)p_self; + godot_string str; + String *s = (String *)&str; + memnew_placement(s, String); + *s = self->get(p_idx); + return str; +} + +godot_int GDAPI godot_pool_string_array_size(const godot_pool_string_array *p_self) { + const PoolVector *self = (const PoolVector *)p_self; + return self->size(); +} + +void GDAPI godot_pool_string_array_destroy(godot_pool_string_array *p_self) { + ((PoolVector *)p_self)->~PoolVector(); +} + +// vector2 + +void GDAPI godot_pool_vector2_array_new(godot_pool_vector2_array *r_dest) { + PoolVector *dest = (PoolVector *)r_dest; + memnew_placement(dest, PoolVector); +} + +void GDAPI godot_pool_vector2_array_new_copy(godot_pool_vector2_array *r_dest, const godot_pool_vector2_array *p_src) { + PoolVector *dest = (PoolVector *)r_dest; + const PoolVector *src = (const PoolVector *)p_src; + memnew_placement(dest, PoolVector(*src)); +} + +void GDAPI godot_pool_vector2_array_new_with_array(godot_pool_vector2_array *r_dest, const godot_array *p_a) { + PoolVector *dest = (PoolVector *)r_dest; + Array *a = (Array *)p_a; + memnew_placement(dest, PoolVector); + + dest->resize(a->size()); + for (int i = 0; i < a->size(); i++) { + dest->set(i, (*a)[i]); + } +} + +void GDAPI godot_pool_vector2_array_append(godot_pool_vector2_array *p_self, const godot_vector2 *p_data) { + PoolVector *self = (PoolVector *)p_self; + Vector2 &s = *(Vector2 *)p_data; + self->append(s); +} + +void GDAPI godot_pool_vector2_array_append_array(godot_pool_vector2_array *p_self, const godot_pool_vector2_array *p_array) { + PoolVector *self = (PoolVector *)p_self; + PoolVector *array = (PoolVector *)p_array; + self->append_array(*array); +} + +godot_error GDAPI godot_pool_vector2_array_insert(godot_pool_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data) { + PoolVector *self = (PoolVector *)p_self; + Vector2 &s = *(Vector2 *)p_data; + return (godot_error)self->insert(p_idx, s); +} + +void GDAPI godot_pool_vector2_array_invert(godot_pool_vector2_array *p_self) { + PoolVector *self = (PoolVector *)p_self; + self->invert(); +} + +void GDAPI godot_pool_vector2_array_push_back(godot_pool_vector2_array *p_self, const godot_vector2 *p_data) { + PoolVector *self = (PoolVector *)p_self; + Vector2 &s = *(Vector2 *)p_data; + self->push_back(s); +} + +void GDAPI godot_pool_vector2_array_remove(godot_pool_vector2_array *p_self, const godot_int p_idx) { + PoolVector *self = (PoolVector *)p_self; + self->remove(p_idx); +} + +void GDAPI godot_pool_vector2_array_resize(godot_pool_vector2_array *p_self, const godot_int p_size) { + PoolVector *self = (PoolVector *)p_self; + self->resize(p_size); +} + +void GDAPI godot_pool_vector2_array_set(godot_pool_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data) { + PoolVector *self = (PoolVector *)p_self; + Vector2 &s = *(Vector2 *)p_data; + self->set(p_idx, s); +} + +godot_vector2 GDAPI godot_pool_vector2_array_get(const godot_pool_vector2_array *p_self, const godot_int p_idx) { + const PoolVector *self = (const PoolVector *)p_self; + godot_vector2 v; + Vector2 *s = (Vector2 *)&v; + *s = self->get(p_idx); + return v; +} + +godot_int GDAPI godot_pool_vector2_array_size(const godot_pool_vector2_array *p_self) { + const PoolVector *self = (const PoolVector *)p_self; + return self->size(); +} + +void GDAPI godot_pool_vector2_array_destroy(godot_pool_vector2_array *p_self) { + ((PoolVector *)p_self)->~PoolVector(); +} + +// vector3 + +void GDAPI godot_pool_vector3_array_new(godot_pool_vector3_array *r_dest) { + PoolVector *dest = (PoolVector *)r_dest; + memnew_placement(dest, PoolVector); +} + +void GDAPI godot_pool_vector3_array_new_copy(godot_pool_vector3_array *r_dest, const godot_pool_vector3_array *p_src) { + PoolVector *dest = (PoolVector *)r_dest; + const PoolVector *src = (const PoolVector *)p_src; + memnew_placement(dest, PoolVector(*src)); +} + +void GDAPI godot_pool_vector3_array_new_with_array(godot_pool_vector3_array *r_dest, const godot_array *p_a) { + PoolVector *dest = (PoolVector *)r_dest; + Array *a = (Array *)p_a; + memnew_placement(dest, PoolVector); + + dest->resize(a->size()); + for (int i = 0; i < a->size(); i++) { + dest->set(i, (*a)[i]); + } +} + +void GDAPI godot_pool_vector3_array_append(godot_pool_vector3_array *p_self, const godot_vector3 *p_data) { + PoolVector *self = (PoolVector *)p_self; + Vector3 &s = *(Vector3 *)p_data; + self->append(s); +} + +void GDAPI godot_pool_vector3_array_append_array(godot_pool_vector3_array *p_self, const godot_pool_vector3_array *p_array) { + PoolVector *self = (PoolVector *)p_self; + PoolVector *array = (PoolVector *)p_array; + self->append_array(*array); +} + +godot_error GDAPI godot_pool_vector3_array_insert(godot_pool_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data) { + PoolVector *self = (PoolVector *)p_self; + Vector3 &s = *(Vector3 *)p_data; + return (godot_error)self->insert(p_idx, s); +} + +void GDAPI godot_pool_vector3_array_invert(godot_pool_vector3_array *p_self) { + PoolVector *self = (PoolVector *)p_self; + self->invert(); +} + +void GDAPI godot_pool_vector3_array_push_back(godot_pool_vector3_array *p_self, const godot_vector3 *p_data) { + PoolVector *self = (PoolVector *)p_self; + Vector3 &s = *(Vector3 *)p_data; + self->push_back(s); +} + +void GDAPI godot_pool_vector3_array_remove(godot_pool_vector3_array *p_self, const godot_int p_idx) { + PoolVector *self = (PoolVector *)p_self; + self->remove(p_idx); +} + +void GDAPI godot_pool_vector3_array_resize(godot_pool_vector3_array *p_self, const godot_int p_size) { + PoolVector *self = (PoolVector *)p_self; + self->resize(p_size); +} + +void GDAPI godot_pool_vector3_array_set(godot_pool_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data) { + PoolVector *self = (PoolVector *)p_self; + Vector3 &s = *(Vector3 *)p_data; + self->set(p_idx, s); +} + +godot_vector3 GDAPI godot_pool_vector3_array_get(const godot_pool_vector3_array *p_self, const godot_int p_idx) { + const PoolVector *self = (const PoolVector *)p_self; + godot_vector3 v; + Vector3 *s = (Vector3 *)&v; + *s = self->get(p_idx); + return v; +} + +godot_int GDAPI godot_pool_vector3_array_size(const godot_pool_vector3_array *p_self) { + const PoolVector *self = (const PoolVector *)p_self; + return self->size(); +} + +void GDAPI godot_pool_vector3_array_destroy(godot_pool_vector3_array *p_self) { + ((PoolVector *)p_self)->~PoolVector(); +} + +// color + +void GDAPI godot_pool_color_array_new(godot_pool_color_array *r_dest) { + PoolVector *dest = (PoolVector *)r_dest; + memnew_placement(dest, PoolVector); +} + +void GDAPI godot_pool_color_array_new_copy(godot_pool_color_array *r_dest, const godot_pool_color_array *p_src) { + PoolVector *dest = (PoolVector *)r_dest; + const PoolVector *src = (const PoolVector *)p_src; + memnew_placement(dest, PoolVector(*src)); +} + +void GDAPI godot_pool_color_array_new_with_array(godot_pool_color_array *r_dest, const godot_array *p_a) { + PoolVector *dest = (PoolVector *)r_dest; + Array *a = (Array *)p_a; + memnew_placement(dest, PoolVector); + + dest->resize(a->size()); + for (int i = 0; i < a->size(); i++) { + dest->set(i, (*a)[i]); + } +} + +void GDAPI godot_pool_color_array_append(godot_pool_color_array *p_self, const godot_color *p_data) { + PoolVector *self = (PoolVector *)p_self; + Color &s = *(Color *)p_data; + self->append(s); +} + +void GDAPI godot_pool_color_array_append_array(godot_pool_color_array *p_self, const godot_pool_color_array *p_array) { + PoolVector *self = (PoolVector *)p_self; + PoolVector *array = (PoolVector *)p_array; + self->append_array(*array); +} + +godot_error GDAPI godot_pool_color_array_insert(godot_pool_color_array *p_self, const godot_int p_idx, const godot_color *p_data) { + PoolVector *self = (PoolVector *)p_self; + Color &s = *(Color *)p_data; + return (godot_error)self->insert(p_idx, s); +} + +void GDAPI godot_pool_color_array_invert(godot_pool_color_array *p_self) { + PoolVector *self = (PoolVector *)p_self; + self->invert(); +} + +void GDAPI godot_pool_color_array_push_back(godot_pool_color_array *p_self, const godot_color *p_data) { + PoolVector *self = (PoolVector *)p_self; + Color &s = *(Color *)p_data; + self->push_back(s); +} + +void GDAPI godot_pool_color_array_remove(godot_pool_color_array *p_self, const godot_int p_idx) { + PoolVector *self = (PoolVector *)p_self; + self->remove(p_idx); +} + +void GDAPI godot_pool_color_array_resize(godot_pool_color_array *p_self, const godot_int p_size) { + PoolVector *self = (PoolVector *)p_self; + self->resize(p_size); +} + +void GDAPI godot_pool_color_array_set(godot_pool_color_array *p_self, const godot_int p_idx, const godot_color *p_data) { + PoolVector *self = (PoolVector *)p_self; + Color &s = *(Color *)p_data; + self->set(p_idx, s); +} + +godot_color GDAPI godot_pool_color_array_get(const godot_pool_color_array *p_self, const godot_int p_idx) { + const PoolVector *self = (const PoolVector *)p_self; + godot_color v; + Color *s = (Color *)&v; + *s = self->get(p_idx); + return v; +} + +godot_int GDAPI godot_pool_color_array_size(const godot_pool_color_array *p_self) { + const PoolVector *self = (const PoolVector *)p_self; + return self->size(); +} + +void GDAPI godot_pool_color_array_destroy(godot_pool_color_array *p_self) { + ((PoolVector *)p_self)->~PoolVector(); +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/quat.cpp b/modules/gdnative/gdnative/quat.cpp new file mode 100644 index 0000000000..7db7847da1 --- /dev/null +++ b/modules/gdnative/gdnative/quat.cpp @@ -0,0 +1,219 @@ +/*************************************************************************/ +/* quat.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/quat.h" + +#include "core/math/quat.h" +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _quat_api_anchor() {} + +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); +} + +void GDAPI godot_quat_new_with_axis_angle(godot_quat *r_dest, const godot_vector3 *p_axis, const godot_real p_angle) { + const Vector3 *axis = (const Vector3 *)p_axis; + Quat *dest = (Quat *)r_dest; + *dest = Quat(*axis, p_angle); +} + +godot_real GDAPI godot_quat_get_x(const godot_quat *p_self) { + const Quat *self = (const Quat *)p_self; + return self->x; +} + +void GDAPI godot_quat_set_x(godot_quat *p_self, const godot_real val) { + Quat *self = (Quat *)p_self; + self->x = val; +} + +godot_real GDAPI godot_quat_get_y(const godot_quat *p_self) { + const Quat *self = (const Quat *)p_self; + return self->y; +} + +void GDAPI godot_quat_set_y(godot_quat *p_self, const godot_real val) { + Quat *self = (Quat *)p_self; + self->y = val; +} + +godot_real GDAPI godot_quat_get_z(const godot_quat *p_self) { + const Quat *self = (const Quat *)p_self; + return self->z; +} + +void GDAPI godot_quat_set_z(godot_quat *p_self, const godot_real val) { + Quat *self = (Quat *)p_self; + self->z = val; +} + +godot_real GDAPI godot_quat_get_w(const godot_quat *p_self) { + const Quat *self = (const Quat *)p_self; + return self->w; +} + +void GDAPI godot_quat_set_w(godot_quat *p_self, const godot_real val) { + Quat *self = (Quat *)p_self; + self->w = val; +} + +godot_string GDAPI godot_quat_as_string(const godot_quat *p_self) { + godot_string ret; + const Quat *self = (const Quat *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_real GDAPI godot_quat_length(const godot_quat *p_self) { + const Quat *self = (const Quat *)p_self; + return self->length(); +} + +godot_real GDAPI godot_quat_length_squared(const godot_quat *p_self) { + const Quat *self = (const Quat *)p_self; + return self->length_squared(); +} + +godot_quat GDAPI godot_quat_normalized(const godot_quat *p_self) { + godot_quat dest; + const Quat *self = (const Quat *)p_self; + *((Quat *)&dest) = self->normalized(); + return dest; +} + +godot_bool GDAPI godot_quat_is_normalized(const godot_quat *p_self) { + const Quat *self = (const Quat *)p_self; + return self->is_normalized(); +} + +godot_quat GDAPI godot_quat_inverse(const godot_quat *p_self) { + godot_quat dest; + const Quat *self = (const Quat *)p_self; + *((Quat *)&dest) = self->inverse(); + return dest; +} + +godot_real GDAPI godot_quat_dot(const godot_quat *p_self, const godot_quat *p_b) { + const Quat *self = (const Quat *)p_self; + const Quat *b = (const Quat *)p_b; + return self->dot(*b); +} + +godot_vector3 GDAPI godot_quat_xform(const godot_quat *p_self, const godot_vector3 *p_v) { + godot_vector3 dest; + const Quat *self = (const Quat *)p_self; + const Vector3 *v = (const Vector3 *)p_v; + *((Vector3 *)&dest) = self->xform(*v); + return dest; +} + +godot_quat GDAPI godot_quat_slerp(const godot_quat *p_self, const godot_quat *p_b, const godot_real p_t) { + godot_quat dest; + const Quat *self = (const Quat *)p_self; + const Quat *b = (const Quat *)p_b; + *((Quat *)&dest) = self->slerp(*b, p_t); + return dest; +} + +godot_quat GDAPI godot_quat_slerpni(const godot_quat *p_self, const godot_quat *p_b, const godot_real p_t) { + godot_quat dest; + const Quat *self = (const Quat *)p_self; + const Quat *b = (const Quat *)p_b; + *((Quat *)&dest) = self->slerpni(*b, p_t); + return dest; +} + +godot_quat GDAPI godot_quat_cubic_slerp(const godot_quat *p_self, const godot_quat *p_b, const godot_quat *p_pre_a, const godot_quat *p_post_b, const godot_real p_t) { + godot_quat dest; + const Quat *self = (const Quat *)p_self; + const Quat *b = (const Quat *)p_b; + const Quat *pre_a = (const Quat *)p_pre_a; + const Quat *post_b = (const Quat *)p_post_b; + *((Quat *)&dest) = self->cubic_slerp(*b, *pre_a, *post_b, p_t); + return dest; +} + +godot_quat GDAPI godot_quat_operator_multiply(const godot_quat *p_self, const godot_real p_b) { + godot_quat raw_dest; + Quat *dest = (Quat *)&raw_dest; + const Quat *self = (const Quat *)p_self; + *dest = *self * p_b; + return raw_dest; +} + +godot_quat GDAPI godot_quat_operator_add(const godot_quat *p_self, const godot_quat *p_b) { + godot_quat raw_dest; + Quat *dest = (Quat *)&raw_dest; + const Quat *self = (const Quat *)p_self; + const Quat *b = (const Quat *)p_b; + *dest = *self + *b; + return raw_dest; +} + +godot_quat GDAPI godot_quat_operator_substract(const godot_quat *p_self, const godot_quat *p_b) { + godot_quat raw_dest; + Quat *dest = (Quat *)&raw_dest; + const Quat *self = (const Quat *)p_self; + const Quat *b = (const Quat *)p_b; + *dest = *self - *b; + return raw_dest; +} + +godot_quat GDAPI godot_quat_operator_divide(const godot_quat *p_self, const godot_real p_b) { + godot_quat raw_dest; + Quat *dest = (Quat *)&raw_dest; + const Quat *self = (const Quat *)p_self; + *dest = *self / p_b; + return raw_dest; +} + +godot_bool GDAPI godot_quat_operator_equal(const godot_quat *p_self, const godot_quat *p_b) { + const Quat *self = (const Quat *)p_self; + const Quat *b = (const Quat *)p_b; + return *self == *b; +} + +godot_quat GDAPI godot_quat_operator_neg(const godot_quat *p_self) { + godot_quat raw_dest; + Quat *dest = (Quat *)&raw_dest; + const Quat *self = (const Quat *)p_self; + *dest = -(*self); + return raw_dest; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/rect2.cpp b/modules/gdnative/gdnative/rect2.cpp new file mode 100644 index 0000000000..ecd8cce9ca --- /dev/null +++ b/modules/gdnative/gdnative/rect2.cpp @@ -0,0 +1,157 @@ +/*************************************************************************/ +/* rect2.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/rect2.h" + +#include "core/math/math_2d.h" +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _rect2_api_anchor() {} + +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; + Rect2 *dest = (Rect2 *)r_dest; + *dest = Rect2(*position, *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) { + + Rect2 *dest = (Rect2 *)r_dest; + *dest = Rect2(p_x, p_y, p_width, p_height); +} + +godot_string GDAPI godot_rect2_as_string(const godot_rect2 *p_self) { + godot_string ret; + const Rect2 *self = (const Rect2 *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_real GDAPI godot_rect2_get_area(const godot_rect2 *p_self) { + const Rect2 *self = (const Rect2 *)p_self; + return self->get_area(); +} + +godot_bool GDAPI godot_rect2_intersects(const godot_rect2 *p_self, const godot_rect2 *p_b) { + const Rect2 *self = (const Rect2 *)p_self; + const Rect2 *b = (const Rect2 *)p_b; + return self->intersects(*b); +} + +godot_bool GDAPI godot_rect2_encloses(const godot_rect2 *p_self, const godot_rect2 *p_b) { + const Rect2 *self = (const Rect2 *)p_self; + const Rect2 *b = (const Rect2 *)p_b; + return self->encloses(*b); +} + +godot_bool GDAPI godot_rect2_has_no_area(const godot_rect2 *p_self) { + const Rect2 *self = (const Rect2 *)p_self; + return self->has_no_area(); +} + +godot_rect2 GDAPI godot_rect2_clip(const godot_rect2 *p_self, const godot_rect2 *p_b) { + godot_rect2 dest; + const Rect2 *self = (const Rect2 *)p_self; + const Rect2 *b = (const Rect2 *)p_b; + *((Rect2 *)&dest) = self->clip(*b); + return dest; +} + +godot_rect2 GDAPI godot_rect2_merge(const godot_rect2 *p_self, const godot_rect2 *p_b) { + godot_rect2 dest; + const Rect2 *self = (const Rect2 *)p_self; + const Rect2 *b = (const Rect2 *)p_b; + *((Rect2 *)&dest) = self->merge(*b); + return dest; +} + +godot_bool GDAPI godot_rect2_has_point(const godot_rect2 *p_self, const godot_vector2 *p_point) { + const Rect2 *self = (const Rect2 *)p_self; + const Vector2 *point = (const Vector2 *)p_point; + return self->has_point(*point); +} + +godot_rect2 GDAPI godot_rect2_grow(const godot_rect2 *p_self, const godot_real p_by) { + godot_rect2 dest; + const Rect2 *self = (const Rect2 *)p_self; + + *((Rect2 *)&dest) = self->grow(p_by); + return dest; +} + +godot_rect2 GDAPI godot_rect2_expand(const godot_rect2 *p_self, const godot_vector2 *p_to) { + godot_rect2 dest; + const Rect2 *self = (const Rect2 *)p_self; + const Vector2 *to = (const Vector2 *)p_to; + *((Rect2 *)&dest) = self->expand(*to); + return dest; +} + +godot_bool GDAPI godot_rect2_operator_equal(const godot_rect2 *p_self, const godot_rect2 *p_b) { + const Rect2 *self = (const Rect2 *)p_self; + const Rect2 *b = (const Rect2 *)p_b; + return *self == *b; +} + +godot_vector2 GDAPI godot_rect2_get_position(const godot_rect2 *p_self) { + godot_vector2 dest; + Vector2 *d = (Vector2 *)&dest; + const Rect2 *self = (const Rect2 *)p_self; + *d = self->get_position(); + return dest; +} + +godot_vector2 GDAPI godot_rect2_get_size(const godot_rect2 *p_self) { + godot_vector2 dest; + Vector2 *d = (Vector2 *)&dest; + const Rect2 *self = (const Rect2 *)p_self; + *d = self->get_size(); + return dest; +} + +void GDAPI godot_rect2_set_position(godot_rect2 *p_self, const godot_vector2 *p_pos) { + Rect2 *self = (Rect2 *)p_self; + const Vector2 *position = (const Vector2 *)p_pos; + self->set_position(*position); +} + +void GDAPI godot_rect2_set_size(godot_rect2 *p_self, const godot_vector2 *p_size) { + Rect2 *self = (Rect2 *)p_self; + const Vector2 *size = (const Vector2 *)p_size; + self->set_size(*size); +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/rect3.cpp b/modules/gdnative/gdnative/rect3.cpp new file mode 100644 index 0000000000..d34d964db9 --- /dev/null +++ b/modules/gdnative/gdnative/rect3.cpp @@ -0,0 +1,219 @@ +/*************************************************************************/ +/* rect3.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/rect3.h" + +#include "core/math/rect3.h" +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _rect3_api_anchor() {} + +void GDAPI godot_rect3_new(godot_rect3 *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; + Rect3 *dest = (Rect3 *)r_dest; + *dest = Rect3(*pos, *size); +} + +godot_vector3 GDAPI godot_rect3_get_position(const godot_rect3 *p_self) { + godot_vector3 raw_ret; + const Rect3 *self = (const Rect3 *)p_self; + Vector3 *ret = (Vector3 *)&raw_ret; + *ret = self->position; + return raw_ret; +} + +void GDAPI godot_rect3_set_position(const godot_rect3 *p_self, const godot_vector3 *p_v) { + Rect3 *self = (Rect3 *)p_self; + const Vector3 *v = (const Vector3 *)p_v; + self->position = *v; +} + +godot_vector3 GDAPI godot_rect3_get_size(const godot_rect3 *p_self) { + godot_vector3 raw_ret; + const Rect3 *self = (const Rect3 *)p_self; + Vector3 *ret = (Vector3 *)&raw_ret; + *ret = self->size; + return raw_ret; +} + +void GDAPI godot_rect3_set_size(const godot_rect3 *p_self, const godot_vector3 *p_v) { + Rect3 *self = (Rect3 *)p_self; + const Vector3 *v = (const Vector3 *)p_v; + self->size = *v; +} + +godot_string GDAPI godot_rect3_as_string(const godot_rect3 *p_self) { + godot_string ret; + const Rect3 *self = (const Rect3 *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_real GDAPI godot_rect3_get_area(const godot_rect3 *p_self) { + const Rect3 *self = (const Rect3 *)p_self; + return self->get_area(); +} + +godot_bool GDAPI godot_rect3_has_no_area(const godot_rect3 *p_self) { + const Rect3 *self = (const Rect3 *)p_self; + return self->has_no_area(); +} + +godot_bool GDAPI godot_rect3_has_no_surface(const godot_rect3 *p_self) { + const Rect3 *self = (const Rect3 *)p_self; + return self->has_no_surface(); +} + +godot_bool GDAPI godot_rect3_intersects(const godot_rect3 *p_self, const godot_rect3 *p_with) { + const Rect3 *self = (const Rect3 *)p_self; + const Rect3 *with = (const Rect3 *)p_with; + return self->intersects(*with); +} + +godot_bool GDAPI godot_rect3_encloses(const godot_rect3 *p_self, const godot_rect3 *p_with) { + const Rect3 *self = (const Rect3 *)p_self; + const Rect3 *with = (const Rect3 *)p_with; + return self->encloses(*with); +} + +godot_rect3 GDAPI godot_rect3_merge(const godot_rect3 *p_self, const godot_rect3 *p_with) { + godot_rect3 dest; + const Rect3 *self = (const Rect3 *)p_self; + const Rect3 *with = (const Rect3 *)p_with; + *((Rect3 *)&dest) = self->merge(*with); + return dest; +} + +godot_rect3 GDAPI godot_rect3_intersection(const godot_rect3 *p_self, const godot_rect3 *p_with) { + godot_rect3 dest; + const Rect3 *self = (const Rect3 *)p_self; + const Rect3 *with = (const Rect3 *)p_with; + *((Rect3 *)&dest) = self->intersection(*with); + return dest; +} + +godot_bool GDAPI godot_rect3_intersects_plane(const godot_rect3 *p_self, const godot_plane *p_plane) { + const Rect3 *self = (const Rect3 *)p_self; + const Plane *plane = (const Plane *)p_plane; + return self->intersects_plane(*plane); +} + +godot_bool GDAPI godot_rect3_intersects_segment(const godot_rect3 *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to) { + const Rect3 *self = (const Rect3 *)p_self; + const Vector3 *from = (const Vector3 *)p_from; + const Vector3 *to = (const Vector3 *)p_to; + return self->intersects_segment(*from, *to); +} + +godot_bool GDAPI godot_rect3_has_point(const godot_rect3 *p_self, const godot_vector3 *p_point) { + const Rect3 *self = (const Rect3 *)p_self; + const Vector3 *point = (const Vector3 *)p_point; + return self->has_point(*point); +} + +godot_vector3 GDAPI godot_rect3_get_support(const godot_rect3 *p_self, const godot_vector3 *p_dir) { + godot_vector3 dest; + const Rect3 *self = (const Rect3 *)p_self; + const Vector3 *dir = (const Vector3 *)p_dir; + *((Vector3 *)&dest) = self->get_support(*dir); + return dest; +} + +godot_vector3 GDAPI godot_rect3_get_longest_axis(const godot_rect3 *p_self) { + godot_vector3 dest; + const Rect3 *self = (const Rect3 *)p_self; + *((Vector3 *)&dest) = self->get_longest_axis(); + return dest; +} + +godot_int GDAPI godot_rect3_get_longest_axis_index(const godot_rect3 *p_self) { + const Rect3 *self = (const Rect3 *)p_self; + return self->get_longest_axis_index(); +} + +godot_real GDAPI godot_rect3_get_longest_axis_size(const godot_rect3 *p_self) { + const Rect3 *self = (const Rect3 *)p_self; + return self->get_longest_axis_size(); +} + +godot_vector3 GDAPI godot_rect3_get_shortest_axis(const godot_rect3 *p_self) { + godot_vector3 dest; + const Rect3 *self = (const Rect3 *)p_self; + *((Vector3 *)&dest) = self->get_shortest_axis(); + return dest; +} + +godot_int GDAPI godot_rect3_get_shortest_axis_index(const godot_rect3 *p_self) { + const Rect3 *self = (const Rect3 *)p_self; + return self->get_shortest_axis_index(); +} + +godot_real GDAPI godot_rect3_get_shortest_axis_size(const godot_rect3 *p_self) { + const Rect3 *self = (const Rect3 *)p_self; + return self->get_shortest_axis_size(); +} + +godot_rect3 GDAPI godot_rect3_expand(const godot_rect3 *p_self, const godot_vector3 *p_to_point) { + godot_rect3 dest; + const Rect3 *self = (const Rect3 *)p_self; + const Vector3 *to_point = (const Vector3 *)p_to_point; + *((Rect3 *)&dest) = self->expand(*to_point); + return dest; +} + +godot_rect3 GDAPI godot_rect3_grow(const godot_rect3 *p_self, const godot_real p_by) { + godot_rect3 dest; + const Rect3 *self = (const Rect3 *)p_self; + + *((Rect3 *)&dest) = self->grow(p_by); + return dest; +} + +godot_vector3 GDAPI godot_rect3_get_endpoint(const godot_rect3 *p_self, const godot_int p_idx) { + godot_vector3 dest; + const Rect3 *self = (const Rect3 *)p_self; + + *((Vector3 *)&dest) = self->get_endpoint(p_idx); + return dest; +} + +godot_bool GDAPI godot_rect3_operator_equal(const godot_rect3 *p_self, const godot_rect3 *p_b) { + const Rect3 *self = (const Rect3 *)p_self; + const Rect3 *b = (const Rect3 *)p_b; + return *self == *b; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/rid.cpp b/modules/gdnative/gdnative/rid.cpp new file mode 100644 index 0000000000..f05c39906c --- /dev/null +++ b/modules/gdnative/gdnative/rid.cpp @@ -0,0 +1,75 @@ +/*************************************************************************/ +/* rid.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/rid.h" + +#include "core/resource.h" +#include "core/rid.h" +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _rid_api_anchor() {} + +void GDAPI godot_rid_new(godot_rid *r_dest) { + RID *dest = (RID *)r_dest; + memnew_placement(dest, RID); +} + +godot_int GDAPI godot_rid_get_id(const godot_rid *p_self) { + const RID *self = (const RID *)p_self; + return self->get_id(); +} + +void GDAPI godot_rid_new_with_resource(godot_rid *r_dest, const godot_object *p_from) { + const Resource *res_from = Object::cast_to((Object *)p_from); + godot_rid_new(r_dest); + if (res_from) { + RID *dest = (RID *)r_dest; + *dest = RID(res_from->get_rid()); + } +} + +godot_bool GDAPI godot_rid_operator_equal(const godot_rid *p_self, const godot_rid *p_b) { + const RID *self = (const RID *)p_self; + const RID *b = (const RID *)p_b; + return *self == *b; +} + +godot_bool GDAPI godot_rid_operator_less(const godot_rid *p_self, const godot_rid *p_b) { + const RID *self = (const RID *)p_self; + const RID *b = (const RID *)p_b; + return *self < *b; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp new file mode 100644 index 0000000000..9b715ce36a --- /dev/null +++ b/modules/gdnative/gdnative/string.cpp @@ -0,0 +1,1267 @@ +/*************************************************************************/ +/* string.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/string.h" + +#include "core/variant.h" +#include "string_db.h" +#include "ustring.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void _string_api_anchor() { +} + +void GDAPI godot_string_new(godot_string *r_dest) { + String *dest = (String *)r_dest; + memnew_placement(dest, String); +} + +void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src) { + String *dest = (String *)r_dest; + const String *src = (const String *)p_src; + memnew_placement(dest, String(*src)); +} + +void GDAPI godot_string_new_data(godot_string *r_dest, const char *p_contents, const int p_size) { + String *dest = (String *)r_dest; + memnew_placement(dest, String(String::utf8(p_contents, p_size))); +} + +void GDAPI godot_string_new_unicode_data(godot_string *r_dest, const wchar_t *p_contents, const int p_size) { + String *dest = (String *)r_dest; + memnew_placement(dest, String(p_contents, p_size)); +} + +void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *p_size) { + String *self = (String *)p_self; + if (p_size != NULL) { + *p_size = self->utf8().length(); + } + if (p_dest != NULL) { + memcpy(p_dest, self->utf8().get_data(), *p_size); + } +} + +wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx) { + String *self = (String *)p_self; + return &(self->operator[](p_idx)); +} + +const char GDAPI *godot_string_c_str(const godot_string *p_self) { + const String *self = (const String *)p_self; + return self->utf8().get_data(); +} + +const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_self) { + const String *self = (const String *)p_self; + return self->c_str(); +} + +godot_bool GDAPI godot_string_operator_equal(const godot_string *p_self, const godot_string *p_b) { + const String *self = (const String *)p_self; + const String *b = (const String *)p_b; + return *self == *b; +} + +godot_bool GDAPI godot_string_operator_less(const godot_string *p_self, const godot_string *p_b) { + const String *self = (const String *)p_self; + const String *b = (const String *)p_b; + return *self < *b; +} + +godot_string GDAPI godot_string_operator_plus(const godot_string *p_self, const godot_string *p_b) { + godot_string ret; + const String *self = (const String *)p_self; + const String *b = (const String *)p_b; + memnew_placement(&ret, String(*self + *b)); + return ret; +} + +void GDAPI godot_string_destroy(godot_string *p_self) { + String *self = (String *)p_self; + self->~String(); +} + +/* Standard size stuff */ + +godot_int GDAPI godot_string_length(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->length(); +} + +/* Helpers */ + +godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string) { + const String *self = (const String *)p_self; + const String *string = (const String *)p_string; + + return self->begins_with(*string); +} + +godot_bool GDAPI godot_string_begins_with_char_array(const godot_string *p_self, const char *p_char_array) { + const String *self = (const String *)p_self; + + return self->begins_with(p_char_array); +} + +godot_array GDAPI godot_string_bigrams(const godot_string *p_self) { + const String *self = (const String *)p_self; + Vector return_value = self->bigrams(); + + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_string GDAPI godot_string_chr(wchar_t p_character) { + godot_string result; + memnew_placement(&result, String(String::chr(p_character))); + + return result; +} + +godot_bool GDAPI godot_string_ends_with(const godot_string *p_self, const godot_string *p_string) { + const String *self = (const String *)p_self; + const String *string = (const String *)p_string; + + return self->ends_with(*string); +} + +godot_int GDAPI godot_string_find(const godot_string *p_self, godot_string p_what) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->find(*what); +} + +godot_int GDAPI godot_string_find_from(const godot_string *p_self, godot_string p_what, godot_int p_from) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->find(*what, p_from); +} + +godot_int GDAPI godot_string_findmk(const godot_string *p_self, const godot_array *p_keys) { + const String *self = (const String *)p_self; + + Vector keys; + Array *keys_proxy = (Array *)p_keys; + keys.resize(keys_proxy->size()); + for (int i = 0; i < keys_proxy->size(); i++) { + keys[i] = (*keys_proxy)[i]; + } + + return self->findmk(keys); +} + +godot_int GDAPI godot_string_findmk_from(const godot_string *p_self, const godot_array *p_keys, godot_int p_from) { + const String *self = (const String *)p_self; + + Vector keys; + Array *keys_proxy = (Array *)p_keys; + keys.resize(keys_proxy->size()); + for (int i = 0; i < keys_proxy->size(); i++) { + keys[i] = (*keys_proxy)[i]; + } + + return self->findmk(keys, p_from); +} + +godot_int GDAPI godot_string_findmk_from_in_place(const godot_string *p_self, const godot_array *p_keys, godot_int p_from, godot_int *r_key) { + const String *self = (const String *)p_self; + + Vector keys; + Array *keys_proxy = (Array *)p_keys; + keys.resize(keys_proxy->size()); + for (int i = 0; i < keys_proxy->size(); i++) { + keys[i] = (*keys_proxy)[i]; + } + + return self->findmk(keys, p_from, r_key); +} + +godot_int GDAPI godot_string_findn(const godot_string *p_self, godot_string p_what) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->findn(*what); +} + +godot_int GDAPI godot_string_findn_from(const godot_string *p_self, godot_string p_what, godot_int p_from) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->findn(*what, p_from); +} + +godot_int GDAPI godot_string_find_last(const godot_string *p_self, godot_string p_what) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->find_last(*what); +} + +godot_string GDAPI godot_string_format(const godot_string *p_self, const godot_variant *p_values) { + const String *self = (const String *)p_self; + const Variant *values = (const Variant *)p_values; + godot_string result; + memnew_placement(&result, String(self->format(*values))); + + return result; +} + +godot_string GDAPI godot_string_format_with_custom_placeholder(const godot_string *p_self, const godot_variant *p_values, const char *p_placeholder) { + const String *self = (const String *)p_self; + const Variant *values = (const Variant *)p_values; + String placeholder = String(p_placeholder); + godot_string result; + memnew_placement(&result, String(self->format(*values, placeholder))); + + return result; +} + +godot_string GDAPI godot_string_hex_encode_buffer(const uint8_t *p_buffer, godot_int p_len) { + godot_string result; + memnew_placement(&result, String(String::hex_encode_buffer(p_buffer, p_len))); + + return result; +} + +godot_int GDAPI godot_string_hex_to_int(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->hex_to_int(); +} + +godot_int GDAPI godot_string_hex_to_int_without_prefix(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->hex_to_int(true); +} + +godot_string GDAPI godot_string_insert(const godot_string *p_self, godot_int p_at_pos, godot_string p_string) { + const String *self = (const String *)p_self; + String *content = (String *)&p_string; + godot_string result; + memnew_placement(&result, String(self->insert(p_at_pos, *content))); + + return result; +} + +godot_bool GDAPI godot_string_is_numeric(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_numeric(); +} + +godot_bool GDAPI godot_string_is_subsequence_of(const godot_string *p_self, const godot_string *p_string) { + const String *self = (const String *)p_self; + const String *string = (const String *)p_string; + + return self->is_subsequence_of(*string); +} + +godot_bool GDAPI godot_string_is_subsequence_ofi(const godot_string *p_self, const godot_string *p_string) { + const String *self = (const String *)p_self; + const String *string = (const String *)p_string; + + return self->is_subsequence_ofi(*string); +} + +godot_string GDAPI godot_string_lpad(const godot_string *p_self, godot_int p_min_length) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->lpad(p_min_length))); + + return result; +} + +godot_string GDAPI godot_string_lpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character) { + const String *self = (const String *)p_self; + const String *character = (const String *)p_character; + godot_string result; + memnew_placement(&result, String(self->lpad(p_min_length, *character))); + + return result; +} + +godot_bool GDAPI godot_string_match(const godot_string *p_self, const godot_string *p_wildcard) { + const String *self = (const String *)p_self; + const String *wildcard = (const String *)p_wildcard; + + return self->match(*wildcard); +} + +godot_bool GDAPI godot_string_matchn(const godot_string *p_self, const godot_string *p_wildcard) { + const String *self = (const String *)p_self; + const String *wildcard = (const String *)p_wildcard; + + return self->matchn(*wildcard); +} + +godot_string GDAPI godot_string_md5(const uint8_t *p_md5) { + godot_string result; + memnew_placement(&result, String(String::md5(p_md5))); + + return result; +} + +godot_string GDAPI godot_string_num(double p_num) { + godot_string result; + memnew_placement(&result, String(String::num(p_num))); + + return result; +} + +godot_string GDAPI godot_string_num_int64(int64_t p_num, godot_int p_base) { + godot_string result; + memnew_placement(&result, String(String::num_int64(p_num, p_base))); + + return result; +} + +godot_string GDAPI godot_string_num_int64_capitalized(int64_t p_num, godot_int p_base, godot_bool p_capitalize_hex) { + godot_string result; + memnew_placement(&result, String(String::num_int64(p_num, p_base, true))); + + return result; +} + +godot_string GDAPI godot_string_num_real(double p_num) { + godot_string result; + memnew_placement(&result, String(String::num_real(p_num))); + + return result; +} + +godot_string GDAPI godot_string_num_scientific(double p_num) { + godot_string result; + memnew_placement(&result, String(String::num_scientific(p_num))); + + return result; +} + +godot_string GDAPI godot_string_num_with_decimals(double p_num, godot_int p_decimals) { + godot_string result; + memnew_placement(&result, String(String::num(p_num, p_decimals))); + + return result; +} + +godot_string GDAPI godot_string_pad_decimals(const godot_string *p_self, godot_int p_digits) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->pad_decimals(p_digits))); + + return result; +} + +godot_string GDAPI godot_string_pad_zeros(const godot_string *p_self, godot_int p_digits) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->pad_zeros(p_digits))); + + return result; +} + +godot_string GDAPI godot_string_replace(const godot_string *p_self, godot_string p_key, godot_string p_with) { + const String *self = (const String *)p_self; + String *key = (String *)&p_key; + String *with = (String *)&p_with; + godot_string result; + memnew_placement(&result, String(self->replace(*key, *with))); + + return result; +} + +godot_string GDAPI godot_string_replacen(const godot_string *p_self, godot_string p_key, godot_string p_with) { + const String *self = (const String *)p_self; + String *key = (String *)&p_key; + String *with = (String *)&p_with; + godot_string result; + memnew_placement(&result, String(self->replacen(*key, *with))); + + return result; +} + +godot_int GDAPI godot_string_rfind(const godot_string *p_self, godot_string p_what) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->rfind(*what); +} + +godot_int GDAPI godot_string_rfindn(const godot_string *p_self, godot_string p_what) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->rfindn(*what); +} + +godot_int GDAPI godot_string_rfind_from(const godot_string *p_self, godot_string p_what, godot_int p_from) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->rfind(*what, p_from); +} + +godot_int GDAPI godot_string_rfindn_from(const godot_string *p_self, godot_string p_what, godot_int p_from) { + const String *self = (const String *)p_self; + String *what = (String *)&p_what; + + return self->rfindn(*what, p_from); +} + +godot_string GDAPI godot_string_replace_first(const godot_string *p_self, godot_string p_key, godot_string p_with) { + const String *self = (const String *)p_self; + String *key = (String *)&p_key; + String *with = (String *)&p_with; + godot_string result; + memnew_placement(&result, String(self->replace_first(*key, *with))); + + return result; +} + +godot_string GDAPI godot_string_rpad(const godot_string *p_self, godot_int p_min_length) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->rpad(p_min_length))); + + return result; +} + +godot_string GDAPI godot_string_rpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character) { + const String *self = (const String *)p_self; + const String *character = (const String *)p_character; + godot_string result; + memnew_placement(&result, String(self->rpad(p_min_length, *character))); + + return result; +} + +godot_real GDAPI godot_string_similarity(const godot_string *p_self, const godot_string *p_string) { + const String *self = (const String *)p_self; + const String *string = (const String *)p_string; + + return self->similarity(*string); +} + +godot_string GDAPI godot_string_sprintf(const godot_string *p_self, const godot_array *p_values, godot_bool *p_error) { + const String *self = (const String *)p_self; + const Array *values = (const Array *)p_values; + + godot_string result; + String return_value = self->sprintf(*values, p_error); + memnew_placement(&result, String(return_value)); + + return result; +} + +godot_string GDAPI godot_string_substr(const godot_string *p_self, godot_int p_from, godot_int p_chars) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->substr(p_from, p_chars))); + + return result; +} + +double GDAPI godot_string_to_double(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->to_double(); +} + +godot_real GDAPI godot_string_to_float(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->to_float(); +} + +godot_int GDAPI godot_string_to_int(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->to_int(); +} + +godot_string GDAPI godot_string_capitalize(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->capitalize())); + + return result; +}; + +godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->camelcase_to_underscore(false))); + + return result; +}; + +godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->camelcase_to_underscore())); + + return result; +}; + +double GDAPI godot_string_char_to_double(const char *p_what) { + return String::to_double(p_what); +}; + +godot_int GDAPI godot_string_char_to_int(const char *p_what) { + return String::to_int(p_what); +}; + +int64_t GDAPI godot_string_wchar_to_int(const wchar_t *p_str) { + return String::to_int(p_str); +}; + +godot_int GDAPI godot_string_char_to_int_with_len(const char *p_what, godot_int p_len) { + return String::to_int(p_what, p_len); +}; + +int64_t GDAPI godot_string_char_to_int64_with_len(const wchar_t *p_str, int p_len) { + return String::to_int(p_str, p_len); +}; + +int64_t GDAPI godot_string_hex_to_int64(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->hex_to_int64(false); +}; + +int64_t GDAPI godot_string_hex_to_int64_with_prefix(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->hex_to_int64(); +}; + +int64_t GDAPI godot_string_to_int64(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->to_int64(); +}; + +double GDAPI godot_string_unicode_char_to_double(const wchar_t *p_str, const wchar_t **r_end) { + return String::to_double(p_str, r_end); +} + +godot_string GDAPI godot_string_get_slice(const godot_string *p_self, godot_string p_splitter, godot_int p_slice) { + const String *self = (const String *)p_self; + String *splitter = (String *)&p_splitter; + godot_string result; + memnew_placement(&result, String(self->get_slice(*splitter, p_slice))); + + return result; +}; + +godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, wchar_t p_splitter, godot_int p_slice) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->get_slicec(p_splitter, p_slice))); + + return result; +}; + +godot_array GDAPI godot_string_split(const godot_string *p_self, const godot_string *p_splitter) { + const String *self = (const String *)p_self; + const String *splitter = (const String *)p_splitter; + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector return_value = self->split(*splitter, false); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, const godot_string *p_splitter) { + const String *self = (const String *)p_self; + const String *splitter = (const String *)p_splitter; + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector return_value = self->split(*splitter); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_floats(const godot_string *p_self, const godot_string *p_splitter) { + const String *self = (const String *)p_self; + const String *splitter = (const String *)p_splitter; + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector return_value = self->split_floats(*splitter, false); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_floats_allows_empty(const godot_string *p_self, const godot_string *p_splitter) { + const String *self = (const String *)p_self; + const String *splitter = (const String *)p_splitter; + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector return_value = self->split_floats(*splitter); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const godot_array *p_splitters) { + const String *self = (const String *)p_self; + + Vector splitters; + Array *splitter_proxy = (Array *)p_splitters; + splitters.resize(splitter_proxy->size()); + for (int i = 0; i < splitter_proxy->size(); i++) { + splitters[i] = (*splitter_proxy)[i]; + } + + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector return_value = self->split_floats_mk(splitters, false); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_floats_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) { + const String *self = (const String *)p_self; + + Vector splitters; + Array *splitter_proxy = (Array *)p_splitters; + splitters.resize(splitter_proxy->size()); + for (int i = 0; i < splitter_proxy->size(); i++) { + splitters[i] = (*splitter_proxy)[i]; + } + + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector return_value = self->split_floats_mk(splitters); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_ints(const godot_string *p_self, const godot_string *p_splitter) { + const String *self = (const String *)p_self; + const String *splitter = (const String *)p_splitter; + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector return_value = self->split_ints(*splitter, false); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_ints_allows_empty(const godot_string *p_self, const godot_string *p_splitter) { + const String *self = (const String *)p_self; + const String *splitter = (const String *)p_splitter; + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector return_value = self->split_ints(*splitter); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const godot_array *p_splitters) { + const String *self = (const String *)p_self; + + Vector splitters; + Array *splitter_proxy = (Array *)p_splitters; + splitters.resize(splitter_proxy->size()); + for (int i = 0; i < splitter_proxy->size(); i++) { + splitters[i] = (*splitter_proxy)[i]; + } + + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector return_value = self->split_ints_mk(splitters, false); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_ints_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) { + const String *self = (const String *)p_self; + + Vector splitters; + Array *splitter_proxy = (Array *)p_splitters; + splitters.resize(splitter_proxy->size()); + for (int i = 0; i < splitter_proxy->size(); i++) { + splitters[i] = (*splitter_proxy)[i]; + } + + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector return_value = self->split_ints_mk(splitters); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_array GDAPI godot_string_split_spaces(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_array result; + memnew_placement(&result, Array); + Array *proxy = (Array *)&result; + Vector return_value = self->split_spaces(); + + proxy->resize(return_value.size()); + for (int i = 0; i < return_value.size(); i++) { + (*proxy)[i] = return_value[i]; + } + + return result; +}; + +godot_int GDAPI godot_string_get_slice_count(const godot_string *p_self, godot_string p_splitter) { + const String *self = (const String *)p_self; + String *splitter = (String *)&p_splitter; + + return self->get_slice_count(*splitter); +}; + +wchar_t GDAPI godot_string_char_lowercase(wchar_t p_char) { + return String::char_lowercase(p_char); +}; + +wchar_t GDAPI godot_string_char_uppercase(wchar_t p_char) { + return String::char_uppercase(p_char); +}; + +godot_string GDAPI godot_string_to_lower(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->to_lower())); + + return result; +}; + +godot_string GDAPI godot_string_to_upper(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->to_upper())); + + return result; +}; + +godot_string GDAPI godot_string_get_basename(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->get_basename())); + + return result; +}; + +godot_string GDAPI godot_string_get_extension(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->get_extension())); + + return result; +}; + +godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->left(p_pos))); + + return result; +}; + +wchar_t GDAPI godot_string_ord_at(const godot_string *p_self, godot_int p_idx) { + const String *self = (const String *)p_self; + + return self->ord_at(p_idx); +}; + +godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godot_string *p_file) { + const String *self = (const String *)p_self; + const String *file = (const String *)p_file; + godot_string result; + memnew_placement(&result, String(self->plus_file(*file))); + + return result; +}; + +godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_pos) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->right(p_pos))); + + return result; +}; + +godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bool p_left, godot_bool p_right) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->strip_edges(p_left, p_right))); + + return result; +}; + +godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->strip_escapes())); + + return result; +}; + +void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars) { + String *self = (String *)p_self; + + return self->erase(p_pos, p_chars); +}; + +void GDAPI godot_string_ascii(godot_string *p_self, char *result) { + String *self = (String *)p_self; + Vector return_value = self->ascii(); + + for (int i = 0; i < return_value.size(); i++) { + result[i] = return_value[i]; + } +} + +void GDAPI godot_string_ascii_extended(godot_string *p_self, char *result) { + String *self = (String *)p_self; + Vector return_value = self->ascii(true); + + for (int i = 0; i < return_value.size(); i++) { + result[i] = return_value[i]; + } +} + +void GDAPI godot_string_utf8(godot_string *p_self, char *result) { + String *self = (String *)p_self; + Vector return_value = self->utf8(); + + for (int i = 0; i < return_value.size(); i++) { + result[i] = return_value[i]; + } +} + +godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8) { + String *self = (String *)p_self; + + return self->parse_utf8(p_utf8); +}; + +godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len) { + String *self = (String *)p_self; + + return self->parse_utf8(p_utf8, p_len); +}; + +godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8) { + godot_string result; + memnew_placement(&result, String(String::utf8(p_utf8))); + + return result; +}; + +godot_string GDAPI godot_string_chars_to_utf8_with_len(const char *p_utf8, godot_int p_len) { + godot_string result; + memnew_placement(&result, String(String::utf8(p_utf8, p_len))); + + return result; +}; + +uint32_t GDAPI godot_string_hash(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->hash(); +}; + +uint64_t GDAPI godot_string_hash64(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->hash64(); +}; + +uint32_t GDAPI godot_string_hash_chars(const char *p_cstr) { + return String::hash(p_cstr); +}; + +uint32_t GDAPI godot_string_hash_chars_with_len(const char *p_cstr, godot_int p_len) { + return String::hash(p_cstr, p_len); +}; + +uint32_t GDAPI godot_string_hash_utf8_chars(const wchar_t *p_str) { + return String::hash(p_str); +}; + +uint32_t GDAPI godot_string_hash_utf8_chars_with_len(const wchar_t *p_str, godot_int p_len) { + return String::hash(p_str, p_len); +}; + +godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self) { + const String *self = (const String *)p_self; + Vector tmp_result = self->md5_buffer(); + + godot_pool_byte_array result; + memnew_placement(&result, PoolByteArray); + PoolByteArray *proxy = (PoolByteArray *)&result; + PoolByteArray::Write proxy_writer = proxy->write(); + proxy->resize(tmp_result.size()); + + for (int i = 0; i < tmp_result.size(); i++) { + proxy_writer[i] = tmp_result[i]; + } + + return result; +}; + +godot_string GDAPI godot_string_md5_text(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->md5_text())); + + return result; +}; + +godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self) { + const String *self = (const String *)p_self; + Vector tmp_result = self->sha256_buffer(); + + godot_pool_byte_array result; + memnew_placement(&result, PoolByteArray); + PoolByteArray *proxy = (PoolByteArray *)&result; + PoolByteArray::Write proxy_writer = proxy->write(); + proxy->resize(tmp_result.size()); + + for (int i = 0; i < tmp_result.size(); i++) { + proxy_writer[i] = tmp_result[i]; + } + + return result; +}; + +godot_string GDAPI godot_string_sha256_text(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + memnew_placement(&result, String(self->sha256_text())); + + return result; +}; + +godot_bool godot_string_empty(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->empty(); +}; + +// path functions +godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->get_base_dir(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_get_file(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->get_file(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_humanize_size(size_t p_size) { + godot_string result; + String return_value = String::humanize_size(p_size); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_bool GDAPI godot_string_is_abs_path(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_abs_path(); +}; + +godot_bool GDAPI godot_string_is_rel_path(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_rel_path(); +}; + +godot_bool GDAPI godot_string_is_resource_file(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_resource_file(); +}; + +godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_string *p_path) { + const String *self = (const String *)p_self; + String *path = (String *)p_path; + godot_string result; + String return_value = self->path_to(*path); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const godot_string *p_path) { + const String *self = (const String *)p_self; + String *path = (String *)p_path; + godot_string result; + String return_value = self->path_to_file(*path); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_simplify_path(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->simplify_path(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_c_escape(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->c_escape(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->c_escape_multiline(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_c_unescape(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->c_unescape(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_http_escape(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->http_escape(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_http_unescape(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->http_unescape(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_json_escape(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->json_escape(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_word_wrap(const godot_string *p_self, godot_int p_chars_per_line) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->word_wrap(p_chars_per_line); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_xml_escape(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->xml_escape(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->xml_escape(true); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->xml_unescape(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_percent_decode(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->percent_decode(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_string GDAPI godot_string_percent_encode(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_string result; + String return_value = self->percent_encode(); + memnew_placement(&result, String(return_value)); + + return result; +}; + +godot_bool GDAPI godot_string_is_valid_float(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_valid_float(); +}; + +godot_bool GDAPI godot_string_is_valid_hex_number(const godot_string *p_self, godot_bool p_with_prefix) { + const String *self = (const String *)p_self; + + return self->is_valid_hex_number(p_with_prefix); +}; + +godot_bool GDAPI godot_string_is_valid_html_color(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_valid_html_color(); +}; + +godot_bool GDAPI godot_string_is_valid_identifier(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_valid_identifier(); +}; + +godot_bool GDAPI godot_string_is_valid_integer(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_valid_integer(); +}; + +godot_bool GDAPI godot_string_is_valid_ip_address(const godot_string *p_self) { + const String *self = (const String *)p_self; + + return self->is_valid_ip_address(); +}; + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/transform.cpp b/modules/gdnative/gdnative/transform.cpp new file mode 100644 index 0000000000..d7a3e78d3f --- /dev/null +++ b/modules/gdnative/gdnative/transform.cpp @@ -0,0 +1,223 @@ +/*************************************************************************/ +/* transform.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/transform.h" + +#include "core/math/transform.h" +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _transform_api_anchor() {} + +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; + const Vector3 *z_axis = (const Vector3 *)p_z_axis; + const Vector3 *origin = (const Vector3 *)p_origin; + Transform *dest = (Transform *)r_dest; + dest->basis.set_axis(0, *x_axis); + dest->basis.set_axis(1, *y_axis); + dest->basis.set_axis(2, *z_axis); + dest->origin = *origin; +} + +void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin) { + const Basis *basis = (const Basis *)p_basis; + const Vector3 *origin = (const Vector3 *)p_origin; + Transform *dest = (Transform *)r_dest; + *dest = Transform(*basis, *origin); +} + +godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self) { + godot_basis dest; + const Transform *self = (const Transform *)p_self; + *((Basis *)&dest) = self->basis; + return dest; +} + +void GDAPI godot_transform_set_basis(godot_transform *p_self, godot_basis *p_v) { + Transform *self = (Transform *)p_self; + const Basis *v = (const Basis *)p_v; + self->basis = *v; +} + +godot_vector3 GDAPI godot_transform_get_origin(const godot_transform *p_self) { + godot_vector3 dest; + const Transform *self = (const Transform *)p_self; + *((Vector3 *)&dest) = self->origin; + return dest; +} + +void GDAPI godot_transform_set_origin(godot_transform *p_self, godot_vector3 *p_v) { + Transform *self = (Transform *)p_self; + const Vector3 *v = (const Vector3 *)p_v; + self->origin = *v; +} + +godot_string GDAPI godot_transform_as_string(const godot_transform *p_self) { + godot_string ret; + const Transform *self = (const Transform *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_transform GDAPI godot_transform_inverse(const godot_transform *p_self) { + godot_transform dest; + const Transform *self = (const Transform *)p_self; + *((Transform *)&dest) = self->inverse(); + return dest; +} + +godot_transform GDAPI godot_transform_affine_inverse(const godot_transform *p_self) { + godot_transform dest; + const Transform *self = (const Transform *)p_self; + *((Transform *)&dest) = self->affine_inverse(); + return dest; +} + +godot_transform GDAPI godot_transform_orthonormalized(const godot_transform *p_self) { + godot_transform dest; + const Transform *self = (const Transform *)p_self; + *((Transform *)&dest) = self->orthonormalized(); + return dest; +} + +godot_transform GDAPI godot_transform_rotated(const godot_transform *p_self, const godot_vector3 *p_axis, const godot_real p_phi) { + godot_transform dest; + const Transform *self = (const Transform *)p_self; + const Vector3 *axis = (const Vector3 *)p_axis; + *((Transform *)&dest) = self->rotated(*axis, p_phi); + return dest; +} + +godot_transform GDAPI godot_transform_scaled(const godot_transform *p_self, const godot_vector3 *p_scale) { + godot_transform dest; + const Transform *self = (const Transform *)p_self; + const Vector3 *scale = (const Vector3 *)p_scale; + *((Transform *)&dest) = self->scaled(*scale); + return dest; +} + +godot_transform GDAPI godot_transform_translated(const godot_transform *p_self, const godot_vector3 *p_ofs) { + godot_transform dest; + const Transform *self = (const Transform *)p_self; + const Vector3 *ofs = (const Vector3 *)p_ofs; + *((Transform *)&dest) = self->translated(*ofs); + return dest; +} + +godot_transform GDAPI godot_transform_looking_at(const godot_transform *p_self, const godot_vector3 *p_target, const godot_vector3 *p_up) { + godot_transform dest; + const Transform *self = (const Transform *)p_self; + const Vector3 *target = (const Vector3 *)p_target; + const Vector3 *up = (const Vector3 *)p_up; + *((Transform *)&dest) = self->looking_at(*target, *up); + return dest; +} + +godot_plane GDAPI godot_transform_xform_plane(const godot_transform *p_self, const godot_plane *p_v) { + godot_plane raw_dest; + Plane *dest = (Plane *)&raw_dest; + const Transform *self = (const Transform *)p_self; + const Plane *v = (const Plane *)p_v; + *dest = self->xform(*v); + return raw_dest; +} + +godot_plane GDAPI godot_transform_xform_inv_plane(const godot_transform *p_self, const godot_plane *p_v) { + godot_plane raw_dest; + Plane *dest = (Plane *)&raw_dest; + const Transform *self = (const Transform *)p_self; + const Plane *v = (const Plane *)p_v; + *dest = self->xform_inv(*v); + return raw_dest; +} + +void GDAPI godot_transform_new_identity(godot_transform *r_dest) { + Transform *dest = (Transform *)r_dest; + *dest = Transform(); +} + +godot_bool GDAPI godot_transform_operator_equal(const godot_transform *p_self, const godot_transform *p_b) { + const Transform *self = (const Transform *)p_self; + const Transform *b = (const Transform *)p_b; + return *self == *b; +} + +godot_transform GDAPI godot_transform_operator_multiply(const godot_transform *p_self, const godot_transform *p_b) { + godot_transform raw_dest; + Transform *dest = (Transform *)&raw_dest; + const Transform *self = (const Transform *)p_self; + const Transform *b = (const Transform *)p_b; + *dest = *self * *b; + return raw_dest; +} + +godot_vector3 GDAPI godot_transform_xform_vector3(const godot_transform *p_self, const godot_vector3 *p_v) { + godot_vector3 raw_dest; + Vector3 *dest = (Vector3 *)&raw_dest; + const Transform *self = (const Transform *)p_self; + const Vector3 *v = (const Vector3 *)p_v; + *dest = self->xform(*v); + return raw_dest; +} + +godot_vector3 GDAPI godot_transform_xform_inv_vector3(const godot_transform *p_self, const godot_vector3 *p_v) { + godot_vector3 raw_dest; + Vector3 *dest = (Vector3 *)&raw_dest; + const Transform *self = (const Transform *)p_self; + const Vector3 *v = (const Vector3 *)p_v; + *dest = self->xform_inv(*v); + return raw_dest; +} + +godot_rect3 GDAPI godot_transform_xform_rect3(const godot_transform *p_self, const godot_rect3 *p_v) { + godot_rect3 raw_dest; + Rect3 *dest = (Rect3 *)&raw_dest; + const Transform *self = (const Transform *)p_self; + const Rect3 *v = (const Rect3 *)p_v; + *dest = self->xform(*v); + return raw_dest; +} + +godot_rect3 GDAPI godot_transform_xform_inv_rect3(const godot_transform *p_self, const godot_rect3 *p_v) { + godot_rect3 raw_dest; + Rect3 *dest = (Rect3 *)&raw_dest; + const Transform *self = (const Transform *)p_self; + const Rect3 *v = (const Rect3 *)p_v; + *dest = self->xform_inv(*v); + return raw_dest; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/transform2d.cpp b/modules/gdnative/gdnative/transform2d.cpp new file mode 100644 index 0000000000..dcb54f7a53 --- /dev/null +++ b/modules/gdnative/gdnative/transform2d.cpp @@ -0,0 +1,210 @@ +/*************************************************************************/ +/* transform2d.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/transform2d.h" + +#include "core/math/math_2d.h" +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _transform2d_api_anchor() {} + +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; + *dest = Transform2D(p_rot, *pos); +} + +void GDAPI godot_transform2d_new_axis_origin(godot_transform2d *r_dest, const godot_vector2 *p_x_axis, const godot_vector2 *p_y_axis, const godot_vector2 *p_origin) { + const Vector2 *x_axis = (const Vector2 *)p_x_axis; + const Vector2 *y_axis = (const Vector2 *)p_y_axis; + const Vector2 *origin = (const Vector2 *)p_origin; + Transform2D *dest = (Transform2D *)r_dest; + *dest = Transform2D(x_axis->x, x_axis->y, y_axis->x, y_axis->y, origin->x, origin->y); +} + +godot_string GDAPI godot_transform2d_as_string(const godot_transform2d *p_self) { + godot_string ret; + const Transform2D *self = (const Transform2D *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_transform2d GDAPI godot_transform2d_inverse(const godot_transform2d *p_self) { + godot_transform2d dest; + const Transform2D *self = (const Transform2D *)p_self; + *((Transform2D *)&dest) = self->inverse(); + return dest; +} + +godot_transform2d GDAPI godot_transform2d_affine_inverse(const godot_transform2d *p_self) { + godot_transform2d dest; + const Transform2D *self = (const Transform2D *)p_self; + *((Transform2D *)&dest) = self->affine_inverse(); + return dest; +} + +godot_real GDAPI godot_transform2d_get_rotation(const godot_transform2d *p_self) { + const Transform2D *self = (const Transform2D *)p_self; + return self->get_rotation(); +} + +godot_vector2 GDAPI godot_transform2d_get_origin(const godot_transform2d *p_self) { + godot_vector2 dest; + const Transform2D *self = (const Transform2D *)p_self; + *((Vector2 *)&dest) = self->get_origin(); + return dest; +} + +godot_vector2 GDAPI godot_transform2d_get_scale(const godot_transform2d *p_self) { + godot_vector2 dest; + const Transform2D *self = (const Transform2D *)p_self; + *((Vector2 *)&dest) = self->get_scale(); + return dest; +} + +godot_transform2d GDAPI godot_transform2d_orthonormalized(const godot_transform2d *p_self) { + godot_transform2d dest; + const Transform2D *self = (const Transform2D *)p_self; + *((Transform2D *)&dest) = self->orthonormalized(); + return dest; +} + +godot_transform2d GDAPI godot_transform2d_rotated(const godot_transform2d *p_self, const godot_real p_phi) { + godot_transform2d dest; + const Transform2D *self = (const Transform2D *)p_self; + + *((Transform2D *)&dest) = self->rotated(p_phi); + return dest; +} + +godot_transform2d GDAPI godot_transform2d_scaled(const godot_transform2d *p_self, const godot_vector2 *p_scale) { + godot_transform2d dest; + const Transform2D *self = (const Transform2D *)p_self; + const Vector2 *scale = (const Vector2 *)p_scale; + *((Transform2D *)&dest) = self->scaled(*scale); + return dest; +} + +godot_transform2d GDAPI godot_transform2d_translated(const godot_transform2d *p_self, const godot_vector2 *p_offset) { + godot_transform2d dest; + const Transform2D *self = (const Transform2D *)p_self; + const Vector2 *offset = (const Vector2 *)p_offset; + *((Transform2D *)&dest) = self->translated(*offset); + return dest; +} + +godot_vector2 GDAPI godot_transform2d_xform_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v) { + godot_vector2 raw_dest; + Vector2 *dest = (Vector2 *)&raw_dest; + const Transform2D *self = (const Transform2D *)p_self; + const Vector2 *v = (const Vector2 *)p_v; + *dest = self->xform(*v); + return raw_dest; +} + +godot_vector2 GDAPI godot_transform2d_xform_inv_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v) { + godot_vector2 raw_dest; + Vector2 *dest = (Vector2 *)&raw_dest; + const Transform2D *self = (const Transform2D *)p_self; + const Vector2 *v = (const Vector2 *)p_v; + *dest = self->xform_inv(*v); + return raw_dest; +} + +godot_vector2 GDAPI godot_transform2d_basis_xform_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v) { + godot_vector2 raw_dest; + Vector2 *dest = (Vector2 *)&raw_dest; + const Transform2D *self = (const Transform2D *)p_self; + const Vector2 *v = (const Vector2 *)p_v; + *dest = self->basis_xform(*v); + return raw_dest; +} + +godot_vector2 GDAPI godot_transform2d_basis_xform_inv_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v) { + godot_vector2 raw_dest; + Vector2 *dest = (Vector2 *)&raw_dest; + const Transform2D *self = (const Transform2D *)p_self; + const Vector2 *v = (const Vector2 *)p_v; + *dest = self->basis_xform_inv(*v); + return raw_dest; +} + +godot_transform2d GDAPI godot_transform2d_interpolate_with(const godot_transform2d *p_self, const godot_transform2d *p_m, const godot_real p_c) { + godot_transform2d dest; + const Transform2D *self = (const Transform2D *)p_self; + const Transform2D *m = (const Transform2D *)p_m; + *((Transform2D *)&dest) = self->interpolate_with(*m, p_c); + return dest; +} + +godot_bool GDAPI godot_transform2d_operator_equal(const godot_transform2d *p_self, const godot_transform2d *p_b) { + const Transform2D *self = (const Transform2D *)p_self; + const Transform2D *b = (const Transform2D *)p_b; + return *self == *b; +} + +godot_transform2d GDAPI godot_transform2d_operator_multiply(const godot_transform2d *p_self, const godot_transform2d *p_b) { + godot_transform2d raw_dest; + Transform2D *dest = (Transform2D *)&raw_dest; + const Transform2D *self = (const Transform2D *)p_self; + const Transform2D *b = (const Transform2D *)p_b; + *dest = *self * *b; + return raw_dest; +} + +void GDAPI godot_transform2d_new_identity(godot_transform2d *r_dest) { + Transform2D *dest = (Transform2D *)r_dest; + *dest = Transform2D(); +} + +godot_rect2 GDAPI godot_transform2d_xform_rect2(const godot_transform2d *p_self, const godot_rect2 *p_v) { + godot_rect2 raw_dest; + Rect2 *dest = (Rect2 *)&raw_dest; + const Transform2D *self = (const Transform2D *)p_self; + const Rect2 *v = (const Rect2 *)p_v; + *dest = self->xform(*v); + return raw_dest; +} + +godot_rect2 GDAPI godot_transform2d_xform_inv_rect2(const godot_transform2d *p_self, const godot_rect2 *p_v) { + godot_rect2 raw_dest; + Rect2 *dest = (Rect2 *)&raw_dest; + const Transform2D *self = (const Transform2D *)p_self; + const Rect2 *v = (const Rect2 *)p_v; + *dest = self->xform_inv(*v); + return raw_dest; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp new file mode 100644 index 0000000000..b61f80b1f9 --- /dev/null +++ b/modules/gdnative/gdnative/variant.cpp @@ -0,0 +1,481 @@ +/*************************************************************************/ +/* variant.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/variant.h" + +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _variant_api_anchor() {} + +#define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr) + +// Constructors + +godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return (godot_variant_type)self->get_type(); +} + +void GDAPI godot_variant_new_copy(godot_variant *p_dest, const godot_variant *p_src) { + Variant *dest = (Variant *)p_dest; + Variant *src = (Variant *)p_src; + memnew_placement(dest, Variant(*src)); +} + +void GDAPI godot_variant_new_nil(godot_variant *r_dest) { + Variant *dest = (Variant *)r_dest; + memnew_placement(dest, Variant); +} + +void GDAPI godot_variant_new_bool(godot_variant *r_dest, const godot_bool p_b) { + Variant *dest = (Variant *)r_dest; + memnew_placement_custom(dest, Variant, Variant(p_b)); +} + +void GDAPI godot_variant_new_uint(godot_variant *r_dest, const uint64_t p_i) { + Variant *dest = (Variant *)r_dest; + memnew_placement_custom(dest, Variant, Variant(p_i)); +} + +void GDAPI godot_variant_new_int(godot_variant *r_dest, const int64_t p_i) { + Variant *dest = (Variant *)r_dest; + memnew_placement_custom(dest, Variant, Variant(p_i)); +} + +void GDAPI godot_variant_new_real(godot_variant *r_dest, const double p_r) { + Variant *dest = (Variant *)r_dest; + memnew_placement_custom(dest, Variant, Variant(p_r)); +} + +void GDAPI godot_variant_new_string(godot_variant *r_dest, const godot_string *p_s) { + Variant *dest = (Variant *)r_dest; + String *s = (String *)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_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_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_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d) { + Variant *dest = (Variant *)r_dest; + Transform2D *t2d = (Transform2D *)p_t2d; + memnew_placement_custom(dest, Variant, Variant(*t2d)); +} + +void GDAPI godot_variant_new_plane(godot_variant *r_dest, const godot_plane *p_plane) { + Variant *dest = (Variant *)r_dest; + Plane *plane = (Plane *)p_plane; + memnew_placement_custom(dest, Variant, Variant(*plane)); +} + +void GDAPI godot_variant_new_quat(godot_variant *r_dest, const godot_quat *p_quat) { + Variant *dest = (Variant *)r_dest; + Quat *quat = (Quat *)p_quat; + memnew_placement_custom(dest, Variant, Variant(*quat)); +} + +void GDAPI godot_variant_new_rect3(godot_variant *r_dest, const godot_rect3 *p_rect3) { + Variant *dest = (Variant *)r_dest; + Rect3 *rect3 = (Rect3 *)p_rect3; + memnew_placement_custom(dest, Variant, Variant(*rect3)); +} + +void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis) { + Variant *dest = (Variant *)r_dest; + Basis *basis = (Basis *)p_basis; + memnew_placement_custom(dest, Variant, Variant(*basis)); +} + +void GDAPI godot_variant_new_transform(godot_variant *r_dest, const godot_transform *p_trans) { + Variant *dest = (Variant *)r_dest; + Transform *trans = (Transform *)p_trans; + memnew_placement_custom(dest, Variant, Variant(*trans)); +} + +void GDAPI godot_variant_new_color(godot_variant *r_dest, const godot_color *p_color) { + Variant *dest = (Variant *)r_dest; + Color *color = (Color *)p_color; + memnew_placement_custom(dest, Variant, Variant(*color)); +} + +void GDAPI godot_variant_new_node_path(godot_variant *r_dest, const godot_node_path *p_np) { + Variant *dest = (Variant *)r_dest; + NodePath *np = (NodePath *)p_np; + memnew_placement_custom(dest, Variant, Variant(*np)); +} + +void GDAPI godot_variant_new_rid(godot_variant *r_dest, const godot_rid *p_rid) { + Variant *dest = (Variant *)r_dest; + RID *rid = (RID *)p_rid; + memnew_placement_custom(dest, Variant, Variant(*rid)); +} + +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; + memnew_placement_custom(dest, Variant, Variant(obj)); +} + +void GDAPI godot_variant_new_dictionary(godot_variant *r_dest, const godot_dictionary *p_dict) { + Variant *dest = (Variant *)r_dest; + Dictionary *dict = (Dictionary *)p_dict; + memnew_placement_custom(dest, Variant, Variant(*dict)); +} + +void GDAPI godot_variant_new_array(godot_variant *r_dest, const godot_array *p_arr) { + Variant *dest = (Variant *)r_dest; + Array *arr = (Array *)p_arr; + memnew_placement_custom(dest, Variant, Variant(*arr)); +} + +void GDAPI godot_variant_new_pool_byte_array(godot_variant *r_dest, const godot_pool_byte_array *p_pba) { + Variant *dest = (Variant *)r_dest; + PoolByteArray *pba = (PoolByteArray *)p_pba; + memnew_placement_custom(dest, Variant, Variant(*pba)); +} + +void GDAPI godot_variant_new_pool_int_array(godot_variant *r_dest, const godot_pool_int_array *p_pia) { + Variant *dest = (Variant *)r_dest; + PoolIntArray *pia = (PoolIntArray *)p_pia; + memnew_placement_custom(dest, Variant, Variant(*pia)); +} + +void GDAPI godot_variant_new_pool_real_array(godot_variant *r_dest, const godot_pool_real_array *p_pra) { + Variant *dest = (Variant *)r_dest; + PoolRealArray *pra = (PoolRealArray *)p_pra; + memnew_placement_custom(dest, Variant, Variant(*pra)); +} + +void GDAPI godot_variant_new_pool_string_array(godot_variant *r_dest, const godot_pool_string_array *p_psa) { + Variant *dest = (Variant *)r_dest; + PoolStringArray *psa = (PoolStringArray *)p_psa; + memnew_placement_custom(dest, Variant, Variant(*psa)); +} + +void GDAPI godot_variant_new_pool_vector2_array(godot_variant *r_dest, const godot_pool_vector2_array *p_pv2a) { + Variant *dest = (Variant *)r_dest; + PoolVector2Array *pv2a = (PoolVector2Array *)p_pv2a; + memnew_placement_custom(dest, Variant, Variant(*pv2a)); +} + +void GDAPI godot_variant_new_pool_vector3_array(godot_variant *r_dest, const godot_pool_vector3_array *p_pv3a) { + Variant *dest = (Variant *)r_dest; + PoolVector3Array *pv3a = (PoolVector3Array *)p_pv3a; + memnew_placement_custom(dest, Variant, Variant(*pv3a)); +} + +void GDAPI godot_variant_new_pool_color_array(godot_variant *r_dest, const godot_pool_color_array *p_pca) { + Variant *dest = (Variant *)r_dest; + PoolColorArray *pca = (PoolColorArray *)p_pca; + memnew_placement_custom(dest, Variant, Variant(*pca)); +} + +godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->operator bool(); +} + +uint64_t GDAPI godot_variant_as_uint(const godot_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->operator uint64_t(); +} + +int64_t GDAPI godot_variant_as_int(const godot_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->operator int64_t(); +} + +double GDAPI godot_variant_as_real(const godot_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->operator double(); +} + +godot_string GDAPI godot_variant_as_string(const godot_variant *p_self) { + godot_string raw_dest; + const Variant *self = (const Variant *)p_self; + String *dest = (String *)&raw_dest; + memnew_placement(dest, String(self->operator String())); // operator = is overloaded by String + 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; + Vector2 *dest = (Vector2 *)&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; + Rect2 *dest = (Rect2 *)&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; + Vector3 *dest = (Vector3 *)&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; + Transform2D *dest = (Transform2D *)&raw_dest; + *dest = *self; + return raw_dest; +} + +godot_plane GDAPI godot_variant_as_plane(const godot_variant *p_self) { + godot_plane raw_dest; + const Variant *self = (const Variant *)p_self; + Plane *dest = (Plane *)&raw_dest; + *dest = *self; + return raw_dest; +} + +godot_quat GDAPI godot_variant_as_quat(const godot_variant *p_self) { + godot_quat raw_dest; + const Variant *self = (const Variant *)p_self; + Quat *dest = (Quat *)&raw_dest; + *dest = *self; + return raw_dest; +} + +godot_rect3 GDAPI godot_variant_as_rect3(const godot_variant *p_self) { + godot_rect3 raw_dest; + const Variant *self = (const Variant *)p_self; + Rect3 *dest = (Rect3 *)&raw_dest; + *dest = *self; + return raw_dest; +} + +godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_self) { + godot_basis raw_dest; + const Variant *self = (const Variant *)p_self; + Basis *dest = (Basis *)&raw_dest; + *dest = *self; + return raw_dest; +} + +godot_transform GDAPI godot_variant_as_transform(const godot_variant *p_self) { + godot_transform raw_dest; + const Variant *self = (const Variant *)p_self; + Transform *dest = (Transform *)&raw_dest; + *dest = *self; + return raw_dest; +} + +godot_color GDAPI godot_variant_as_color(const godot_variant *p_self) { + godot_color raw_dest; + const Variant *self = (const Variant *)p_self; + Color *dest = (Color *)&raw_dest; + *dest = *self; + return raw_dest; +} + +godot_node_path GDAPI godot_variant_as_node_path(const godot_variant *p_self) { + godot_node_path raw_dest; + const Variant *self = (const Variant *)p_self; + NodePath *dest = (NodePath *)&raw_dest; + memnew_placement(dest, NodePath(self->operator NodePath())); // operator = is overloaded by NodePath + return raw_dest; +} + +godot_rid GDAPI godot_variant_as_rid(const godot_variant *p_self) { + godot_rid raw_dest; + const Variant *self = (const Variant *)p_self; + RID *dest = (RID *)&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; + dest = *self; + return (godot_object *)dest; +} + +godot_dictionary GDAPI godot_variant_as_dictionary(const godot_variant *p_self) { + godot_dictionary raw_dest; + const Variant *self = (const Variant *)p_self; + Dictionary *dest = (Dictionary *)&raw_dest; + memnew_placement(dest, Dictionary(self->operator Dictionary())); // operator = is overloaded by Dictionary + return raw_dest; +} + +godot_array GDAPI godot_variant_as_array(const godot_variant *p_self) { + godot_array raw_dest; + const Variant *self = (const Variant *)p_self; + Array *dest = (Array *)&raw_dest; + memnew_placement(dest, Array(self->operator Array())); // operator = is overloaded by Array + return raw_dest; +} + +godot_pool_byte_array GDAPI godot_variant_as_pool_byte_array(const godot_variant *p_self) { + godot_pool_byte_array raw_dest; + const Variant *self = (const Variant *)p_self; + PoolByteArray *dest = (PoolByteArray *)&raw_dest; + memnew_placement(dest, PoolByteArray(self->operator PoolByteArray())); // operator = is overloaded by PoolByteArray + *dest = *self; + return raw_dest; +} + +godot_pool_int_array GDAPI godot_variant_as_pool_int_array(const godot_variant *p_self) { + godot_pool_int_array raw_dest; + const Variant *self = (const Variant *)p_self; + PoolIntArray *dest = (PoolIntArray *)&raw_dest; + memnew_placement(dest, PoolIntArray(self->operator PoolIntArray())); // operator = is overloaded by PoolIntArray + *dest = *self; + return raw_dest; +} + +godot_pool_real_array GDAPI godot_variant_as_pool_real_array(const godot_variant *p_self) { + godot_pool_real_array raw_dest; + const Variant *self = (const Variant *)p_self; + PoolRealArray *dest = (PoolRealArray *)&raw_dest; + memnew_placement(dest, PoolRealArray(self->operator PoolRealArray())); // operator = is overloaded by PoolRealArray + *dest = *self; + return raw_dest; +} + +godot_pool_string_array GDAPI godot_variant_as_pool_string_array(const godot_variant *p_self) { + godot_pool_string_array raw_dest; + const Variant *self = (const Variant *)p_self; + PoolStringArray *dest = (PoolStringArray *)&raw_dest; + memnew_placement(dest, PoolStringArray(self->operator PoolStringArray())); // operator = is overloaded by PoolStringArray + *dest = *self; + return raw_dest; +} + +godot_pool_vector2_array GDAPI godot_variant_as_pool_vector2_array(const godot_variant *p_self) { + godot_pool_vector2_array raw_dest; + const Variant *self = (const Variant *)p_self; + PoolVector2Array *dest = (PoolVector2Array *)&raw_dest; + memnew_placement(dest, PoolVector2Array(self->operator PoolVector2Array())); // operator = is overloaded by PoolVector2Array + *dest = *self; + return raw_dest; +} + +godot_pool_vector3_array GDAPI godot_variant_as_pool_vector3_array(const godot_variant *p_self) { + godot_pool_vector3_array raw_dest; + const Variant *self = (const Variant *)p_self; + PoolVector3Array *dest = (PoolVector3Array *)&raw_dest; + memnew_placement(dest, PoolVector3Array(self->operator PoolVector3Array())); // operator = is overloaded by PoolVector3Array + *dest = *self; + return raw_dest; +} + +godot_pool_color_array GDAPI godot_variant_as_pool_color_array(const godot_variant *p_self) { + godot_pool_color_array raw_dest; + const Variant *self = (const Variant *)p_self; + PoolColorArray *dest = (PoolColorArray *)&raw_dest; + memnew_placement(dest, PoolColorArray(self->operator PoolColorArray())); // operator = is overloaded by PoolColorArray + *dest = *self; + return raw_dest; +} + +godot_variant GDAPI godot_variant_call(godot_variant *p_self, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant_call_error *r_error) { + Variant *self = (Variant *)p_self; + String *method = (String *)p_method; + const Variant **args = (const Variant **)p_args; + godot_variant raw_dest; + Variant *dest = (Variant *)&raw_dest; + Variant::CallError error; + memnew_placement_custom(dest, Variant, Variant(self->call(*method, args, p_argcount, error))); + if (r_error) { + r_error->error = (godot_variant_call_error_error)error.error; + r_error->argument = error.argument; + r_error->expected = (godot_variant_type)error.expected; + } + return raw_dest; +} + +godot_bool GDAPI godot_variant_has_method(const godot_variant *p_self, const godot_string *p_method) { + const Variant *self = (const Variant *)p_self; + const String *method = (const String *)p_method; + return self->has_method(*method); +} + +godot_bool GDAPI godot_variant_operator_equal(const godot_variant *p_self, const godot_variant *p_other) { + const Variant *self = (const Variant *)p_self; + const Variant *other = (const Variant *)p_other; + return self->operator==(*other); +} + +godot_bool GDAPI godot_variant_operator_less(const godot_variant *p_self, const godot_variant *p_other) { + const Variant *self = (const Variant *)p_self; + const Variant *other = (const Variant *)p_other; + return self->operator<(*other); +} + +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; + return self->hash_compare(*other); +} + +godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self, godot_bool *r_valid) { + const Variant *self = (const Variant *)p_self; + bool &valid = *r_valid; + return self->booleanize(valid); +} + +void GDAPI godot_variant_destroy(godot_variant *p_self) { + Variant *self = (Variant *)p_self; + self->~Variant(); +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp new file mode 100644 index 0000000000..67f858997f --- /dev/null +++ b/modules/gdnative/gdnative/vector2.cpp @@ -0,0 +1,297 @@ +/*************************************************************************/ +/* vector2.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/vector2.h" + +#include "core/math/math_2d.h" +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _vector2_api_anchor() {} + +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); +} + +godot_string GDAPI godot_vector2_as_string(const godot_vector2 *p_self) { + godot_string ret; + const Vector2 *self = (const Vector2 *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_vector2 GDAPI godot_vector2_normalized(const godot_vector2 *p_self) { + godot_vector2 dest; + const Vector2 *self = (const Vector2 *)p_self; + *((Vector2 *)&dest) = self->normalized(); + return dest; +} + +godot_real GDAPI godot_vector2_length(const godot_vector2 *p_self) { + const Vector2 *self = (const Vector2 *)p_self; + return self->length(); +} + +godot_real GDAPI godot_vector2_angle(const godot_vector2 *p_self) { + const Vector2 *self = (const Vector2 *)p_self; + return self->angle(); +} + +godot_real GDAPI godot_vector2_length_squared(const godot_vector2 *p_self) { + const Vector2 *self = (const Vector2 *)p_self; + return self->length_squared(); +} + +godot_bool GDAPI godot_vector2_is_normalized(const godot_vector2 *p_self) { + const Vector2 *self = (const Vector2 *)p_self; + return self->is_normalized(); +} + +godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_self, const godot_vector2 *p_to) { + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *to = (const Vector2 *)p_to; + return self->distance_to(*to); +} + +godot_real GDAPI godot_vector2_distance_squared_to(const godot_vector2 *p_self, const godot_vector2 *p_to) { + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *to = (const Vector2 *)p_to; + return self->distance_squared_to(*to); +} + +godot_real GDAPI godot_vector2_angle_to(const godot_vector2 *p_self, const godot_vector2 *p_to) { + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *to = (const Vector2 *)p_to; + return self->angle_to(*to); +} + +godot_real GDAPI godot_vector2_angle_to_point(const godot_vector2 *p_self, const godot_vector2 *p_to) { + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *to = (const Vector2 *)p_to; + return self->angle_to_point(*to); +} + +godot_vector2 GDAPI godot_vector2_linear_interpolate(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_real p_t) { + godot_vector2 dest; + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *b = (const Vector2 *)p_b; + *((Vector2 *)&dest) = self->linear_interpolate(*b, p_t); + return dest; +} + +godot_vector2 GDAPI godot_vector2_cubic_interpolate(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_vector2 *p_pre_a, const godot_vector2 *p_post_b, const godot_real p_t) { + godot_vector2 dest; + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *b = (const Vector2 *)p_b; + const Vector2 *pre_a = (const Vector2 *)p_pre_a; + const Vector2 *post_b = (const Vector2 *)p_post_b; + *((Vector2 *)&dest) = self->cubic_interpolate(*b, *pre_a, *post_b, p_t); + return dest; +} + +godot_vector2 GDAPI godot_vector2_rotated(const godot_vector2 *p_self, const godot_real p_phi) { + godot_vector2 dest; + const Vector2 *self = (const Vector2 *)p_self; + + *((Vector2 *)&dest) = self->rotated(p_phi); + return dest; +} + +godot_vector2 GDAPI godot_vector2_tangent(const godot_vector2 *p_self) { + godot_vector2 dest; + const Vector2 *self = (const Vector2 *)p_self; + *((Vector2 *)&dest) = self->tangent(); + return dest; +} + +godot_vector2 GDAPI godot_vector2_floor(const godot_vector2 *p_self) { + godot_vector2 dest; + const Vector2 *self = (const Vector2 *)p_self; + *((Vector2 *)&dest) = self->floor(); + 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; + const Vector2 *by = (const Vector2 *)p_by; + *((Vector2 *)&dest) = self->snapped(*by); + return dest; +} + +godot_real GDAPI godot_vector2_aspect(const godot_vector2 *p_self) { + const Vector2 *self = (const Vector2 *)p_self; + return self->aspect(); +} + +godot_real GDAPI godot_vector2_dot(const godot_vector2 *p_self, const godot_vector2 *p_with) { + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *with = (const Vector2 *)p_with; + return self->dot(*with); +} + +godot_vector2 GDAPI godot_vector2_slide(const godot_vector2 *p_self, const godot_vector2 *p_n) { + godot_vector2 dest; + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *n = (const Vector2 *)p_n; + *((Vector2 *)&dest) = self->slide(*n); + return dest; +} + +godot_vector2 GDAPI godot_vector2_bounce(const godot_vector2 *p_self, const godot_vector2 *p_n) { + godot_vector2 dest; + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *n = (const Vector2 *)p_n; + *((Vector2 *)&dest) = self->bounce(*n); + return dest; +} + +godot_vector2 GDAPI godot_vector2_reflect(const godot_vector2 *p_self, const godot_vector2 *p_n) { + godot_vector2 dest; + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *n = (const Vector2 *)p_n; + *((Vector2 *)&dest) = self->reflect(*n); + return dest; +} + +godot_vector2 GDAPI godot_vector2_abs(const godot_vector2 *p_self) { + godot_vector2 dest; + const Vector2 *self = (const Vector2 *)p_self; + *((Vector2 *)&dest) = self->abs(); + return dest; +} + +godot_vector2 GDAPI godot_vector2_clamped(const godot_vector2 *p_self, const godot_real p_length) { + godot_vector2 dest; + const Vector2 *self = (const Vector2 *)p_self; + + *((Vector2 *)&dest) = self->clamped(p_length); + return dest; +} + +godot_vector2 GDAPI godot_vector2_operator_add(const godot_vector2 *p_self, const godot_vector2 *p_b) { + godot_vector2 raw_dest; + Vector2 *dest = (Vector2 *)&raw_dest; + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *b = (const Vector2 *)p_b; + *dest = *self + *b; + return raw_dest; +} + +godot_vector2 GDAPI godot_vector2_operator_substract(const godot_vector2 *p_self, const godot_vector2 *p_b) { + godot_vector2 raw_dest; + Vector2 *dest = (Vector2 *)&raw_dest; + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *b = (const Vector2 *)p_b; + *dest = *self - *b; + return raw_dest; +} + +godot_vector2 GDAPI godot_vector2_operator_multiply_vector(const godot_vector2 *p_self, const godot_vector2 *p_b) { + godot_vector2 raw_dest; + Vector2 *dest = (Vector2 *)&raw_dest; + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *b = (const Vector2 *)p_b; + *dest = *self * *b; + return raw_dest; +} + +godot_vector2 GDAPI godot_vector2_operator_multiply_scalar(const godot_vector2 *p_self, const godot_real p_b) { + godot_vector2 raw_dest; + Vector2 *dest = (Vector2 *)&raw_dest; + const Vector2 *self = (const Vector2 *)p_self; + *dest = *self * p_b; + return raw_dest; +} + +godot_vector2 GDAPI godot_vector2_operator_divide_vector(const godot_vector2 *p_self, const godot_vector2 *p_b) { + godot_vector2 raw_dest; + Vector2 *dest = (Vector2 *)&raw_dest; + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *b = (const Vector2 *)p_b; + *dest = *self / *b; + return raw_dest; +} + +godot_vector2 GDAPI godot_vector2_operator_divide_scalar(const godot_vector2 *p_self, const godot_real p_b) { + godot_vector2 raw_dest; + Vector2 *dest = (Vector2 *)&raw_dest; + const Vector2 *self = (const Vector2 *)p_self; + *dest = *self / p_b; + return raw_dest; +} + +godot_bool GDAPI godot_vector2_operator_equal(const godot_vector2 *p_self, const godot_vector2 *p_b) { + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *b = (const Vector2 *)p_b; + return *self == *b; +} + +godot_bool GDAPI godot_vector2_operator_less(const godot_vector2 *p_self, const godot_vector2 *p_b) { + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *b = (const Vector2 *)p_b; + return *self < *b; +} + +godot_vector2 GDAPI godot_vector2_operator_neg(const godot_vector2 *p_self) { + godot_vector2 raw_dest; + Vector2 *dest = (Vector2 *)&raw_dest; + const Vector2 *self = (const Vector2 *)p_self; + *dest = -(*self); + return raw_dest; +} + +void GDAPI godot_vector2_set_x(godot_vector2 *p_self, const godot_real p_x) { + Vector2 *self = (Vector2 *)p_self; + self->x = p_x; +} + +void GDAPI godot_vector2_set_y(godot_vector2 *p_self, const godot_real p_y) { + Vector2 *self = (Vector2 *)p_self; + self->y = p_y; +} + +godot_real GDAPI godot_vector2_get_x(const godot_vector2 *p_self) { + const Vector2 *self = (const Vector2 *)p_self; + return self->x; +} + +godot_real GDAPI godot_vector2_get_y(const godot_vector2 *p_self) { + const Vector2 *self = (const Vector2 *)p_self; + return self->y; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp new file mode 100644 index 0000000000..c85a3f1c08 --- /dev/null +++ b/modules/gdnative/gdnative/vector3.cpp @@ -0,0 +1,304 @@ +/*************************************************************************/ +/* vector3.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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/vector3.h" + +#include "core/variant.h" +#include "core/vector.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _vector3_api_anchor() {} + +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); +} + +godot_string GDAPI godot_vector3_as_string(const godot_vector3 *p_self) { + godot_string ret; + const Vector3 *self = (const Vector3 *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_int GDAPI godot_vector3_min_axis(const godot_vector3 *p_self) { + const Vector3 *self = (const Vector3 *)p_self; + return self->min_axis(); +} + +godot_int GDAPI godot_vector3_max_axis(const godot_vector3 *p_self) { + const Vector3 *self = (const Vector3 *)p_self; + return self->max_axis(); +} + +godot_real GDAPI godot_vector3_length(const godot_vector3 *p_self) { + const Vector3 *self = (const Vector3 *)p_self; + return self->length(); +} + +godot_real GDAPI godot_vector3_length_squared(const godot_vector3 *p_self) { + const Vector3 *self = (const Vector3 *)p_self; + return self->length_squared(); +} + +godot_bool GDAPI godot_vector3_is_normalized(const godot_vector3 *p_self) { + const Vector3 *self = (const Vector3 *)p_self; + return self->is_normalized(); +} + +godot_vector3 GDAPI godot_vector3_normalized(const godot_vector3 *p_self) { + godot_vector3 dest; + const Vector3 *self = (const Vector3 *)p_self; + *((Vector3 *)&dest) = self->normalized(); + return dest; +} + +godot_vector3 GDAPI godot_vector3_inverse(const godot_vector3 *p_self) { + godot_vector3 dest; + const Vector3 *self = (const Vector3 *)p_self; + *((Vector3 *)&dest) = self->inverse(); + return dest; +} + +godot_vector3 GDAPI godot_vector3_snapped(const godot_vector3 *p_self, const godot_vector3 *p_by) { + godot_vector3 dest; + const Vector3 *self = (const Vector3 *)p_self; + const Vector3 *snap_axis = (const Vector3 *)p_by; + + *((Vector3 *)&dest) = self->snapped(*snap_axis); + return dest; +} + +godot_vector3 GDAPI godot_vector3_rotated(const godot_vector3 *p_self, const godot_vector3 *p_axis, const godot_real p_phi) { + godot_vector3 dest; + const Vector3 *self = (const Vector3 *)p_self; + const Vector3 *axis = (const Vector3 *)p_axis; + *((Vector3 *)&dest) = self->rotated(*axis, p_phi); + return dest; +} + +godot_vector3 GDAPI godot_vector3_linear_interpolate(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_real p_t) { + godot_vector3 dest; + const Vector3 *self = (const Vector3 *)p_self; + const Vector3 *b = (const Vector3 *)p_b; + *((Vector3 *)&dest) = self->linear_interpolate(*b, p_t); + return dest; +} + +godot_vector3 GDAPI godot_vector3_cubic_interpolate(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_vector3 *p_pre_a, const godot_vector3 *p_post_b, const godot_real p_t) { + godot_vector3 dest; + const Vector3 *self = (const Vector3 *)p_self; + const Vector3 *b = (const Vector3 *)p_b; + const Vector3 *pre_a = (const Vector3 *)p_pre_a; + const Vector3 *post_b = (const Vector3 *)p_post_b; + *((Vector3 *)&dest) = self->cubic_interpolate(*b, *pre_a, *post_b, p_t); + return dest; +} + +godot_real GDAPI godot_vector3_dot(const godot_vector3 *p_self, const godot_vector3 *p_b) { + const Vector3 *self = (const Vector3 *)p_self; + const Vector3 *b = (const Vector3 *)p_b; + return self->dot(*b); +} + +godot_vector3 GDAPI godot_vector3_cross(const godot_vector3 *p_self, const godot_vector3 *p_b) { + godot_vector3 dest; + const Vector3 *self = (const Vector3 *)p_self; + const Vector3 *b = (const Vector3 *)p_b; + *((Vector3 *)&dest) = self->cross(*b); + return dest; +} + +godot_basis GDAPI godot_vector3_outer(const godot_vector3 *p_self, const godot_vector3 *p_b) { + godot_basis dest; + const Vector3 *self = (const Vector3 *)p_self; + const Vector3 *b = (const Vector3 *)p_b; + *((Basis *)&dest) = self->outer(*b); + return dest; +} + +godot_basis GDAPI godot_vector3_to_diagonal_matrix(const godot_vector3 *p_self) { + godot_basis dest; + const Vector3 *self = (const Vector3 *)p_self; + *((Basis *)&dest) = self->to_diagonal_matrix(); + return dest; +} + +godot_vector3 GDAPI godot_vector3_abs(const godot_vector3 *p_self) { + godot_vector3 dest; + const Vector3 *self = (const Vector3 *)p_self; + *((Vector3 *)&dest) = self->abs(); + return dest; +} + +godot_vector3 GDAPI godot_vector3_floor(const godot_vector3 *p_self) { + godot_vector3 dest; + const Vector3 *self = (const Vector3 *)p_self; + *((Vector3 *)&dest) = self->floor(); + return dest; +} + +godot_vector3 GDAPI godot_vector3_ceil(const godot_vector3 *p_self) { + godot_vector3 dest; + const Vector3 *self = (const Vector3 *)p_self; + *((Vector3 *)&dest) = self->ceil(); + return dest; +} + +godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_self, const godot_vector3 *p_b) { + const Vector3 *self = (const Vector3 *)p_self; + const Vector3 *b = (const Vector3 *)p_b; + return self->distance_to(*b); +} + +godot_real GDAPI godot_vector3_distance_squared_to(const godot_vector3 *p_self, const godot_vector3 *p_b) { + const Vector3 *self = (const Vector3 *)p_self; + const Vector3 *b = (const Vector3 *)p_b; + return self->distance_squared_to(*b); +} + +godot_real GDAPI godot_vector3_angle_to(const godot_vector3 *p_self, const godot_vector3 *p_to) { + const Vector3 *self = (const Vector3 *)p_self; + const Vector3 *to = (const Vector3 *)p_to; + return self->angle_to(*to); +} + +godot_vector3 GDAPI godot_vector3_slide(const godot_vector3 *p_self, const godot_vector3 *p_n) { + godot_vector3 dest; + const Vector3 *self = (const Vector3 *)p_self; + const Vector3 *n = (const Vector3 *)p_n; + *((Vector3 *)&dest) = self->slide(*n); + return dest; +} + +godot_vector3 GDAPI godot_vector3_bounce(const godot_vector3 *p_self, const godot_vector3 *p_n) { + godot_vector3 dest; + const Vector3 *self = (const Vector3 *)p_self; + const Vector3 *n = (const Vector3 *)p_n; + *((Vector3 *)&dest) = self->bounce(*n); + return dest; +} + +godot_vector3 GDAPI godot_vector3_reflect(const godot_vector3 *p_self, const godot_vector3 *p_n) { + godot_vector3 dest; + const Vector3 *self = (const Vector3 *)p_self; + const Vector3 *n = (const Vector3 *)p_n; + *((Vector3 *)&dest) = self->reflect(*n); + return dest; +} + +godot_vector3 GDAPI godot_vector3_operator_add(const godot_vector3 *p_self, const godot_vector3 *p_b) { + godot_vector3 raw_dest; + Vector3 *dest = (Vector3 *)&raw_dest; + Vector3 *self = (Vector3 *)p_self; + const Vector3 *b = (const Vector3 *)p_b; + *dest = *self + *b; + return raw_dest; +} + +godot_vector3 GDAPI godot_vector3_operator_substract(const godot_vector3 *p_self, const godot_vector3 *p_b) { + godot_vector3 raw_dest; + Vector3 *dest = (Vector3 *)&raw_dest; + Vector3 *self = (Vector3 *)p_self; + const Vector3 *b = (const Vector3 *)p_b; + *dest = *self - *b; + return raw_dest; +} + +godot_vector3 GDAPI godot_vector3_operator_multiply_vector(const godot_vector3 *p_self, const godot_vector3 *p_b) { + godot_vector3 raw_dest; + Vector3 *dest = (Vector3 *)&raw_dest; + Vector3 *self = (Vector3 *)p_self; + const Vector3 *b = (const Vector3 *)p_b; + *dest = *self * *b; + return raw_dest; +} + +godot_vector3 GDAPI godot_vector3_operator_multiply_scalar(const godot_vector3 *p_self, const godot_real p_b) { + godot_vector3 raw_dest; + Vector3 *dest = (Vector3 *)&raw_dest; + Vector3 *self = (Vector3 *)p_self; + *dest = *self * p_b; + return raw_dest; +} + +godot_vector3 GDAPI godot_vector3_operator_divide_vector(const godot_vector3 *p_self, const godot_vector3 *p_b) { + godot_vector3 raw_dest; + Vector3 *dest = (Vector3 *)&raw_dest; + Vector3 *self = (Vector3 *)p_self; + const Vector3 *b = (const Vector3 *)p_b; + *dest = *self / *b; + return raw_dest; +} + +godot_vector3 GDAPI godot_vector3_operator_divide_scalar(const godot_vector3 *p_self, const godot_real p_b) { + godot_vector3 raw_dest; + Vector3 *dest = (Vector3 *)&raw_dest; + Vector3 *self = (Vector3 *)p_self; + *dest = *self / p_b; + return raw_dest; +} + +godot_bool GDAPI godot_vector3_operator_equal(const godot_vector3 *p_self, const godot_vector3 *p_b) { + Vector3 *self = (Vector3 *)p_self; + const Vector3 *b = (const Vector3 *)p_b; + return *self == *b; +} + +godot_bool GDAPI godot_vector3_operator_less(const godot_vector3 *p_self, const godot_vector3 *p_b) { + Vector3 *self = (Vector3 *)p_self; + const Vector3 *b = (const Vector3 *)p_b; + return *self < *b; +} + +godot_vector3 GDAPI godot_vector3_operator_neg(const godot_vector3 *p_self) { + godot_vector3 raw_dest; + Vector3 *dest = (Vector3 *)&raw_dest; + const Vector3 *self = (const Vector3 *)p_self; + *dest = -(*self); + return raw_dest; +} + +void GDAPI godot_vector3_set_axis(godot_vector3 *p_self, const godot_vector3_axis p_axis, const godot_real p_val) { + Vector3 *self = (Vector3 *)p_self; + self->set_axis(p_axis, p_val); +} + +godot_real GDAPI godot_vector3_get_axis(const godot_vector3 *p_self, const godot_vector3_axis p_axis) { + const Vector3 *self = (const Vector3 *)p_self; + return self->get_axis(p_axis); +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/godot/array.cpp b/modules/gdnative/godot/array.cpp deleted file mode 100644 index c3fde0e954..0000000000 --- a/modules/gdnative/godot/array.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/*************************************************************************/ -/* array.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/array.h" -#include "core/os/memory.h" - -#include "core/color.h" -#include "core/dvector.h" - -#include "core/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _array_api_anchor() { -} - -void GDAPI godot_array_new(godot_array *r_dest) { - Array *dest = (Array *)r_dest; - memnew_placement(dest, Array); -} - -void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src) { - Array *dest = (Array *)r_dest; - const Array *src = (const Array *)p_src; - memnew_placement(dest, Array(*src)); -} - -void GDAPI godot_array_new_pool_color_array(godot_array *r_dest, const godot_pool_color_array *p_pca) { - Array *dest = (Array *)r_dest; - PoolVector *pca = (PoolVector *)p_pca; - 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_pool_vector3_array(godot_array *r_dest, const godot_pool_vector3_array *p_pv3a) { - Array *dest = (Array *)r_dest; - PoolVector *pca = (PoolVector *)p_pv3a; - 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_pool_vector2_array(godot_array *r_dest, const godot_pool_vector2_array *p_pv2a) { - Array *dest = (Array *)r_dest; - PoolVector *pca = (PoolVector *)p_pv2a; - 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_pool_string_array(godot_array *r_dest, const godot_pool_string_array *p_psa) { - Array *dest = (Array *)r_dest; - PoolVector *pca = (PoolVector *)p_psa; - 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_pool_real_array(godot_array *r_dest, const godot_pool_real_array *p_pra) { - Array *dest = (Array *)r_dest; - PoolVector *pca = (PoolVector *)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_pool_int_array(godot_array *r_dest, const godot_pool_int_array *p_pia) { - Array *dest = (Array *)r_dest; - PoolVector *pca = (PoolVector *)p_pia; - 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_pool_byte_array(godot_array *r_dest, const godot_pool_byte_array *p_pba) { - Array *dest = (Array *)r_dest; - PoolVector *pca = (PoolVector *)p_pba; - 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_set(godot_array *p_self, const godot_int p_idx, const godot_variant *p_value) { - Array *self = (Array *)p_self; - Variant *val = (Variant *)p_value; - self->operator[](p_idx) = *val; -} - -godot_variant GDAPI godot_array_get(const godot_array *p_self, const godot_int p_idx) { - godot_variant raw_dest; - Variant *dest = (Variant *)&raw_dest; - const Array *self = (const Array *)p_self; - memnew_placement(dest, Variant(self->operator[](p_idx))); - return raw_dest; -} - -godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, const godot_int p_idx) { - Array *self = (Array *)p_self; - return (godot_variant *)&self->operator[](p_idx); -} - -void GDAPI godot_array_append(godot_array *p_self, const godot_variant *p_value) { - Array *self = (Array *)p_self; - Variant *val = (Variant *)p_value; - self->append(*val); -} - -void GDAPI godot_array_clear(godot_array *p_self) { - Array *self = (Array *)p_self; - self->clear(); -} - -godot_int GDAPI godot_array_count(const godot_array *p_self, const godot_variant *p_value) { - const Array *self = (const Array *)p_self; - const Variant *val = (const Variant *)p_value; - return self->count(*val); -} - -godot_bool GDAPI godot_array_empty(const godot_array *p_self) { - const Array *self = (const Array *)p_self; - return self->empty(); -} - -void GDAPI godot_array_erase(godot_array *p_self, const godot_variant *p_value) { - Array *self = (Array *)p_self; - const Variant *val = (const Variant *)p_value; - self->erase(*val); -} - -godot_variant GDAPI godot_array_front(const godot_array *p_self) { - const Array *self = (const Array *)p_self; - godot_variant v; - Variant *val = (Variant *)&v; - memnew_placement(val, Variant); - *val = self->front(); - return v; -} - -godot_variant GDAPI godot_array_back(const godot_array *p_self) { - const Array *self = (const Array *)p_self; - godot_variant v; - Variant *val = (Variant *)&v; - memnew_placement(val, Variant); - *val = self->back(); - return v; -} - -godot_int GDAPI godot_array_find(const godot_array *p_self, const godot_variant *p_what, const godot_int p_from) { - const Array *self = (const Array *)p_self; - const Variant *val = (const Variant *)p_what; - return self->find(*val, p_from); -} - -godot_int GDAPI godot_array_find_last(const godot_array *p_self, const godot_variant *p_what) { - const Array *self = (const Array *)p_self; - const Variant *val = (const Variant *)p_what; - return self->find_last(*val); -} - -godot_bool GDAPI godot_array_has(const godot_array *p_self, const godot_variant *p_value) { - const Array *self = (const Array *)p_self; - const Variant *val = (const Variant *)p_value; - return self->has(*val); -} - -godot_int GDAPI godot_array_hash(const godot_array *p_self) { - const Array *self = (const Array *)p_self; - return self->hash(); -} - -void GDAPI godot_array_insert(godot_array *p_self, const godot_int p_pos, const godot_variant *p_value) { - Array *self = (Array *)p_self; - const Variant *val = (const Variant *)p_value; - self->insert(p_pos, *val); -} - -void GDAPI godot_array_invert(godot_array *p_self) { - Array *self = (Array *)p_self; - self->invert(); -} - -godot_variant GDAPI godot_array_pop_back(godot_array *p_self) { - Array *self = (Array *)p_self; - godot_variant v; - Variant *val = (Variant *)&v; - memnew_placement(val, Variant); - *val = self->pop_back(); - return v; -} - -godot_variant GDAPI godot_array_pop_front(godot_array *p_self) { - Array *self = (Array *)p_self; - godot_variant v; - Variant *val = (Variant *)&v; - memnew_placement(val, Variant); - *val = self->pop_front(); - return v; -} - -void GDAPI godot_array_push_back(godot_array *p_self, const godot_variant *p_value) { - Array *self = (Array *)p_self; - const Variant *val = (const Variant *)p_value; - self->push_back(*val); -} - -void GDAPI godot_array_push_front(godot_array *p_self, const godot_variant *p_value) { - Array *self = (Array *)p_self; - const Variant *val = (const Variant *)p_value; - self->push_front(*val); -} - -void GDAPI godot_array_remove(godot_array *p_self, const godot_int p_idx) { - Array *self = (Array *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_array_resize(godot_array *p_self, const godot_int p_size) { - Array *self = (Array *)p_self; - self->resize(p_size); -} - -godot_int GDAPI godot_array_rfind(const godot_array *p_self, const godot_variant *p_what, const godot_int p_from) { - const Array *self = (const Array *)p_self; - const Variant *val = (const Variant *)p_what; - return self->rfind(*val, p_from); -} - -godot_int GDAPI godot_array_size(const godot_array *p_self) { - const Array *self = (const Array *)p_self; - return self->size(); -} - -void GDAPI godot_array_sort(godot_array *p_self) { - Array *self = (Array *)p_self; - self->sort(); -} - -void GDAPI godot_array_sort_custom(godot_array *p_self, godot_object *p_obj, const godot_string *p_func) { - Array *self = (Array *)p_self; - const String *func = (const String *)p_func; - self->sort_custom((Object *)p_obj, *func); -} - -void GDAPI godot_array_destroy(godot_array *p_self) { - ((Array *)p_self)->~Array(); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/array.h b/modules/gdnative/godot/array.h deleted file mode 100644 index 08f73c8785..0000000000 --- a/modules/gdnative/godot/array.h +++ /dev/null @@ -1,122 +0,0 @@ -/*************************************************************************/ -/* array.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_ARRAY_H -#define GODOT_ARRAY_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define GODOT_ARRAY_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_ARRAY_SIZE]; -} godot_array; -#endif - -#include -#include - -#include - -void GDAPI godot_array_new(godot_array *r_dest); -void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src); -void GDAPI godot_array_new_pool_color_array(godot_array *r_dest, const godot_pool_color_array *p_pca); -void GDAPI godot_array_new_pool_vector3_array(godot_array *r_dest, const godot_pool_vector3_array *p_pv3a); -void GDAPI godot_array_new_pool_vector2_array(godot_array *r_dest, const godot_pool_vector2_array *p_pv2a); -void GDAPI godot_array_new_pool_string_array(godot_array *r_dest, const godot_pool_string_array *p_psa); -void GDAPI godot_array_new_pool_real_array(godot_array *r_dest, const godot_pool_real_array *p_pra); -void GDAPI godot_array_new_pool_int_array(godot_array *r_dest, const godot_pool_int_array *p_pia); -void GDAPI godot_array_new_pool_byte_array(godot_array *r_dest, const godot_pool_byte_array *p_pba); - -void GDAPI godot_array_set(godot_array *p_self, const godot_int p_idx, const godot_variant *p_value); - -godot_variant GDAPI godot_array_get(const godot_array *p_self, const godot_int p_idx); - -godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, const godot_int p_idx); - -void GDAPI godot_array_append(godot_array *p_self, const godot_variant *p_value); - -void GDAPI godot_array_clear(godot_array *p_self); - -godot_int GDAPI godot_array_count(const godot_array *p_self, const godot_variant *p_value); - -godot_bool GDAPI godot_array_empty(const godot_array *p_self); - -void GDAPI godot_array_erase(godot_array *p_self, const godot_variant *p_value); - -godot_variant GDAPI godot_array_front(const godot_array *p_self); - -godot_variant GDAPI godot_array_back(const godot_array *p_self); - -godot_int GDAPI godot_array_find(const godot_array *p_self, const godot_variant *p_what, const godot_int p_from); - -godot_int GDAPI godot_array_find_last(const godot_array *p_self, const godot_variant *p_what); - -godot_bool GDAPI godot_array_has(const godot_array *p_self, const godot_variant *p_value); - -godot_int GDAPI godot_array_hash(const godot_array *p_self); - -void GDAPI godot_array_insert(godot_array *p_self, const godot_int p_pos, const godot_variant *p_value); - -void GDAPI godot_array_invert(godot_array *p_self); - -godot_variant GDAPI godot_array_pop_back(godot_array *p_self); - -godot_variant GDAPI godot_array_pop_front(godot_array *p_self); - -void GDAPI godot_array_push_back(godot_array *p_self, const godot_variant *p_value); - -void GDAPI godot_array_push_front(godot_array *p_self, const godot_variant *p_value); - -void GDAPI godot_array_remove(godot_array *p_self, const godot_int p_idx); - -void GDAPI godot_array_resize(godot_array *p_self, const godot_int p_size); - -godot_int GDAPI godot_array_rfind(const godot_array *p_self, const godot_variant *p_what, const godot_int p_from); - -godot_int GDAPI godot_array_size(const godot_array *p_self); - -void GDAPI godot_array_sort(godot_array *p_self); - -void GDAPI godot_array_sort_custom(godot_array *p_self, godot_object *p_obj, const godot_string *p_func); - -void GDAPI godot_array_destroy(godot_array *p_self); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_ARRAY_H diff --git a/modules/gdnative/godot/basis.cpp b/modules/gdnative/godot/basis.cpp deleted file mode 100644 index 1d7aa18a70..0000000000 --- a/modules/gdnative/godot/basis.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/*************************************************************************/ -/* basis.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/math/matrix3.h" -#include "core/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _basis_api_anchor() {} - -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; - const Vector3 *z_axis = (const Vector3 *)p_z_axis; - Basis *dest = (Basis *)r_dest; - *dest = Basis(*x_axis, *y_axis, *z_axis); -} - -void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *r_dest, const godot_vector3 *p_axis, const godot_real p_phi) { - const Vector3 *axis = (const Vector3 *)p_axis; - Basis *dest = (Basis *)r_dest; - *dest = Basis(*axis, p_phi); -} - -void GDAPI godot_basis_new_with_euler(godot_basis *r_dest, const godot_vector3 *p_euler) { - const Vector3 *euler = (const Vector3 *)p_euler; - Basis *dest = (Basis *)r_dest; - *dest = Basis(*euler); -} - -godot_string GDAPI godot_basis_as_string(const godot_basis *p_self) { - godot_string ret; - const Basis *self = (const Basis *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_basis GDAPI godot_basis_inverse(const godot_basis *p_self) { - godot_basis dest; - const Basis *self = (const Basis *)p_self; - *((Basis *)&dest) = self->inverse(); - return dest; -} - -godot_basis GDAPI godot_basis_transposed(const godot_basis *p_self) { - godot_basis dest; - const Basis *self = (const Basis *)p_self; - *((Basis *)&dest) = self->transposed(); - return dest; -} - -godot_basis GDAPI godot_basis_orthonormalized(const godot_basis *p_self) { - godot_basis dest; - const Basis *self = (const Basis *)p_self; - *((Basis *)&dest) = self->orthonormalized(); - return dest; -} - -godot_real GDAPI godot_basis_determinant(const godot_basis *p_self) { - const Basis *self = (const Basis *)p_self; - return self->determinant(); -} - -godot_basis GDAPI godot_basis_rotated(const godot_basis *p_self, const godot_vector3 *p_axis, const godot_real p_phi) { - godot_basis dest; - const Basis *self = (const Basis *)p_self; - const Vector3 *axis = (const Vector3 *)p_axis; - *((Basis *)&dest) = self->rotated(*axis, p_phi); - return dest; -} - -godot_basis GDAPI godot_basis_scaled(const godot_basis *p_self, const godot_vector3 *p_scale) { - godot_basis dest; - const Basis *self = (const Basis *)p_self; - const Vector3 *scale = (const Vector3 *)p_scale; - *((Basis *)&dest) = self->scaled(*scale); - return dest; -} - -godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self) { - godot_vector3 dest; - const Basis *self = (const Basis *)p_self; - *((Vector3 *)&dest) = self->get_scale(); - return dest; -} - -godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_self) { - godot_vector3 dest; - const Basis *self = (const Basis *)p_self; - *((Vector3 *)&dest) = self->get_euler(); - return dest; -} - -godot_real GDAPI godot_basis_tdotx(const godot_basis *p_self, const godot_vector3 *p_with) { - const Basis *self = (const Basis *)p_self; - const Vector3 *with = (const Vector3 *)p_with; - return self->tdotx(*with); -} - -godot_real GDAPI godot_basis_tdoty(const godot_basis *p_self, const godot_vector3 *p_with) { - const Basis *self = (const Basis *)p_self; - const Vector3 *with = (const Vector3 *)p_with; - return self->tdoty(*with); -} - -godot_real GDAPI godot_basis_tdotz(const godot_basis *p_self, const godot_vector3 *p_with) { - const Basis *self = (const Basis *)p_self; - const Vector3 *with = (const Vector3 *)p_with; - return self->tdotz(*with); -} - -godot_vector3 GDAPI godot_basis_xform(const godot_basis *p_self, const godot_vector3 *p_v) { - godot_vector3 dest; - const Basis *self = (const Basis *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - *((Vector3 *)&dest) = self->xform(*v); - return dest; -} - -godot_vector3 GDAPI godot_basis_xform_inv(const godot_basis *p_self, const godot_vector3 *p_v) { - godot_vector3 dest; - const Basis *self = (const Basis *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - *((Vector3 *)&dest) = self->xform_inv(*v); - return dest; -} - -godot_int GDAPI godot_basis_get_orthogonal_index(const godot_basis *p_self) { - const Basis *self = (const Basis *)p_self; - return self->get_orthogonal_index(); -} - -void GDAPI godot_basis_new(godot_basis *r_dest) { - Basis *dest = (Basis *)r_dest; - *dest = Basis(); -} - -void GDAPI godot_basis_new_with_euler_quat(godot_basis *r_dest, const godot_quat *p_euler) { - Basis *dest = (Basis *)r_dest; - const Quat *euler = (const Quat *)p_euler; - *dest = Basis(*euler); -} - -// p_elements is a pointer to an array of 3 (!!) vector3 -void GDAPI godot_basis_get_elements(godot_basis *p_self, godot_vector3 *p_elements) { - const Basis *self = (const Basis *)p_self; - Vector3 *elements = (Vector3 *)p_elements; - elements[0] = self->elements[0]; - elements[1] = self->elements[1]; - elements[2] = self->elements[2]; -} - -godot_vector3 GDAPI godot_basis_get_axis(const godot_basis *p_self, const godot_int p_axis) { - godot_vector3 dest; - Vector3 *d = (Vector3 *)&dest; - const Basis *self = (const Basis *)p_self; - *d = self->get_axis(p_axis); - return dest; -} - -void GDAPI godot_basis_set_axis(godot_basis *p_self, const godot_int p_axis, const godot_vector3 *p_value) { - Basis *self = (Basis *)p_self; - const Vector3 *value = (const Vector3 *)p_value; - self->set_axis(p_axis, *value); -} - -godot_vector3 GDAPI godot_basis_get_row(const godot_basis *p_self, const godot_int p_row) { - godot_vector3 dest; - Vector3 *d = (Vector3 *)&dest; - const Basis *self = (const Basis *)p_self; - *d = self->get_row(p_row); - return dest; -} - -void GDAPI godot_basis_set_row(godot_basis *p_self, const godot_int p_row, const godot_vector3 *p_value) { - Basis *self = (Basis *)p_self; - const Vector3 *value = (const Vector3 *)p_value; - self->set_row(p_row, *value); -} - -godot_bool GDAPI godot_basis_operator_equal(const godot_basis *p_self, const godot_basis *p_b) { - const Basis *self = (const Basis *)p_self; - const Basis *b = (const Basis *)p_b; - return *self == *b; -} - -godot_basis GDAPI godot_basis_operator_add(const godot_basis *p_self, const godot_basis *p_b) { - godot_basis raw_dest; - Basis *dest = (Basis *)&raw_dest; - const Basis *self = (const Basis *)p_self; - const Basis *b = (const Basis *)p_b; - *dest = *self + *b; - return raw_dest; -} - -godot_basis GDAPI godot_basis_operator_substract(const godot_basis *p_self, const godot_basis *p_b) { - godot_basis raw_dest; - Basis *dest = (Basis *)&raw_dest; - const Basis *self = (const Basis *)p_self; - const Basis *b = (const Basis *)p_b; - *dest = *self - *b; - return raw_dest; -} - -godot_basis GDAPI godot_basis_operator_multiply_vector(const godot_basis *p_self, const godot_basis *p_b) { - godot_basis raw_dest; - Basis *dest = (Basis *)&raw_dest; - const Basis *self = (const Basis *)p_self; - const Basis *b = (const Basis *)p_b; - *dest = *self * *b; - return raw_dest; -} - -godot_basis GDAPI godot_basis_operator_multiply_scalar(const godot_basis *p_self, const godot_real p_b) { - godot_basis raw_dest; - Basis *dest = (Basis *)&raw_dest; - const Basis *self = (const Basis *)p_self; - *dest = *self * p_b; - return raw_dest; -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/basis.h b/modules/gdnative/godot/basis.h deleted file mode 100644 index f36d2199de..0000000000 --- a/modules/gdnative/godot/basis.h +++ /dev/null @@ -1,115 +0,0 @@ -/*************************************************************************/ -/* basis.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_BASIS_H -#define GODOT_BASIS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define GODOT_BASIS_SIZE 36 - -#ifndef GODOT_CORE_API_GODOT_BASIS_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_BASIS_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_BASIS_SIZE]; -} godot_basis; -#endif - -#include -#include -#include - -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); -void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *r_dest, const godot_vector3 *p_axis, const godot_real p_phi); -void GDAPI godot_basis_new_with_euler(godot_basis *r_dest, const godot_vector3 *p_euler); - -godot_string GDAPI godot_basis_as_string(const godot_basis *p_self); - -godot_basis GDAPI godot_basis_inverse(const godot_basis *p_self); - -godot_basis GDAPI godot_basis_transposed(const godot_basis *p_self); - -godot_basis GDAPI godot_basis_orthonormalized(const godot_basis *p_self); - -godot_real GDAPI godot_basis_determinant(const godot_basis *p_self); - -godot_basis GDAPI godot_basis_rotated(const godot_basis *p_self, const godot_vector3 *p_axis, const godot_real p_phi); - -godot_basis GDAPI godot_basis_scaled(const godot_basis *p_self, const godot_vector3 *p_scale); - -godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self); - -godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_self); - -godot_real GDAPI godot_basis_tdotx(const godot_basis *p_self, const godot_vector3 *p_with); - -godot_real GDAPI godot_basis_tdoty(const godot_basis *p_self, const godot_vector3 *p_with); - -godot_real GDAPI godot_basis_tdotz(const godot_basis *p_self, const godot_vector3 *p_with); - -godot_vector3 GDAPI godot_basis_xform(const godot_basis *p_self, const godot_vector3 *p_v); - -godot_vector3 GDAPI godot_basis_xform_inv(const godot_basis *p_self, const godot_vector3 *p_v); - -godot_int GDAPI godot_basis_get_orthogonal_index(const godot_basis *p_self); - -void GDAPI godot_basis_new(godot_basis *r_dest); - -void GDAPI godot_basis_new_with_euler_quat(godot_basis *r_dest, const godot_quat *p_euler); - -// p_elements is a pointer to an array of 3 (!!) vector3 -void GDAPI godot_basis_get_elements(godot_basis *p_self, godot_vector3 *p_elements); - -godot_vector3 GDAPI godot_basis_get_axis(const godot_basis *p_self, const godot_int p_axis); - -void GDAPI godot_basis_set_axis(godot_basis *p_self, const godot_int p_axis, const godot_vector3 *p_value); - -godot_vector3 GDAPI godot_basis_get_row(const godot_basis *p_self, const godot_int p_row); - -void GDAPI godot_basis_set_row(godot_basis *p_self, const godot_int p_row, const godot_vector3 *p_value); - -godot_bool GDAPI godot_basis_operator_equal(const godot_basis *p_self, const godot_basis *p_b); - -godot_basis GDAPI godot_basis_operator_add(const godot_basis *p_self, const godot_basis *p_b); - -godot_basis GDAPI godot_basis_operator_substract(const godot_basis *p_self, const godot_basis *p_b); - -godot_basis GDAPI godot_basis_operator_multiply_vector(const godot_basis *p_self, const godot_basis *p_b); - -godot_basis GDAPI godot_basis_operator_multiply_scalar(const godot_basis *p_self, const godot_real p_b); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_BASIS_H diff --git a/modules/gdnative/godot/color.cpp b/modules/gdnative/godot/color.cpp deleted file mode 100644 index 3677fdc265..0000000000 --- a/modules/gdnative/godot/color.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/*************************************************************************/ -/* color.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/color.h" -#include "core/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _color_api_anchor() {} - -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); -} - -void GDAPI godot_color_new_rgb(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b) { - - Color *dest = (Color *)r_dest; - *dest = Color(p_r, p_g, p_b); -} - -godot_real godot_color_get_r(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->r; -} - -void godot_color_set_r(godot_color *p_self, const godot_real val) { - Color *self = (Color *)p_self; - self->r = val; -} - -godot_real godot_color_get_g(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->g; -} - -void godot_color_set_g(godot_color *p_self, const godot_real val) { - Color *self = (Color *)p_self; - self->g = val; -} - -godot_real godot_color_get_b(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->b; -} - -void godot_color_set_b(godot_color *p_self, const godot_real val) { - Color *self = (Color *)p_self; - self->b = val; -} - -godot_real godot_color_get_a(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->a; -} - -void godot_color_set_a(godot_color *p_self, const godot_real val) { - Color *self = (Color *)p_self; - self->a = val; -} - -godot_real godot_color_get_h(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->get_h(); -} - -godot_real godot_color_get_s(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->get_s(); -} - -godot_real godot_color_get_v(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->get_v(); -} - -godot_string GDAPI godot_color_as_string(const godot_color *p_self) { - godot_string ret; - const Color *self = (const Color *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_int GDAPI godot_color_to_32(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->to_32(); -} - -godot_int GDAPI godot_color_to_ARGB32(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->to_ARGB32(); -} - -godot_real GDAPI godot_color_gray(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->gray(); -} - -godot_color GDAPI godot_color_inverted(const godot_color *p_self) { - godot_color dest; - const Color *self = (const Color *)p_self; - *((Color *)&dest) = self->inverted(); - return dest; -} - -godot_color GDAPI godot_color_contrasted(const godot_color *p_self) { - godot_color dest; - const Color *self = (const Color *)p_self; - *((Color *)&dest) = self->contrasted(); - return dest; -} - -godot_color GDAPI godot_color_linear_interpolate(const godot_color *p_self, const godot_color *p_b, const godot_real p_t) { - godot_color dest; - const Color *self = (const Color *)p_self; - const Color *b = (const Color *)p_b; - *((Color *)&dest) = self->linear_interpolate(*b, p_t); - return dest; -} - -godot_color GDAPI godot_color_blend(const godot_color *p_self, const godot_color *p_over) { - godot_color dest; - const Color *self = (const Color *)p_self; - const Color *over = (const Color *)p_over; - *((Color *)&dest) = self->blend(*over); - return dest; -} - -godot_string GDAPI godot_color_to_html(const godot_color *p_self, const godot_bool p_with_alpha) { - godot_string dest; - const Color *self = (const Color *)p_self; - - memnew_placement(&dest, String(self->to_html(p_with_alpha))); - return dest; -} - -godot_bool GDAPI godot_color_operator_equal(const godot_color *p_self, const godot_color *p_b) { - const Color *self = (const Color *)p_self; - const Color *b = (const Color *)p_b; - return *self == *b; -} - -godot_bool GDAPI godot_color_operator_less(const godot_color *p_self, const godot_color *p_b) { - const Color *self = (const Color *)p_self; - const Color *b = (const Color *)p_b; - return *self < *b; -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/color.h b/modules/gdnative/godot/color.h deleted file mode 100644 index 5d550e40b3..0000000000 --- a/modules/gdnative/godot/color.h +++ /dev/null @@ -1,96 +0,0 @@ -/*************************************************************************/ -/* color.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_COLOR_H -#define GODOT_COLOR_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define GODOT_COLOR_SIZE 16 - -#ifndef GODOT_CORE_API_GODOT_COLOR_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_COLOR_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_COLOR_SIZE]; -} godot_color; -#endif - -#include -#include - -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); -void GDAPI godot_color_new_rgb(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b); - -godot_real godot_color_get_r(const godot_color *p_self); -void godot_color_set_r(godot_color *p_self, const godot_real r); - -godot_real godot_color_get_g(const godot_color *p_self); -void godot_color_set_g(godot_color *p_self, const godot_real g); - -godot_real godot_color_get_b(const godot_color *p_self); -void godot_color_set_b(godot_color *p_self, const godot_real b); - -godot_real godot_color_get_a(const godot_color *p_self); -void godot_color_set_a(godot_color *p_self, const godot_real a); - -godot_real godot_color_get_h(const godot_color *p_self); -godot_real godot_color_get_s(const godot_color *p_self); -godot_real godot_color_get_v(const godot_color *p_self); - -godot_string GDAPI godot_color_as_string(const godot_color *p_self); - -godot_int GDAPI godot_color_to_32(const godot_color *p_self); - -godot_int GDAPI godot_color_to_ARGB32(const godot_color *p_self); - -godot_real GDAPI godot_color_gray(const godot_color *p_self); - -godot_color GDAPI godot_color_inverted(const godot_color *p_self); - -godot_color GDAPI godot_color_contrasted(const godot_color *p_self); - -godot_color GDAPI godot_color_linear_interpolate(const godot_color *p_self, const godot_color *p_b, const godot_real p_t); - -godot_color GDAPI godot_color_blend(const godot_color *p_self, const godot_color *p_over); - -godot_string GDAPI godot_color_to_html(const godot_color *p_self, const godot_bool p_with_alpha); - -godot_bool GDAPI godot_color_operator_equal(const godot_color *p_self, const godot_color *p_b); - -godot_bool GDAPI godot_color_operator_less(const godot_color *p_self, const godot_color *p_b); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_COLOR_H diff --git a/modules/gdnative/godot/dictionary.cpp b/modules/gdnative/godot/dictionary.cpp deleted file mode 100644 index 2996cc78a3..0000000000 --- a/modules/gdnative/godot/dictionary.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/*************************************************************************/ -/* dictionary.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/variant.h" -// core/variant.h before to avoid compile errors with MSVC -#include "core/dictionary.h" -#include "core/io/json.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _dictionary_api_anchor() {} - -void GDAPI godot_dictionary_new(godot_dictionary *r_dest) { - Dictionary *dest = (Dictionary *)r_dest; - memnew_placement(dest, Dictionary); -} - -void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src) { - Dictionary *dest = (Dictionary *)r_dest; - const Dictionary *src = (const Dictionary *)p_src; - memnew_placement(dest, Dictionary(*src)); -} - -void GDAPI godot_dictionary_destroy(godot_dictionary *p_self) { - Dictionary *self = (Dictionary *)p_self; - self->~Dictionary(); -} - -godot_int GDAPI godot_dictionary_size(const godot_dictionary *p_self) { - const Dictionary *self = (const Dictionary *)p_self; - return self->size(); -} - -godot_bool GDAPI godot_dictionary_empty(const godot_dictionary *p_self) { - const Dictionary *self = (const Dictionary *)p_self; - return self->empty(); -} - -void GDAPI godot_dictionary_clear(godot_dictionary *p_self) { - Dictionary *self = (Dictionary *)p_self; - self->clear(); -} - -godot_bool GDAPI godot_dictionary_has(const godot_dictionary *p_self, const godot_variant *p_key) { - const Dictionary *self = (const Dictionary *)p_self; - const Variant *key = (const Variant *)p_key; - return self->has(*key); -} - -godot_bool GDAPI godot_dictionary_has_all(const godot_dictionary *p_self, const godot_array *p_keys) { - const Dictionary *self = (const Dictionary *)p_self; - const Array *keys = (const Array *)p_keys; - return self->has_all(*keys); -} - -void GDAPI godot_dictionary_erase(godot_dictionary *p_self, const godot_variant *p_key) { - Dictionary *self = (Dictionary *)p_self; - const Variant *key = (const Variant *)p_key; - self->erase(*key); -} - -godot_int GDAPI godot_dictionary_hash(const godot_dictionary *p_self) { - const Dictionary *self = (const Dictionary *)p_self; - return self->hash(); -} - -godot_array GDAPI godot_dictionary_keys(const godot_dictionary *p_self) { - godot_array dest; - const Dictionary *self = (const Dictionary *)p_self; - memnew_placement(&dest, Array(self->keys())); - return dest; -} - -godot_array GDAPI godot_dictionary_values(const godot_dictionary *p_self) { - godot_array dest; - const Dictionary *self = (const Dictionary *)p_self; - memnew_placement(&dest, Array(self->values())); - return dest; -} - -godot_variant GDAPI godot_dictionary_get(const godot_dictionary *p_self, const godot_variant *p_key) { - godot_variant raw_dest; - Variant *dest = (Variant *)&raw_dest; - const Dictionary *self = (const Dictionary *)p_self; - const Variant *key = (const Variant *)p_key; - memnew_placement(dest, Variant(self->operator[](*key))); - return raw_dest; -} - -void GDAPI godot_dictionary_set(godot_dictionary *p_self, const godot_variant *p_key, const godot_variant *p_value) { - Dictionary *self = (Dictionary *)p_self; - const Variant *key = (const Variant *)p_key; - const Variant *value = (const Variant *)p_value; - self->operator[](*key) = *value; -} - -godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key) { - Dictionary *self = (Dictionary *)p_self; - const Variant *key = (const Variant *)p_key; - return (godot_variant *)&self->operator[](*key); -} - -godot_variant GDAPI *godot_dictionary_next(const godot_dictionary *p_self, const godot_variant *p_key) { - Dictionary *self = (Dictionary *)p_self; - const Variant *key = (const Variant *)p_key; - return (godot_variant *)self->next(key); -} - -godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self, const godot_dictionary *p_b) { - const Dictionary *self = (const Dictionary *)p_self; - const Dictionary *b = (const Dictionary *)p_b; - return *self == *b; -} - -godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self) { - godot_string raw_dest; - String *dest = (String *)&raw_dest; - const Dictionary *self = (const Dictionary *)p_self; - memnew_placement(dest, String(JSON::print(Variant(*self)))); - return raw_dest; -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/dictionary.h b/modules/gdnative/godot/dictionary.h deleted file mode 100644 index 10d580af08..0000000000 --- a/modules/gdnative/godot/dictionary.h +++ /dev/null @@ -1,89 +0,0 @@ -/*************************************************************************/ -/* dictionary.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_DICTIONARY_H -#define GODOT_DICTIONARY_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define GODOT_DICTIONARY_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_DICTIONARY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_DICTIONARY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_DICTIONARY_SIZE]; -} godot_dictionary; -#endif - -#include -#include -#include - -void GDAPI godot_dictionary_new(godot_dictionary *r_dest); -void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src); -void GDAPI godot_dictionary_destroy(godot_dictionary *p_self); - -godot_int GDAPI godot_dictionary_size(const godot_dictionary *p_self); - -godot_bool GDAPI godot_dictionary_empty(const godot_dictionary *p_self); - -void GDAPI godot_dictionary_clear(godot_dictionary *p_self); - -godot_bool GDAPI godot_dictionary_has(const godot_dictionary *p_self, const godot_variant *p_key); - -godot_bool GDAPI godot_dictionary_has_all(const godot_dictionary *p_self, const godot_array *p_keys); - -void GDAPI godot_dictionary_erase(godot_dictionary *p_self, const godot_variant *p_key); - -godot_int GDAPI godot_dictionary_hash(const godot_dictionary *p_self); - -godot_array GDAPI godot_dictionary_keys(const godot_dictionary *p_self); - -godot_array GDAPI godot_dictionary_values(const godot_dictionary *p_self); - -godot_variant GDAPI godot_dictionary_get(const godot_dictionary *p_self, const godot_variant *p_key); -void GDAPI godot_dictionary_set(godot_dictionary *p_self, const godot_variant *p_key, const godot_variant *p_value); - -godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key); - -godot_variant GDAPI *godot_dictionary_next(const godot_dictionary *p_self, const godot_variant *p_key); - -godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self, const godot_dictionary *p_b); - -godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_DICTIONARY_H diff --git a/modules/gdnative/godot/gdnative.cpp b/modules/gdnative/godot/gdnative.cpp deleted file mode 100644 index 7cd52da34d..0000000000 --- a/modules/gdnative/godot/gdnative.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/*************************************************************************/ -/* gdnative.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "class_db.h" -#include "error_macros.h" -#include "gdnative.h" -#include "global_constants.h" -#include "os/os.h" -#include "project_settings.h" -#include "variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern "C" void _string_api_anchor(); -extern "C" void _vector2_api_anchor(); -extern "C" void _rect2_api_anchor(); -extern "C" void _vector3_api_anchor(); -extern "C" void _transform2d_api_anchor(); -extern "C" void _plane_api_anchor(); -extern "C" void _quat_api_anchor(); -extern "C" void _basis_api_anchor(); -extern "C" void _rect3_api_anchor(); -extern "C" void _transform_api_anchor(); -extern "C" void _color_api_anchor(); -extern "C" void _node_path_api_anchor(); -extern "C" void _rid_api_anchor(); -extern "C" void _dictionary_api_anchor(); -extern "C" void _array_api_anchor(); -extern "C" void _pool_arrays_api_anchor(); -extern "C" void _variant_api_anchor(); - -void _api_anchor() { - - _string_api_anchor(); - _vector2_api_anchor(); - _rect2_api_anchor(); - _vector3_api_anchor(); - _transform2d_api_anchor(); - _plane_api_anchor(); - _quat_api_anchor(); - _rect3_api_anchor(); - _basis_api_anchor(); - _transform_api_anchor(); - _color_api_anchor(); - _node_path_api_anchor(); - _rid_api_anchor(); - _dictionary_api_anchor(); - _array_api_anchor(); - _pool_arrays_api_anchor(); - _variant_api_anchor(); -} - -void GDAPI godot_object_destroy(godot_object *p_o) { - memdelete((Object *)p_o); -} - -// Singleton API - -godot_object GDAPI *godot_global_get_singleton(char *p_name) { - return (godot_object *)ProjectSettings::get_singleton()->get_singleton_object(String(p_name)); -} // result shouldn't be freed - -void GDAPI *godot_get_stack_bottom() { - return OS::get_singleton()->get_stack_bottom(); -} - -// MethodBind API - -godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname) { - - MethodBind *mb = ClassDB::get_method(StringName(p_classname), StringName(p_methodname)); - // MethodBind *mb = ClassDB::get_method("Node", "get_name"); - return (godot_method_bind *)mb; -} - -void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_object *p_instance, const void **p_args, void *p_ret) { - - MethodBind *mb = (MethodBind *)p_method_bind; - Object *o = (Object *)p_instance; - mb->ptrcall(o, p_args, p_ret); -} - -godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, godot_object *p_instance, const godot_variant **p_args, const int p_arg_count, godot_variant_call_error *p_call_error) { - MethodBind *mb = (MethodBind *)p_method_bind; - Object *o = (Object *)p_instance; - const Variant **args = (const Variant **)p_args; - - godot_variant ret; - godot_variant_new_nil(&ret); - - Variant *ret_val = (Variant *)&ret; - - Variant::CallError r_error; - *ret_val = mb->call(o, args, p_arg_count, r_error); - - if (p_call_error) { - p_call_error->error = (godot_variant_call_error_error)r_error.error; - p_call_error->argument = r_error.argument; - p_call_error->expected = (godot_variant_type)r_error.expected; - } - - return ret; -} - -// @Todo -/* -void GDAPI godot_method_bind_varcall(godot_method_bind *p_method_bind) -{ - -} -*/ - -godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname) { - ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname)); - if (class_info) - return (godot_class_constructor)class_info->creation_func; - return NULL; -} - -godot_dictionary GDAPI godot_get_global_constants() { - godot_dictionary constants; - godot_dictionary_new(&constants); - Dictionary *p_constants = (Dictionary *)&constants; - const int constants_count = GlobalConstants::get_global_constant_count(); - for (int i = 0; i < constants_count; ++i) { - const char *name = GlobalConstants::get_global_constant_name(i); - int value = GlobalConstants::get_global_constant_value(i); - (*p_constants)[name] = value; - } - return constants; -} - -// System functions -void GDAPI *godot_alloc(int p_bytes) { - return memalloc(p_bytes); -} - -void GDAPI *godot_realloc(void *p_ptr, int p_bytes) { - return memrealloc(p_ptr, p_bytes); -} - -void GDAPI godot_free(void *p_ptr) { - memfree(p_ptr); -} - -void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line) { - _err_print_error(p_function, p_file, p_line, p_description, ERR_HANDLER_ERROR); -} - -void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line) { - _err_print_error(p_function, p_file, p_line, p_description, ERR_HANDLER_WARNING); -} - -void GDAPI godot_print(const godot_string *p_message) { - print_line(*(String *)p_message); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/gdnative.h b/modules/gdnative/godot/gdnative.h deleted file mode 100644 index c71a7ae1ef..0000000000 --- a/modules/gdnative/godot/gdnative.h +++ /dev/null @@ -1,303 +0,0 @@ -/*************************************************************************/ -/* gdnative.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_GDNATIVE_H -#define GODOT_GDNATIVE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef GDAPI_BUILT_IN -#define GDAPI_EXPORT -#endif - -#ifdef _WIN32 -#if defined(GDAPI_EXPORT) -#define GDCALLINGCONV -#define GDAPI __declspec(dllexport) GDCALLINGCONV -#else -#define GDCALLINGCONV -#define GDAPI __declspec(dllimport) GDCALLINGCONV -#endif -#elif defined(__APPLE__) -#include "TargetConditionals.h" -#if TARGET_OS_IPHONE -#define GDCALLINGCONV -#define GDAPI -#elif TARGET_OS_MAC -#define GDCALLINGCONV __attribute__((sysv_abi)) -#define GDAPI GDCALLINGCONV -#endif -#else -#define GDCALLINGCONV __attribute__((sysv_abi, visibility("default"))) -#define GDAPI GDCALLINGCONV -#endif - -// This is for libraries *using* the header, NOT GODOT EXPOSING STUFF!! -#ifdef _WIN32 -#define GDN_EXPORT __declspec(dllexport) -#else -#define GDN_EXPORT -#endif - -#include -#include - -#define GODOT_API_VERSION 1 - -////// Error - -typedef enum { - GODOT_OK, - GODOT_FAILED, ///< Generic fail error - GODOT_ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable - GODOT_ERR_UNCONFIGURED, ///< The object being used hasnt been properly set up yet - GODOT_ERR_UNAUTHORIZED, ///< Missing credentials for requested resource - GODOT_ERR_PARAMETER_RANGE_ERROR, ///< Parameter given out of range (5) - GODOT_ERR_OUT_OF_MEMORY, ///< Out of memory - GODOT_ERR_FILE_NOT_FOUND, - GODOT_ERR_FILE_BAD_DRIVE, - GODOT_ERR_FILE_BAD_PATH, - GODOT_ERR_FILE_NO_PERMISSION, // (10) - GODOT_ERR_FILE_ALREADY_IN_USE, - GODOT_ERR_FILE_CANT_OPEN, - GODOT_ERR_FILE_CANT_WRITE, - GODOT_ERR_FILE_CANT_READ, - GODOT_ERR_FILE_UNRECOGNIZED, // (15) - GODOT_ERR_FILE_CORRUPT, - GODOT_ERR_FILE_MISSING_DEPENDENCIES, - GODOT_ERR_FILE_EOF, - GODOT_ERR_CANT_OPEN, ///< Can't open a resource/socket/file - GODOT_ERR_CANT_CREATE, // (20) - GODOT_ERR_QUERY_FAILED, - GODOT_ERR_ALREADY_IN_USE, - GODOT_ERR_LOCKED, ///< resource is locked - GODOT_ERR_TIMEOUT, - GODOT_ERR_CANT_CONNECT, // (25) - GODOT_ERR_CANT_RESOLVE, - GODOT_ERR_CONNECTION_ERROR, - GODOT_ERR_CANT_AQUIRE_RESOURCE, - GODOT_ERR_CANT_FORK, - GODOT_ERR_INVALID_DATA, ///< Data passed is invalid (30) - GODOT_ERR_INVALID_PARAMETER, ///< Parameter passed is invalid - GODOT_ERR_ALREADY_EXISTS, ///< When adding, item already exists - GODOT_ERR_DOES_NOT_EXIST, ///< When retrieving/erasing, it item does not exist - GODOT_ERR_DATABASE_CANT_READ, ///< database is full - GODOT_ERR_DATABASE_CANT_WRITE, ///< database is full (35) - GODOT_ERR_COMPILATION_FAILED, - GODOT_ERR_METHOD_NOT_FOUND, - GODOT_ERR_LINK_FAILED, - GODOT_ERR_SCRIPT_FAILED, - GODOT_ERR_CYCLIC_LINK, // (40) - GODOT_ERR_INVALID_DECLARATION, - GODOT_ERR_DUPLICATE_SYMBOL, - GODOT_ERR_PARSE_ERROR, - GODOT_ERR_BUSY, - GODOT_ERR_SKIP, // (45) - GODOT_ERR_HELP, ///< user requested help!! - GODOT_ERR_BUG, ///< a bug in the software certainly happened, due to a double check failing or unexpected behavior. - GODOT_ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames - GODOT_ERR_OMFG_THIS_IS_VERY_VERY_BAD, ///< shit happens, has never been used, though - GODOT_ERR_WTF = GODOT_ERR_OMFG_THIS_IS_VERY_VERY_BAD ///< short version of the above -} godot_error; - -////// bool - -typedef bool godot_bool; - -#define GODOT_TRUE 1 -#define GODOT_FALSE 0 - -/////// int - -typedef int godot_int; - -/////// real - -typedef float godot_real; - -/////// Object (forward declared) -typedef void godot_object; - -/////// Brute force forward declarations for the rest -/* -typedef struct godot_variant godot_variant; -typedef struct godot_string godot_string; -typedef struct godot_vector2 godot_vector2; -typedef struct godot_rect2 godot_rect2; -typedef struct godot_vector3 godot_vector3; -typedef struct godot_transform2d godot_transform2d; -typedef struct godot_plane godot_plane; -typedef struct godot_quat godot_quat; -typedef struct godot_rect3 godot_rect3; -typedef struct godot_basis godot_basis; -typedef struct godot_transform godot_transform; -typedef struct godot_color godot_color; -typedef struct godot_node_path godot_node_path; -typedef struct godot_rid godot_rid; -typedef struct godot_dictionary godot_dictionary; -typedef struct godot_array godot_array; -typedef struct godot_pool_byte_array godot_pool_byte_array; -typedef struct godot_pool_int_array godot_pool_int_array; -typedef struct godot_pool_real_array godot_pool_real_array; -typedef struct godot_pool_string_array godot_pool_string_array; -typedef struct godot_pool_vector2_array godot_pool_vector2_array; -typedef struct godot_pool_vector3_array godot_pool_vector3_array; -typedef struct godot_pool_color_array godot_pool_color_array; -*/ -/////// String - -#include - -////// Vector2 - -#include - -////// Rect2 - -#include - -////// Vector3 - -#include - -////// Transform2D - -#include - -/////// Plane - -#include - -/////// Quat - -#include - -/////// Rect3 - -#include - -/////// Basis - -#include - -/////// Transform - -#include - -/////// Color - -#include - -/////// NodePath - -#include - -/////// RID - -#include - -/////// Dictionary - -#include - -/////// Array - -#include - -// single API file for Pool*Array -#include - -void GDAPI godot_object_destroy(godot_object *p_o); - -////// Variant - -#include - -////// Singleton API - -godot_object GDAPI *godot_global_get_singleton(char *p_name); // result shouldn't be freed - -////// OS API - -void GDAPI *godot_get_stack_bottom(); // returns stack bottom of the main thread - -////// MethodBind API - -typedef struct { - uint8_t _dont_touch_that[1]; // TODO -} godot_method_bind; - -godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname); -void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_object *p_instance, const void **p_args, void *p_ret); -godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, godot_object *p_instance, const godot_variant **p_args, const int p_arg_count, godot_variant_call_error *p_call_error); -////// Script API - -typedef struct { - godot_bool in_editor; - uint64_t core_api_hash; - uint64_t editor_api_hash; - uint64_t no_api_hash; - godot_object *gd_native_library; // pointer to GDNativeLibrary that is being initialized -} godot_gdnative_init_options; - -typedef struct { - godot_bool in_editor; -} godot_gdnative_terminate_options; - -// Calling convention? -typedef godot_object *(*godot_class_constructor)(); - -godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname); - -godot_dictionary GDAPI godot_get_global_constants(); - -////// GDNative procedure types -typedef void (*godot_gdnative_init_fn)(godot_gdnative_init_options *); -typedef void (*godot_gdnative_terminate_fn)(godot_gdnative_terminate_options *); -typedef godot_variant (*godot_gdnative_procedure_fn)(void *, godot_array *); - -////// System Functions - -//using these will help Godot track how much memory is in use in debug mode -void GDAPI *godot_alloc(int p_bytes); -void GDAPI *godot_realloc(void *p_ptr, int p_bytes); -void GDAPI godot_free(void *p_ptr); - -//print using Godot's error handler list -void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line); -void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line); -void GDAPI godot_print(const godot_string *p_message); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_C_H diff --git a/modules/gdnative/godot/icon.png.import b/modules/gdnative/godot/icon.png.import deleted file mode 100644 index 27920124f9..0000000000 --- a/modules/gdnative/godot/icon.png.import +++ /dev/null @@ -1,23 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture" -path="res://.import/icon.png-aa47d037a37fb38b3b7e7828e4eec407.stex" - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 -process/fix_alpha_border=true -process/premult_alpha=false -process/HDR_as_SRGB=false -stream=false -size_limit=0 -detect_3d=true diff --git a/modules/gdnative/godot/node_path.cpp b/modules/gdnative/godot/node_path.cpp deleted file mode 100644 index 2309588a81..0000000000 --- a/modules/gdnative/godot/node_path.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/*************************************************************************/ -/* node_path.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/node_path.h" -#include "core/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _node_path_api_anchor() {} - -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; - memnew_placement(dest, NodePath(*from)); -} - -void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src) { - NodePath *dest = (NodePath *)r_dest; - const NodePath *src = (const NodePath *)p_src; - memnew_placement(dest, NodePath(*src)); -} - -void GDAPI godot_node_path_destroy(godot_node_path *p_self) { - NodePath *self = (NodePath *)p_self; - self->~NodePath(); -} - -godot_string GDAPI godot_node_path_as_string(const godot_node_path *p_self) { - godot_string ret; - const NodePath *self = (const NodePath *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_bool GDAPI godot_node_path_is_absolute(const godot_node_path *p_self) { - const NodePath *self = (const NodePath *)p_self; - return self->is_absolute(); -} - -godot_int GDAPI godot_node_path_get_name_count(const godot_node_path *p_self) { - const NodePath *self = (const NodePath *)p_self; - return self->get_name_count(); -} - -godot_string GDAPI godot_node_path_get_name(const godot_node_path *p_self, const godot_int p_idx) { - godot_string dest; - const NodePath *self = (const NodePath *)p_self; - - memnew_placement(&dest, String(self->get_name(p_idx))); - return dest; -} - -godot_int GDAPI godot_node_path_get_subname_count(const godot_node_path *p_self) { - const NodePath *self = (const NodePath *)p_self; - return self->get_subname_count(); -} - -godot_string GDAPI godot_node_path_get_subname(const godot_node_path *p_self, const godot_int p_idx) { - godot_string dest; - const NodePath *self = (const NodePath *)p_self; - - memnew_placement(&dest, String(self->get_subname(p_idx))); - return dest; -} - -godot_string GDAPI godot_node_path_get_property(const godot_node_path *p_self) { - godot_string dest; - const NodePath *self = (const NodePath *)p_self; - memnew_placement(&dest, String(self->get_property())); - return dest; -} - -godot_bool GDAPI godot_node_path_is_empty(const godot_node_path *p_self) { - const NodePath *self = (const NodePath *)p_self; - return self->is_empty(); -} - -godot_bool GDAPI godot_node_path_operator_equal(const godot_node_path *p_self, const godot_node_path *p_b) { - const NodePath *self = (const NodePath *)p_self; - const NodePath *b = (const NodePath *)p_b; - return *self == *b; -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/node_path.h b/modules/gdnative/godot/node_path.h deleted file mode 100644 index 2f71ddd59d..0000000000 --- a/modules/gdnative/godot/node_path.h +++ /dev/null @@ -1,77 +0,0 @@ -/*************************************************************************/ -/* node_path.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_NODE_PATH_H -#define GODOT_NODE_PATH_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define GODOT_NODE_PATH_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_NODE_PATH_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_NODE_PATH_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_NODE_PATH_SIZE]; -} godot_node_path; -#endif - -#include -#include - -void GDAPI godot_node_path_new(godot_node_path *r_dest, const godot_string *p_from); -void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src); -void GDAPI godot_node_path_destroy(godot_node_path *p_self); - -godot_string GDAPI godot_node_path_as_string(const godot_node_path *p_self); - -godot_bool GDAPI godot_node_path_is_absolute(const godot_node_path *p_self); - -godot_int GDAPI godot_node_path_get_name_count(const godot_node_path *p_self); - -godot_string GDAPI godot_node_path_get_name(const godot_node_path *p_self, const godot_int p_idx); - -godot_int GDAPI godot_node_path_get_subname_count(const godot_node_path *p_self); - -godot_string GDAPI godot_node_path_get_subname(const godot_node_path *p_self, const godot_int p_idx); - -godot_string GDAPI godot_node_path_get_property(const godot_node_path *p_self); - -godot_bool GDAPI godot_node_path_is_empty(const godot_node_path *p_self); - -godot_bool GDAPI godot_node_path_operator_equal(const godot_node_path *p_self, const godot_node_path *p_b); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_NODE_PATH_H diff --git a/modules/gdnative/godot/plane.cpp b/modules/gdnative/godot/plane.cpp deleted file mode 100644 index f3d4b6971e..0000000000 --- a/modules/gdnative/godot/plane.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/*************************************************************************/ -/* plane.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/math/plane.h" -#include "core/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _plane_api_anchor() {} - -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); -} - -void GDAPI godot_plane_new_with_vectors(godot_plane *r_dest, const godot_vector3 *p_v1, const godot_vector3 *p_v2, const godot_vector3 *p_v3) { - const Vector3 *v1 = (const Vector3 *)p_v1; - const Vector3 *v2 = (const Vector3 *)p_v2; - const Vector3 *v3 = (const Vector3 *)p_v3; - Plane *dest = (Plane *)r_dest; - *dest = Plane(*v1, *v2, *v3); -} - -void GDAPI godot_plane_new_with_normal(godot_plane *r_dest, const godot_vector3 *p_normal, const godot_real p_d) { - const Vector3 *normal = (const Vector3 *)p_normal; - Plane *dest = (Plane *)r_dest; - *dest = Plane(*normal, p_d); -} - -godot_string GDAPI godot_plane_as_string(const godot_plane *p_self) { - godot_string ret; - const Plane *self = (const Plane *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_plane GDAPI godot_plane_normalized(const godot_plane *p_self) { - godot_plane dest; - const Plane *self = (const Plane *)p_self; - *((Plane *)&dest) = self->normalized(); - return dest; -} - -godot_vector3 GDAPI godot_plane_center(const godot_plane *p_self) { - godot_vector3 dest; - const Plane *self = (const Plane *)p_self; - *((Vector3 *)&dest) = self->center(); - return dest; -} - -godot_vector3 GDAPI godot_plane_get_any_point(const godot_plane *p_self) { - godot_vector3 dest; - const Plane *self = (const Plane *)p_self; - *((Vector3 *)&dest) = self->get_any_point(); - return dest; -} - -godot_bool GDAPI godot_plane_is_point_over(const godot_plane *p_self, const godot_vector3 *p_point) { - const Plane *self = (const Plane *)p_self; - const Vector3 *point = (const Vector3 *)p_point; - return self->is_point_over(*point); -} - -godot_real GDAPI godot_plane_distance_to(const godot_plane *p_self, const godot_vector3 *p_point) { - const Plane *self = (const Plane *)p_self; - const Vector3 *point = (const Vector3 *)p_point; - return self->distance_to(*point); -} - -godot_bool GDAPI godot_plane_has_point(const godot_plane *p_self, const godot_vector3 *p_point, const godot_real p_epsilon) { - const Plane *self = (const Plane *)p_self; - const Vector3 *point = (const Vector3 *)p_point; - return self->has_point(*point, p_epsilon); -} - -godot_vector3 GDAPI godot_plane_project(const godot_plane *p_self, const godot_vector3 *p_point) { - godot_vector3 dest; - const Plane *self = (const Plane *)p_self; - const Vector3 *point = (const Vector3 *)p_point; - *((Vector3 *)&dest) = self->project(*point); - return dest; -} - -godot_bool GDAPI godot_plane_intersect_3(const godot_plane *p_self, godot_vector3 *r_dest, const godot_plane *p_b, const godot_plane *p_c) { - const Plane *self = (const Plane *)p_self; - const Plane *b = (const Plane *)p_b; - const Plane *c = (const Plane *)p_c; - Vector3 *dest = (Vector3 *)r_dest; - return self->intersect_3(*b, *c, dest); -} - -godot_bool GDAPI godot_plane_intersects_ray(const godot_plane *p_self, godot_vector3 *r_dest, const godot_vector3 *p_from, const godot_vector3 *p_dir) { - const Plane *self = (const Plane *)p_self; - const Vector3 *from = (const Vector3 *)p_from; - const Vector3 *dir = (const Vector3 *)p_dir; - Vector3 *dest = (Vector3 *)r_dest; - return self->intersects_ray(*from, *dir, dest); -} - -godot_bool GDAPI godot_plane_intersects_segment(const godot_plane *p_self, godot_vector3 *r_dest, const godot_vector3 *p_begin, const godot_vector3 *p_end) { - const Plane *self = (const Plane *)p_self; - const Vector3 *begin = (const Vector3 *)p_begin; - const Vector3 *end = (const Vector3 *)p_end; - Vector3 *dest = (Vector3 *)r_dest; - return self->intersects_segment(*begin, *end, dest); -} - -godot_plane GDAPI godot_plane_operator_neg(const godot_plane *p_self) { - godot_plane raw_dest; - Plane *dest = (Plane *)&raw_dest; - const Plane *self = (const Plane *)p_self; - *dest = -(*self); - return raw_dest; -} - -godot_bool GDAPI godot_plane_operator_equal(const godot_plane *p_self, const godot_plane *p_b) { - const Plane *self = (const Plane *)p_self; - const Plane *b = (const Plane *)p_b; - return *self == *b; -} - -void GDAPI godot_plane_set_normal(godot_plane *p_self, const godot_vector3 *p_normal) { - Plane *self = (Plane *)p_self; - const Vector3 *normal = (const Vector3 *)p_normal; - self->set_normal(*normal); -} - -godot_vector3 GDAPI godot_plane_get_normal(const godot_plane *p_self) { - const Plane *self = (const Plane *)p_self; - const Vector3 normal = self->get_normal(); - godot_vector3 *v3 = (godot_vector3 *)&normal; - return *v3; -} - -godot_real GDAPI godot_plane_get_d(const godot_plane *p_self) { - const Plane *self = (const Plane *)p_self; - return self->d; -} - -void GDAPI godot_plane_set_d(godot_plane *p_self, const godot_real p_d) { - Plane *self = (Plane *)p_self; - self->d = p_d; -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/plane.h b/modules/gdnative/godot/plane.h deleted file mode 100644 index 27548c8b0c..0000000000 --- a/modules/gdnative/godot/plane.h +++ /dev/null @@ -1,93 +0,0 @@ -/*************************************************************************/ -/* plane.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_PLANE_H -#define GODOT_PLANE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define GODOT_PLANE_SIZE 16 - -#ifndef GODOT_CORE_API_GODOT_PLANE_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_PLANE_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_PLANE_SIZE]; -} godot_plane; -#endif - -#include -#include - -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); -void GDAPI godot_plane_new_with_vectors(godot_plane *r_dest, const godot_vector3 *p_v1, const godot_vector3 *p_v2, const godot_vector3 *p_v3); -void GDAPI godot_plane_new_with_normal(godot_plane *r_dest, const godot_vector3 *p_normal, const godot_real p_d); - -godot_string GDAPI godot_plane_as_string(const godot_plane *p_self); - -godot_plane GDAPI godot_plane_normalized(const godot_plane *p_self); - -godot_vector3 GDAPI godot_plane_center(const godot_plane *p_self); - -godot_vector3 GDAPI godot_plane_get_any_point(const godot_plane *p_self); - -godot_bool GDAPI godot_plane_is_point_over(const godot_plane *p_self, const godot_vector3 *p_point); - -godot_real GDAPI godot_plane_distance_to(const godot_plane *p_self, const godot_vector3 *p_point); - -godot_bool GDAPI godot_plane_has_point(const godot_plane *p_self, const godot_vector3 *p_point, const godot_real p_epsilon); - -godot_vector3 GDAPI godot_plane_project(const godot_plane *p_self, const godot_vector3 *p_point); - -godot_bool GDAPI godot_plane_intersect_3(const godot_plane *p_self, godot_vector3 *r_dest, const godot_plane *p_b, const godot_plane *p_c); - -godot_bool GDAPI godot_plane_intersects_ray(const godot_plane *p_self, godot_vector3 *r_dest, const godot_vector3 *p_from, const godot_vector3 *p_dir); - -godot_bool GDAPI godot_plane_intersects_segment(const godot_plane *p_self, godot_vector3 *r_dest, const godot_vector3 *p_begin, const godot_vector3 *p_end); - -godot_plane GDAPI godot_plane_operator_neg(const godot_plane *p_self); - -godot_bool GDAPI godot_plane_operator_equal(const godot_plane *p_self, const godot_plane *p_b); - -void GDAPI godot_plane_set_normal(godot_plane *p_self, const godot_vector3 *p_normal); - -godot_vector3 GDAPI godot_plane_get_normal(const godot_plane *p_self); - -godot_real GDAPI godot_plane_get_d(const godot_plane *p_self); - -void GDAPI godot_plane_set_d(godot_plane *p_self, const godot_real p_d); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_PLANE_H diff --git a/modules/gdnative/godot/pool_arrays.cpp b/modules/gdnative/godot/pool_arrays.cpp deleted file mode 100644 index 49bf851051..0000000000 --- a/modules/gdnative/godot/pool_arrays.cpp +++ /dev/null @@ -1,633 +0,0 @@ -/*************************************************************************/ -/* pool_arrays.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "array.h" -#include "core/variant.h" -#include "dvector.h" - -#include "core/color.h" -#include "core/math/math_2d.h" -#include "core/math/vector3.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _pool_arrays_api_anchor() { -} - -#define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr) - -// byte - -void GDAPI godot_pool_byte_array_new(godot_pool_byte_array *r_dest) { - PoolVector *dest = (PoolVector *)r_dest; - memnew_placement(dest, PoolVector); -} - -void GDAPI godot_pool_byte_array_new_copy(godot_pool_byte_array *r_dest, const godot_pool_byte_array *p_src) { - PoolVector *dest = (PoolVector *)r_dest; - const PoolVector *src = (const PoolVector *)p_src; - memnew_placement(dest, PoolVector(*src)); -} - -void GDAPI godot_pool_byte_array_new_with_array(godot_pool_byte_array *r_dest, const godot_array *p_a) { - PoolVector *dest = (PoolVector *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, PoolVector); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } -} - -void GDAPI godot_pool_byte_array_append(godot_pool_byte_array *p_self, const uint8_t p_data) { - PoolVector *self = (PoolVector *)p_self; - self->append(p_data); -} - -void GDAPI godot_pool_byte_array_append_array(godot_pool_byte_array *p_self, const godot_pool_byte_array *p_array) { - PoolVector *self = (PoolVector *)p_self; - PoolVector *array = (PoolVector *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_pool_byte_array_insert(godot_pool_byte_array *p_self, const godot_int p_idx, const uint8_t p_data) { - PoolVector *self = (PoolVector *)p_self; - return (godot_error)self->insert(p_idx, p_data); -} - -void GDAPI godot_pool_byte_array_invert(godot_pool_byte_array *p_self) { - PoolVector *self = (PoolVector *)p_self; - self->invert(); -} - -void GDAPI godot_pool_byte_array_push_back(godot_pool_byte_array *p_self, const uint8_t p_data) { - PoolVector *self = (PoolVector *)p_self; - self->push_back(p_data); -} - -void GDAPI godot_pool_byte_array_remove(godot_pool_byte_array *p_self, const godot_int p_idx) { - PoolVector *self = (PoolVector *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_pool_byte_array_resize(godot_pool_byte_array *p_self, const godot_int p_size) { - PoolVector *self = (PoolVector *)p_self; - self->resize(p_size); -} - -void GDAPI godot_pool_byte_array_set(godot_pool_byte_array *p_self, const godot_int p_idx, const uint8_t p_data) { - PoolVector *self = (PoolVector *)p_self; - self->set(p_idx, p_data); -} - -uint8_t GDAPI godot_pool_byte_array_get(const godot_pool_byte_array *p_self, const godot_int p_idx) { - const PoolVector *self = (const PoolVector *)p_self; - return self->get(p_idx); -} - -godot_int GDAPI godot_pool_byte_array_size(const godot_pool_byte_array *p_self) { - const PoolVector *self = (const PoolVector *)p_self; - return self->size(); -} - -void GDAPI godot_pool_byte_array_destroy(godot_pool_byte_array *p_self) { - ((PoolVector *)p_self)->~PoolVector(); -} - -// int - -void GDAPI godot_pool_int_array_new(godot_pool_int_array *r_dest) { - PoolVector *dest = (PoolVector *)r_dest; - memnew_placement(dest, PoolVector); -} - -void GDAPI godot_pool_int_array_new_copy(godot_pool_int_array *r_dest, const godot_pool_int_array *p_src) { - PoolVector *dest = (PoolVector *)r_dest; - const PoolVector *src = (const PoolVector *)p_src; - memnew_placement(dest, PoolVector(*src)); -} - -void GDAPI godot_pool_int_array_new_with_array(godot_pool_int_array *r_dest, const godot_array *p_a) { - PoolVector *dest = (PoolVector *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, PoolVector); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } -} - -void GDAPI godot_pool_int_array_append(godot_pool_int_array *p_self, const godot_int p_data) { - PoolVector *self = (PoolVector *)p_self; - self->append(p_data); -} - -void GDAPI godot_pool_int_array_append_array(godot_pool_int_array *p_self, const godot_pool_int_array *p_array) { - PoolVector *self = (PoolVector *)p_self; - PoolVector *array = (PoolVector *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_pool_int_array_insert(godot_pool_int_array *p_self, const godot_int p_idx, const godot_int p_data) { - PoolVector *self = (PoolVector *)p_self; - return (godot_error)self->insert(p_idx, p_data); -} - -void GDAPI godot_pool_int_array_invert(godot_pool_int_array *p_self) { - PoolVector *self = (PoolVector *)p_self; - self->invert(); -} - -void GDAPI godot_pool_int_array_push_back(godot_pool_int_array *p_self, const godot_int p_data) { - PoolVector *self = (PoolVector *)p_self; - self->push_back(p_data); -} - -void GDAPI godot_pool_int_array_remove(godot_pool_int_array *p_self, const godot_int p_idx) { - PoolVector *self = (PoolVector *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_pool_int_array_resize(godot_pool_int_array *p_self, const godot_int p_size) { - PoolVector *self = (PoolVector *)p_self; - self->resize(p_size); -} - -void GDAPI godot_pool_int_array_set(godot_pool_int_array *p_self, const godot_int p_idx, const godot_int p_data) { - PoolVector *self = (PoolVector *)p_self; - self->set(p_idx, p_data); -} - -godot_int GDAPI godot_pool_int_array_get(const godot_pool_int_array *p_self, const godot_int p_idx) { - const PoolVector *self = (const PoolVector *)p_self; - return self->get(p_idx); -} - -godot_int GDAPI godot_pool_int_array_size(const godot_pool_int_array *p_self) { - const PoolVector *self = (const PoolVector *)p_self; - return self->size(); -} - -void GDAPI godot_pool_int_array_destroy(godot_pool_int_array *p_self) { - ((PoolVector *)p_self)->~PoolVector(); -} - -// real - -void GDAPI godot_pool_real_array_new(godot_pool_real_array *r_dest) { - PoolVector *dest = (PoolVector *)r_dest; - memnew_placement(dest, PoolVector); -} - -void GDAPI godot_pool_real_array_new_copy(godot_pool_real_array *r_dest, const godot_pool_real_array *p_src) { - PoolVector *dest = (PoolVector *)r_dest; - const PoolVector *src = (const PoolVector *)p_src; - memnew_placement(dest, PoolVector(*src)); -} - -void GDAPI godot_pool_real_array_new_with_array(godot_pool_real_array *r_dest, const godot_array *p_a) { - PoolVector *dest = (PoolVector *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, PoolVector); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } -} - -void GDAPI godot_pool_real_array_append(godot_pool_real_array *p_self, const godot_real p_data) { - PoolVector *self = (PoolVector *)p_self; - self->append(p_data); -} - -void GDAPI godot_pool_real_array_append_array(godot_pool_real_array *p_self, const godot_pool_real_array *p_array) { - PoolVector *self = (PoolVector *)p_self; - PoolVector *array = (PoolVector *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_pool_real_array_insert(godot_pool_real_array *p_self, const godot_int p_idx, const godot_real p_data) { - PoolVector *self = (PoolVector *)p_self; - return (godot_error)self->insert(p_idx, p_data); -} - -void GDAPI godot_pool_real_array_invert(godot_pool_real_array *p_self) { - PoolVector *self = (PoolVector *)p_self; - self->invert(); -} - -void GDAPI godot_pool_real_array_push_back(godot_pool_real_array *p_self, const godot_real p_data) { - PoolVector *self = (PoolVector *)p_self; - self->push_back(p_data); -} - -void GDAPI godot_pool_real_array_remove(godot_pool_real_array *p_self, const godot_int p_idx) { - PoolVector *self = (PoolVector *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_pool_real_array_resize(godot_pool_real_array *p_self, const godot_int p_size) { - PoolVector *self = (PoolVector *)p_self; - self->resize(p_size); -} - -void GDAPI godot_pool_real_array_set(godot_pool_real_array *p_self, const godot_int p_idx, const godot_real p_data) { - PoolVector *self = (PoolVector *)p_self; - self->set(p_idx, p_data); -} - -godot_real GDAPI godot_pool_real_array_get(const godot_pool_real_array *p_self, const godot_int p_idx) { - const PoolVector *self = (const PoolVector *)p_self; - return self->get(p_idx); -} - -godot_int GDAPI godot_pool_real_array_size(const godot_pool_real_array *p_self) { - const PoolVector *self = (const PoolVector *)p_self; - return self->size(); -} - -void GDAPI godot_pool_real_array_destroy(godot_pool_real_array *p_self) { - ((PoolVector *)p_self)->~PoolVector(); -} - -// string - -void GDAPI godot_pool_string_array_new(godot_pool_string_array *r_dest) { - PoolVector *dest = (PoolVector *)r_dest; - memnew_placement(dest, PoolVector); -} - -void GDAPI godot_pool_string_array_new_copy(godot_pool_string_array *r_dest, const godot_pool_string_array *p_src) { - PoolVector *dest = (PoolVector *)r_dest; - const PoolVector *src = (const PoolVector *)p_src; - memnew_placement(dest, PoolVector(*src)); -} - -void GDAPI godot_pool_string_array_new_with_array(godot_pool_string_array *r_dest, const godot_array *p_a) { - PoolVector *dest = (PoolVector *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, PoolVector); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } -} - -void GDAPI godot_pool_string_array_append(godot_pool_string_array *p_self, const godot_string *p_data) { - PoolVector *self = (PoolVector *)p_self; - String &s = *(String *)p_data; - self->append(s); -} - -void GDAPI godot_pool_string_array_append_array(godot_pool_string_array *p_self, const godot_pool_string_array *p_array) { - PoolVector *self = (PoolVector *)p_self; - PoolVector *array = (PoolVector *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_pool_string_array_insert(godot_pool_string_array *p_self, const godot_int p_idx, const godot_string *p_data) { - PoolVector *self = (PoolVector *)p_self; - String &s = *(String *)p_data; - return (godot_error)self->insert(p_idx, s); -} - -void GDAPI godot_pool_string_array_invert(godot_pool_string_array *p_self) { - PoolVector *self = (PoolVector *)p_self; - self->invert(); -} - -void GDAPI godot_pool_string_array_push_back(godot_pool_string_array *p_self, const godot_string *p_data) { - PoolVector *self = (PoolVector *)p_self; - String &s = *(String *)p_data; - self->push_back(s); -} - -void GDAPI godot_pool_string_array_remove(godot_pool_string_array *p_self, const godot_int p_idx) { - PoolVector *self = (PoolVector *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_pool_string_array_resize(godot_pool_string_array *p_self, const godot_int p_size) { - PoolVector *self = (PoolVector *)p_self; - self->resize(p_size); -} - -void GDAPI godot_pool_string_array_set(godot_pool_string_array *p_self, const godot_int p_idx, const godot_string *p_data) { - PoolVector *self = (PoolVector *)p_self; - String &s = *(String *)p_data; - self->set(p_idx, s); -} - -godot_string GDAPI godot_pool_string_array_get(const godot_pool_string_array *p_self, const godot_int p_idx) { - const PoolVector *self = (const PoolVector *)p_self; - godot_string str; - String *s = (String *)&str; - memnew_placement(s, String); - *s = self->get(p_idx); - return str; -} - -godot_int GDAPI godot_pool_string_array_size(const godot_pool_string_array *p_self) { - const PoolVector *self = (const PoolVector *)p_self; - return self->size(); -} - -void GDAPI godot_pool_string_array_destroy(godot_pool_string_array *p_self) { - ((PoolVector *)p_self)->~PoolVector(); -} - -// vector2 - -void GDAPI godot_pool_vector2_array_new(godot_pool_vector2_array *r_dest) { - PoolVector *dest = (PoolVector *)r_dest; - memnew_placement(dest, PoolVector); -} - -void GDAPI godot_pool_vector2_array_new_copy(godot_pool_vector2_array *r_dest, const godot_pool_vector2_array *p_src) { - PoolVector *dest = (PoolVector *)r_dest; - const PoolVector *src = (const PoolVector *)p_src; - memnew_placement(dest, PoolVector(*src)); -} - -void GDAPI godot_pool_vector2_array_new_with_array(godot_pool_vector2_array *r_dest, const godot_array *p_a) { - PoolVector *dest = (PoolVector *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, PoolVector); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } -} - -void GDAPI godot_pool_vector2_array_append(godot_pool_vector2_array *p_self, const godot_vector2 *p_data) { - PoolVector *self = (PoolVector *)p_self; - Vector2 &s = *(Vector2 *)p_data; - self->append(s); -} - -void GDAPI godot_pool_vector2_array_append_array(godot_pool_vector2_array *p_self, const godot_pool_vector2_array *p_array) { - PoolVector *self = (PoolVector *)p_self; - PoolVector *array = (PoolVector *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_pool_vector2_array_insert(godot_pool_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data) { - PoolVector *self = (PoolVector *)p_self; - Vector2 &s = *(Vector2 *)p_data; - return (godot_error)self->insert(p_idx, s); -} - -void GDAPI godot_pool_vector2_array_invert(godot_pool_vector2_array *p_self) { - PoolVector *self = (PoolVector *)p_self; - self->invert(); -} - -void GDAPI godot_pool_vector2_array_push_back(godot_pool_vector2_array *p_self, const godot_vector2 *p_data) { - PoolVector *self = (PoolVector *)p_self; - Vector2 &s = *(Vector2 *)p_data; - self->push_back(s); -} - -void GDAPI godot_pool_vector2_array_remove(godot_pool_vector2_array *p_self, const godot_int p_idx) { - PoolVector *self = (PoolVector *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_pool_vector2_array_resize(godot_pool_vector2_array *p_self, const godot_int p_size) { - PoolVector *self = (PoolVector *)p_self; - self->resize(p_size); -} - -void GDAPI godot_pool_vector2_array_set(godot_pool_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data) { - PoolVector *self = (PoolVector *)p_self; - Vector2 &s = *(Vector2 *)p_data; - self->set(p_idx, s); -} - -godot_vector2 GDAPI godot_pool_vector2_array_get(const godot_pool_vector2_array *p_self, const godot_int p_idx) { - const PoolVector *self = (const PoolVector *)p_self; - godot_vector2 v; - Vector2 *s = (Vector2 *)&v; - *s = self->get(p_idx); - return v; -} - -godot_int GDAPI godot_pool_vector2_array_size(const godot_pool_vector2_array *p_self) { - const PoolVector *self = (const PoolVector *)p_self; - return self->size(); -} - -void GDAPI godot_pool_vector2_array_destroy(godot_pool_vector2_array *p_self) { - ((PoolVector *)p_self)->~PoolVector(); -} - -// vector3 - -void GDAPI godot_pool_vector3_array_new(godot_pool_vector3_array *r_dest) { - PoolVector *dest = (PoolVector *)r_dest; - memnew_placement(dest, PoolVector); -} - -void GDAPI godot_pool_vector3_array_new_copy(godot_pool_vector3_array *r_dest, const godot_pool_vector3_array *p_src) { - PoolVector *dest = (PoolVector *)r_dest; - const PoolVector *src = (const PoolVector *)p_src; - memnew_placement(dest, PoolVector(*src)); -} - -void GDAPI godot_pool_vector3_array_new_with_array(godot_pool_vector3_array *r_dest, const godot_array *p_a) { - PoolVector *dest = (PoolVector *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, PoolVector); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } -} - -void GDAPI godot_pool_vector3_array_append(godot_pool_vector3_array *p_self, const godot_vector3 *p_data) { - PoolVector *self = (PoolVector *)p_self; - Vector3 &s = *(Vector3 *)p_data; - self->append(s); -} - -void GDAPI godot_pool_vector3_array_append_array(godot_pool_vector3_array *p_self, const godot_pool_vector3_array *p_array) { - PoolVector *self = (PoolVector *)p_self; - PoolVector *array = (PoolVector *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_pool_vector3_array_insert(godot_pool_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data) { - PoolVector *self = (PoolVector *)p_self; - Vector3 &s = *(Vector3 *)p_data; - return (godot_error)self->insert(p_idx, s); -} - -void GDAPI godot_pool_vector3_array_invert(godot_pool_vector3_array *p_self) { - PoolVector *self = (PoolVector *)p_self; - self->invert(); -} - -void GDAPI godot_pool_vector3_array_push_back(godot_pool_vector3_array *p_self, const godot_vector3 *p_data) { - PoolVector *self = (PoolVector *)p_self; - Vector3 &s = *(Vector3 *)p_data; - self->push_back(s); -} - -void GDAPI godot_pool_vector3_array_remove(godot_pool_vector3_array *p_self, const godot_int p_idx) { - PoolVector *self = (PoolVector *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_pool_vector3_array_resize(godot_pool_vector3_array *p_self, const godot_int p_size) { - PoolVector *self = (PoolVector *)p_self; - self->resize(p_size); -} - -void GDAPI godot_pool_vector3_array_set(godot_pool_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data) { - PoolVector *self = (PoolVector *)p_self; - Vector3 &s = *(Vector3 *)p_data; - self->set(p_idx, s); -} - -godot_vector3 GDAPI godot_pool_vector3_array_get(const godot_pool_vector3_array *p_self, const godot_int p_idx) { - const PoolVector *self = (const PoolVector *)p_self; - godot_vector3 v; - Vector3 *s = (Vector3 *)&v; - *s = self->get(p_idx); - return v; -} - -godot_int GDAPI godot_pool_vector3_array_size(const godot_pool_vector3_array *p_self) { - const PoolVector *self = (const PoolVector *)p_self; - return self->size(); -} - -void GDAPI godot_pool_vector3_array_destroy(godot_pool_vector3_array *p_self) { - ((PoolVector *)p_self)->~PoolVector(); -} - -// color - -void GDAPI godot_pool_color_array_new(godot_pool_color_array *r_dest) { - PoolVector *dest = (PoolVector *)r_dest; - memnew_placement(dest, PoolVector); -} - -void GDAPI godot_pool_color_array_new_copy(godot_pool_color_array *r_dest, const godot_pool_color_array *p_src) { - PoolVector *dest = (PoolVector *)r_dest; - const PoolVector *src = (const PoolVector *)p_src; - memnew_placement(dest, PoolVector(*src)); -} - -void GDAPI godot_pool_color_array_new_with_array(godot_pool_color_array *r_dest, const godot_array *p_a) { - PoolVector *dest = (PoolVector *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, PoolVector); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } -} - -void GDAPI godot_pool_color_array_append(godot_pool_color_array *p_self, const godot_color *p_data) { - PoolVector *self = (PoolVector *)p_self; - Color &s = *(Color *)p_data; - self->append(s); -} - -void GDAPI godot_pool_color_array_append_array(godot_pool_color_array *p_self, const godot_pool_color_array *p_array) { - PoolVector *self = (PoolVector *)p_self; - PoolVector *array = (PoolVector *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_pool_color_array_insert(godot_pool_color_array *p_self, const godot_int p_idx, const godot_color *p_data) { - PoolVector *self = (PoolVector *)p_self; - Color &s = *(Color *)p_data; - return (godot_error)self->insert(p_idx, s); -} - -void GDAPI godot_pool_color_array_invert(godot_pool_color_array *p_self) { - PoolVector *self = (PoolVector *)p_self; - self->invert(); -} - -void GDAPI godot_pool_color_array_push_back(godot_pool_color_array *p_self, const godot_color *p_data) { - PoolVector *self = (PoolVector *)p_self; - Color &s = *(Color *)p_data; - self->push_back(s); -} - -void GDAPI godot_pool_color_array_remove(godot_pool_color_array *p_self, const godot_int p_idx) { - PoolVector *self = (PoolVector *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_pool_color_array_resize(godot_pool_color_array *p_self, const godot_int p_size) { - PoolVector *self = (PoolVector *)p_self; - self->resize(p_size); -} - -void GDAPI godot_pool_color_array_set(godot_pool_color_array *p_self, const godot_int p_idx, const godot_color *p_data) { - PoolVector *self = (PoolVector *)p_self; - Color &s = *(Color *)p_data; - self->set(p_idx, s); -} - -godot_color GDAPI godot_pool_color_array_get(const godot_pool_color_array *p_self, const godot_int p_idx) { - const PoolVector *self = (const PoolVector *)p_self; - godot_color v; - Color *s = (Color *)&v; - *s = self->get(p_idx); - return v; -} - -godot_int GDAPI godot_pool_color_array_size(const godot_pool_color_array *p_self) { - const PoolVector *self = (const PoolVector *)p_self; - return self->size(); -} - -void GDAPI godot_pool_color_array_destroy(godot_pool_color_array *p_self) { - ((PoolVector *)p_self)->~PoolVector(); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/pool_arrays.h b/modules/gdnative/godot/pool_arrays.h deleted file mode 100644 index 1b51dca38c..0000000000 --- a/modules/gdnative/godot/pool_arrays.h +++ /dev/null @@ -1,316 +0,0 @@ -/*************************************************************************/ -/* pool_arrays.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_POOL_ARRAYS_H -#define GODOT_POOL_ARRAYS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/////// PoolByteArray - -#define GODOT_POOL_BYTE_ARRAY_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_POOL_BYTE_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_POOL_BYTE_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_POOL_BYTE_ARRAY_SIZE]; -} godot_pool_byte_array; -#endif - -/////// PoolIntArray - -#define GODOT_POOL_INT_ARRAY_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_POOL_INT_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_POOL_INT_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_POOL_INT_ARRAY_SIZE]; -} godot_pool_int_array; -#endif - -/////// PoolRealArray - -#define GODOT_POOL_REAL_ARRAY_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_POOL_REAL_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_POOL_REAL_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_POOL_REAL_ARRAY_SIZE]; -} godot_pool_real_array; -#endif - -/////// PoolStringArray - -#define GODOT_POOL_STRING_ARRAY_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_POOL_STRING_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_POOL_STRING_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_POOL_STRING_ARRAY_SIZE]; -} godot_pool_string_array; -#endif - -/////// PoolVector2Array - -#define GODOT_POOL_VECTOR2_ARRAY_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_POOL_VECTOR2_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_POOL_VECTOR2_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_POOL_VECTOR2_ARRAY_SIZE]; -} godot_pool_vector2_array; -#endif - -/////// PoolVector3Array - -#define GODOT_POOL_VECTOR3_ARRAY_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_POOL_VECTOR3_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_POOL_VECTOR3_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_POOL_VECTOR3_ARRAY_SIZE]; -} godot_pool_vector3_array; -#endif - -/////// PoolColorArray - -#define GODOT_POOL_COLOR_ARRAY_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_POOL_COLOR_ARRAY_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_POOL_COLOR_ARRAY_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_POOL_COLOR_ARRAY_SIZE]; -} godot_pool_color_array; -#endif - -#include -#include -#include -#include - -#include - -// byte - -void GDAPI godot_pool_byte_array_new(godot_pool_byte_array *r_dest); -void GDAPI godot_pool_byte_array_new_copy(godot_pool_byte_array *r_dest, const godot_pool_byte_array *p_src); -void GDAPI godot_pool_byte_array_new_with_array(godot_pool_byte_array *r_dest, const godot_array *p_a); - -void GDAPI godot_pool_byte_array_append(godot_pool_byte_array *p_self, const uint8_t p_data); - -void GDAPI godot_pool_byte_array_append_array(godot_pool_byte_array *p_self, const godot_pool_byte_array *p_array); - -godot_error GDAPI godot_pool_byte_array_insert(godot_pool_byte_array *p_self, const godot_int p_idx, const uint8_t p_data); - -void GDAPI godot_pool_byte_array_invert(godot_pool_byte_array *p_self); - -void GDAPI godot_pool_byte_array_push_back(godot_pool_byte_array *p_self, const uint8_t p_data); - -void GDAPI godot_pool_byte_array_remove(godot_pool_byte_array *p_self, const godot_int p_idx); - -void GDAPI godot_pool_byte_array_resize(godot_pool_byte_array *p_self, const godot_int p_size); - -void GDAPI godot_pool_byte_array_set(godot_pool_byte_array *p_self, const godot_int p_idx, const uint8_t p_data); -uint8_t GDAPI godot_pool_byte_array_get(const godot_pool_byte_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_pool_byte_array_size(const godot_pool_byte_array *p_self); - -void GDAPI godot_pool_byte_array_destroy(godot_pool_byte_array *p_self); - -// int - -void GDAPI godot_pool_int_array_new(godot_pool_int_array *r_dest); -void GDAPI godot_pool_int_array_new_copy(godot_pool_int_array *r_dest, const godot_pool_int_array *p_src); -void GDAPI godot_pool_int_array_new_with_array(godot_pool_int_array *r_dest, const godot_array *p_a); - -void GDAPI godot_pool_int_array_append(godot_pool_int_array *p_self, const godot_int p_data); - -void GDAPI godot_pool_int_array_append_array(godot_pool_int_array *p_self, const godot_pool_int_array *p_array); - -godot_error GDAPI godot_pool_int_array_insert(godot_pool_int_array *p_self, const godot_int p_idx, const godot_int p_data); - -void GDAPI godot_pool_int_array_invert(godot_pool_int_array *p_self); - -void GDAPI godot_pool_int_array_push_back(godot_pool_int_array *p_self, const godot_int p_data); - -void GDAPI godot_pool_int_array_remove(godot_pool_int_array *p_self, const godot_int p_idx); - -void GDAPI godot_pool_int_array_resize(godot_pool_int_array *p_self, const godot_int p_size); - -void GDAPI godot_pool_int_array_set(godot_pool_int_array *p_self, const godot_int p_idx, const godot_int p_data); -godot_int GDAPI godot_pool_int_array_get(const godot_pool_int_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_pool_int_array_size(const godot_pool_int_array *p_self); - -void GDAPI godot_pool_int_array_destroy(godot_pool_int_array *p_self); - -// real - -void GDAPI godot_pool_real_array_new(godot_pool_real_array *r_dest); -void GDAPI godot_pool_real_array_new_copy(godot_pool_real_array *r_dest, const godot_pool_real_array *p_src); -void GDAPI godot_pool_real_array_new_with_array(godot_pool_real_array *r_dest, const godot_array *p_a); - -void GDAPI godot_pool_real_array_append(godot_pool_real_array *p_self, const godot_real p_data); - -void GDAPI godot_pool_real_array_append_array(godot_pool_real_array *p_self, const godot_pool_real_array *p_array); - -godot_error GDAPI godot_pool_real_array_insert(godot_pool_real_array *p_self, const godot_int p_idx, const godot_real p_data); - -void GDAPI godot_pool_real_array_invert(godot_pool_real_array *p_self); - -void GDAPI godot_pool_real_array_push_back(godot_pool_real_array *p_self, const godot_real p_data); - -void GDAPI godot_pool_real_array_remove(godot_pool_real_array *p_self, const godot_int p_idx); - -void GDAPI godot_pool_real_array_resize(godot_pool_real_array *p_self, const godot_int p_size); - -void GDAPI godot_pool_real_array_set(godot_pool_real_array *p_self, const godot_int p_idx, const godot_real p_data); -godot_real GDAPI godot_pool_real_array_get(const godot_pool_real_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_pool_real_array_size(const godot_pool_real_array *p_self); - -void GDAPI godot_pool_real_array_destroy(godot_pool_real_array *p_self); - -// string - -void GDAPI godot_pool_string_array_new(godot_pool_string_array *r_dest); -void GDAPI godot_pool_string_array_new_copy(godot_pool_string_array *r_dest, const godot_pool_string_array *p_src); -void GDAPI godot_pool_string_array_new_with_array(godot_pool_string_array *r_dest, const godot_array *p_a); - -void GDAPI godot_pool_string_array_append(godot_pool_string_array *p_self, const godot_string *p_data); - -void GDAPI godot_pool_string_array_append_array(godot_pool_string_array *p_self, const godot_pool_string_array *p_array); - -godot_error GDAPI godot_pool_string_array_insert(godot_pool_string_array *p_self, const godot_int p_idx, const godot_string *p_data); - -void GDAPI godot_pool_string_array_invert(godot_pool_string_array *p_self); - -void GDAPI godot_pool_string_array_push_back(godot_pool_string_array *p_self, const godot_string *p_data); - -void GDAPI godot_pool_string_array_remove(godot_pool_string_array *p_self, const godot_int p_idx); - -void GDAPI godot_pool_string_array_resize(godot_pool_string_array *p_self, const godot_int p_size); - -void GDAPI godot_pool_string_array_set(godot_pool_string_array *p_self, const godot_int p_idx, const godot_string *p_data); -godot_string GDAPI godot_pool_string_array_get(const godot_pool_string_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_pool_string_array_size(const godot_pool_string_array *p_self); - -void GDAPI godot_pool_string_array_destroy(godot_pool_string_array *p_self); - -// vector2 - -void GDAPI godot_pool_vector2_array_new(godot_pool_vector2_array *r_dest); -void GDAPI godot_pool_vector2_array_new_copy(godot_pool_vector2_array *r_dest, const godot_pool_vector2_array *p_src); -void GDAPI godot_pool_vector2_array_new_with_array(godot_pool_vector2_array *r_dest, const godot_array *p_a); - -void GDAPI godot_pool_vector2_array_append(godot_pool_vector2_array *p_self, const godot_vector2 *p_data); - -void GDAPI godot_pool_vector2_array_append_array(godot_pool_vector2_array *p_self, const godot_pool_vector2_array *p_array); - -godot_error GDAPI godot_pool_vector2_array_insert(godot_pool_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data); - -void GDAPI godot_pool_vector2_array_invert(godot_pool_vector2_array *p_self); - -void GDAPI godot_pool_vector2_array_push_back(godot_pool_vector2_array *p_self, const godot_vector2 *p_data); - -void GDAPI godot_pool_vector2_array_remove(godot_pool_vector2_array *p_self, const godot_int p_idx); - -void GDAPI godot_pool_vector2_array_resize(godot_pool_vector2_array *p_self, const godot_int p_size); - -void GDAPI godot_pool_vector2_array_set(godot_pool_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data); -godot_vector2 GDAPI godot_pool_vector2_array_get(const godot_pool_vector2_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_pool_vector2_array_size(const godot_pool_vector2_array *p_self); - -void GDAPI godot_pool_vector2_array_destroy(godot_pool_vector2_array *p_self); - -// vector3 - -void GDAPI godot_pool_vector3_array_new(godot_pool_vector3_array *r_dest); -void GDAPI godot_pool_vector3_array_new_copy(godot_pool_vector3_array *r_dest, const godot_pool_vector3_array *p_src); -void GDAPI godot_pool_vector3_array_new_with_array(godot_pool_vector3_array *r_dest, const godot_array *p_a); - -void GDAPI godot_pool_vector3_array_append(godot_pool_vector3_array *p_self, const godot_vector3 *p_data); - -void GDAPI godot_pool_vector3_array_append_array(godot_pool_vector3_array *p_self, const godot_pool_vector3_array *p_array); - -godot_error GDAPI godot_pool_vector3_array_insert(godot_pool_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data); - -void GDAPI godot_pool_vector3_array_invert(godot_pool_vector3_array *p_self); - -void GDAPI godot_pool_vector3_array_push_back(godot_pool_vector3_array *p_self, const godot_vector3 *p_data); - -void GDAPI godot_pool_vector3_array_remove(godot_pool_vector3_array *p_self, const godot_int p_idx); - -void GDAPI godot_pool_vector3_array_resize(godot_pool_vector3_array *p_self, const godot_int p_size); - -void GDAPI godot_pool_vector3_array_set(godot_pool_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data); -godot_vector3 GDAPI godot_pool_vector3_array_get(const godot_pool_vector3_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_pool_vector3_array_size(const godot_pool_vector3_array *p_self); - -void GDAPI godot_pool_vector3_array_destroy(godot_pool_vector3_array *p_self); - -// color - -void GDAPI godot_pool_color_array_new(godot_pool_color_array *r_dest); -void GDAPI godot_pool_color_array_new_copy(godot_pool_color_array *r_dest, const godot_pool_color_array *p_src); -void GDAPI godot_pool_color_array_new_with_array(godot_pool_color_array *r_dest, const godot_array *p_a); - -void GDAPI godot_pool_color_array_append(godot_pool_color_array *p_self, const godot_color *p_data); - -void GDAPI godot_pool_color_array_append_array(godot_pool_color_array *p_self, const godot_pool_color_array *p_array); - -godot_error GDAPI godot_pool_color_array_insert(godot_pool_color_array *p_self, const godot_int p_idx, const godot_color *p_data); - -void GDAPI godot_pool_color_array_invert(godot_pool_color_array *p_self); - -void GDAPI godot_pool_color_array_push_back(godot_pool_color_array *p_self, const godot_color *p_data); - -void GDAPI godot_pool_color_array_remove(godot_pool_color_array *p_self, const godot_int p_idx); - -void GDAPI godot_pool_color_array_resize(godot_pool_color_array *p_self, const godot_int p_size); - -void GDAPI godot_pool_color_array_set(godot_pool_color_array *p_self, const godot_int p_idx, const godot_color *p_data); -godot_color GDAPI godot_pool_color_array_get(const godot_pool_color_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_pool_color_array_size(const godot_pool_color_array *p_self); - -void GDAPI godot_pool_color_array_destroy(godot_pool_color_array *p_self); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_POOL_ARRAYS_H diff --git a/modules/gdnative/godot/quat.cpp b/modules/gdnative/godot/quat.cpp deleted file mode 100644 index e6bea78b60..0000000000 --- a/modules/gdnative/godot/quat.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/*************************************************************************/ -/* quat.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/math/quat.h" -#include "core/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _quat_api_anchor() {} - -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); -} - -void GDAPI godot_quat_new_with_axis_angle(godot_quat *r_dest, const godot_vector3 *p_axis, const godot_real p_angle) { - const Vector3 *axis = (const Vector3 *)p_axis; - Quat *dest = (Quat *)r_dest; - *dest = Quat(*axis, p_angle); -} - -godot_real GDAPI godot_quat_get_x(const godot_quat *p_self) { - const Quat *self = (const Quat *)p_self; - return self->x; -} - -void GDAPI godot_quat_set_x(godot_quat *p_self, const godot_real val) { - Quat *self = (Quat *)p_self; - self->x = val; -} - -godot_real GDAPI godot_quat_get_y(const godot_quat *p_self) { - const Quat *self = (const Quat *)p_self; - return self->y; -} - -void GDAPI godot_quat_set_y(godot_quat *p_self, const godot_real val) { - Quat *self = (Quat *)p_self; - self->y = val; -} - -godot_real GDAPI godot_quat_get_z(const godot_quat *p_self) { - const Quat *self = (const Quat *)p_self; - return self->z; -} - -void GDAPI godot_quat_set_z(godot_quat *p_self, const godot_real val) { - Quat *self = (Quat *)p_self; - self->z = val; -} - -godot_real GDAPI godot_quat_get_w(const godot_quat *p_self) { - const Quat *self = (const Quat *)p_self; - return self->w; -} - -void GDAPI godot_quat_set_w(godot_quat *p_self, const godot_real val) { - Quat *self = (Quat *)p_self; - self->w = val; -} - -godot_string GDAPI godot_quat_as_string(const godot_quat *p_self) { - godot_string ret; - const Quat *self = (const Quat *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_real GDAPI godot_quat_length(const godot_quat *p_self) { - const Quat *self = (const Quat *)p_self; - return self->length(); -} - -godot_real GDAPI godot_quat_length_squared(const godot_quat *p_self) { - const Quat *self = (const Quat *)p_self; - return self->length_squared(); -} - -godot_quat GDAPI godot_quat_normalized(const godot_quat *p_self) { - godot_quat dest; - const Quat *self = (const Quat *)p_self; - *((Quat *)&dest) = self->normalized(); - return dest; -} - -godot_bool GDAPI godot_quat_is_normalized(const godot_quat *p_self) { - const Quat *self = (const Quat *)p_self; - return self->is_normalized(); -} - -godot_quat GDAPI godot_quat_inverse(const godot_quat *p_self) { - godot_quat dest; - const Quat *self = (const Quat *)p_self; - *((Quat *)&dest) = self->inverse(); - return dest; -} - -godot_real GDAPI godot_quat_dot(const godot_quat *p_self, const godot_quat *p_b) { - const Quat *self = (const Quat *)p_self; - const Quat *b = (const Quat *)p_b; - return self->dot(*b); -} - -godot_vector3 GDAPI godot_quat_xform(const godot_quat *p_self, const godot_vector3 *p_v) { - godot_vector3 dest; - const Quat *self = (const Quat *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - *((Vector3 *)&dest) = self->xform(*v); - return dest; -} - -godot_quat GDAPI godot_quat_slerp(const godot_quat *p_self, const godot_quat *p_b, const godot_real p_t) { - godot_quat dest; - const Quat *self = (const Quat *)p_self; - const Quat *b = (const Quat *)p_b; - *((Quat *)&dest) = self->slerp(*b, p_t); - return dest; -} - -godot_quat GDAPI godot_quat_slerpni(const godot_quat *p_self, const godot_quat *p_b, const godot_real p_t) { - godot_quat dest; - const Quat *self = (const Quat *)p_self; - const Quat *b = (const Quat *)p_b; - *((Quat *)&dest) = self->slerpni(*b, p_t); - return dest; -} - -godot_quat GDAPI godot_quat_cubic_slerp(const godot_quat *p_self, const godot_quat *p_b, const godot_quat *p_pre_a, const godot_quat *p_post_b, const godot_real p_t) { - godot_quat dest; - const Quat *self = (const Quat *)p_self; - const Quat *b = (const Quat *)p_b; - const Quat *pre_a = (const Quat *)p_pre_a; - const Quat *post_b = (const Quat *)p_post_b; - *((Quat *)&dest) = self->cubic_slerp(*b, *pre_a, *post_b, p_t); - return dest; -} - -godot_quat GDAPI godot_quat_operator_multiply(const godot_quat *p_self, const godot_real p_b) { - godot_quat raw_dest; - Quat *dest = (Quat *)&raw_dest; - const Quat *self = (const Quat *)p_self; - *dest = *self * p_b; - return raw_dest; -} - -godot_quat GDAPI godot_quat_operator_add(const godot_quat *p_self, const godot_quat *p_b) { - godot_quat raw_dest; - Quat *dest = (Quat *)&raw_dest; - const Quat *self = (const Quat *)p_self; - const Quat *b = (const Quat *)p_b; - *dest = *self + *b; - return raw_dest; -} - -godot_quat GDAPI godot_quat_operator_substract(const godot_quat *p_self, const godot_quat *p_b) { - godot_quat raw_dest; - Quat *dest = (Quat *)&raw_dest; - const Quat *self = (const Quat *)p_self; - const Quat *b = (const Quat *)p_b; - *dest = *self - *b; - return raw_dest; -} - -godot_quat GDAPI godot_quat_operator_divide(const godot_quat *p_self, const godot_real p_b) { - godot_quat raw_dest; - Quat *dest = (Quat *)&raw_dest; - const Quat *self = (const Quat *)p_self; - *dest = *self / p_b; - return raw_dest; -} - -godot_bool GDAPI godot_quat_operator_equal(const godot_quat *p_self, const godot_quat *p_b) { - const Quat *self = (const Quat *)p_self; - const Quat *b = (const Quat *)p_b; - return *self == *b; -} - -godot_quat GDAPI godot_quat_operator_neg(const godot_quat *p_self) { - godot_quat raw_dest; - Quat *dest = (Quat *)&raw_dest; - const Quat *self = (const Quat *)p_self; - *dest = -(*self); - return raw_dest; -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/quat.h b/modules/gdnative/godot/quat.h deleted file mode 100644 index 9a3238a337..0000000000 --- a/modules/gdnative/godot/quat.h +++ /dev/null @@ -1,104 +0,0 @@ -/*************************************************************************/ -/* quat.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_QUAT_H -#define GODOT_QUAT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define GODOT_QUAT_SIZE 16 - -#ifndef GODOT_CORE_API_GODOT_QUAT_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_QUAT_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_QUAT_SIZE]; -} godot_quat; -#endif - -#include -#include - -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); -void GDAPI godot_quat_new_with_axis_angle(godot_quat *r_dest, const godot_vector3 *p_axis, const godot_real p_angle); - -godot_real GDAPI godot_quat_get_x(const godot_quat *p_self); -void GDAPI godot_quat_set_x(godot_quat *p_self, const godot_real val); - -godot_real GDAPI godot_quat_get_y(const godot_quat *p_self); -void GDAPI godot_quat_set_y(godot_quat *p_self, const godot_real val); - -godot_real GDAPI godot_quat_get_z(const godot_quat *p_self); -void GDAPI godot_quat_set_z(godot_quat *p_self, const godot_real val); - -godot_real GDAPI godot_quat_get_w(const godot_quat *p_self); -void GDAPI godot_quat_set_w(godot_quat *p_self, const godot_real val); - -godot_string GDAPI godot_quat_as_string(const godot_quat *p_self); - -godot_real GDAPI godot_quat_length(const godot_quat *p_self); - -godot_real GDAPI godot_quat_length_squared(const godot_quat *p_self); - -godot_quat GDAPI godot_quat_normalized(const godot_quat *p_self); - -godot_bool GDAPI godot_quat_is_normalized(const godot_quat *p_self); - -godot_quat GDAPI godot_quat_inverse(const godot_quat *p_self); - -godot_real GDAPI godot_quat_dot(const godot_quat *p_self, const godot_quat *p_b); - -godot_vector3 GDAPI godot_quat_xform(const godot_quat *p_self, const godot_vector3 *p_v); - -godot_quat GDAPI godot_quat_slerp(const godot_quat *p_self, const godot_quat *p_b, const godot_real p_t); - -godot_quat GDAPI godot_quat_slerpni(const godot_quat *p_self, const godot_quat *p_b, const godot_real p_t); - -godot_quat GDAPI godot_quat_cubic_slerp(const godot_quat *p_self, const godot_quat *p_b, const godot_quat *p_pre_a, const godot_quat *p_post_b, const godot_real p_t); - -godot_quat GDAPI godot_quat_operator_multiply(const godot_quat *p_self, const godot_real p_b); - -godot_quat GDAPI godot_quat_operator_add(const godot_quat *p_self, const godot_quat *p_b); - -godot_quat GDAPI godot_quat_operator_substract(const godot_quat *p_self, const godot_quat *p_b); - -godot_quat GDAPI godot_quat_operator_divide(const godot_quat *p_self, const godot_real p_b); - -godot_bool GDAPI godot_quat_operator_equal(const godot_quat *p_self, const godot_quat *p_b); - -godot_quat GDAPI godot_quat_operator_neg(const godot_quat *p_self); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_QUAT_H diff --git a/modules/gdnative/godot/rect2.cpp b/modules/gdnative/godot/rect2.cpp deleted file mode 100644 index 98e7855dc9..0000000000 --- a/modules/gdnative/godot/rect2.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/*************************************************************************/ -/* rect2.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/math/math_2d.h" -#include "core/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _rect2_api_anchor() {} - -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; - Rect2 *dest = (Rect2 *)r_dest; - *dest = Rect2(*position, *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) { - - Rect2 *dest = (Rect2 *)r_dest; - *dest = Rect2(p_x, p_y, p_width, p_height); -} - -godot_string GDAPI godot_rect2_as_string(const godot_rect2 *p_self) { - godot_string ret; - const Rect2 *self = (const Rect2 *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_real GDAPI godot_rect2_get_area(const godot_rect2 *p_self) { - const Rect2 *self = (const Rect2 *)p_self; - return self->get_area(); -} - -godot_bool GDAPI godot_rect2_intersects(const godot_rect2 *p_self, const godot_rect2 *p_b) { - const Rect2 *self = (const Rect2 *)p_self; - const Rect2 *b = (const Rect2 *)p_b; - return self->intersects(*b); -} - -godot_bool GDAPI godot_rect2_encloses(const godot_rect2 *p_self, const godot_rect2 *p_b) { - const Rect2 *self = (const Rect2 *)p_self; - const Rect2 *b = (const Rect2 *)p_b; - return self->encloses(*b); -} - -godot_bool GDAPI godot_rect2_has_no_area(const godot_rect2 *p_self) { - const Rect2 *self = (const Rect2 *)p_self; - return self->has_no_area(); -} - -godot_rect2 GDAPI godot_rect2_clip(const godot_rect2 *p_self, const godot_rect2 *p_b) { - godot_rect2 dest; - const Rect2 *self = (const Rect2 *)p_self; - const Rect2 *b = (const Rect2 *)p_b; - *((Rect2 *)&dest) = self->clip(*b); - return dest; -} - -godot_rect2 GDAPI godot_rect2_merge(const godot_rect2 *p_self, const godot_rect2 *p_b) { - godot_rect2 dest; - const Rect2 *self = (const Rect2 *)p_self; - const Rect2 *b = (const Rect2 *)p_b; - *((Rect2 *)&dest) = self->merge(*b); - return dest; -} - -godot_bool GDAPI godot_rect2_has_point(const godot_rect2 *p_self, const godot_vector2 *p_point) { - const Rect2 *self = (const Rect2 *)p_self; - const Vector2 *point = (const Vector2 *)p_point; - return self->has_point(*point); -} - -godot_rect2 GDAPI godot_rect2_grow(const godot_rect2 *p_self, const godot_real p_by) { - godot_rect2 dest; - const Rect2 *self = (const Rect2 *)p_self; - - *((Rect2 *)&dest) = self->grow(p_by); - return dest; -} - -godot_rect2 GDAPI godot_rect2_expand(const godot_rect2 *p_self, const godot_vector2 *p_to) { - godot_rect2 dest; - const Rect2 *self = (const Rect2 *)p_self; - const Vector2 *to = (const Vector2 *)p_to; - *((Rect2 *)&dest) = self->expand(*to); - return dest; -} - -godot_bool GDAPI godot_rect2_operator_equal(const godot_rect2 *p_self, const godot_rect2 *p_b) { - const Rect2 *self = (const Rect2 *)p_self; - const Rect2 *b = (const Rect2 *)p_b; - return *self == *b; -} - -godot_vector2 GDAPI godot_rect2_get_position(const godot_rect2 *p_self) { - godot_vector2 dest; - Vector2 *d = (Vector2 *)&dest; - const Rect2 *self = (const Rect2 *)p_self; - *d = self->get_position(); - return dest; -} - -godot_vector2 GDAPI godot_rect2_get_size(const godot_rect2 *p_self) { - godot_vector2 dest; - Vector2 *d = (Vector2 *)&dest; - const Rect2 *self = (const Rect2 *)p_self; - *d = self->get_size(); - return dest; -} - -void GDAPI godot_rect2_set_position(godot_rect2 *p_self, const godot_vector2 *p_pos) { - Rect2 *self = (Rect2 *)p_self; - const Vector2 *position = (const Vector2 *)p_pos; - self->set_position(*position); -} - -void GDAPI godot_rect2_set_size(godot_rect2 *p_self, const godot_vector2 *p_size) { - Rect2 *self = (Rect2 *)p_self; - const Vector2 *size = (const Vector2 *)p_size; - self->set_size(*size); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/rect2.h b/modules/gdnative/godot/rect2.h deleted file mode 100644 index 8ceeddf1b4..0000000000 --- a/modules/gdnative/godot/rect2.h +++ /dev/null @@ -1,86 +0,0 @@ -/*************************************************************************/ -/* rect2.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_RECT2_H -#define GODOT_RECT2_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#ifndef GODOT_CORE_API_GODOT_RECT2_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_RECT2_TYPE_DEFINED -typedef struct godot_rect2 { - uint8_t _dont_touch_that[16]; -} godot_rect2; -#endif - -#include -#include - -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_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); - -godot_bool GDAPI godot_rect2_encloses(const godot_rect2 *p_self, const godot_rect2 *p_b); - -godot_bool GDAPI godot_rect2_has_no_area(const godot_rect2 *p_self); - -godot_rect2 GDAPI godot_rect2_clip(const godot_rect2 *p_self, const godot_rect2 *p_b); - -godot_rect2 GDAPI godot_rect2_merge(const godot_rect2 *p_self, const godot_rect2 *p_b); - -godot_bool GDAPI godot_rect2_has_point(const godot_rect2 *p_self, const godot_vector2 *p_point); - -godot_rect2 GDAPI godot_rect2_grow(const godot_rect2 *p_self, const godot_real p_by); - -godot_rect2 GDAPI godot_rect2_expand(const godot_rect2 *p_self, const godot_vector2 *p_to); - -godot_bool GDAPI godot_rect2_operator_equal(const godot_rect2 *p_self, const godot_rect2 *p_b); - -godot_vector2 GDAPI godot_rect2_get_position(const godot_rect2 *p_self); - -godot_vector2 GDAPI godot_rect2_get_size(const godot_rect2 *p_self); - -void GDAPI godot_rect2_set_position(godot_rect2 *p_self, const godot_vector2 *p_pos); - -void GDAPI godot_rect2_set_size(godot_rect2 *p_self, const godot_vector2 *p_size); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_RECT2_H diff --git a/modules/gdnative/godot/rect3.cpp b/modules/gdnative/godot/rect3.cpp deleted file mode 100644 index 88952ab49c..0000000000 --- a/modules/gdnative/godot/rect3.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/*************************************************************************/ -/* rect3.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/math/rect3.h" -#include "core/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _rect3_api_anchor() {} - -void GDAPI godot_rect3_new(godot_rect3 *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; - Rect3 *dest = (Rect3 *)r_dest; - *dest = Rect3(*pos, *size); -} - -godot_vector3 GDAPI godot_rect3_get_position(const godot_rect3 *p_self) { - godot_vector3 raw_ret; - const Rect3 *self = (const Rect3 *)p_self; - Vector3 *ret = (Vector3 *)&raw_ret; - *ret = self->position; - return raw_ret; -} - -void GDAPI godot_rect3_set_position(const godot_rect3 *p_self, const godot_vector3 *p_v) { - Rect3 *self = (Rect3 *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - self->position = *v; -} - -godot_vector3 GDAPI godot_rect3_get_size(const godot_rect3 *p_self) { - godot_vector3 raw_ret; - const Rect3 *self = (const Rect3 *)p_self; - Vector3 *ret = (Vector3 *)&raw_ret; - *ret = self->size; - return raw_ret; -} - -void GDAPI godot_rect3_set_size(const godot_rect3 *p_self, const godot_vector3 *p_v) { - Rect3 *self = (Rect3 *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - self->size = *v; -} - -godot_string GDAPI godot_rect3_as_string(const godot_rect3 *p_self) { - godot_string ret; - const Rect3 *self = (const Rect3 *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_real GDAPI godot_rect3_get_area(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->get_area(); -} - -godot_bool GDAPI godot_rect3_has_no_area(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->has_no_area(); -} - -godot_bool GDAPI godot_rect3_has_no_surface(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->has_no_surface(); -} - -godot_bool GDAPI godot_rect3_intersects(const godot_rect3 *p_self, const godot_rect3 *p_with) { - const Rect3 *self = (const Rect3 *)p_self; - const Rect3 *with = (const Rect3 *)p_with; - return self->intersects(*with); -} - -godot_bool GDAPI godot_rect3_encloses(const godot_rect3 *p_self, const godot_rect3 *p_with) { - const Rect3 *self = (const Rect3 *)p_self; - const Rect3 *with = (const Rect3 *)p_with; - return self->encloses(*with); -} - -godot_rect3 GDAPI godot_rect3_merge(const godot_rect3 *p_self, const godot_rect3 *p_with) { - godot_rect3 dest; - const Rect3 *self = (const Rect3 *)p_self; - const Rect3 *with = (const Rect3 *)p_with; - *((Rect3 *)&dest) = self->merge(*with); - return dest; -} - -godot_rect3 GDAPI godot_rect3_intersection(const godot_rect3 *p_self, const godot_rect3 *p_with) { - godot_rect3 dest; - const Rect3 *self = (const Rect3 *)p_self; - const Rect3 *with = (const Rect3 *)p_with; - *((Rect3 *)&dest) = self->intersection(*with); - return dest; -} - -godot_bool GDAPI godot_rect3_intersects_plane(const godot_rect3 *p_self, const godot_plane *p_plane) { - const Rect3 *self = (const Rect3 *)p_self; - const Plane *plane = (const Plane *)p_plane; - return self->intersects_plane(*plane); -} - -godot_bool GDAPI godot_rect3_intersects_segment(const godot_rect3 *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to) { - const Rect3 *self = (const Rect3 *)p_self; - const Vector3 *from = (const Vector3 *)p_from; - const Vector3 *to = (const Vector3 *)p_to; - return self->intersects_segment(*from, *to); -} - -godot_bool GDAPI godot_rect3_has_point(const godot_rect3 *p_self, const godot_vector3 *p_point) { - const Rect3 *self = (const Rect3 *)p_self; - const Vector3 *point = (const Vector3 *)p_point; - return self->has_point(*point); -} - -godot_vector3 GDAPI godot_rect3_get_support(const godot_rect3 *p_self, const godot_vector3 *p_dir) { - godot_vector3 dest; - const Rect3 *self = (const Rect3 *)p_self; - const Vector3 *dir = (const Vector3 *)p_dir; - *((Vector3 *)&dest) = self->get_support(*dir); - return dest; -} - -godot_vector3 GDAPI godot_rect3_get_longest_axis(const godot_rect3 *p_self) { - godot_vector3 dest; - const Rect3 *self = (const Rect3 *)p_self; - *((Vector3 *)&dest) = self->get_longest_axis(); - return dest; -} - -godot_int GDAPI godot_rect3_get_longest_axis_index(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->get_longest_axis_index(); -} - -godot_real GDAPI godot_rect3_get_longest_axis_size(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->get_longest_axis_size(); -} - -godot_vector3 GDAPI godot_rect3_get_shortest_axis(const godot_rect3 *p_self) { - godot_vector3 dest; - const Rect3 *self = (const Rect3 *)p_self; - *((Vector3 *)&dest) = self->get_shortest_axis(); - return dest; -} - -godot_int GDAPI godot_rect3_get_shortest_axis_index(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->get_shortest_axis_index(); -} - -godot_real GDAPI godot_rect3_get_shortest_axis_size(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->get_shortest_axis_size(); -} - -godot_rect3 GDAPI godot_rect3_expand(const godot_rect3 *p_self, const godot_vector3 *p_to_point) { - godot_rect3 dest; - const Rect3 *self = (const Rect3 *)p_self; - const Vector3 *to_point = (const Vector3 *)p_to_point; - *((Rect3 *)&dest) = self->expand(*to_point); - return dest; -} - -godot_rect3 GDAPI godot_rect3_grow(const godot_rect3 *p_self, const godot_real p_by) { - godot_rect3 dest; - const Rect3 *self = (const Rect3 *)p_self; - - *((Rect3 *)&dest) = self->grow(p_by); - return dest; -} - -godot_vector3 GDAPI godot_rect3_get_endpoint(const godot_rect3 *p_self, const godot_int p_idx) { - godot_vector3 dest; - const Rect3 *self = (const Rect3 *)p_self; - - *((Vector3 *)&dest) = self->get_endpoint(p_idx); - return dest; -} - -godot_bool GDAPI godot_rect3_operator_equal(const godot_rect3 *p_self, const godot_rect3 *p_b) { - const Rect3 *self = (const Rect3 *)p_self; - const Rect3 *b = (const Rect3 *)p_b; - return *self == *b; -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/rect3.h b/modules/gdnative/godot/rect3.h deleted file mode 100644 index ca96aadd5c..0000000000 --- a/modules/gdnative/godot/rect3.h +++ /dev/null @@ -1,108 +0,0 @@ -/*************************************************************************/ -/* rect3.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_RECT3_H -#define GODOT_RECT3_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define GODOT_RECT3_SIZE 24 - -#ifndef GODOT_CORE_API_GODOT_RECT3_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_RECT3_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_RECT3_SIZE]; -} godot_rect3; -#endif - -#include -#include -#include - -void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size); - -godot_vector3 GDAPI godot_rect3_get_position(const godot_rect3 *p_self); -void GDAPI godot_rect3_set_position(const godot_rect3 *p_self, const godot_vector3 *p_v); - -godot_vector3 GDAPI godot_rect3_get_size(const godot_rect3 *p_self); -void GDAPI godot_rect3_set_size(const godot_rect3 *p_self, const godot_vector3 *p_v); - -godot_string GDAPI godot_rect3_as_string(const godot_rect3 *p_self); - -godot_real GDAPI godot_rect3_get_area(const godot_rect3 *p_self); - -godot_bool GDAPI godot_rect3_has_no_area(const godot_rect3 *p_self); - -godot_bool GDAPI godot_rect3_has_no_surface(const godot_rect3 *p_self); - -godot_bool GDAPI godot_rect3_intersects(const godot_rect3 *p_self, const godot_rect3 *p_with); - -godot_bool GDAPI godot_rect3_encloses(const godot_rect3 *p_self, const godot_rect3 *p_with); - -godot_rect3 GDAPI godot_rect3_merge(const godot_rect3 *p_self, const godot_rect3 *p_with); - -godot_rect3 GDAPI godot_rect3_intersection(const godot_rect3 *p_self, const godot_rect3 *p_with); - -godot_bool GDAPI godot_rect3_intersects_plane(const godot_rect3 *p_self, const godot_plane *p_plane); - -godot_bool GDAPI godot_rect3_intersects_segment(const godot_rect3 *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to); - -godot_bool GDAPI godot_rect3_has_point(const godot_rect3 *p_self, const godot_vector3 *p_point); - -godot_vector3 GDAPI godot_rect3_get_support(const godot_rect3 *p_self, const godot_vector3 *p_dir); - -godot_vector3 GDAPI godot_rect3_get_longest_axis(const godot_rect3 *p_self); - -godot_int GDAPI godot_rect3_get_longest_axis_index(const godot_rect3 *p_self); - -godot_real GDAPI godot_rect3_get_longest_axis_size(const godot_rect3 *p_self); - -godot_vector3 GDAPI godot_rect3_get_shortest_axis(const godot_rect3 *p_self); - -godot_int GDAPI godot_rect3_get_shortest_axis_index(const godot_rect3 *p_self); - -godot_real GDAPI godot_rect3_get_shortest_axis_size(const godot_rect3 *p_self); - -godot_rect3 GDAPI godot_rect3_expand(const godot_rect3 *p_self, const godot_vector3 *p_to_point); - -godot_rect3 GDAPI godot_rect3_grow(const godot_rect3 *p_self, const godot_real p_by); - -godot_vector3 GDAPI godot_rect3_get_endpoint(const godot_rect3 *p_self, const godot_int p_idx); - -godot_bool GDAPI godot_rect3_operator_equal(const godot_rect3 *p_self, const godot_rect3 *p_b); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_RECT3_H diff --git a/modules/gdnative/godot/rid.cpp b/modules/gdnative/godot/rid.cpp deleted file mode 100644 index 51c8aaa1b3..0000000000 --- a/modules/gdnative/godot/rid.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************/ -/* rid.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/resource.h" -#include "core/rid.h" -#include "core/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _rid_api_anchor() {} - -void GDAPI godot_rid_new(godot_rid *r_dest) { - RID *dest = (RID *)r_dest; - memnew_placement(dest, RID); -} - -godot_int GDAPI godot_rid_get_id(const godot_rid *p_self) { - const RID *self = (const RID *)p_self; - return self->get_id(); -} - -void GDAPI godot_rid_new_with_resource(godot_rid *r_dest, const godot_object *p_from) { - const Resource *res_from = Object::cast_to((Object *)p_from); - godot_rid_new(r_dest); - if (res_from) { - RID *dest = (RID *)r_dest; - *dest = RID(res_from->get_rid()); - } -} - -godot_bool GDAPI godot_rid_operator_equal(const godot_rid *p_self, const godot_rid *p_b) { - const RID *self = (const RID *)p_self; - const RID *b = (const RID *)p_b; - return *self == *b; -} - -godot_bool GDAPI godot_rid_operator_less(const godot_rid *p_self, const godot_rid *p_b) { - const RID *self = (const RID *)p_self; - const RID *b = (const RID *)p_b; - return *self < *b; -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/rid.h b/modules/gdnative/godot/rid.h deleted file mode 100644 index c56ff38735..0000000000 --- a/modules/gdnative/godot/rid.h +++ /dev/null @@ -1,64 +0,0 @@ -/*************************************************************************/ -/* rid.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_RID_H -#define GODOT_RID_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define GODOT_RID_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_RID_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_RID_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_RID_SIZE]; -} godot_rid; -#endif - -#include - -void GDAPI godot_rid_new(godot_rid *r_dest); - -godot_int GDAPI godot_rid_get_id(const godot_rid *p_self); - -void GDAPI godot_rid_new_with_resource(godot_rid *r_dest, const godot_object *p_from); - -godot_bool GDAPI godot_rid_operator_equal(const godot_rid *p_self, const godot_rid *p_b); - -godot_bool GDAPI godot_rid_operator_less(const godot_rid *p_self, const godot_rid *p_b); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_RID_H diff --git a/modules/gdnative/godot/string.cpp b/modules/gdnative/godot/string.cpp deleted file mode 100644 index 1282cf95e5..0000000000 --- a/modules/gdnative/godot/string.cpp +++ /dev/null @@ -1,1267 +0,0 @@ -/*************************************************************************/ -/* string.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/variant.h" -#include "string_db.h" -#include "ustring.h" - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -void _string_api_anchor() { -} - -void GDAPI godot_string_new(godot_string *r_dest) { - String *dest = (String *)r_dest; - memnew_placement(dest, String); -} - -void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src) { - String *dest = (String *)r_dest; - const String *src = (const String *)p_src; - memnew_placement(dest, String(*src)); -} - -void GDAPI godot_string_new_data(godot_string *r_dest, const char *p_contents, const int p_size) { - String *dest = (String *)r_dest; - memnew_placement(dest, String(String::utf8(p_contents, p_size))); -} - -void GDAPI godot_string_new_unicode_data(godot_string *r_dest, const wchar_t *p_contents, const int p_size) { - String *dest = (String *)r_dest; - memnew_placement(dest, String(p_contents, p_size)); -} - -void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *p_size) { - String *self = (String *)p_self; - if (p_size != NULL) { - *p_size = self->utf8().length(); - } - if (p_dest != NULL) { - memcpy(p_dest, self->utf8().get_data(), *p_size); - } -} - -wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx) { - String *self = (String *)p_self; - return &(self->operator[](p_idx)); -} - -const char GDAPI *godot_string_c_str(const godot_string *p_self) { - const String *self = (const String *)p_self; - return self->utf8().get_data(); -} - -const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_self) { - const String *self = (const String *)p_self; - return self->c_str(); -} - -godot_bool GDAPI godot_string_operator_equal(const godot_string *p_self, const godot_string *p_b) { - const String *self = (const String *)p_self; - const String *b = (const String *)p_b; - return *self == *b; -} - -godot_bool GDAPI godot_string_operator_less(const godot_string *p_self, const godot_string *p_b) { - const String *self = (const String *)p_self; - const String *b = (const String *)p_b; - return *self < *b; -} - -godot_string GDAPI godot_string_operator_plus(const godot_string *p_self, const godot_string *p_b) { - godot_string ret; - const String *self = (const String *)p_self; - const String *b = (const String *)p_b; - memnew_placement(&ret, String(*self + *b)); - return ret; -} - -void GDAPI godot_string_destroy(godot_string *p_self) { - String *self = (String *)p_self; - self->~String(); -} - -/* Standard size stuff */ - -godot_int GDAPI godot_string_length(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->length(); -} - -/* Helpers */ - -godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string) { - const String *self = (const String *)p_self; - const String *string = (const String *)p_string; - - return self->begins_with(*string); -} - -godot_bool GDAPI godot_string_begins_with_char_array(const godot_string *p_self, const char *p_char_array) { - const String *self = (const String *)p_self; - - return self->begins_with(p_char_array); -} - -godot_array GDAPI godot_string_bigrams(const godot_string *p_self) { - const String *self = (const String *)p_self; - Vector return_value = self->bigrams(); - - godot_array result; - memnew_placement(&result, Array); - Array *proxy = (Array *)&result; - proxy->resize(return_value.size()); - for (int i = 0; i < return_value.size(); i++) { - (*proxy)[i] = return_value[i]; - } - - return result; -}; - -godot_string GDAPI godot_string_chr(wchar_t p_character) { - godot_string result; - memnew_placement(&result, String(String::chr(p_character))); - - return result; -} - -godot_bool GDAPI godot_string_ends_with(const godot_string *p_self, const godot_string *p_string) { - const String *self = (const String *)p_self; - const String *string = (const String *)p_string; - - return self->ends_with(*string); -} - -godot_int GDAPI godot_string_find(const godot_string *p_self, godot_string p_what) { - const String *self = (const String *)p_self; - String *what = (String *)&p_what; - - return self->find(*what); -} - -godot_int GDAPI godot_string_find_from(const godot_string *p_self, godot_string p_what, godot_int p_from) { - const String *self = (const String *)p_self; - String *what = (String *)&p_what; - - return self->find(*what, p_from); -} - -godot_int GDAPI godot_string_findmk(const godot_string *p_self, const godot_array *p_keys) { - const String *self = (const String *)p_self; - - Vector keys; - Array *keys_proxy = (Array *)p_keys; - keys.resize(keys_proxy->size()); - for (int i = 0; i < keys_proxy->size(); i++) { - keys[i] = (*keys_proxy)[i]; - } - - return self->findmk(keys); -} - -godot_int GDAPI godot_string_findmk_from(const godot_string *p_self, const godot_array *p_keys, godot_int p_from) { - const String *self = (const String *)p_self; - - Vector keys; - Array *keys_proxy = (Array *)p_keys; - keys.resize(keys_proxy->size()); - for (int i = 0; i < keys_proxy->size(); i++) { - keys[i] = (*keys_proxy)[i]; - } - - return self->findmk(keys, p_from); -} - -godot_int GDAPI godot_string_findmk_from_in_place(const godot_string *p_self, const godot_array *p_keys, godot_int p_from, godot_int *r_key) { - const String *self = (const String *)p_self; - - Vector keys; - Array *keys_proxy = (Array *)p_keys; - keys.resize(keys_proxy->size()); - for (int i = 0; i < keys_proxy->size(); i++) { - keys[i] = (*keys_proxy)[i]; - } - - return self->findmk(keys, p_from, r_key); -} - -godot_int GDAPI godot_string_findn(const godot_string *p_self, godot_string p_what) { - const String *self = (const String *)p_self; - String *what = (String *)&p_what; - - return self->findn(*what); -} - -godot_int GDAPI godot_string_findn_from(const godot_string *p_self, godot_string p_what, godot_int p_from) { - const String *self = (const String *)p_self; - String *what = (String *)&p_what; - - return self->findn(*what, p_from); -} - -godot_int GDAPI godot_string_find_last(const godot_string *p_self, godot_string p_what) { - const String *self = (const String *)p_self; - String *what = (String *)&p_what; - - return self->find_last(*what); -} - -godot_string GDAPI godot_string_format(const godot_string *p_self, const godot_variant *p_values) { - const String *self = (const String *)p_self; - const Variant *values = (const Variant *)p_values; - godot_string result; - memnew_placement(&result, String(self->format(*values))); - - return result; -} - -godot_string GDAPI godot_string_format_with_custom_placeholder(const godot_string *p_self, const godot_variant *p_values, const char *p_placeholder) { - const String *self = (const String *)p_self; - const Variant *values = (const Variant *)p_values; - String placeholder = String(p_placeholder); - godot_string result; - memnew_placement(&result, String(self->format(*values, placeholder))); - - return result; -} - -godot_string GDAPI godot_string_hex_encode_buffer(const uint8_t *p_buffer, godot_int p_len) { - godot_string result; - memnew_placement(&result, String(String::hex_encode_buffer(p_buffer, p_len))); - - return result; -} - -godot_int GDAPI godot_string_hex_to_int(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->hex_to_int(); -} - -godot_int GDAPI godot_string_hex_to_int_without_prefix(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->hex_to_int(true); -} - -godot_string GDAPI godot_string_insert(const godot_string *p_self, godot_int p_at_pos, godot_string p_string) { - const String *self = (const String *)p_self; - String *content = (String *)&p_string; - godot_string result; - memnew_placement(&result, String(self->insert(p_at_pos, *content))); - - return result; -} - -godot_bool GDAPI godot_string_is_numeric(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_numeric(); -} - -godot_bool GDAPI godot_string_is_subsequence_of(const godot_string *p_self, const godot_string *p_string) { - const String *self = (const String *)p_self; - const String *string = (const String *)p_string; - - return self->is_subsequence_of(*string); -} - -godot_bool GDAPI godot_string_is_subsequence_ofi(const godot_string *p_self, const godot_string *p_string) { - const String *self = (const String *)p_self; - const String *string = (const String *)p_string; - - return self->is_subsequence_ofi(*string); -} - -godot_string GDAPI godot_string_lpad(const godot_string *p_self, godot_int p_min_length) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->lpad(p_min_length))); - - return result; -} - -godot_string GDAPI godot_string_lpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character) { - const String *self = (const String *)p_self; - const String *character = (const String *)p_character; - godot_string result; - memnew_placement(&result, String(self->lpad(p_min_length, *character))); - - return result; -} - -godot_bool GDAPI godot_string_match(const godot_string *p_self, const godot_string *p_wildcard) { - const String *self = (const String *)p_self; - const String *wildcard = (const String *)p_wildcard; - - return self->match(*wildcard); -} - -godot_bool GDAPI godot_string_matchn(const godot_string *p_self, const godot_string *p_wildcard) { - const String *self = (const String *)p_self; - const String *wildcard = (const String *)p_wildcard; - - return self->matchn(*wildcard); -} - -godot_string GDAPI godot_string_md5(const uint8_t *p_md5) { - godot_string result; - memnew_placement(&result, String(String::md5(p_md5))); - - return result; -} - -godot_string GDAPI godot_string_num(double p_num) { - godot_string result; - memnew_placement(&result, String(String::num(p_num))); - - return result; -} - -godot_string GDAPI godot_string_num_int64(int64_t p_num, godot_int p_base) { - godot_string result; - memnew_placement(&result, String(String::num_int64(p_num, p_base))); - - return result; -} - -godot_string GDAPI godot_string_num_int64_capitalized(int64_t p_num, godot_int p_base, godot_bool p_capitalize_hex) { - godot_string result; - memnew_placement(&result, String(String::num_int64(p_num, p_base, true))); - - return result; -} - -godot_string GDAPI godot_string_num_real(double p_num) { - godot_string result; - memnew_placement(&result, String(String::num_real(p_num))); - - return result; -} - -godot_string GDAPI godot_string_num_scientific(double p_num) { - godot_string result; - memnew_placement(&result, String(String::num_scientific(p_num))); - - return result; -} - -godot_string GDAPI godot_string_num_with_decimals(double p_num, godot_int p_decimals) { - godot_string result; - memnew_placement(&result, String(String::num(p_num, p_decimals))); - - return result; -} - -godot_string GDAPI godot_string_pad_decimals(const godot_string *p_self, godot_int p_digits) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->pad_decimals(p_digits))); - - return result; -} - -godot_string GDAPI godot_string_pad_zeros(const godot_string *p_self, godot_int p_digits) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->pad_zeros(p_digits))); - - return result; -} - -godot_string GDAPI godot_string_replace(const godot_string *p_self, godot_string p_key, godot_string p_with) { - const String *self = (const String *)p_self; - String *key = (String *)&p_key; - String *with = (String *)&p_with; - godot_string result; - memnew_placement(&result, String(self->replace(*key, *with))); - - return result; -} - -godot_string GDAPI godot_string_replacen(const godot_string *p_self, godot_string p_key, godot_string p_with) { - const String *self = (const String *)p_self; - String *key = (String *)&p_key; - String *with = (String *)&p_with; - godot_string result; - memnew_placement(&result, String(self->replacen(*key, *with))); - - return result; -} - -godot_int GDAPI godot_string_rfind(const godot_string *p_self, godot_string p_what) { - const String *self = (const String *)p_self; - String *what = (String *)&p_what; - - return self->rfind(*what); -} - -godot_int GDAPI godot_string_rfindn(const godot_string *p_self, godot_string p_what) { - const String *self = (const String *)p_self; - String *what = (String *)&p_what; - - return self->rfindn(*what); -} - -godot_int GDAPI godot_string_rfind_from(const godot_string *p_self, godot_string p_what, godot_int p_from) { - const String *self = (const String *)p_self; - String *what = (String *)&p_what; - - return self->rfind(*what, p_from); -} - -godot_int GDAPI godot_string_rfindn_from(const godot_string *p_self, godot_string p_what, godot_int p_from) { - const String *self = (const String *)p_self; - String *what = (String *)&p_what; - - return self->rfindn(*what, p_from); -} - -godot_string GDAPI godot_string_replace_first(const godot_string *p_self, godot_string p_key, godot_string p_with) { - const String *self = (const String *)p_self; - String *key = (String *)&p_key; - String *with = (String *)&p_with; - godot_string result; - memnew_placement(&result, String(self->replace_first(*key, *with))); - - return result; -} - -godot_string GDAPI godot_string_rpad(const godot_string *p_self, godot_int p_min_length) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->rpad(p_min_length))); - - return result; -} - -godot_string GDAPI godot_string_rpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character) { - const String *self = (const String *)p_self; - const String *character = (const String *)p_character; - godot_string result; - memnew_placement(&result, String(self->rpad(p_min_length, *character))); - - return result; -} - -godot_real GDAPI godot_string_similarity(const godot_string *p_self, const godot_string *p_string) { - const String *self = (const String *)p_self; - const String *string = (const String *)p_string; - - return self->similarity(*string); -} - -godot_string GDAPI godot_string_sprintf(const godot_string *p_self, const godot_array *p_values, godot_bool *p_error) { - const String *self = (const String *)p_self; - const Array *values = (const Array *)p_values; - - godot_string result; - String return_value = self->sprintf(*values, p_error); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_substr(const godot_string *p_self, godot_int p_from, godot_int p_chars) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->substr(p_from, p_chars))); - - return result; -} - -double GDAPI godot_string_to_double(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->to_double(); -} - -godot_real GDAPI godot_string_to_float(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->to_float(); -} - -godot_int GDAPI godot_string_to_int(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->to_int(); -} - -godot_string GDAPI godot_string_capitalize(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->capitalize())); - - return result; -}; - -godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->camelcase_to_underscore(false))); - - return result; -}; - -godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->camelcase_to_underscore())); - - return result; -}; - -double GDAPI godot_string_char_to_double(const char *p_what) { - return String::to_double(p_what); -}; - -godot_int GDAPI godot_string_char_to_int(const char *p_what) { - return String::to_int(p_what); -}; - -int64_t GDAPI godot_string_wchar_to_int(const wchar_t *p_str) { - return String::to_int(p_str); -}; - -godot_int GDAPI godot_string_char_to_int_with_len(const char *p_what, godot_int p_len) { - return String::to_int(p_what, p_len); -}; - -int64_t GDAPI godot_string_char_to_int64_with_len(const wchar_t *p_str, int p_len) { - return String::to_int(p_str, p_len); -}; - -int64_t GDAPI godot_string_hex_to_int64(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->hex_to_int64(false); -}; - -int64_t GDAPI godot_string_hex_to_int64_with_prefix(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->hex_to_int64(); -}; - -int64_t GDAPI godot_string_to_int64(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->to_int64(); -}; - -double GDAPI godot_string_unicode_char_to_double(const wchar_t *p_str, const wchar_t **r_end) { - return String::to_double(p_str, r_end); -} - -godot_string GDAPI godot_string_get_slice(const godot_string *p_self, godot_string p_splitter, godot_int p_slice) { - const String *self = (const String *)p_self; - String *splitter = (String *)&p_splitter; - godot_string result; - memnew_placement(&result, String(self->get_slice(*splitter, p_slice))); - - return result; -}; - -godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, wchar_t p_splitter, godot_int p_slice) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->get_slicec(p_splitter, p_slice))); - - return result; -}; - -godot_array GDAPI godot_string_split(const godot_string *p_self, const godot_string *p_splitter) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - godot_array result; - memnew_placement(&result, Array); - Array *proxy = (Array *)&result; - Vector return_value = self->split(*splitter, false); - - proxy->resize(return_value.size()); - for (int i = 0; i < return_value.size(); i++) { - (*proxy)[i] = return_value[i]; - } - - return result; -}; - -godot_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, const godot_string *p_splitter) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - godot_array result; - memnew_placement(&result, Array); - Array *proxy = (Array *)&result; - Vector return_value = self->split(*splitter); - - proxy->resize(return_value.size()); - for (int i = 0; i < return_value.size(); i++) { - (*proxy)[i] = return_value[i]; - } - - return result; -}; - -godot_array GDAPI godot_string_split_floats(const godot_string *p_self, const godot_string *p_splitter) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - godot_array result; - memnew_placement(&result, Array); - Array *proxy = (Array *)&result; - Vector return_value = self->split_floats(*splitter, false); - - proxy->resize(return_value.size()); - for (int i = 0; i < return_value.size(); i++) { - (*proxy)[i] = return_value[i]; - } - - return result; -}; - -godot_array GDAPI godot_string_split_floats_allows_empty(const godot_string *p_self, const godot_string *p_splitter) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - godot_array result; - memnew_placement(&result, Array); - Array *proxy = (Array *)&result; - Vector return_value = self->split_floats(*splitter); - - proxy->resize(return_value.size()); - for (int i = 0; i < return_value.size(); i++) { - (*proxy)[i] = return_value[i]; - } - - return result; -}; - -godot_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const godot_array *p_splitters) { - const String *self = (const String *)p_self; - - Vector splitters; - Array *splitter_proxy = (Array *)p_splitters; - splitters.resize(splitter_proxy->size()); - for (int i = 0; i < splitter_proxy->size(); i++) { - splitters[i] = (*splitter_proxy)[i]; - } - - godot_array result; - memnew_placement(&result, Array); - Array *proxy = (Array *)&result; - Vector return_value = self->split_floats_mk(splitters, false); - - proxy->resize(return_value.size()); - for (int i = 0; i < return_value.size(); i++) { - (*proxy)[i] = return_value[i]; - } - - return result; -}; - -godot_array GDAPI godot_string_split_floats_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) { - const String *self = (const String *)p_self; - - Vector splitters; - Array *splitter_proxy = (Array *)p_splitters; - splitters.resize(splitter_proxy->size()); - for (int i = 0; i < splitter_proxy->size(); i++) { - splitters[i] = (*splitter_proxy)[i]; - } - - godot_array result; - memnew_placement(&result, Array); - Array *proxy = (Array *)&result; - Vector return_value = self->split_floats_mk(splitters); - - proxy->resize(return_value.size()); - for (int i = 0; i < return_value.size(); i++) { - (*proxy)[i] = return_value[i]; - } - - return result; -}; - -godot_array GDAPI godot_string_split_ints(const godot_string *p_self, const godot_string *p_splitter) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - godot_array result; - memnew_placement(&result, Array); - Array *proxy = (Array *)&result; - Vector return_value = self->split_ints(*splitter, false); - - proxy->resize(return_value.size()); - for (int i = 0; i < return_value.size(); i++) { - (*proxy)[i] = return_value[i]; - } - - return result; -}; - -godot_array GDAPI godot_string_split_ints_allows_empty(const godot_string *p_self, const godot_string *p_splitter) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - godot_array result; - memnew_placement(&result, Array); - Array *proxy = (Array *)&result; - Vector return_value = self->split_ints(*splitter); - - proxy->resize(return_value.size()); - for (int i = 0; i < return_value.size(); i++) { - (*proxy)[i] = return_value[i]; - } - - return result; -}; - -godot_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const godot_array *p_splitters) { - const String *self = (const String *)p_self; - - Vector splitters; - Array *splitter_proxy = (Array *)p_splitters; - splitters.resize(splitter_proxy->size()); - for (int i = 0; i < splitter_proxy->size(); i++) { - splitters[i] = (*splitter_proxy)[i]; - } - - godot_array result; - memnew_placement(&result, Array); - Array *proxy = (Array *)&result; - Vector return_value = self->split_ints_mk(splitters, false); - - proxy->resize(return_value.size()); - for (int i = 0; i < return_value.size(); i++) { - (*proxy)[i] = return_value[i]; - } - - return result; -}; - -godot_array GDAPI godot_string_split_ints_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) { - const String *self = (const String *)p_self; - - Vector splitters; - Array *splitter_proxy = (Array *)p_splitters; - splitters.resize(splitter_proxy->size()); - for (int i = 0; i < splitter_proxy->size(); i++) { - splitters[i] = (*splitter_proxy)[i]; - } - - godot_array result; - memnew_placement(&result, Array); - Array *proxy = (Array *)&result; - Vector return_value = self->split_ints_mk(splitters); - - proxy->resize(return_value.size()); - for (int i = 0; i < return_value.size(); i++) { - (*proxy)[i] = return_value[i]; - } - - return result; -}; - -godot_array GDAPI godot_string_split_spaces(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_array result; - memnew_placement(&result, Array); - Array *proxy = (Array *)&result; - Vector return_value = self->split_spaces(); - - proxy->resize(return_value.size()); - for (int i = 0; i < return_value.size(); i++) { - (*proxy)[i] = return_value[i]; - } - - return result; -}; - -godot_int GDAPI godot_string_get_slice_count(const godot_string *p_self, godot_string p_splitter) { - const String *self = (const String *)p_self; - String *splitter = (String *)&p_splitter; - - return self->get_slice_count(*splitter); -}; - -wchar_t GDAPI godot_string_char_lowercase(wchar_t p_char) { - return String::char_lowercase(p_char); -}; - -wchar_t GDAPI godot_string_char_uppercase(wchar_t p_char) { - return String::char_uppercase(p_char); -}; - -godot_string GDAPI godot_string_to_lower(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->to_lower())); - - return result; -}; - -godot_string GDAPI godot_string_to_upper(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->to_upper())); - - return result; -}; - -godot_string GDAPI godot_string_get_basename(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->get_basename())); - - return result; -}; - -godot_string GDAPI godot_string_get_extension(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->get_extension())); - - return result; -}; - -godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->left(p_pos))); - - return result; -}; - -wchar_t GDAPI godot_string_ord_at(const godot_string *p_self, godot_int p_idx) { - const String *self = (const String *)p_self; - - return self->ord_at(p_idx); -}; - -godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godot_string *p_file) { - const String *self = (const String *)p_self; - const String *file = (const String *)p_file; - godot_string result; - memnew_placement(&result, String(self->plus_file(*file))); - - return result; -}; - -godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_pos) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->right(p_pos))); - - return result; -}; - -godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bool p_left, godot_bool p_right) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->strip_edges(p_left, p_right))); - - return result; -}; - -godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->strip_escapes())); - - return result; -}; - -void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars) { - String *self = (String *)p_self; - - return self->erase(p_pos, p_chars); -}; - -void GDAPI godot_string_ascii(godot_string *p_self, char *result) { - String *self = (String *)p_self; - Vector return_value = self->ascii(); - - for (int i = 0; i < return_value.size(); i++) { - result[i] = return_value[i]; - } -} - -void GDAPI godot_string_ascii_extended(godot_string *p_self, char *result) { - String *self = (String *)p_self; - Vector return_value = self->ascii(true); - - for (int i = 0; i < return_value.size(); i++) { - result[i] = return_value[i]; - } -} - -void GDAPI godot_string_utf8(godot_string *p_self, char *result) { - String *self = (String *)p_self; - Vector return_value = self->utf8(); - - for (int i = 0; i < return_value.size(); i++) { - result[i] = return_value[i]; - } -} - -godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8) { - String *self = (String *)p_self; - - return self->parse_utf8(p_utf8); -}; - -godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len) { - String *self = (String *)p_self; - - return self->parse_utf8(p_utf8, p_len); -}; - -godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8) { - godot_string result; - memnew_placement(&result, String(String::utf8(p_utf8))); - - return result; -}; - -godot_string GDAPI godot_string_chars_to_utf8_with_len(const char *p_utf8, godot_int p_len) { - godot_string result; - memnew_placement(&result, String(String::utf8(p_utf8, p_len))); - - return result; -}; - -uint32_t GDAPI godot_string_hash(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->hash(); -}; - -uint64_t GDAPI godot_string_hash64(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->hash64(); -}; - -uint32_t GDAPI godot_string_hash_chars(const char *p_cstr) { - return String::hash(p_cstr); -}; - -uint32_t GDAPI godot_string_hash_chars_with_len(const char *p_cstr, godot_int p_len) { - return String::hash(p_cstr, p_len); -}; - -uint32_t GDAPI godot_string_hash_utf8_chars(const wchar_t *p_str) { - return String::hash(p_str); -}; - -uint32_t GDAPI godot_string_hash_utf8_chars_with_len(const wchar_t *p_str, godot_int p_len) { - return String::hash(p_str, p_len); -}; - -godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self) { - const String *self = (const String *)p_self; - Vector tmp_result = self->md5_buffer(); - - godot_pool_byte_array result; - memnew_placement(&result, PoolByteArray); - PoolByteArray *proxy = (PoolByteArray *)&result; - PoolByteArray::Write proxy_writer = proxy->write(); - proxy->resize(tmp_result.size()); - - for (int i = 0; i < tmp_result.size(); i++) { - proxy_writer[i] = tmp_result[i]; - } - - return result; -}; - -godot_string GDAPI godot_string_md5_text(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->md5_text())); - - return result; -}; - -godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self) { - const String *self = (const String *)p_self; - Vector tmp_result = self->sha256_buffer(); - - godot_pool_byte_array result; - memnew_placement(&result, PoolByteArray); - PoolByteArray *proxy = (PoolByteArray *)&result; - PoolByteArray::Write proxy_writer = proxy->write(); - proxy->resize(tmp_result.size()); - - for (int i = 0; i < tmp_result.size(); i++) { - proxy_writer[i] = tmp_result[i]; - } - - return result; -}; - -godot_string GDAPI godot_string_sha256_text(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->sha256_text())); - - return result; -}; - -godot_bool godot_string_empty(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->empty(); -}; - -// path functions -godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->get_base_dir(); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_get_file(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->get_file(); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_humanize_size(size_t p_size) { - godot_string result; - String return_value = String::humanize_size(p_size); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_bool GDAPI godot_string_is_abs_path(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_abs_path(); -}; - -godot_bool GDAPI godot_string_is_rel_path(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_rel_path(); -}; - -godot_bool GDAPI godot_string_is_resource_file(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_resource_file(); -}; - -godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_string *p_path) { - const String *self = (const String *)p_self; - String *path = (String *)p_path; - godot_string result; - String return_value = self->path_to(*path); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const godot_string *p_path) { - const String *self = (const String *)p_self; - String *path = (String *)p_path; - godot_string result; - String return_value = self->path_to_file(*path); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_simplify_path(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->simplify_path(); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_c_escape(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->c_escape(); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->c_escape_multiline(); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_c_unescape(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->c_unescape(); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_http_escape(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->http_escape(); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_http_unescape(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->http_unescape(); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_json_escape(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->json_escape(); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_word_wrap(const godot_string *p_self, godot_int p_chars_per_line) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->word_wrap(p_chars_per_line); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_xml_escape(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->xml_escape(); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->xml_escape(true); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->xml_unescape(); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_percent_decode(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->percent_decode(); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_string GDAPI godot_string_percent_encode(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->percent_encode(); - memnew_placement(&result, String(return_value)); - - return result; -}; - -godot_bool GDAPI godot_string_is_valid_float(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_valid_float(); -}; - -godot_bool GDAPI godot_string_is_valid_hex_number(const godot_string *p_self, godot_bool p_with_prefix) { - const String *self = (const String *)p_self; - - return self->is_valid_hex_number(p_with_prefix); -}; - -godot_bool GDAPI godot_string_is_valid_html_color(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_valid_html_color(); -}; - -godot_bool GDAPI godot_string_is_valid_identifier(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_valid_identifier(); -}; - -godot_bool GDAPI godot_string_is_valid_integer(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_valid_integer(); -}; - -godot_bool GDAPI godot_string_is_valid_ip_address(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_valid_ip_address(); -}; - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/string.h b/modules/gdnative/godot/string.h deleted file mode 100644 index 128448e64e..0000000000 --- a/modules/gdnative/godot/string.h +++ /dev/null @@ -1,228 +0,0 @@ -/*************************************************************************/ -/* string.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_STRING_H -#define GODOT_STRING_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -#define GODOT_STRING_SIZE sizeof(void *) - -#ifndef GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_STRING_SIZE]; -} godot_string; -#endif - -#include -#include - -void GDAPI godot_string_new(godot_string *r_dest); -void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src); -void GDAPI godot_string_new_data(godot_string *r_dest, const char *p_contents, const int p_size); -void GDAPI godot_string_new_unicode_data(godot_string *r_dest, const wchar_t *p_contents, const int p_size); - -void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *p_size); - -wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx); -const char GDAPI *godot_string_c_str(const godot_string *p_self); -const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_self); - -godot_bool GDAPI godot_string_operator_equal(const godot_string *p_self, const godot_string *p_b); -godot_bool GDAPI godot_string_operator_less(const godot_string *p_self, const godot_string *p_b); -godot_string GDAPI godot_string_operator_plus(const godot_string *p_self, const godot_string *p_b); - -/* Standard size stuff */ - -godot_int GDAPI godot_string_length(const godot_string *p_self); - -/* Helpers */ - -godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string); -godot_bool GDAPI godot_string_begins_with_char_array(const godot_string *p_self, const char *p_char_array); -godot_array GDAPI godot_string_bigrams(const godot_string *p_self); -godot_string GDAPI godot_string_chr(wchar_t p_character); -godot_bool GDAPI godot_string_ends_with(const godot_string *p_self, const godot_string *p_string); -godot_int GDAPI godot_string_find(const godot_string *p_self, godot_string p_what); -godot_int GDAPI godot_string_find_from(const godot_string *p_self, godot_string p_what, godot_int p_from); -godot_int GDAPI godot_string_findmk(const godot_string *p_self, const godot_array *p_keys); -godot_int GDAPI godot_string_findmk_from(const godot_string *p_self, const godot_array *p_keys, godot_int p_from); -godot_int GDAPI godot_string_findmk_from_in_place(const godot_string *p_self, const godot_array *p_keys, godot_int p_from, godot_int *r_key); -godot_int GDAPI godot_string_findn(const godot_string *p_self, godot_string p_what); -godot_int GDAPI godot_string_findn_from(const godot_string *p_self, godot_string p_what, godot_int p_from); -godot_int GDAPI godot_string_find_last(const godot_string *p_self, godot_string p_what); -godot_string GDAPI godot_string_format(const godot_string *p_self, const godot_variant *p_values); -godot_string GDAPI godot_string_format_with_custom_placeholder(const godot_string *p_self, const godot_variant *p_values, const char *p_placeholder); -godot_string GDAPI godot_string_hex_encode_buffer(const uint8_t *p_buffer, godot_int p_len); -godot_int GDAPI godot_string_hex_to_int(const godot_string *p_self); -godot_int GDAPI godot_string_hex_to_int_without_prefix(const godot_string *p_self); -godot_string GDAPI godot_string_insert(const godot_string *p_self, godot_int p_at_pos, godot_string p_string); -godot_bool GDAPI godot_string_is_numeric(const godot_string *p_self); -godot_bool GDAPI godot_string_is_subsequence_of(const godot_string *p_self, const godot_string *p_string); -godot_bool GDAPI godot_string_is_subsequence_ofi(const godot_string *p_self, const godot_string *p_string); -godot_string GDAPI godot_string_lpad(const godot_string *p_self, godot_int p_min_length); -godot_string GDAPI godot_string_lpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character); -godot_bool GDAPI godot_string_match(const godot_string *p_self, const godot_string *p_wildcard); -godot_bool GDAPI godot_string_matchn(const godot_string *p_self, const godot_string *p_wildcard); -godot_string GDAPI godot_string_md5(const uint8_t *p_md5); -godot_string GDAPI godot_string_num(double p_num); -godot_string GDAPI godot_string_num_int64(int64_t p_num, godot_int p_base); -godot_string GDAPI godot_string_num_int64_capitalized(int64_t p_num, godot_int p_base, godot_bool p_capitalize_hex); -godot_string GDAPI godot_string_num_real(double p_num); -godot_string GDAPI godot_string_num_scientific(double p_num); -godot_string GDAPI godot_string_num_with_decimals(double p_num, godot_int p_decimals); -godot_string GDAPI godot_string_pad_decimals(const godot_string *p_self, godot_int p_digits); -godot_string GDAPI godot_string_pad_zeros(const godot_string *p_self, godot_int p_digits); -godot_string GDAPI godot_string_replace_first(const godot_string *p_self, godot_string p_key, godot_string p_with); -godot_string GDAPI godot_string_replace(const godot_string *p_self, godot_string p_key, godot_string p_with); -godot_string GDAPI godot_string_replacen(const godot_string *p_self, godot_string p_key, godot_string p_with); -godot_int GDAPI godot_string_rfind(const godot_string *p_self, godot_string p_what); -godot_int GDAPI godot_string_rfindn(const godot_string *p_self, godot_string p_what); -godot_int GDAPI godot_string_rfind_from(const godot_string *p_self, godot_string p_what, godot_int p_from); -godot_int GDAPI godot_string_rfindn_from(const godot_string *p_self, godot_string p_what, godot_int p_from); -godot_string GDAPI godot_string_rpad(const godot_string *p_self, godot_int p_min_length); -godot_string GDAPI godot_string_rpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character); -godot_real GDAPI godot_string_similarity(const godot_string *p_self, const godot_string *p_string); -godot_string GDAPI godot_string_sprintf(const godot_string *p_self, const godot_array *p_values, godot_bool *p_error); -godot_string GDAPI godot_string_substr(const godot_string *p_self, godot_int p_from, godot_int p_chars); -double GDAPI godot_string_to_double(const godot_string *p_self); -godot_real GDAPI godot_string_to_float(const godot_string *p_self); -godot_int GDAPI godot_string_to_int(const godot_string *p_self); - -godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_self); -godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_string *p_self); -godot_string GDAPI godot_string_capitalize(const godot_string *p_self); -double GDAPI godot_string_char_to_double(const char *p_what); -godot_int GDAPI godot_string_char_to_int(const char *p_what); -int64_t GDAPI godot_string_wchar_to_int(const wchar_t *p_str); -godot_int GDAPI godot_string_char_to_int_with_len(const char *p_what, godot_int p_len); -int64_t GDAPI godot_string_char_to_int64_with_len(const wchar_t *p_str, int p_len); -int64_t GDAPI godot_string_hex_to_int64(const godot_string *p_self); -int64_t GDAPI godot_string_hex_to_int64_with_prefix(const godot_string *p_self); -int64_t GDAPI godot_string_to_int64(const godot_string *p_self); -double GDAPI godot_string_unicode_char_to_double(const wchar_t *p_str, const wchar_t **r_end); - -godot_int GDAPI godot_string_get_slice_count(const godot_string *p_self, godot_string p_splitter); -godot_string GDAPI godot_string_get_slice(const godot_string *p_self, godot_string p_splitter, godot_int p_slice); -godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, wchar_t p_splitter, godot_int p_slice); - -godot_array GDAPI godot_string_split(const godot_string *p_self, const godot_string *p_splitter); -godot_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, const godot_string *p_splitter); -godot_array GDAPI godot_string_split_floats(const godot_string *p_self, const godot_string *p_splitter); -godot_array GDAPI godot_string_split_floats_allows_empty(const godot_string *p_self, const godot_string *p_splitter); -godot_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const godot_array *p_splitters); -godot_array GDAPI godot_string_split_floats_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters); -godot_array GDAPI godot_string_split_ints(const godot_string *p_self, const godot_string *p_splitter); -godot_array GDAPI godot_string_split_ints_allows_empty(const godot_string *p_self, const godot_string *p_splitter); -godot_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const godot_array *p_splitters); -godot_array GDAPI godot_string_split_ints_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters); -godot_array GDAPI godot_string_split_spaces(const godot_string *p_self); - -wchar_t GDAPI godot_string_char_lowercase(wchar_t p_char); -wchar_t GDAPI godot_string_char_uppercase(wchar_t p_char); -godot_string GDAPI godot_string_to_lower(const godot_string *p_self); -godot_string GDAPI godot_string_to_upper(const godot_string *p_self); - -godot_string GDAPI godot_string_get_basename(const godot_string *p_self); -godot_string GDAPI godot_string_get_extension(const godot_string *p_self); -godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos); -wchar_t GDAPI godot_string_ord_at(const godot_string *p_self, godot_int p_idx); -godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godot_string *p_file); -godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_pos); -godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bool p_left, godot_bool p_right); -godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self); - -void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars); - -void GDAPI godot_string_ascii(godot_string *p_self, char *result); -void GDAPI godot_string_ascii_extended(godot_string *p_self, char *result); -void GDAPI godot_string_utf8(godot_string *p_self, char *result); -godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8); -godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len); -godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8); -godot_string GDAPI godot_string_chars_to_utf8_with_len(const char *p_utf8, godot_int p_len); - -uint32_t GDAPI godot_string_hash(const godot_string *p_self); -uint64_t GDAPI godot_string_hash64(const godot_string *p_self); -uint32_t GDAPI godot_string_hash_chars(const char *p_cstr); -uint32_t GDAPI godot_string_hash_chars_with_len(const char *p_cstr, godot_int p_len); -uint32_t GDAPI godot_string_hash_utf8_chars(const wchar_t *p_str); -uint32_t GDAPI godot_string_hash_utf8_chars_with_len(const wchar_t *p_str, godot_int p_len); -godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self); -godot_string GDAPI godot_string_md5_text(const godot_string *p_self); -godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self); -godot_string GDAPI godot_string_sha256_text(const godot_string *p_self); - -godot_bool godot_string_empty(const godot_string *p_self); - -// path functions -godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self); -godot_string GDAPI godot_string_get_file(const godot_string *p_self); -godot_string GDAPI godot_string_humanize_size(size_t p_size); -godot_bool GDAPI godot_string_is_abs_path(const godot_string *p_self); -godot_bool GDAPI godot_string_is_rel_path(const godot_string *p_self); -godot_bool GDAPI godot_string_is_resource_file(const godot_string *p_self); -godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_string *p_path); -godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const godot_string *p_path); -godot_string GDAPI godot_string_simplify_path(const godot_string *p_self); - -godot_string GDAPI godot_string_c_escape(const godot_string *p_self); -godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self); -godot_string GDAPI godot_string_c_unescape(const godot_string *p_self); -godot_string GDAPI godot_string_http_escape(const godot_string *p_self); -godot_string GDAPI godot_string_http_unescape(const godot_string *p_self); -godot_string GDAPI godot_string_json_escape(const godot_string *p_self); -godot_string GDAPI godot_string_word_wrap(const godot_string *p_self, godot_int p_chars_per_line); -godot_string GDAPI godot_string_xml_escape(const godot_string *p_self); -godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_self); -godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self); - -godot_string GDAPI godot_string_percent_decode(const godot_string *p_self); -godot_string GDAPI godot_string_percent_encode(const godot_string *p_self); - -godot_bool GDAPI godot_string_is_valid_float(const godot_string *p_self); -godot_bool GDAPI godot_string_is_valid_hex_number(const godot_string *p_self, godot_bool p_with_prefix); -godot_bool GDAPI godot_string_is_valid_html_color(const godot_string *p_self); -godot_bool GDAPI godot_string_is_valid_identifier(const godot_string *p_self); -godot_bool GDAPI godot_string_is_valid_integer(const godot_string *p_self); -godot_bool GDAPI godot_string_is_valid_ip_address(const godot_string *p_self); - -void GDAPI godot_string_destroy(godot_string *p_self); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_STRING_H diff --git a/modules/gdnative/godot/transform.cpp b/modules/gdnative/godot/transform.cpp deleted file mode 100644 index a965067b77..0000000000 --- a/modules/gdnative/godot/transform.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/*************************************************************************/ -/* transform.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/math/transform.h" -#include "core/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _transform_api_anchor() {} - -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; - const Vector3 *z_axis = (const Vector3 *)p_z_axis; - const Vector3 *origin = (const Vector3 *)p_origin; - Transform *dest = (Transform *)r_dest; - dest->basis.set_axis(0, *x_axis); - dest->basis.set_axis(1, *y_axis); - dest->basis.set_axis(2, *z_axis); - dest->origin = *origin; -} - -void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin) { - const Basis *basis = (const Basis *)p_basis; - const Vector3 *origin = (const Vector3 *)p_origin; - Transform *dest = (Transform *)r_dest; - *dest = Transform(*basis, *origin); -} - -godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self) { - godot_basis dest; - const Transform *self = (const Transform *)p_self; - *((Basis *)&dest) = self->basis; - return dest; -} - -void GDAPI godot_transform_set_basis(godot_transform *p_self, godot_basis *p_v) { - Transform *self = (Transform *)p_self; - const Basis *v = (const Basis *)p_v; - self->basis = *v; -} - -godot_vector3 GDAPI godot_transform_get_origin(const godot_transform *p_self) { - godot_vector3 dest; - const Transform *self = (const Transform *)p_self; - *((Vector3 *)&dest) = self->origin; - return dest; -} - -void GDAPI godot_transform_set_origin(godot_transform *p_self, godot_vector3 *p_v) { - Transform *self = (Transform *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - self->origin = *v; -} - -godot_string GDAPI godot_transform_as_string(const godot_transform *p_self) { - godot_string ret; - const Transform *self = (const Transform *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_transform GDAPI godot_transform_inverse(const godot_transform *p_self) { - godot_transform dest; - const Transform *self = (const Transform *)p_self; - *((Transform *)&dest) = self->inverse(); - return dest; -} - -godot_transform GDAPI godot_transform_affine_inverse(const godot_transform *p_self) { - godot_transform dest; - const Transform *self = (const Transform *)p_self; - *((Transform *)&dest) = self->affine_inverse(); - return dest; -} - -godot_transform GDAPI godot_transform_orthonormalized(const godot_transform *p_self) { - godot_transform dest; - const Transform *self = (const Transform *)p_self; - *((Transform *)&dest) = self->orthonormalized(); - return dest; -} - -godot_transform GDAPI godot_transform_rotated(const godot_transform *p_self, const godot_vector3 *p_axis, const godot_real p_phi) { - godot_transform dest; - const Transform *self = (const Transform *)p_self; - const Vector3 *axis = (const Vector3 *)p_axis; - *((Transform *)&dest) = self->rotated(*axis, p_phi); - return dest; -} - -godot_transform GDAPI godot_transform_scaled(const godot_transform *p_self, const godot_vector3 *p_scale) { - godot_transform dest; - const Transform *self = (const Transform *)p_self; - const Vector3 *scale = (const Vector3 *)p_scale; - *((Transform *)&dest) = self->scaled(*scale); - return dest; -} - -godot_transform GDAPI godot_transform_translated(const godot_transform *p_self, const godot_vector3 *p_ofs) { - godot_transform dest; - const Transform *self = (const Transform *)p_self; - const Vector3 *ofs = (const Vector3 *)p_ofs; - *((Transform *)&dest) = self->translated(*ofs); - return dest; -} - -godot_transform GDAPI godot_transform_looking_at(const godot_transform *p_self, const godot_vector3 *p_target, const godot_vector3 *p_up) { - godot_transform dest; - const Transform *self = (const Transform *)p_self; - const Vector3 *target = (const Vector3 *)p_target; - const Vector3 *up = (const Vector3 *)p_up; - *((Transform *)&dest) = self->looking_at(*target, *up); - return dest; -} - -godot_plane GDAPI godot_transform_xform_plane(const godot_transform *p_self, const godot_plane *p_v) { - godot_plane raw_dest; - Plane *dest = (Plane *)&raw_dest; - const Transform *self = (const Transform *)p_self; - const Plane *v = (const Plane *)p_v; - *dest = self->xform(*v); - return raw_dest; -} - -godot_plane GDAPI godot_transform_xform_inv_plane(const godot_transform *p_self, const godot_plane *p_v) { - godot_plane raw_dest; - Plane *dest = (Plane *)&raw_dest; - const Transform *self = (const Transform *)p_self; - const Plane *v = (const Plane *)p_v; - *dest = self->xform_inv(*v); - return raw_dest; -} - -void GDAPI godot_transform_new_identity(godot_transform *r_dest) { - Transform *dest = (Transform *)r_dest; - *dest = Transform(); -} - -godot_bool GDAPI godot_transform_operator_equal(const godot_transform *p_self, const godot_transform *p_b) { - const Transform *self = (const Transform *)p_self; - const Transform *b = (const Transform *)p_b; - return *self == *b; -} - -godot_transform GDAPI godot_transform_operator_multiply(const godot_transform *p_self, const godot_transform *p_b) { - godot_transform raw_dest; - Transform *dest = (Transform *)&raw_dest; - const Transform *self = (const Transform *)p_self; - const Transform *b = (const Transform *)p_b; - *dest = *self * *b; - return raw_dest; -} - -godot_vector3 GDAPI godot_transform_xform_vector3(const godot_transform *p_self, const godot_vector3 *p_v) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - const Transform *self = (const Transform *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - *dest = self->xform(*v); - return raw_dest; -} - -godot_vector3 GDAPI godot_transform_xform_inv_vector3(const godot_transform *p_self, const godot_vector3 *p_v) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - const Transform *self = (const Transform *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - *dest = self->xform_inv(*v); - return raw_dest; -} - -godot_rect3 GDAPI godot_transform_xform_rect3(const godot_transform *p_self, const godot_rect3 *p_v) { - godot_rect3 raw_dest; - Rect3 *dest = (Rect3 *)&raw_dest; - const Transform *self = (const Transform *)p_self; - const Rect3 *v = (const Rect3 *)p_v; - *dest = self->xform(*v); - return raw_dest; -} - -godot_rect3 GDAPI godot_transform_xform_inv_rect3(const godot_transform *p_self, const godot_rect3 *p_v) { - godot_rect3 raw_dest; - Rect3 *dest = (Rect3 *)&raw_dest; - const Transform *self = (const Transform *)p_self; - const Rect3 *v = (const Rect3 *)p_v; - *dest = self->xform_inv(*v); - return raw_dest; -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/transform.h b/modules/gdnative/godot/transform.h deleted file mode 100644 index 60788e3d57..0000000000 --- a/modules/gdnative/godot/transform.h +++ /dev/null @@ -1,100 +0,0 @@ -/*************************************************************************/ -/* transform.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_TRANSFORM_H -#define GODOT_TRANSFORM_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define GODOT_TRANSFORM_SIZE 48 - -#ifndef GODOT_CORE_API_GODOT_TRANSFORM_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_TRANSFORM_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_TRANSFORM_SIZE]; -} godot_transform; -#endif - -#include -#include -#include -#include - -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); -void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin); - -godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self); -void GDAPI godot_transform_set_basis(godot_transform *p_self, godot_basis *p_v); - -godot_vector3 GDAPI godot_transform_get_origin(const godot_transform *p_self); -void GDAPI godot_transform_set_origin(godot_transform *p_self, godot_vector3 *p_v); - -godot_string GDAPI godot_transform_as_string(const godot_transform *p_self); - -godot_transform GDAPI godot_transform_inverse(const godot_transform *p_self); - -godot_transform GDAPI godot_transform_affine_inverse(const godot_transform *p_self); - -godot_transform GDAPI godot_transform_orthonormalized(const godot_transform *p_self); - -godot_transform GDAPI godot_transform_rotated(const godot_transform *p_self, const godot_vector3 *p_axis, const godot_real p_phi); - -godot_transform GDAPI godot_transform_scaled(const godot_transform *p_self, const godot_vector3 *p_scale); - -godot_transform GDAPI godot_transform_translated(const godot_transform *p_self, const godot_vector3 *p_ofs); - -godot_transform GDAPI godot_transform_looking_at(const godot_transform *p_self, const godot_vector3 *p_target, const godot_vector3 *p_up); - -godot_plane GDAPI godot_transform_xform_plane(const godot_transform *p_self, const godot_plane *p_v); - -godot_plane GDAPI godot_transform_xform_inv_plane(const godot_transform *p_self, const godot_plane *p_v); - -void GDAPI godot_transform_new_identity(godot_transform *r_dest); - -godot_bool GDAPI godot_transform_operator_equal(const godot_transform *p_self, const godot_transform *p_b); - -godot_transform GDAPI godot_transform_operator_multiply(const godot_transform *p_self, const godot_transform *p_b); - -godot_vector3 GDAPI godot_transform_xform_vector3(const godot_transform *p_self, const godot_vector3 *p_v); - -godot_vector3 GDAPI godot_transform_xform_inv_vector3(const godot_transform *p_self, const godot_vector3 *p_v); - -godot_rect3 GDAPI godot_transform_xform_rect3(const godot_transform *p_self, const godot_rect3 *p_v); - -godot_rect3 GDAPI godot_transform_xform_inv_rect3(const godot_transform *p_self, const godot_rect3 *p_v); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_TRANSFORM_H diff --git a/modules/gdnative/godot/transform2d.cpp b/modules/gdnative/godot/transform2d.cpp deleted file mode 100644 index 9fc44ecdfa..0000000000 --- a/modules/gdnative/godot/transform2d.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/*************************************************************************/ -/* transform2d.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/math/math_2d.h" -#include "core/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _transform2d_api_anchor() {} - -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; - *dest = Transform2D(p_rot, *pos); -} - -void GDAPI godot_transform2d_new_axis_origin(godot_transform2d *r_dest, const godot_vector2 *p_x_axis, const godot_vector2 *p_y_axis, const godot_vector2 *p_origin) { - const Vector2 *x_axis = (const Vector2 *)p_x_axis; - const Vector2 *y_axis = (const Vector2 *)p_y_axis; - const Vector2 *origin = (const Vector2 *)p_origin; - Transform2D *dest = (Transform2D *)r_dest; - *dest = Transform2D(x_axis->x, x_axis->y, y_axis->x, y_axis->y, origin->x, origin->y); -} - -godot_string GDAPI godot_transform2d_as_string(const godot_transform2d *p_self) { - godot_string ret; - const Transform2D *self = (const Transform2D *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_transform2d GDAPI godot_transform2d_inverse(const godot_transform2d *p_self) { - godot_transform2d dest; - const Transform2D *self = (const Transform2D *)p_self; - *((Transform2D *)&dest) = self->inverse(); - return dest; -} - -godot_transform2d GDAPI godot_transform2d_affine_inverse(const godot_transform2d *p_self) { - godot_transform2d dest; - const Transform2D *self = (const Transform2D *)p_self; - *((Transform2D *)&dest) = self->affine_inverse(); - return dest; -} - -godot_real GDAPI godot_transform2d_get_rotation(const godot_transform2d *p_self) { - const Transform2D *self = (const Transform2D *)p_self; - return self->get_rotation(); -} - -godot_vector2 GDAPI godot_transform2d_get_origin(const godot_transform2d *p_self) { - godot_vector2 dest; - const Transform2D *self = (const Transform2D *)p_self; - *((Vector2 *)&dest) = self->get_origin(); - return dest; -} - -godot_vector2 GDAPI godot_transform2d_get_scale(const godot_transform2d *p_self) { - godot_vector2 dest; - const Transform2D *self = (const Transform2D *)p_self; - *((Vector2 *)&dest) = self->get_scale(); - return dest; -} - -godot_transform2d GDAPI godot_transform2d_orthonormalized(const godot_transform2d *p_self) { - godot_transform2d dest; - const Transform2D *self = (const Transform2D *)p_self; - *((Transform2D *)&dest) = self->orthonormalized(); - return dest; -} - -godot_transform2d GDAPI godot_transform2d_rotated(const godot_transform2d *p_self, const godot_real p_phi) { - godot_transform2d dest; - const Transform2D *self = (const Transform2D *)p_self; - - *((Transform2D *)&dest) = self->rotated(p_phi); - return dest; -} - -godot_transform2d GDAPI godot_transform2d_scaled(const godot_transform2d *p_self, const godot_vector2 *p_scale) { - godot_transform2d dest; - const Transform2D *self = (const Transform2D *)p_self; - const Vector2 *scale = (const Vector2 *)p_scale; - *((Transform2D *)&dest) = self->scaled(*scale); - return dest; -} - -godot_transform2d GDAPI godot_transform2d_translated(const godot_transform2d *p_self, const godot_vector2 *p_offset) { - godot_transform2d dest; - const Transform2D *self = (const Transform2D *)p_self; - const Vector2 *offset = (const Vector2 *)p_offset; - *((Transform2D *)&dest) = self->translated(*offset); - return dest; -} - -godot_vector2 GDAPI godot_transform2d_xform_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Transform2D *self = (const Transform2D *)p_self; - const Vector2 *v = (const Vector2 *)p_v; - *dest = self->xform(*v); - return raw_dest; -} - -godot_vector2 GDAPI godot_transform2d_xform_inv_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Transform2D *self = (const Transform2D *)p_self; - const Vector2 *v = (const Vector2 *)p_v; - *dest = self->xform_inv(*v); - return raw_dest; -} - -godot_vector2 GDAPI godot_transform2d_basis_xform_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Transform2D *self = (const Transform2D *)p_self; - const Vector2 *v = (const Vector2 *)p_v; - *dest = self->basis_xform(*v); - return raw_dest; -} - -godot_vector2 GDAPI godot_transform2d_basis_xform_inv_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Transform2D *self = (const Transform2D *)p_self; - const Vector2 *v = (const Vector2 *)p_v; - *dest = self->basis_xform_inv(*v); - return raw_dest; -} - -godot_transform2d GDAPI godot_transform2d_interpolate_with(const godot_transform2d *p_self, const godot_transform2d *p_m, const godot_real p_c) { - godot_transform2d dest; - const Transform2D *self = (const Transform2D *)p_self; - const Transform2D *m = (const Transform2D *)p_m; - *((Transform2D *)&dest) = self->interpolate_with(*m, p_c); - return dest; -} - -godot_bool GDAPI godot_transform2d_operator_equal(const godot_transform2d *p_self, const godot_transform2d *p_b) { - const Transform2D *self = (const Transform2D *)p_self; - const Transform2D *b = (const Transform2D *)p_b; - return *self == *b; -} - -godot_transform2d GDAPI godot_transform2d_operator_multiply(const godot_transform2d *p_self, const godot_transform2d *p_b) { - godot_transform2d raw_dest; - Transform2D *dest = (Transform2D *)&raw_dest; - const Transform2D *self = (const Transform2D *)p_self; - const Transform2D *b = (const Transform2D *)p_b; - *dest = *self * *b; - return raw_dest; -} - -void GDAPI godot_transform2d_new_identity(godot_transform2d *r_dest) { - Transform2D *dest = (Transform2D *)r_dest; - *dest = Transform2D(); -} - -godot_rect2 GDAPI godot_transform2d_xform_rect2(const godot_transform2d *p_self, const godot_rect2 *p_v) { - godot_rect2 raw_dest; - Rect2 *dest = (Rect2 *)&raw_dest; - const Transform2D *self = (const Transform2D *)p_self; - const Rect2 *v = (const Rect2 *)p_v; - *dest = self->xform(*v); - return raw_dest; -} - -godot_rect2 GDAPI godot_transform2d_xform_inv_rect2(const godot_transform2d *p_self, const godot_rect2 *p_v) { - godot_rect2 raw_dest; - Rect2 *dest = (Rect2 *)&raw_dest; - const Transform2D *self = (const Transform2D *)p_self; - const Rect2 *v = (const Rect2 *)p_v; - *dest = self->xform_inv(*v); - return raw_dest; -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/transform2d.h b/modules/gdnative/godot/transform2d.h deleted file mode 100644 index c0f5725eed..0000000000 --- a/modules/gdnative/godot/transform2d.h +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************/ -/* transform2d.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_TRANSFORM2D_H -#define GODOT_TRANSFORM2D_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define GODOT_TRANSFORM2D_SIZE 24 - -#ifndef GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_TRANSFORM2D_SIZE]; -} godot_transform2d; -#endif - -#include -#include -#include - -void GDAPI godot_transform2d_new(godot_transform2d *r_dest, const godot_real p_rot, const godot_vector2 *p_pos); -void GDAPI godot_transform2d_new_axis_origin(godot_transform2d *r_dest, const godot_vector2 *p_x_axis, const godot_vector2 *p_y_axis, const godot_vector2 *p_origin); - -godot_string GDAPI godot_transform2d_as_string(const godot_transform2d *p_self); - -godot_transform2d GDAPI godot_transform2d_inverse(const godot_transform2d *p_self); - -godot_transform2d GDAPI godot_transform2d_affine_inverse(const godot_transform2d *p_self); - -godot_real GDAPI godot_transform2d_get_rotation(const godot_transform2d *p_self); - -godot_vector2 GDAPI godot_transform2d_get_origin(const godot_transform2d *p_self); - -godot_vector2 GDAPI godot_transform2d_get_scale(const godot_transform2d *p_self); - -godot_transform2d GDAPI godot_transform2d_orthonormalized(const godot_transform2d *p_self); - -godot_transform2d GDAPI godot_transform2d_rotated(const godot_transform2d *p_self, const godot_real p_phi); - -godot_transform2d GDAPI godot_transform2d_scaled(const godot_transform2d *p_self, const godot_vector2 *p_scale); - -godot_transform2d GDAPI godot_transform2d_translated(const godot_transform2d *p_self, const godot_vector2 *p_offset); - -godot_vector2 GDAPI godot_transform2d_xform_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v); - -godot_vector2 GDAPI godot_transform2d_xform_inv_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v); - -godot_vector2 GDAPI godot_transform2d_basis_xform_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v); - -godot_vector2 GDAPI godot_transform2d_basis_xform_inv_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v); - -godot_transform2d GDAPI godot_transform2d_interpolate_with(const godot_transform2d *p_self, const godot_transform2d *p_m, const godot_real p_c); - -godot_bool GDAPI godot_transform2d_operator_equal(const godot_transform2d *p_self, const godot_transform2d *p_b); - -godot_transform2d GDAPI godot_transform2d_operator_multiply(const godot_transform2d *p_self, const godot_transform2d *p_b); - -void GDAPI godot_transform2d_new_identity(godot_transform2d *r_dest); - -godot_rect2 GDAPI godot_transform2d_xform_rect2(const godot_transform2d *p_self, const godot_rect2 *p_v); - -godot_rect2 GDAPI godot_transform2d_xform_inv_rect2(const godot_transform2d *p_self, const godot_rect2 *p_v); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_TRANSFORM2D_H diff --git a/modules/gdnative/godot/variant.cpp b/modules/gdnative/godot/variant.cpp deleted file mode 100644 index 582544b3a0..0000000000 --- a/modules/gdnative/godot/variant.cpp +++ /dev/null @@ -1,481 +0,0 @@ -/*************************************************************************/ -/* variant.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _variant_api_anchor() {} - -#define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr) - -// Constructors - -godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_self) { - const Variant *self = (const Variant *)p_self; - return (godot_variant_type)self->get_type(); -} - -void GDAPI godot_variant_new_copy(godot_variant *p_dest, const godot_variant *p_src) { - Variant *dest = (Variant *)p_dest; - Variant *src = (Variant *)p_src; - memnew_placement(dest, Variant(*src)); -} - -void GDAPI godot_variant_new_nil(godot_variant *r_dest) { - Variant *dest = (Variant *)r_dest; - memnew_placement(dest, Variant); -} - -void GDAPI godot_variant_new_bool(godot_variant *r_dest, const godot_bool p_b) { - Variant *dest = (Variant *)r_dest; - memnew_placement_custom(dest, Variant, Variant(p_b)); -} - -void GDAPI godot_variant_new_uint(godot_variant *r_dest, const uint64_t p_i) { - Variant *dest = (Variant *)r_dest; - memnew_placement_custom(dest, Variant, Variant(p_i)); -} - -void GDAPI godot_variant_new_int(godot_variant *r_dest, const int64_t p_i) { - Variant *dest = (Variant *)r_dest; - memnew_placement_custom(dest, Variant, Variant(p_i)); -} - -void GDAPI godot_variant_new_real(godot_variant *r_dest, const double p_r) { - Variant *dest = (Variant *)r_dest; - memnew_placement_custom(dest, Variant, Variant(p_r)); -} - -void GDAPI godot_variant_new_string(godot_variant *r_dest, const godot_string *p_s) { - Variant *dest = (Variant *)r_dest; - String *s = (String *)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_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_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_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d) { - Variant *dest = (Variant *)r_dest; - Transform2D *t2d = (Transform2D *)p_t2d; - memnew_placement_custom(dest, Variant, Variant(*t2d)); -} - -void GDAPI godot_variant_new_plane(godot_variant *r_dest, const godot_plane *p_plane) { - Variant *dest = (Variant *)r_dest; - Plane *plane = (Plane *)p_plane; - memnew_placement_custom(dest, Variant, Variant(*plane)); -} - -void GDAPI godot_variant_new_quat(godot_variant *r_dest, const godot_quat *p_quat) { - Variant *dest = (Variant *)r_dest; - Quat *quat = (Quat *)p_quat; - memnew_placement_custom(dest, Variant, Variant(*quat)); -} - -void GDAPI godot_variant_new_rect3(godot_variant *r_dest, const godot_rect3 *p_rect3) { - Variant *dest = (Variant *)r_dest; - Rect3 *rect3 = (Rect3 *)p_rect3; - memnew_placement_custom(dest, Variant, Variant(*rect3)); -} - -void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis) { - Variant *dest = (Variant *)r_dest; - Basis *basis = (Basis *)p_basis; - memnew_placement_custom(dest, Variant, Variant(*basis)); -} - -void GDAPI godot_variant_new_transform(godot_variant *r_dest, const godot_transform *p_trans) { - Variant *dest = (Variant *)r_dest; - Transform *trans = (Transform *)p_trans; - memnew_placement_custom(dest, Variant, Variant(*trans)); -} - -void GDAPI godot_variant_new_color(godot_variant *r_dest, const godot_color *p_color) { - Variant *dest = (Variant *)r_dest; - Color *color = (Color *)p_color; - memnew_placement_custom(dest, Variant, Variant(*color)); -} - -void GDAPI godot_variant_new_node_path(godot_variant *r_dest, const godot_node_path *p_np) { - Variant *dest = (Variant *)r_dest; - NodePath *np = (NodePath *)p_np; - memnew_placement_custom(dest, Variant, Variant(*np)); -} - -void GDAPI godot_variant_new_rid(godot_variant *r_dest, const godot_rid *p_rid) { - Variant *dest = (Variant *)r_dest; - RID *rid = (RID *)p_rid; - memnew_placement_custom(dest, Variant, Variant(*rid)); -} - -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; - memnew_placement_custom(dest, Variant, Variant(obj)); -} - -void GDAPI godot_variant_new_dictionary(godot_variant *r_dest, const godot_dictionary *p_dict) { - Variant *dest = (Variant *)r_dest; - Dictionary *dict = (Dictionary *)p_dict; - memnew_placement_custom(dest, Variant, Variant(*dict)); -} - -void GDAPI godot_variant_new_array(godot_variant *r_dest, const godot_array *p_arr) { - Variant *dest = (Variant *)r_dest; - Array *arr = (Array *)p_arr; - memnew_placement_custom(dest, Variant, Variant(*arr)); -} - -void GDAPI godot_variant_new_pool_byte_array(godot_variant *r_dest, const godot_pool_byte_array *p_pba) { - Variant *dest = (Variant *)r_dest; - PoolByteArray *pba = (PoolByteArray *)p_pba; - memnew_placement_custom(dest, Variant, Variant(*pba)); -} - -void GDAPI godot_variant_new_pool_int_array(godot_variant *r_dest, const godot_pool_int_array *p_pia) { - Variant *dest = (Variant *)r_dest; - PoolIntArray *pia = (PoolIntArray *)p_pia; - memnew_placement_custom(dest, Variant, Variant(*pia)); -} - -void GDAPI godot_variant_new_pool_real_array(godot_variant *r_dest, const godot_pool_real_array *p_pra) { - Variant *dest = (Variant *)r_dest; - PoolRealArray *pra = (PoolRealArray *)p_pra; - memnew_placement_custom(dest, Variant, Variant(*pra)); -} - -void GDAPI godot_variant_new_pool_string_array(godot_variant *r_dest, const godot_pool_string_array *p_psa) { - Variant *dest = (Variant *)r_dest; - PoolStringArray *psa = (PoolStringArray *)p_psa; - memnew_placement_custom(dest, Variant, Variant(*psa)); -} - -void GDAPI godot_variant_new_pool_vector2_array(godot_variant *r_dest, const godot_pool_vector2_array *p_pv2a) { - Variant *dest = (Variant *)r_dest; - PoolVector2Array *pv2a = (PoolVector2Array *)p_pv2a; - memnew_placement_custom(dest, Variant, Variant(*pv2a)); -} - -void GDAPI godot_variant_new_pool_vector3_array(godot_variant *r_dest, const godot_pool_vector3_array *p_pv3a) { - Variant *dest = (Variant *)r_dest; - PoolVector3Array *pv3a = (PoolVector3Array *)p_pv3a; - memnew_placement_custom(dest, Variant, Variant(*pv3a)); -} - -void GDAPI godot_variant_new_pool_color_array(godot_variant *r_dest, const godot_pool_color_array *p_pca) { - Variant *dest = (Variant *)r_dest; - PoolColorArray *pca = (PoolColorArray *)p_pca; - memnew_placement_custom(dest, Variant, Variant(*pca)); -} - -godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_self) { - const Variant *self = (const Variant *)p_self; - return self->operator bool(); -} - -uint64_t GDAPI godot_variant_as_uint(const godot_variant *p_self) { - const Variant *self = (const Variant *)p_self; - return self->operator uint64_t(); -} - -int64_t GDAPI godot_variant_as_int(const godot_variant *p_self) { - const Variant *self = (const Variant *)p_self; - return self->operator int64_t(); -} - -double GDAPI godot_variant_as_real(const godot_variant *p_self) { - const Variant *self = (const Variant *)p_self; - return self->operator double(); -} - -godot_string GDAPI godot_variant_as_string(const godot_variant *p_self) { - godot_string raw_dest; - const Variant *self = (const Variant *)p_self; - String *dest = (String *)&raw_dest; - memnew_placement(dest, String(self->operator String())); // operator = is overloaded by String - 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; - Vector2 *dest = (Vector2 *)&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; - Rect2 *dest = (Rect2 *)&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; - Vector3 *dest = (Vector3 *)&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; - Transform2D *dest = (Transform2D *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_plane GDAPI godot_variant_as_plane(const godot_variant *p_self) { - godot_plane raw_dest; - const Variant *self = (const Variant *)p_self; - Plane *dest = (Plane *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_quat GDAPI godot_variant_as_quat(const godot_variant *p_self) { - godot_quat raw_dest; - const Variant *self = (const Variant *)p_self; - Quat *dest = (Quat *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_rect3 GDAPI godot_variant_as_rect3(const godot_variant *p_self) { - godot_rect3 raw_dest; - const Variant *self = (const Variant *)p_self; - Rect3 *dest = (Rect3 *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_self) { - godot_basis raw_dest; - const Variant *self = (const Variant *)p_self; - Basis *dest = (Basis *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_transform GDAPI godot_variant_as_transform(const godot_variant *p_self) { - godot_transform raw_dest; - const Variant *self = (const Variant *)p_self; - Transform *dest = (Transform *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_color GDAPI godot_variant_as_color(const godot_variant *p_self) { - godot_color raw_dest; - const Variant *self = (const Variant *)p_self; - Color *dest = (Color *)&raw_dest; - *dest = *self; - return raw_dest; -} - -godot_node_path GDAPI godot_variant_as_node_path(const godot_variant *p_self) { - godot_node_path raw_dest; - const Variant *self = (const Variant *)p_self; - NodePath *dest = (NodePath *)&raw_dest; - memnew_placement(dest, NodePath(self->operator NodePath())); // operator = is overloaded by NodePath - return raw_dest; -} - -godot_rid GDAPI godot_variant_as_rid(const godot_variant *p_self) { - godot_rid raw_dest; - const Variant *self = (const Variant *)p_self; - RID *dest = (RID *)&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; - dest = *self; - return (godot_object *)dest; -} - -godot_dictionary GDAPI godot_variant_as_dictionary(const godot_variant *p_self) { - godot_dictionary raw_dest; - const Variant *self = (const Variant *)p_self; - Dictionary *dest = (Dictionary *)&raw_dest; - memnew_placement(dest, Dictionary(self->operator Dictionary())); // operator = is overloaded by Dictionary - return raw_dest; -} - -godot_array GDAPI godot_variant_as_array(const godot_variant *p_self) { - godot_array raw_dest; - const Variant *self = (const Variant *)p_self; - Array *dest = (Array *)&raw_dest; - memnew_placement(dest, Array(self->operator Array())); // operator = is overloaded by Array - return raw_dest; -} - -godot_pool_byte_array GDAPI godot_variant_as_pool_byte_array(const godot_variant *p_self) { - godot_pool_byte_array raw_dest; - const Variant *self = (const Variant *)p_self; - PoolByteArray *dest = (PoolByteArray *)&raw_dest; - memnew_placement(dest, PoolByteArray(self->operator PoolByteArray())); // operator = is overloaded by PoolByteArray - *dest = *self; - return raw_dest; -} - -godot_pool_int_array GDAPI godot_variant_as_pool_int_array(const godot_variant *p_self) { - godot_pool_int_array raw_dest; - const Variant *self = (const Variant *)p_self; - PoolIntArray *dest = (PoolIntArray *)&raw_dest; - memnew_placement(dest, PoolIntArray(self->operator PoolIntArray())); // operator = is overloaded by PoolIntArray - *dest = *self; - return raw_dest; -} - -godot_pool_real_array GDAPI godot_variant_as_pool_real_array(const godot_variant *p_self) { - godot_pool_real_array raw_dest; - const Variant *self = (const Variant *)p_self; - PoolRealArray *dest = (PoolRealArray *)&raw_dest; - memnew_placement(dest, PoolRealArray(self->operator PoolRealArray())); // operator = is overloaded by PoolRealArray - *dest = *self; - return raw_dest; -} - -godot_pool_string_array GDAPI godot_variant_as_pool_string_array(const godot_variant *p_self) { - godot_pool_string_array raw_dest; - const Variant *self = (const Variant *)p_self; - PoolStringArray *dest = (PoolStringArray *)&raw_dest; - memnew_placement(dest, PoolStringArray(self->operator PoolStringArray())); // operator = is overloaded by PoolStringArray - *dest = *self; - return raw_dest; -} - -godot_pool_vector2_array GDAPI godot_variant_as_pool_vector2_array(const godot_variant *p_self) { - godot_pool_vector2_array raw_dest; - const Variant *self = (const Variant *)p_self; - PoolVector2Array *dest = (PoolVector2Array *)&raw_dest; - memnew_placement(dest, PoolVector2Array(self->operator PoolVector2Array())); // operator = is overloaded by PoolVector2Array - *dest = *self; - return raw_dest; -} - -godot_pool_vector3_array GDAPI godot_variant_as_pool_vector3_array(const godot_variant *p_self) { - godot_pool_vector3_array raw_dest; - const Variant *self = (const Variant *)p_self; - PoolVector3Array *dest = (PoolVector3Array *)&raw_dest; - memnew_placement(dest, PoolVector3Array(self->operator PoolVector3Array())); // operator = is overloaded by PoolVector3Array - *dest = *self; - return raw_dest; -} - -godot_pool_color_array GDAPI godot_variant_as_pool_color_array(const godot_variant *p_self) { - godot_pool_color_array raw_dest; - const Variant *self = (const Variant *)p_self; - PoolColorArray *dest = (PoolColorArray *)&raw_dest; - memnew_placement(dest, PoolColorArray(self->operator PoolColorArray())); // operator = is overloaded by PoolColorArray - *dest = *self; - return raw_dest; -} - -godot_variant GDAPI godot_variant_call(godot_variant *p_self, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant_call_error *r_error) { - Variant *self = (Variant *)p_self; - String *method = (String *)p_method; - const Variant **args = (const Variant **)p_args; - godot_variant raw_dest; - Variant *dest = (Variant *)&raw_dest; - Variant::CallError error; - memnew_placement_custom(dest, Variant, Variant(self->call(*method, args, p_argcount, error))); - if (r_error) { - r_error->error = (godot_variant_call_error_error)error.error; - r_error->argument = error.argument; - r_error->expected = (godot_variant_type)error.expected; - } - return raw_dest; -} - -godot_bool GDAPI godot_variant_has_method(const godot_variant *p_self, const godot_string *p_method) { - const Variant *self = (const Variant *)p_self; - const String *method = (const String *)p_method; - return self->has_method(*method); -} - -godot_bool GDAPI godot_variant_operator_equal(const godot_variant *p_self, const godot_variant *p_other) { - const Variant *self = (const Variant *)p_self; - const Variant *other = (const Variant *)p_other; - return self->operator==(*other); -} - -godot_bool GDAPI godot_variant_operator_less(const godot_variant *p_self, const godot_variant *p_other) { - const Variant *self = (const Variant *)p_self; - const Variant *other = (const Variant *)p_other; - return self->operator<(*other); -} - -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; - return self->hash_compare(*other); -} - -godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self, godot_bool *r_valid) { - const Variant *self = (const Variant *)p_self; - bool &valid = *r_valid; - return self->booleanize(valid); -} - -void GDAPI godot_variant_destroy(godot_variant *p_self) { - Variant *self = (Variant *)p_self; - self->~Variant(); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/variant.h b/modules/gdnative/godot/variant.h deleted file mode 100644 index 849ba8bda6..0000000000 --- a/modules/gdnative/godot/variant.h +++ /dev/null @@ -1,201 +0,0 @@ -/*************************************************************************/ -/* variant.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_VARIANT_H -#define GODOT_VARIANT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define GODOT_VARIANT_SIZE (16 + sizeof(void *)) - -#ifndef GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_VARIANT_SIZE]; -} godot_variant; -#endif - -typedef enum godot_variant_type { - GODOT_VARIANT_TYPE_NIL, - - // atomic types - GODOT_VARIANT_TYPE_BOOL, - GODOT_VARIANT_TYPE_INT, - GODOT_VARIANT_TYPE_REAL, - GODOT_VARIANT_TYPE_STRING, - - // math types - - GODOT_VARIANT_TYPE_VECTOR2, // 5 - GODOT_VARIANT_TYPE_RECT2, - GODOT_VARIANT_TYPE_VECTOR3, - GODOT_VARIANT_TYPE_TRANSFORM2D, - GODOT_VARIANT_TYPE_PLANE, - GODOT_VARIANT_TYPE_QUAT, // 10 - GODOT_VARIANT_TYPE_RECT3, - GODOT_VARIANT_TYPE_BASIS, - GODOT_VARIANT_TYPE_TRANSFORM, - - // misc types - GODOT_VARIANT_TYPE_COLOR, - GODOT_VARIANT_TYPE_NODE_PATH, // 15 - GODOT_VARIANT_TYPE_RID, - GODOT_VARIANT_TYPE_OBJECT, - GODOT_VARIANT_TYPE_DICTIONARY, - GODOT_VARIANT_TYPE_ARRAY, // 20 - - // arrays - GODOT_VARIANT_TYPE_POOL_BYTE_ARRAY, - GODOT_VARIANT_TYPE_POOL_INT_ARRAY, - GODOT_VARIANT_TYPE_POOL_REAL_ARRAY, - GODOT_VARIANT_TYPE_POOL_STRING_ARRAY, - GODOT_VARIANT_TYPE_POOL_VECTOR2_ARRAY, // 25 - GODOT_VARIANT_TYPE_POOL_VECTOR3_ARRAY, - GODOT_VARIANT_TYPE_POOL_COLOR_ARRAY, -} godot_variant_type; - -typedef enum godot_variant_call_error_error { - GODOT_CALL_ERROR_CALL_OK, - GODOT_CALL_ERROR_CALL_ERROR_INVALID_METHOD, - GODOT_CALL_ERROR_CALL_ERROR_INVALID_ARGUMENT, - GODOT_CALL_ERROR_CALL_ERROR_TOO_MANY_ARGUMENTS, - GODOT_CALL_ERROR_CALL_ERROR_TOO_FEW_ARGUMENTS, - GODOT_CALL_ERROR_CALL_ERROR_INSTANCE_IS_NULL, -} godot_variant_call_error_error; - -typedef struct godot_variant_call_error { - godot_variant_call_error_error error; - int argument; - godot_variant_type expected; -} godot_variant_call_error; - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_v); - -void GDAPI godot_variant_new_copy(godot_variant *r_dest, const godot_variant *p_src); - -void GDAPI godot_variant_new_nil(godot_variant *r_dest); - -void GDAPI godot_variant_new_bool(godot_variant *p_v, const godot_bool p_b); -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_vector2(godot_variant *r_dest, const godot_vector2 *p_v2); -void GDAPI godot_variant_new_rect2(godot_variant *r_dest, const godot_rect2 *p_rect2); -void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3 *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); -void GDAPI godot_variant_new_rect3(godot_variant *r_dest, const godot_rect3 *p_rect3); -void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis); -void GDAPI godot_variant_new_transform(godot_variant *r_dest, const godot_transform *p_trans); -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_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_pool_byte_array(godot_variant *r_dest, const godot_pool_byte_array *p_pba); -void GDAPI godot_variant_new_pool_int_array(godot_variant *r_dest, const godot_pool_int_array *p_pia); -void GDAPI godot_variant_new_pool_real_array(godot_variant *r_dest, const godot_pool_real_array *p_pra); -void GDAPI godot_variant_new_pool_string_array(godot_variant *r_dest, const godot_pool_string_array *p_psa); -void GDAPI godot_variant_new_pool_vector2_array(godot_variant *r_dest, const godot_pool_vector2_array *p_pv2a); -void GDAPI godot_variant_new_pool_vector3_array(godot_variant *r_dest, const godot_pool_vector3_array *p_pv3a); -void GDAPI godot_variant_new_pool_color_array(godot_variant *r_dest, const godot_pool_color_array *p_pca); - -godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_self); -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_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_self); -godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_self); -godot_vector3 GDAPI godot_variant_as_vector3(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); -godot_rect3 GDAPI godot_variant_as_rect3(const godot_variant *p_self); -godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_self); -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_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_pool_byte_array GDAPI godot_variant_as_pool_byte_array(const godot_variant *p_self); -godot_pool_int_array GDAPI godot_variant_as_pool_int_array(const godot_variant *p_self); -godot_pool_real_array GDAPI godot_variant_as_pool_real_array(const godot_variant *p_self); -godot_pool_string_array GDAPI godot_variant_as_pool_string_array(const godot_variant *p_self); -godot_pool_vector2_array GDAPI godot_variant_as_pool_vector2_array(const godot_variant *p_self); -godot_pool_vector3_array GDAPI godot_variant_as_pool_vector3_array(const godot_variant *p_self); -godot_pool_color_array GDAPI godot_variant_as_pool_color_array(const godot_variant *p_self); - -godot_variant GDAPI godot_variant_call(godot_variant *p_self, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant_call_error *r_error); - -godot_bool GDAPI godot_variant_has_method(const godot_variant *p_self, const godot_string *p_method); - -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); - -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, godot_bool *r_valid); - -void GDAPI godot_variant_destroy(godot_variant *p_self); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/modules/gdnative/godot/vector2.cpp b/modules/gdnative/godot/vector2.cpp deleted file mode 100644 index 78ed5f06a9..0000000000 --- a/modules/gdnative/godot/vector2.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/*************************************************************************/ -/* vector2.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/math/math_2d.h" -#include "core/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _vector2_api_anchor() {} - -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); -} - -godot_string GDAPI godot_vector2_as_string(const godot_vector2 *p_self) { - godot_string ret; - const Vector2 *self = (const Vector2 *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_vector2 GDAPI godot_vector2_normalized(const godot_vector2 *p_self) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - *((Vector2 *)&dest) = self->normalized(); - return dest; -} - -godot_real GDAPI godot_vector2_length(const godot_vector2 *p_self) { - const Vector2 *self = (const Vector2 *)p_self; - return self->length(); -} - -godot_real GDAPI godot_vector2_angle(const godot_vector2 *p_self) { - const Vector2 *self = (const Vector2 *)p_self; - return self->angle(); -} - -godot_real GDAPI godot_vector2_length_squared(const godot_vector2 *p_self) { - const Vector2 *self = (const Vector2 *)p_self; - return self->length_squared(); -} - -godot_bool GDAPI godot_vector2_is_normalized(const godot_vector2 *p_self) { - const Vector2 *self = (const Vector2 *)p_self; - return self->is_normalized(); -} - -godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_self, const godot_vector2 *p_to) { - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *to = (const Vector2 *)p_to; - return self->distance_to(*to); -} - -godot_real GDAPI godot_vector2_distance_squared_to(const godot_vector2 *p_self, const godot_vector2 *p_to) { - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *to = (const Vector2 *)p_to; - return self->distance_squared_to(*to); -} - -godot_real GDAPI godot_vector2_angle_to(const godot_vector2 *p_self, const godot_vector2 *p_to) { - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *to = (const Vector2 *)p_to; - return self->angle_to(*to); -} - -godot_real GDAPI godot_vector2_angle_to_point(const godot_vector2 *p_self, const godot_vector2 *p_to) { - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *to = (const Vector2 *)p_to; - return self->angle_to_point(*to); -} - -godot_vector2 GDAPI godot_vector2_linear_interpolate(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_real p_t) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - *((Vector2 *)&dest) = self->linear_interpolate(*b, p_t); - return dest; -} - -godot_vector2 GDAPI godot_vector2_cubic_interpolate(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_vector2 *p_pre_a, const godot_vector2 *p_post_b, const godot_real p_t) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - const Vector2 *pre_a = (const Vector2 *)p_pre_a; - const Vector2 *post_b = (const Vector2 *)p_post_b; - *((Vector2 *)&dest) = self->cubic_interpolate(*b, *pre_a, *post_b, p_t); - return dest; -} - -godot_vector2 GDAPI godot_vector2_rotated(const godot_vector2 *p_self, const godot_real p_phi) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - - *((Vector2 *)&dest) = self->rotated(p_phi); - return dest; -} - -godot_vector2 GDAPI godot_vector2_tangent(const godot_vector2 *p_self) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - *((Vector2 *)&dest) = self->tangent(); - return dest; -} - -godot_vector2 GDAPI godot_vector2_floor(const godot_vector2 *p_self) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - *((Vector2 *)&dest) = self->floor(); - 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; - const Vector2 *by = (const Vector2 *)p_by; - *((Vector2 *)&dest) = self->snapped(*by); - return dest; -} - -godot_real GDAPI godot_vector2_aspect(const godot_vector2 *p_self) { - const Vector2 *self = (const Vector2 *)p_self; - return self->aspect(); -} - -godot_real GDAPI godot_vector2_dot(const godot_vector2 *p_self, const godot_vector2 *p_with) { - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *with = (const Vector2 *)p_with; - return self->dot(*with); -} - -godot_vector2 GDAPI godot_vector2_slide(const godot_vector2 *p_self, const godot_vector2 *p_n) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *n = (const Vector2 *)p_n; - *((Vector2 *)&dest) = self->slide(*n); - return dest; -} - -godot_vector2 GDAPI godot_vector2_bounce(const godot_vector2 *p_self, const godot_vector2 *p_n) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *n = (const Vector2 *)p_n; - *((Vector2 *)&dest) = self->bounce(*n); - return dest; -} - -godot_vector2 GDAPI godot_vector2_reflect(const godot_vector2 *p_self, const godot_vector2 *p_n) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *n = (const Vector2 *)p_n; - *((Vector2 *)&dest) = self->reflect(*n); - return dest; -} - -godot_vector2 GDAPI godot_vector2_abs(const godot_vector2 *p_self) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - *((Vector2 *)&dest) = self->abs(); - return dest; -} - -godot_vector2 GDAPI godot_vector2_clamped(const godot_vector2 *p_self, const godot_real p_length) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - - *((Vector2 *)&dest) = self->clamped(p_length); - return dest; -} - -godot_vector2 GDAPI godot_vector2_operator_add(const godot_vector2 *p_self, const godot_vector2 *p_b) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - *dest = *self + *b; - return raw_dest; -} - -godot_vector2 GDAPI godot_vector2_operator_substract(const godot_vector2 *p_self, const godot_vector2 *p_b) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - *dest = *self - *b; - return raw_dest; -} - -godot_vector2 GDAPI godot_vector2_operator_multiply_vector(const godot_vector2 *p_self, const godot_vector2 *p_b) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - *dest = *self * *b; - return raw_dest; -} - -godot_vector2 GDAPI godot_vector2_operator_multiply_scalar(const godot_vector2 *p_self, const godot_real p_b) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Vector2 *self = (const Vector2 *)p_self; - *dest = *self * p_b; - return raw_dest; -} - -godot_vector2 GDAPI godot_vector2_operator_divide_vector(const godot_vector2 *p_self, const godot_vector2 *p_b) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - *dest = *self / *b; - return raw_dest; -} - -godot_vector2 GDAPI godot_vector2_operator_divide_scalar(const godot_vector2 *p_self, const godot_real p_b) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Vector2 *self = (const Vector2 *)p_self; - *dest = *self / p_b; - return raw_dest; -} - -godot_bool GDAPI godot_vector2_operator_equal(const godot_vector2 *p_self, const godot_vector2 *p_b) { - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - return *self == *b; -} - -godot_bool GDAPI godot_vector2_operator_less(const godot_vector2 *p_self, const godot_vector2 *p_b) { - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - return *self < *b; -} - -godot_vector2 GDAPI godot_vector2_operator_neg(const godot_vector2 *p_self) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Vector2 *self = (const Vector2 *)p_self; - *dest = -(*self); - return raw_dest; -} - -void GDAPI godot_vector2_set_x(godot_vector2 *p_self, const godot_real p_x) { - Vector2 *self = (Vector2 *)p_self; - self->x = p_x; -} - -void GDAPI godot_vector2_set_y(godot_vector2 *p_self, const godot_real p_y) { - Vector2 *self = (Vector2 *)p_self; - self->y = p_y; -} - -godot_real GDAPI godot_vector2_get_x(const godot_vector2 *p_self) { - const Vector2 *self = (const Vector2 *)p_self; - return self->x; -} - -godot_real GDAPI godot_vector2_get_y(const godot_vector2 *p_self) { - const Vector2 *self = (const Vector2 *)p_self; - return self->y; -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/vector2.h b/modules/gdnative/godot/vector2.h deleted file mode 100644 index 98e9700e32..0000000000 --- a/modules/gdnative/godot/vector2.h +++ /dev/null @@ -1,128 +0,0 @@ -/*************************************************************************/ -/* vector2.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_VECTOR2_H -#define GODOT_VECTOR2_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define GODOT_VECTOR2_SIZE 8 - -#ifndef GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_VECTOR2_SIZE]; -} godot_vector2; -#endif - -#include - -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_vector2 GDAPI godot_vector2_normalized(const godot_vector2 *p_self); - -godot_real GDAPI godot_vector2_length(const godot_vector2 *p_self); - -godot_real GDAPI godot_vector2_angle(const godot_vector2 *p_self); - -godot_real GDAPI godot_vector2_length_squared(const godot_vector2 *p_self); - -godot_bool GDAPI godot_vector2_is_normalized(const godot_vector2 *p_self); - -godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_self, const godot_vector2 *p_to); - -godot_real GDAPI godot_vector2_distance_squared_to(const godot_vector2 *p_self, const godot_vector2 *p_to); - -godot_real GDAPI godot_vector2_angle_to(const godot_vector2 *p_self, const godot_vector2 *p_to); - -godot_real GDAPI godot_vector2_angle_to_point(const godot_vector2 *p_self, const godot_vector2 *p_to); - -godot_vector2 GDAPI godot_vector2_linear_interpolate(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_real p_t); - -godot_vector2 GDAPI godot_vector2_cubic_interpolate(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_vector2 *p_pre_a, const godot_vector2 *p_post_b, const godot_real p_t); - -godot_vector2 GDAPI godot_vector2_rotated(const godot_vector2 *p_self, const godot_real p_phi); - -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_snapped(const godot_vector2 *p_self, const godot_vector2 *p_by); - -godot_real GDAPI godot_vector2_aspect(const godot_vector2 *p_self); - -godot_real GDAPI godot_vector2_dot(const godot_vector2 *p_self, const godot_vector2 *p_with); - -godot_vector2 GDAPI godot_vector2_slide(const godot_vector2 *p_self, const godot_vector2 *p_n); - -godot_vector2 GDAPI godot_vector2_bounce(const godot_vector2 *p_self, const godot_vector2 *p_n); - -godot_vector2 GDAPI godot_vector2_reflect(const godot_vector2 *p_self, const godot_vector2 *p_n); - -godot_vector2 GDAPI godot_vector2_abs(const godot_vector2 *p_self); - -godot_vector2 GDAPI godot_vector2_clamped(const godot_vector2 *p_self, const godot_real p_length); - -godot_vector2 GDAPI godot_vector2_operator_add(const godot_vector2 *p_self, const godot_vector2 *p_b); - -godot_vector2 GDAPI godot_vector2_operator_substract(const godot_vector2 *p_self, const godot_vector2 *p_b); - -godot_vector2 GDAPI godot_vector2_operator_multiply_vector(const godot_vector2 *p_self, const godot_vector2 *p_b); - -godot_vector2 GDAPI godot_vector2_operator_multiply_scalar(const godot_vector2 *p_self, const godot_real p_b); - -godot_vector2 GDAPI godot_vector2_operator_divide_vector(const godot_vector2 *p_self, const godot_vector2 *p_b); - -godot_vector2 GDAPI godot_vector2_operator_divide_scalar(const godot_vector2 *p_self, const godot_real p_b); - -godot_bool GDAPI godot_vector2_operator_equal(const godot_vector2 *p_self, const godot_vector2 *p_b); - -godot_bool GDAPI godot_vector2_operator_less(const godot_vector2 *p_self, const godot_vector2 *p_b); - -godot_vector2 GDAPI godot_vector2_operator_neg(const godot_vector2 *p_self); - -void GDAPI godot_vector2_set_x(godot_vector2 *p_self, const godot_real p_x); - -void GDAPI godot_vector2_set_y(godot_vector2 *p_self, const godot_real p_y); - -godot_real GDAPI godot_vector2_get_x(const godot_vector2 *p_self); - -godot_real GDAPI godot_vector2_get_y(const godot_vector2 *p_self); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_VECTOR2_H diff --git a/modules/gdnative/godot/vector3.cpp b/modules/gdnative/godot/vector3.cpp deleted file mode 100644 index 5faeac2864..0000000000 --- a/modules/gdnative/godot/vector3.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/*************************************************************************/ -/* vector3.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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 - -#include "core/variant.h" -#include "core/vector.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _vector3_api_anchor() {} - -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); -} - -godot_string GDAPI godot_vector3_as_string(const godot_vector3 *p_self) { - godot_string ret; - const Vector3 *self = (const Vector3 *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_int GDAPI godot_vector3_min_axis(const godot_vector3 *p_self) { - const Vector3 *self = (const Vector3 *)p_self; - return self->min_axis(); -} - -godot_int GDAPI godot_vector3_max_axis(const godot_vector3 *p_self) { - const Vector3 *self = (const Vector3 *)p_self; - return self->max_axis(); -} - -godot_real GDAPI godot_vector3_length(const godot_vector3 *p_self) { - const Vector3 *self = (const Vector3 *)p_self; - return self->length(); -} - -godot_real GDAPI godot_vector3_length_squared(const godot_vector3 *p_self) { - const Vector3 *self = (const Vector3 *)p_self; - return self->length_squared(); -} - -godot_bool GDAPI godot_vector3_is_normalized(const godot_vector3 *p_self) { - const Vector3 *self = (const Vector3 *)p_self; - return self->is_normalized(); -} - -godot_vector3 GDAPI godot_vector3_normalized(const godot_vector3 *p_self) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - *((Vector3 *)&dest) = self->normalized(); - return dest; -} - -godot_vector3 GDAPI godot_vector3_inverse(const godot_vector3 *p_self) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - *((Vector3 *)&dest) = self->inverse(); - return dest; -} - -godot_vector3 GDAPI godot_vector3_snapped(const godot_vector3 *p_self, const godot_vector3 *p_by) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *snap_axis = (const Vector3 *)p_by; - - *((Vector3 *)&dest) = self->snapped(*snap_axis); - return dest; -} - -godot_vector3 GDAPI godot_vector3_rotated(const godot_vector3 *p_self, const godot_vector3 *p_axis, const godot_real p_phi) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *axis = (const Vector3 *)p_axis; - *((Vector3 *)&dest) = self->rotated(*axis, p_phi); - return dest; -} - -godot_vector3 GDAPI godot_vector3_linear_interpolate(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_real p_t) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - *((Vector3 *)&dest) = self->linear_interpolate(*b, p_t); - return dest; -} - -godot_vector3 GDAPI godot_vector3_cubic_interpolate(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_vector3 *p_pre_a, const godot_vector3 *p_post_b, const godot_real p_t) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - const Vector3 *pre_a = (const Vector3 *)p_pre_a; - const Vector3 *post_b = (const Vector3 *)p_post_b; - *((Vector3 *)&dest) = self->cubic_interpolate(*b, *pre_a, *post_b, p_t); - return dest; -} - -godot_real GDAPI godot_vector3_dot(const godot_vector3 *p_self, const godot_vector3 *p_b) { - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - return self->dot(*b); -} - -godot_vector3 GDAPI godot_vector3_cross(const godot_vector3 *p_self, const godot_vector3 *p_b) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - *((Vector3 *)&dest) = self->cross(*b); - return dest; -} - -godot_basis GDAPI godot_vector3_outer(const godot_vector3 *p_self, const godot_vector3 *p_b) { - godot_basis dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - *((Basis *)&dest) = self->outer(*b); - return dest; -} - -godot_basis GDAPI godot_vector3_to_diagonal_matrix(const godot_vector3 *p_self) { - godot_basis dest; - const Vector3 *self = (const Vector3 *)p_self; - *((Basis *)&dest) = self->to_diagonal_matrix(); - return dest; -} - -godot_vector3 GDAPI godot_vector3_abs(const godot_vector3 *p_self) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - *((Vector3 *)&dest) = self->abs(); - return dest; -} - -godot_vector3 GDAPI godot_vector3_floor(const godot_vector3 *p_self) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - *((Vector3 *)&dest) = self->floor(); - return dest; -} - -godot_vector3 GDAPI godot_vector3_ceil(const godot_vector3 *p_self) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - *((Vector3 *)&dest) = self->ceil(); - return dest; -} - -godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_self, const godot_vector3 *p_b) { - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - return self->distance_to(*b); -} - -godot_real GDAPI godot_vector3_distance_squared_to(const godot_vector3 *p_self, const godot_vector3 *p_b) { - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - return self->distance_squared_to(*b); -} - -godot_real GDAPI godot_vector3_angle_to(const godot_vector3 *p_self, const godot_vector3 *p_to) { - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *to = (const Vector3 *)p_to; - return self->angle_to(*to); -} - -godot_vector3 GDAPI godot_vector3_slide(const godot_vector3 *p_self, const godot_vector3 *p_n) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *n = (const Vector3 *)p_n; - *((Vector3 *)&dest) = self->slide(*n); - return dest; -} - -godot_vector3 GDAPI godot_vector3_bounce(const godot_vector3 *p_self, const godot_vector3 *p_n) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *n = (const Vector3 *)p_n; - *((Vector3 *)&dest) = self->bounce(*n); - return dest; -} - -godot_vector3 GDAPI godot_vector3_reflect(const godot_vector3 *p_self, const godot_vector3 *p_n) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *n = (const Vector3 *)p_n; - *((Vector3 *)&dest) = self->reflect(*n); - return dest; -} - -godot_vector3 GDAPI godot_vector3_operator_add(const godot_vector3 *p_self, const godot_vector3 *p_b) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - Vector3 *self = (Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - *dest = *self + *b; - return raw_dest; -} - -godot_vector3 GDAPI godot_vector3_operator_substract(const godot_vector3 *p_self, const godot_vector3 *p_b) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - Vector3 *self = (Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - *dest = *self - *b; - return raw_dest; -} - -godot_vector3 GDAPI godot_vector3_operator_multiply_vector(const godot_vector3 *p_self, const godot_vector3 *p_b) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - Vector3 *self = (Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - *dest = *self * *b; - return raw_dest; -} - -godot_vector3 GDAPI godot_vector3_operator_multiply_scalar(const godot_vector3 *p_self, const godot_real p_b) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - Vector3 *self = (Vector3 *)p_self; - *dest = *self * p_b; - return raw_dest; -} - -godot_vector3 GDAPI godot_vector3_operator_divide_vector(const godot_vector3 *p_self, const godot_vector3 *p_b) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - Vector3 *self = (Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - *dest = *self / *b; - return raw_dest; -} - -godot_vector3 GDAPI godot_vector3_operator_divide_scalar(const godot_vector3 *p_self, const godot_real p_b) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - Vector3 *self = (Vector3 *)p_self; - *dest = *self / p_b; - return raw_dest; -} - -godot_bool GDAPI godot_vector3_operator_equal(const godot_vector3 *p_self, const godot_vector3 *p_b) { - Vector3 *self = (Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - return *self == *b; -} - -godot_bool GDAPI godot_vector3_operator_less(const godot_vector3 *p_self, const godot_vector3 *p_b) { - Vector3 *self = (Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - return *self < *b; -} - -godot_vector3 GDAPI godot_vector3_operator_neg(const godot_vector3 *p_self) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - const Vector3 *self = (const Vector3 *)p_self; - *dest = -(*self); - return raw_dest; -} - -void GDAPI godot_vector3_set_axis(godot_vector3 *p_self, const godot_vector3_axis p_axis, const godot_real p_val) { - Vector3 *self = (Vector3 *)p_self; - self->set_axis(p_axis, p_val); -} - -godot_real GDAPI godot_vector3_get_axis(const godot_vector3 *p_self, const godot_vector3_axis p_axis) { - const Vector3 *self = (const Vector3 *)p_self; - return self->get_axis(p_axis); -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/godot/vector3.h b/modules/gdnative/godot/vector3.h deleted file mode 100644 index b76ca11a9c..0000000000 --- a/modules/gdnative/godot/vector3.h +++ /dev/null @@ -1,135 +0,0 @@ -/*************************************************************************/ -/* vector3.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 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_VECTOR3_H -#define GODOT_VECTOR3_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define GODOT_VECTOR3_SIZE 12 - -#ifndef GODOT_CORE_API_GODOT_VECTOR3_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_VECTOR3_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_VECTOR3_SIZE]; -} godot_vector3; -#endif - -#include -#include - -typedef enum { - GODOT_VECTOR3_AXIS_X, - GODOT_VECTOR3_AXIS_Y, - GODOT_VECTOR3_AXIS_Z, -} godot_vector3_axis; - -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_int GDAPI godot_vector3_min_axis(const godot_vector3 *p_self); - -godot_int GDAPI godot_vector3_max_axis(const godot_vector3 *p_self); - -godot_real GDAPI godot_vector3_length(const godot_vector3 *p_self); - -godot_real GDAPI godot_vector3_length_squared(const godot_vector3 *p_self); - -godot_bool GDAPI godot_vector3_is_normalized(const godot_vector3 *p_self); - -godot_vector3 GDAPI godot_vector3_normalized(const godot_vector3 *p_self); - -godot_vector3 GDAPI godot_vector3_inverse(const godot_vector3 *p_self); - -godot_vector3 GDAPI godot_vector3_snapped(const godot_vector3 *p_self, const godot_vector3 *p_by); - -godot_vector3 GDAPI godot_vector3_rotated(const godot_vector3 *p_self, const godot_vector3 *p_axis, const godot_real p_phi); - -godot_vector3 GDAPI godot_vector3_linear_interpolate(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_real p_t); - -godot_vector3 GDAPI godot_vector3_cubic_interpolate(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_vector3 *p_pre_a, const godot_vector3 *p_post_b, const godot_real p_t); - -godot_real GDAPI godot_vector3_dot(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_vector3 GDAPI godot_vector3_cross(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_basis GDAPI godot_vector3_outer(const godot_vector3 *p_self, const godot_vector3 *p_b); - -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_floor(const godot_vector3 *p_self); - -godot_vector3 GDAPI godot_vector3_ceil(const godot_vector3 *p_self); - -godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_real GDAPI godot_vector3_distance_squared_to(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_real GDAPI godot_vector3_angle_to(const godot_vector3 *p_self, const godot_vector3 *p_to); - -godot_vector3 GDAPI godot_vector3_slide(const godot_vector3 *p_self, const godot_vector3 *p_n); - -godot_vector3 GDAPI godot_vector3_bounce(const godot_vector3 *p_self, const godot_vector3 *p_n); - -godot_vector3 GDAPI godot_vector3_reflect(const godot_vector3 *p_self, const godot_vector3 *p_n); - -godot_vector3 GDAPI godot_vector3_operator_add(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_vector3 GDAPI godot_vector3_operator_substract(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_vector3 GDAPI godot_vector3_operator_multiply_vector(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_vector3 GDAPI godot_vector3_operator_multiply_scalar(const godot_vector3 *p_self, const godot_real p_b); - -godot_vector3 GDAPI godot_vector3_operator_divide_vector(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_vector3 GDAPI godot_vector3_operator_divide_scalar(const godot_vector3 *p_self, const godot_real p_b); - -godot_bool GDAPI godot_vector3_operator_equal(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_bool GDAPI godot_vector3_operator_less(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_vector3 GDAPI godot_vector3_operator_neg(const godot_vector3 *p_self); - -void GDAPI godot_vector3_set_axis(godot_vector3 *p_self, const godot_vector3_axis p_axis, const godot_real p_val); - -godot_real GDAPI godot_vector3_get_axis(const godot_vector3 *p_self, const godot_vector3_axis p_axis); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_VECTOR3_H diff --git a/modules/gdnative/include/gdnative/array.h b/modules/gdnative/include/gdnative/array.h new file mode 100644 index 0000000000..edab028cba --- /dev/null +++ b/modules/gdnative/include/gdnative/array.h @@ -0,0 +1,122 @@ +/*************************************************************************/ +/* array.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_ARRAY_H +#define GODOT_ARRAY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define GODOT_ARRAY_SIZE sizeof(void *) + +#ifndef GODOT_CORE_API_GODOT_ARRAY_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_ARRAY_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_ARRAY_SIZE]; +} godot_array; +#endif + +#include +#include + +#include + +void GDAPI godot_array_new(godot_array *r_dest); +void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src); +void GDAPI godot_array_new_pool_color_array(godot_array *r_dest, const godot_pool_color_array *p_pca); +void GDAPI godot_array_new_pool_vector3_array(godot_array *r_dest, const godot_pool_vector3_array *p_pv3a); +void GDAPI godot_array_new_pool_vector2_array(godot_array *r_dest, const godot_pool_vector2_array *p_pv2a); +void GDAPI godot_array_new_pool_string_array(godot_array *r_dest, const godot_pool_string_array *p_psa); +void GDAPI godot_array_new_pool_real_array(godot_array *r_dest, const godot_pool_real_array *p_pra); +void GDAPI godot_array_new_pool_int_array(godot_array *r_dest, const godot_pool_int_array *p_pia); +void GDAPI godot_array_new_pool_byte_array(godot_array *r_dest, const godot_pool_byte_array *p_pba); + +void GDAPI godot_array_set(godot_array *p_self, const godot_int p_idx, const godot_variant *p_value); + +godot_variant GDAPI godot_array_get(const godot_array *p_self, const godot_int p_idx); + +godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, const godot_int p_idx); + +void GDAPI godot_array_append(godot_array *p_self, const godot_variant *p_value); + +void GDAPI godot_array_clear(godot_array *p_self); + +godot_int GDAPI godot_array_count(const godot_array *p_self, const godot_variant *p_value); + +godot_bool GDAPI godot_array_empty(const godot_array *p_self); + +void GDAPI godot_array_erase(godot_array *p_self, const godot_variant *p_value); + +godot_variant GDAPI godot_array_front(const godot_array *p_self); + +godot_variant GDAPI godot_array_back(const godot_array *p_self); + +godot_int GDAPI godot_array_find(const godot_array *p_self, const godot_variant *p_what, const godot_int p_from); + +godot_int GDAPI godot_array_find_last(const godot_array *p_self, const godot_variant *p_what); + +godot_bool GDAPI godot_array_has(const godot_array *p_self, const godot_variant *p_value); + +godot_int GDAPI godot_array_hash(const godot_array *p_self); + +void GDAPI godot_array_insert(godot_array *p_self, const godot_int p_pos, const godot_variant *p_value); + +void GDAPI godot_array_invert(godot_array *p_self); + +godot_variant GDAPI godot_array_pop_back(godot_array *p_self); + +godot_variant GDAPI godot_array_pop_front(godot_array *p_self); + +void GDAPI godot_array_push_back(godot_array *p_self, const godot_variant *p_value); + +void GDAPI godot_array_push_front(godot_array *p_self, const godot_variant *p_value); + +void GDAPI godot_array_remove(godot_array *p_self, const godot_int p_idx); + +void GDAPI godot_array_resize(godot_array *p_self, const godot_int p_size); + +godot_int GDAPI godot_array_rfind(const godot_array *p_self, const godot_variant *p_what, const godot_int p_from); + +godot_int GDAPI godot_array_size(const godot_array *p_self); + +void GDAPI godot_array_sort(godot_array *p_self); + +void GDAPI godot_array_sort_custom(godot_array *p_self, godot_object *p_obj, const godot_string *p_func); + +void GDAPI godot_array_destroy(godot_array *p_self); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_ARRAY_H diff --git a/modules/gdnative/include/gdnative/basis.h b/modules/gdnative/include/gdnative/basis.h new file mode 100644 index 0000000000..8ff6a6f541 --- /dev/null +++ b/modules/gdnative/include/gdnative/basis.h @@ -0,0 +1,115 @@ +/*************************************************************************/ +/* basis.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_BASIS_H +#define GODOT_BASIS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define GODOT_BASIS_SIZE 36 + +#ifndef GODOT_CORE_API_GODOT_BASIS_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_BASIS_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_BASIS_SIZE]; +} godot_basis; +#endif + +#include +#include +#include + +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); +void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *r_dest, const godot_vector3 *p_axis, const godot_real p_phi); +void GDAPI godot_basis_new_with_euler(godot_basis *r_dest, const godot_vector3 *p_euler); + +godot_string GDAPI godot_basis_as_string(const godot_basis *p_self); + +godot_basis GDAPI godot_basis_inverse(const godot_basis *p_self); + +godot_basis GDAPI godot_basis_transposed(const godot_basis *p_self); + +godot_basis GDAPI godot_basis_orthonormalized(const godot_basis *p_self); + +godot_real GDAPI godot_basis_determinant(const godot_basis *p_self); + +godot_basis GDAPI godot_basis_rotated(const godot_basis *p_self, const godot_vector3 *p_axis, const godot_real p_phi); + +godot_basis GDAPI godot_basis_scaled(const godot_basis *p_self, const godot_vector3 *p_scale); + +godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self); + +godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_self); + +godot_real GDAPI godot_basis_tdotx(const godot_basis *p_self, const godot_vector3 *p_with); + +godot_real GDAPI godot_basis_tdoty(const godot_basis *p_self, const godot_vector3 *p_with); + +godot_real GDAPI godot_basis_tdotz(const godot_basis *p_self, const godot_vector3 *p_with); + +godot_vector3 GDAPI godot_basis_xform(const godot_basis *p_self, const godot_vector3 *p_v); + +godot_vector3 GDAPI godot_basis_xform_inv(const godot_basis *p_self, const godot_vector3 *p_v); + +godot_int GDAPI godot_basis_get_orthogonal_index(const godot_basis *p_self); + +void GDAPI godot_basis_new(godot_basis *r_dest); + +void GDAPI godot_basis_new_with_euler_quat(godot_basis *r_dest, const godot_quat *p_euler); + +// p_elements is a pointer to an array of 3 (!!) vector3 +void GDAPI godot_basis_get_elements(godot_basis *p_self, godot_vector3 *p_elements); + +godot_vector3 GDAPI godot_basis_get_axis(const godot_basis *p_self, const godot_int p_axis); + +void GDAPI godot_basis_set_axis(godot_basis *p_self, const godot_int p_axis, const godot_vector3 *p_value); + +godot_vector3 GDAPI godot_basis_get_row(const godot_basis *p_self, const godot_int p_row); + +void GDAPI godot_basis_set_row(godot_basis *p_self, const godot_int p_row, const godot_vector3 *p_value); + +godot_bool GDAPI godot_basis_operator_equal(const godot_basis *p_self, const godot_basis *p_b); + +godot_basis GDAPI godot_basis_operator_add(const godot_basis *p_self, const godot_basis *p_b); + +godot_basis GDAPI godot_basis_operator_substract(const godot_basis *p_self, const godot_basis *p_b); + +godot_basis GDAPI godot_basis_operator_multiply_vector(const godot_basis *p_self, const godot_basis *p_b); + +godot_basis GDAPI godot_basis_operator_multiply_scalar(const godot_basis *p_self, const godot_real p_b); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_BASIS_H diff --git a/modules/gdnative/include/gdnative/color.h b/modules/gdnative/include/gdnative/color.h new file mode 100644 index 0000000000..90dccf75aa --- /dev/null +++ b/modules/gdnative/include/gdnative/color.h @@ -0,0 +1,96 @@ +/*************************************************************************/ +/* color.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_COLOR_H +#define GODOT_COLOR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define GODOT_COLOR_SIZE 16 + +#ifndef GODOT_CORE_API_GODOT_COLOR_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_COLOR_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_COLOR_SIZE]; +} godot_color; +#endif + +#include +#include + +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); +void GDAPI godot_color_new_rgb(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b); + +godot_real godot_color_get_r(const godot_color *p_self); +void godot_color_set_r(godot_color *p_self, const godot_real r); + +godot_real godot_color_get_g(const godot_color *p_self); +void godot_color_set_g(godot_color *p_self, const godot_real g); + +godot_real godot_color_get_b(const godot_color *p_self); +void godot_color_set_b(godot_color *p_self, const godot_real b); + +godot_real godot_color_get_a(const godot_color *p_self); +void godot_color_set_a(godot_color *p_self, const godot_real a); + +godot_real godot_color_get_h(const godot_color *p_self); +godot_real godot_color_get_s(const godot_color *p_self); +godot_real godot_color_get_v(const godot_color *p_self); + +godot_string GDAPI godot_color_as_string(const godot_color *p_self); + +godot_int GDAPI godot_color_to_32(const godot_color *p_self); + +godot_int GDAPI godot_color_to_ARGB32(const godot_color *p_self); + +godot_real GDAPI godot_color_gray(const godot_color *p_self); + +godot_color GDAPI godot_color_inverted(const godot_color *p_self); + +godot_color GDAPI godot_color_contrasted(const godot_color *p_self); + +godot_color GDAPI godot_color_linear_interpolate(const godot_color *p_self, const godot_color *p_b, const godot_real p_t); + +godot_color GDAPI godot_color_blend(const godot_color *p_self, const godot_color *p_over); + +godot_string GDAPI godot_color_to_html(const godot_color *p_self, const godot_bool p_with_alpha); + +godot_bool GDAPI godot_color_operator_equal(const godot_color *p_self, const godot_color *p_b); + +godot_bool GDAPI godot_color_operator_less(const godot_color *p_self, const godot_color *p_b); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_COLOR_H diff --git a/modules/gdnative/include/gdnative/dictionary.h b/modules/gdnative/include/gdnative/dictionary.h new file mode 100644 index 0000000000..c85c3f3830 --- /dev/null +++ b/modules/gdnative/include/gdnative/dictionary.h @@ -0,0 +1,89 @@ +/*************************************************************************/ +/* dictionary.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_DICTIONARY_H +#define GODOT_DICTIONARY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define GODOT_DICTIONARY_SIZE sizeof(void *) + +#ifndef GODOT_CORE_API_GODOT_DICTIONARY_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_DICTIONARY_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_DICTIONARY_SIZE]; +} godot_dictionary; +#endif + +#include +#include +#include + +void GDAPI godot_dictionary_new(godot_dictionary *r_dest); +void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src); +void GDAPI godot_dictionary_destroy(godot_dictionary *p_self); + +godot_int GDAPI godot_dictionary_size(const godot_dictionary *p_self); + +godot_bool GDAPI godot_dictionary_empty(const godot_dictionary *p_self); + +void GDAPI godot_dictionary_clear(godot_dictionary *p_self); + +godot_bool GDAPI godot_dictionary_has(const godot_dictionary *p_self, const godot_variant *p_key); + +godot_bool GDAPI godot_dictionary_has_all(const godot_dictionary *p_self, const godot_array *p_keys); + +void GDAPI godot_dictionary_erase(godot_dictionary *p_self, const godot_variant *p_key); + +godot_int GDAPI godot_dictionary_hash(const godot_dictionary *p_self); + +godot_array GDAPI godot_dictionary_keys(const godot_dictionary *p_self); + +godot_array GDAPI godot_dictionary_values(const godot_dictionary *p_self); + +godot_variant GDAPI godot_dictionary_get(const godot_dictionary *p_self, const godot_variant *p_key); +void GDAPI godot_dictionary_set(godot_dictionary *p_self, const godot_variant *p_key, const godot_variant *p_value); + +godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key); + +godot_variant GDAPI *godot_dictionary_next(const godot_dictionary *p_self, const godot_variant *p_key); + +godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self, const godot_dictionary *p_b); + +godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DICTIONARY_H diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h new file mode 100644 index 0000000000..c574c56d5a --- /dev/null +++ b/modules/gdnative/include/gdnative/gdnative.h @@ -0,0 +1,277 @@ +/*************************************************************************/ +/* gdnative.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_GDNATIVE_H +#define GODOT_GDNATIVE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef GDAPI_BUILT_IN +#define GDAPI_EXPORT +#endif + +#ifdef _WIN32 +#if defined(GDAPI_EXPORT) +#define GDCALLINGCONV +#define GDAPI __declspec(dllexport) GDCALLINGCONV +#else +#define GDCALLINGCONV +#define GDAPI __declspec(dllimport) GDCALLINGCONV +#endif +#elif defined(__APPLE__) +#include "TargetConditionals.h" +#if TARGET_OS_IPHONE +#define GDCALLINGCONV +#define GDAPI +#elif TARGET_OS_MAC +#define GDCALLINGCONV __attribute__((sysv_abi)) +#define GDAPI GDCALLINGCONV +#endif +#else +#define GDCALLINGCONV __attribute__((sysv_abi, visibility("default"))) +#define GDAPI GDCALLINGCONV +#endif + +// This is for libraries *using* the header, NOT GODOT EXPOSING STUFF!! +#ifdef _WIN32 +#define GDN_EXPORT __declspec(dllexport) +#else +#define GDN_EXPORT +#endif + +#include +#include + +#define GODOT_API_VERSION 1 + +////// Error + +typedef enum { + GODOT_OK, + GODOT_FAILED, ///< Generic fail error + GODOT_ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable + GODOT_ERR_UNCONFIGURED, ///< The object being used hasnt been properly set up yet + GODOT_ERR_UNAUTHORIZED, ///< Missing credentials for requested resource + GODOT_ERR_PARAMETER_RANGE_ERROR, ///< Parameter given out of range (5) + GODOT_ERR_OUT_OF_MEMORY, ///< Out of memory + GODOT_ERR_FILE_NOT_FOUND, + GODOT_ERR_FILE_BAD_DRIVE, + GODOT_ERR_FILE_BAD_PATH, + GODOT_ERR_FILE_NO_PERMISSION, // (10) + GODOT_ERR_FILE_ALREADY_IN_USE, + GODOT_ERR_FILE_CANT_OPEN, + GODOT_ERR_FILE_CANT_WRITE, + GODOT_ERR_FILE_CANT_READ, + GODOT_ERR_FILE_UNRECOGNIZED, // (15) + GODOT_ERR_FILE_CORRUPT, + GODOT_ERR_FILE_MISSING_DEPENDENCIES, + GODOT_ERR_FILE_EOF, + GODOT_ERR_CANT_OPEN, ///< Can't open a resource/socket/file + GODOT_ERR_CANT_CREATE, // (20) + GODOT_ERR_QUERY_FAILED, + GODOT_ERR_ALREADY_IN_USE, + GODOT_ERR_LOCKED, ///< resource is locked + GODOT_ERR_TIMEOUT, + GODOT_ERR_CANT_CONNECT, // (25) + GODOT_ERR_CANT_RESOLVE, + GODOT_ERR_CONNECTION_ERROR, + GODOT_ERR_CANT_AQUIRE_RESOURCE, + GODOT_ERR_CANT_FORK, + GODOT_ERR_INVALID_DATA, ///< Data passed is invalid (30) + GODOT_ERR_INVALID_PARAMETER, ///< Parameter passed is invalid + GODOT_ERR_ALREADY_EXISTS, ///< When adding, item already exists + GODOT_ERR_DOES_NOT_EXIST, ///< When retrieving/erasing, it item does not exist + GODOT_ERR_DATABASE_CANT_READ, ///< database is full + GODOT_ERR_DATABASE_CANT_WRITE, ///< database is full (35) + GODOT_ERR_COMPILATION_FAILED, + GODOT_ERR_METHOD_NOT_FOUND, + GODOT_ERR_LINK_FAILED, + GODOT_ERR_SCRIPT_FAILED, + GODOT_ERR_CYCLIC_LINK, // (40) + GODOT_ERR_INVALID_DECLARATION, + GODOT_ERR_DUPLICATE_SYMBOL, + GODOT_ERR_PARSE_ERROR, + GODOT_ERR_BUSY, + GODOT_ERR_SKIP, // (45) + GODOT_ERR_HELP, ///< user requested help!! + GODOT_ERR_BUG, ///< a bug in the software certainly happened, due to a double check failing or unexpected behavior. + GODOT_ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames + GODOT_ERR_OMFG_THIS_IS_VERY_VERY_BAD, ///< shit happens, has never been used, though + GODOT_ERR_WTF = GODOT_ERR_OMFG_THIS_IS_VERY_VERY_BAD ///< short version of the above +} godot_error; + +////// bool + +typedef bool godot_bool; + +#define GODOT_TRUE 1 +#define GODOT_FALSE 0 + +/////// int + +typedef int godot_int; + +/////// real + +typedef float godot_real; + +/////// Object (forward declared) +typedef void godot_object; + +/////// String + +#include + +////// Vector2 + +#include + +////// Rect2 + +#include + +////// Vector3 + +#include + +////// Transform2D + +#include + +/////// Plane + +#include + +/////// Quat + +#include + +/////// Rect3 + +#include + +/////// Basis + +#include + +/////// Transform + +#include + +/////// Color + +#include + +/////// NodePath + +#include + +/////// RID + +#include + +/////// Dictionary + +#include + +/////// Array + +#include + +// single API file for Pool*Array +#include + +void GDAPI godot_object_destroy(godot_object *p_o); + +////// Variant + +#include + +////// Singleton API + +godot_object GDAPI *godot_global_get_singleton(char *p_name); // result shouldn't be freed + +////// OS API + +void GDAPI *godot_get_stack_bottom(); // returns stack bottom of the main thread + +////// MethodBind API + +typedef struct { + uint8_t _dont_touch_that[1]; // TODO +} godot_method_bind; + +godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname); +void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_object *p_instance, const void **p_args, void *p_ret); +godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, godot_object *p_instance, const godot_variant **p_args, const int p_arg_count, godot_variant_call_error *p_call_error); +////// Script API + +typedef struct { + godot_bool in_editor; + uint64_t core_api_hash; + uint64_t editor_api_hash; + uint64_t no_api_hash; + godot_object *gd_native_library; // pointer to GDNativeLibrary that is being initialized +} godot_gdnative_init_options; + +typedef struct { + godot_bool in_editor; +} godot_gdnative_terminate_options; + +// Calling convention? +typedef godot_object *(*godot_class_constructor)(); + +godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname); + +godot_dictionary GDAPI godot_get_global_constants(); + +////// GDNative procedure types +typedef void (*godot_gdnative_init_fn)(godot_gdnative_init_options *); +typedef void (*godot_gdnative_terminate_fn)(godot_gdnative_terminate_options *); +typedef godot_variant (*godot_gdnative_procedure_fn)(void *, godot_array *); + +////// System Functions + +//using these will help Godot track how much memory is in use in debug mode +void GDAPI *godot_alloc(int p_bytes); +void GDAPI *godot_realloc(void *p_ptr, int p_bytes); +void GDAPI godot_free(void *p_ptr); + +//print using Godot's error handler list +void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line); +void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line); +void GDAPI godot_print(const godot_string *p_message); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_C_H diff --git a/modules/gdnative/include/gdnative/node_path.h b/modules/gdnative/include/gdnative/node_path.h new file mode 100644 index 0000000000..0cfdbc1127 --- /dev/null +++ b/modules/gdnative/include/gdnative/node_path.h @@ -0,0 +1,77 @@ +/*************************************************************************/ +/* node_path.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_NODE_PATH_H +#define GODOT_NODE_PATH_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define GODOT_NODE_PATH_SIZE sizeof(void *) + +#ifndef GODOT_CORE_API_GODOT_NODE_PATH_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_NODE_PATH_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_NODE_PATH_SIZE]; +} godot_node_path; +#endif + +#include +#include + +void GDAPI godot_node_path_new(godot_node_path *r_dest, const godot_string *p_from); +void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src); +void GDAPI godot_node_path_destroy(godot_node_path *p_self); + +godot_string GDAPI godot_node_path_as_string(const godot_node_path *p_self); + +godot_bool GDAPI godot_node_path_is_absolute(const godot_node_path *p_self); + +godot_int GDAPI godot_node_path_get_name_count(const godot_node_path *p_self); + +godot_string GDAPI godot_node_path_get_name(const godot_node_path *p_self, const godot_int p_idx); + +godot_int GDAPI godot_node_path_get_subname_count(const godot_node_path *p_self); + +godot_string GDAPI godot_node_path_get_subname(const godot_node_path *p_self, const godot_int p_idx); + +godot_string GDAPI godot_node_path_get_property(const godot_node_path *p_self); + +godot_bool GDAPI godot_node_path_is_empty(const godot_node_path *p_self); + +godot_bool GDAPI godot_node_path_operator_equal(const godot_node_path *p_self, const godot_node_path *p_b); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_NODE_PATH_H diff --git a/modules/gdnative/include/gdnative/plane.h b/modules/gdnative/include/gdnative/plane.h new file mode 100644 index 0000000000..6a8915e08b --- /dev/null +++ b/modules/gdnative/include/gdnative/plane.h @@ -0,0 +1,93 @@ +/*************************************************************************/ +/* plane.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_PLANE_H +#define GODOT_PLANE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define GODOT_PLANE_SIZE 16 + +#ifndef GODOT_CORE_API_GODOT_PLANE_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_PLANE_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_PLANE_SIZE]; +} godot_plane; +#endif + +#include +#include + +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); +void GDAPI godot_plane_new_with_vectors(godot_plane *r_dest, const godot_vector3 *p_v1, const godot_vector3 *p_v2, const godot_vector3 *p_v3); +void GDAPI godot_plane_new_with_normal(godot_plane *r_dest, const godot_vector3 *p_normal, const godot_real p_d); + +godot_string GDAPI godot_plane_as_string(const godot_plane *p_self); + +godot_plane GDAPI godot_plane_normalized(const godot_plane *p_self); + +godot_vector3 GDAPI godot_plane_center(const godot_plane *p_self); + +godot_vector3 GDAPI godot_plane_get_any_point(const godot_plane *p_self); + +godot_bool GDAPI godot_plane_is_point_over(const godot_plane *p_self, const godot_vector3 *p_point); + +godot_real GDAPI godot_plane_distance_to(const godot_plane *p_self, const godot_vector3 *p_point); + +godot_bool GDAPI godot_plane_has_point(const godot_plane *p_self, const godot_vector3 *p_point, const godot_real p_epsilon); + +godot_vector3 GDAPI godot_plane_project(const godot_plane *p_self, const godot_vector3 *p_point); + +godot_bool GDAPI godot_plane_intersect_3(const godot_plane *p_self, godot_vector3 *r_dest, const godot_plane *p_b, const godot_plane *p_c); + +godot_bool GDAPI godot_plane_intersects_ray(const godot_plane *p_self, godot_vector3 *r_dest, const godot_vector3 *p_from, const godot_vector3 *p_dir); + +godot_bool GDAPI godot_plane_intersects_segment(const godot_plane *p_self, godot_vector3 *r_dest, const godot_vector3 *p_begin, const godot_vector3 *p_end); + +godot_plane GDAPI godot_plane_operator_neg(const godot_plane *p_self); + +godot_bool GDAPI godot_plane_operator_equal(const godot_plane *p_self, const godot_plane *p_b); + +void GDAPI godot_plane_set_normal(godot_plane *p_self, const godot_vector3 *p_normal); + +godot_vector3 GDAPI godot_plane_get_normal(const godot_plane *p_self); + +godot_real GDAPI godot_plane_get_d(const godot_plane *p_self); + +void GDAPI godot_plane_set_d(godot_plane *p_self, const godot_real p_d); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_PLANE_H diff --git a/modules/gdnative/include/gdnative/pool_arrays.h b/modules/gdnative/include/gdnative/pool_arrays.h new file mode 100644 index 0000000000..cb1095ee8c --- /dev/null +++ b/modules/gdnative/include/gdnative/pool_arrays.h @@ -0,0 +1,316 @@ +/*************************************************************************/ +/* pool_arrays.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_POOL_ARRAYS_H +#define GODOT_POOL_ARRAYS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/////// PoolByteArray + +#define GODOT_POOL_BYTE_ARRAY_SIZE sizeof(void *) + +#ifndef GODOT_CORE_API_GODOT_POOL_BYTE_ARRAY_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_POOL_BYTE_ARRAY_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_POOL_BYTE_ARRAY_SIZE]; +} godot_pool_byte_array; +#endif + +/////// PoolIntArray + +#define GODOT_POOL_INT_ARRAY_SIZE sizeof(void *) + +#ifndef GODOT_CORE_API_GODOT_POOL_INT_ARRAY_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_POOL_INT_ARRAY_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_POOL_INT_ARRAY_SIZE]; +} godot_pool_int_array; +#endif + +/////// PoolRealArray + +#define GODOT_POOL_REAL_ARRAY_SIZE sizeof(void *) + +#ifndef GODOT_CORE_API_GODOT_POOL_REAL_ARRAY_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_POOL_REAL_ARRAY_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_POOL_REAL_ARRAY_SIZE]; +} godot_pool_real_array; +#endif + +/////// PoolStringArray + +#define GODOT_POOL_STRING_ARRAY_SIZE sizeof(void *) + +#ifndef GODOT_CORE_API_GODOT_POOL_STRING_ARRAY_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_POOL_STRING_ARRAY_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_POOL_STRING_ARRAY_SIZE]; +} godot_pool_string_array; +#endif + +/////// PoolVector2Array + +#define GODOT_POOL_VECTOR2_ARRAY_SIZE sizeof(void *) + +#ifndef GODOT_CORE_API_GODOT_POOL_VECTOR2_ARRAY_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_POOL_VECTOR2_ARRAY_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_POOL_VECTOR2_ARRAY_SIZE]; +} godot_pool_vector2_array; +#endif + +/////// PoolVector3Array + +#define GODOT_POOL_VECTOR3_ARRAY_SIZE sizeof(void *) + +#ifndef GODOT_CORE_API_GODOT_POOL_VECTOR3_ARRAY_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_POOL_VECTOR3_ARRAY_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_POOL_VECTOR3_ARRAY_SIZE]; +} godot_pool_vector3_array; +#endif + +/////// PoolColorArray + +#define GODOT_POOL_COLOR_ARRAY_SIZE sizeof(void *) + +#ifndef GODOT_CORE_API_GODOT_POOL_COLOR_ARRAY_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_POOL_COLOR_ARRAY_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_POOL_COLOR_ARRAY_SIZE]; +} godot_pool_color_array; +#endif + +#include +#include +#include +#include + +#include + +// byte + +void GDAPI godot_pool_byte_array_new(godot_pool_byte_array *r_dest); +void GDAPI godot_pool_byte_array_new_copy(godot_pool_byte_array *r_dest, const godot_pool_byte_array *p_src); +void GDAPI godot_pool_byte_array_new_with_array(godot_pool_byte_array *r_dest, const godot_array *p_a); + +void GDAPI godot_pool_byte_array_append(godot_pool_byte_array *p_self, const uint8_t p_data); + +void GDAPI godot_pool_byte_array_append_array(godot_pool_byte_array *p_self, const godot_pool_byte_array *p_array); + +godot_error GDAPI godot_pool_byte_array_insert(godot_pool_byte_array *p_self, const godot_int p_idx, const uint8_t p_data); + +void GDAPI godot_pool_byte_array_invert(godot_pool_byte_array *p_self); + +void GDAPI godot_pool_byte_array_push_back(godot_pool_byte_array *p_self, const uint8_t p_data); + +void GDAPI godot_pool_byte_array_remove(godot_pool_byte_array *p_self, const godot_int p_idx); + +void GDAPI godot_pool_byte_array_resize(godot_pool_byte_array *p_self, const godot_int p_size); + +void GDAPI godot_pool_byte_array_set(godot_pool_byte_array *p_self, const godot_int p_idx, const uint8_t p_data); +uint8_t GDAPI godot_pool_byte_array_get(const godot_pool_byte_array *p_self, const godot_int p_idx); + +godot_int GDAPI godot_pool_byte_array_size(const godot_pool_byte_array *p_self); + +void GDAPI godot_pool_byte_array_destroy(godot_pool_byte_array *p_self); + +// int + +void GDAPI godot_pool_int_array_new(godot_pool_int_array *r_dest); +void GDAPI godot_pool_int_array_new_copy(godot_pool_int_array *r_dest, const godot_pool_int_array *p_src); +void GDAPI godot_pool_int_array_new_with_array(godot_pool_int_array *r_dest, const godot_array *p_a); + +void GDAPI godot_pool_int_array_append(godot_pool_int_array *p_self, const godot_int p_data); + +void GDAPI godot_pool_int_array_append_array(godot_pool_int_array *p_self, const godot_pool_int_array *p_array); + +godot_error GDAPI godot_pool_int_array_insert(godot_pool_int_array *p_self, const godot_int p_idx, const godot_int p_data); + +void GDAPI godot_pool_int_array_invert(godot_pool_int_array *p_self); + +void GDAPI godot_pool_int_array_push_back(godot_pool_int_array *p_self, const godot_int p_data); + +void GDAPI godot_pool_int_array_remove(godot_pool_int_array *p_self, const godot_int p_idx); + +void GDAPI godot_pool_int_array_resize(godot_pool_int_array *p_self, const godot_int p_size); + +void GDAPI godot_pool_int_array_set(godot_pool_int_array *p_self, const godot_int p_idx, const godot_int p_data); +godot_int GDAPI godot_pool_int_array_get(const godot_pool_int_array *p_self, const godot_int p_idx); + +godot_int GDAPI godot_pool_int_array_size(const godot_pool_int_array *p_self); + +void GDAPI godot_pool_int_array_destroy(godot_pool_int_array *p_self); + +// real + +void GDAPI godot_pool_real_array_new(godot_pool_real_array *r_dest); +void GDAPI godot_pool_real_array_new_copy(godot_pool_real_array *r_dest, const godot_pool_real_array *p_src); +void GDAPI godot_pool_real_array_new_with_array(godot_pool_real_array *r_dest, const godot_array *p_a); + +void GDAPI godot_pool_real_array_append(godot_pool_real_array *p_self, const godot_real p_data); + +void GDAPI godot_pool_real_array_append_array(godot_pool_real_array *p_self, const godot_pool_real_array *p_array); + +godot_error GDAPI godot_pool_real_array_insert(godot_pool_real_array *p_self, const godot_int p_idx, const godot_real p_data); + +void GDAPI godot_pool_real_array_invert(godot_pool_real_array *p_self); + +void GDAPI godot_pool_real_array_push_back(godot_pool_real_array *p_self, const godot_real p_data); + +void GDAPI godot_pool_real_array_remove(godot_pool_real_array *p_self, const godot_int p_idx); + +void GDAPI godot_pool_real_array_resize(godot_pool_real_array *p_self, const godot_int p_size); + +void GDAPI godot_pool_real_array_set(godot_pool_real_array *p_self, const godot_int p_idx, const godot_real p_data); +godot_real GDAPI godot_pool_real_array_get(const godot_pool_real_array *p_self, const godot_int p_idx); + +godot_int GDAPI godot_pool_real_array_size(const godot_pool_real_array *p_self); + +void GDAPI godot_pool_real_array_destroy(godot_pool_real_array *p_self); + +// string + +void GDAPI godot_pool_string_array_new(godot_pool_string_array *r_dest); +void GDAPI godot_pool_string_array_new_copy(godot_pool_string_array *r_dest, const godot_pool_string_array *p_src); +void GDAPI godot_pool_string_array_new_with_array(godot_pool_string_array *r_dest, const godot_array *p_a); + +void GDAPI godot_pool_string_array_append(godot_pool_string_array *p_self, const godot_string *p_data); + +void GDAPI godot_pool_string_array_append_array(godot_pool_string_array *p_self, const godot_pool_string_array *p_array); + +godot_error GDAPI godot_pool_string_array_insert(godot_pool_string_array *p_self, const godot_int p_idx, const godot_string *p_data); + +void GDAPI godot_pool_string_array_invert(godot_pool_string_array *p_self); + +void GDAPI godot_pool_string_array_push_back(godot_pool_string_array *p_self, const godot_string *p_data); + +void GDAPI godot_pool_string_array_remove(godot_pool_string_array *p_self, const godot_int p_idx); + +void GDAPI godot_pool_string_array_resize(godot_pool_string_array *p_self, const godot_int p_size); + +void GDAPI godot_pool_string_array_set(godot_pool_string_array *p_self, const godot_int p_idx, const godot_string *p_data); +godot_string GDAPI godot_pool_string_array_get(const godot_pool_string_array *p_self, const godot_int p_idx); + +godot_int GDAPI godot_pool_string_array_size(const godot_pool_string_array *p_self); + +void GDAPI godot_pool_string_array_destroy(godot_pool_string_array *p_self); + +// vector2 + +void GDAPI godot_pool_vector2_array_new(godot_pool_vector2_array *r_dest); +void GDAPI godot_pool_vector2_array_new_copy(godot_pool_vector2_array *r_dest, const godot_pool_vector2_array *p_src); +void GDAPI godot_pool_vector2_array_new_with_array(godot_pool_vector2_array *r_dest, const godot_array *p_a); + +void GDAPI godot_pool_vector2_array_append(godot_pool_vector2_array *p_self, const godot_vector2 *p_data); + +void GDAPI godot_pool_vector2_array_append_array(godot_pool_vector2_array *p_self, const godot_pool_vector2_array *p_array); + +godot_error GDAPI godot_pool_vector2_array_insert(godot_pool_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data); + +void GDAPI godot_pool_vector2_array_invert(godot_pool_vector2_array *p_self); + +void GDAPI godot_pool_vector2_array_push_back(godot_pool_vector2_array *p_self, const godot_vector2 *p_data); + +void GDAPI godot_pool_vector2_array_remove(godot_pool_vector2_array *p_self, const godot_int p_idx); + +void GDAPI godot_pool_vector2_array_resize(godot_pool_vector2_array *p_self, const godot_int p_size); + +void GDAPI godot_pool_vector2_array_set(godot_pool_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data); +godot_vector2 GDAPI godot_pool_vector2_array_get(const godot_pool_vector2_array *p_self, const godot_int p_idx); + +godot_int GDAPI godot_pool_vector2_array_size(const godot_pool_vector2_array *p_self); + +void GDAPI godot_pool_vector2_array_destroy(godot_pool_vector2_array *p_self); + +// vector3 + +void GDAPI godot_pool_vector3_array_new(godot_pool_vector3_array *r_dest); +void GDAPI godot_pool_vector3_array_new_copy(godot_pool_vector3_array *r_dest, const godot_pool_vector3_array *p_src); +void GDAPI godot_pool_vector3_array_new_with_array(godot_pool_vector3_array *r_dest, const godot_array *p_a); + +void GDAPI godot_pool_vector3_array_append(godot_pool_vector3_array *p_self, const godot_vector3 *p_data); + +void GDAPI godot_pool_vector3_array_append_array(godot_pool_vector3_array *p_self, const godot_pool_vector3_array *p_array); + +godot_error GDAPI godot_pool_vector3_array_insert(godot_pool_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data); + +void GDAPI godot_pool_vector3_array_invert(godot_pool_vector3_array *p_self); + +void GDAPI godot_pool_vector3_array_push_back(godot_pool_vector3_array *p_self, const godot_vector3 *p_data); + +void GDAPI godot_pool_vector3_array_remove(godot_pool_vector3_array *p_self, const godot_int p_idx); + +void GDAPI godot_pool_vector3_array_resize(godot_pool_vector3_array *p_self, const godot_int p_size); + +void GDAPI godot_pool_vector3_array_set(godot_pool_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data); +godot_vector3 GDAPI godot_pool_vector3_array_get(const godot_pool_vector3_array *p_self, const godot_int p_idx); + +godot_int GDAPI godot_pool_vector3_array_size(const godot_pool_vector3_array *p_self); + +void GDAPI godot_pool_vector3_array_destroy(godot_pool_vector3_array *p_self); + +// color + +void GDAPI godot_pool_color_array_new(godot_pool_color_array *r_dest); +void GDAPI godot_pool_color_array_new_copy(godot_pool_color_array *r_dest, const godot_pool_color_array *p_src); +void GDAPI godot_pool_color_array_new_with_array(godot_pool_color_array *r_dest, const godot_array *p_a); + +void GDAPI godot_pool_color_array_append(godot_pool_color_array *p_self, const godot_color *p_data); + +void GDAPI godot_pool_color_array_append_array(godot_pool_color_array *p_self, const godot_pool_color_array *p_array); + +godot_error GDAPI godot_pool_color_array_insert(godot_pool_color_array *p_self, const godot_int p_idx, const godot_color *p_data); + +void GDAPI godot_pool_color_array_invert(godot_pool_color_array *p_self); + +void GDAPI godot_pool_color_array_push_back(godot_pool_color_array *p_self, const godot_color *p_data); + +void GDAPI godot_pool_color_array_remove(godot_pool_color_array *p_self, const godot_int p_idx); + +void GDAPI godot_pool_color_array_resize(godot_pool_color_array *p_self, const godot_int p_size); + +void GDAPI godot_pool_color_array_set(godot_pool_color_array *p_self, const godot_int p_idx, const godot_color *p_data); +godot_color GDAPI godot_pool_color_array_get(const godot_pool_color_array *p_self, const godot_int p_idx); + +godot_int GDAPI godot_pool_color_array_size(const godot_pool_color_array *p_self); + +void GDAPI godot_pool_color_array_destroy(godot_pool_color_array *p_self); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_POOL_ARRAYS_H diff --git a/modules/gdnative/include/gdnative/quat.h b/modules/gdnative/include/gdnative/quat.h new file mode 100644 index 0000000000..4ffb96eb26 --- /dev/null +++ b/modules/gdnative/include/gdnative/quat.h @@ -0,0 +1,104 @@ +/*************************************************************************/ +/* quat.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_QUAT_H +#define GODOT_QUAT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define GODOT_QUAT_SIZE 16 + +#ifndef GODOT_CORE_API_GODOT_QUAT_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_QUAT_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_QUAT_SIZE]; +} godot_quat; +#endif + +#include +#include + +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); +void GDAPI godot_quat_new_with_axis_angle(godot_quat *r_dest, const godot_vector3 *p_axis, const godot_real p_angle); + +godot_real GDAPI godot_quat_get_x(const godot_quat *p_self); +void GDAPI godot_quat_set_x(godot_quat *p_self, const godot_real val); + +godot_real GDAPI godot_quat_get_y(const godot_quat *p_self); +void GDAPI godot_quat_set_y(godot_quat *p_self, const godot_real val); + +godot_real GDAPI godot_quat_get_z(const godot_quat *p_self); +void GDAPI godot_quat_set_z(godot_quat *p_self, const godot_real val); + +godot_real GDAPI godot_quat_get_w(const godot_quat *p_self); +void GDAPI godot_quat_set_w(godot_quat *p_self, const godot_real val); + +godot_string GDAPI godot_quat_as_string(const godot_quat *p_self); + +godot_real GDAPI godot_quat_length(const godot_quat *p_self); + +godot_real GDAPI godot_quat_length_squared(const godot_quat *p_self); + +godot_quat GDAPI godot_quat_normalized(const godot_quat *p_self); + +godot_bool GDAPI godot_quat_is_normalized(const godot_quat *p_self); + +godot_quat GDAPI godot_quat_inverse(const godot_quat *p_self); + +godot_real GDAPI godot_quat_dot(const godot_quat *p_self, const godot_quat *p_b); + +godot_vector3 GDAPI godot_quat_xform(const godot_quat *p_self, const godot_vector3 *p_v); + +godot_quat GDAPI godot_quat_slerp(const godot_quat *p_self, const godot_quat *p_b, const godot_real p_t); + +godot_quat GDAPI godot_quat_slerpni(const godot_quat *p_self, const godot_quat *p_b, const godot_real p_t); + +godot_quat GDAPI godot_quat_cubic_slerp(const godot_quat *p_self, const godot_quat *p_b, const godot_quat *p_pre_a, const godot_quat *p_post_b, const godot_real p_t); + +godot_quat GDAPI godot_quat_operator_multiply(const godot_quat *p_self, const godot_real p_b); + +godot_quat GDAPI godot_quat_operator_add(const godot_quat *p_self, const godot_quat *p_b); + +godot_quat GDAPI godot_quat_operator_substract(const godot_quat *p_self, const godot_quat *p_b); + +godot_quat GDAPI godot_quat_operator_divide(const godot_quat *p_self, const godot_real p_b); + +godot_bool GDAPI godot_quat_operator_equal(const godot_quat *p_self, const godot_quat *p_b); + +godot_quat GDAPI godot_quat_operator_neg(const godot_quat *p_self); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_QUAT_H diff --git a/modules/gdnative/include/gdnative/rect2.h b/modules/gdnative/include/gdnative/rect2.h new file mode 100644 index 0000000000..9e6cf60342 --- /dev/null +++ b/modules/gdnative/include/gdnative/rect2.h @@ -0,0 +1,86 @@ +/*************************************************************************/ +/* rect2.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_RECT2_H +#define GODOT_RECT2_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef GODOT_CORE_API_GODOT_RECT2_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_RECT2_TYPE_DEFINED +typedef struct godot_rect2 { + uint8_t _dont_touch_that[16]; +} godot_rect2; +#endif + +#include +#include + +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_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); + +godot_bool GDAPI godot_rect2_encloses(const godot_rect2 *p_self, const godot_rect2 *p_b); + +godot_bool GDAPI godot_rect2_has_no_area(const godot_rect2 *p_self); + +godot_rect2 GDAPI godot_rect2_clip(const godot_rect2 *p_self, const godot_rect2 *p_b); + +godot_rect2 GDAPI godot_rect2_merge(const godot_rect2 *p_self, const godot_rect2 *p_b); + +godot_bool GDAPI godot_rect2_has_point(const godot_rect2 *p_self, const godot_vector2 *p_point); + +godot_rect2 GDAPI godot_rect2_grow(const godot_rect2 *p_self, const godot_real p_by); + +godot_rect2 GDAPI godot_rect2_expand(const godot_rect2 *p_self, const godot_vector2 *p_to); + +godot_bool GDAPI godot_rect2_operator_equal(const godot_rect2 *p_self, const godot_rect2 *p_b); + +godot_vector2 GDAPI godot_rect2_get_position(const godot_rect2 *p_self); + +godot_vector2 GDAPI godot_rect2_get_size(const godot_rect2 *p_self); + +void GDAPI godot_rect2_set_position(godot_rect2 *p_self, const godot_vector2 *p_pos); + +void GDAPI godot_rect2_set_size(godot_rect2 *p_self, const godot_vector2 *p_size); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_RECT2_H diff --git a/modules/gdnative/include/gdnative/rect3.h b/modules/gdnative/include/gdnative/rect3.h new file mode 100644 index 0000000000..f94b6fea25 --- /dev/null +++ b/modules/gdnative/include/gdnative/rect3.h @@ -0,0 +1,108 @@ +/*************************************************************************/ +/* rect3.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_RECT3_H +#define GODOT_RECT3_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define GODOT_RECT3_SIZE 24 + +#ifndef GODOT_CORE_API_GODOT_RECT3_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_RECT3_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_RECT3_SIZE]; +} godot_rect3; +#endif + +#include +#include +#include + +void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size); + +godot_vector3 GDAPI godot_rect3_get_position(const godot_rect3 *p_self); +void GDAPI godot_rect3_set_position(const godot_rect3 *p_self, const godot_vector3 *p_v); + +godot_vector3 GDAPI godot_rect3_get_size(const godot_rect3 *p_self); +void GDAPI godot_rect3_set_size(const godot_rect3 *p_self, const godot_vector3 *p_v); + +godot_string GDAPI godot_rect3_as_string(const godot_rect3 *p_self); + +godot_real GDAPI godot_rect3_get_area(const godot_rect3 *p_self); + +godot_bool GDAPI godot_rect3_has_no_area(const godot_rect3 *p_self); + +godot_bool GDAPI godot_rect3_has_no_surface(const godot_rect3 *p_self); + +godot_bool GDAPI godot_rect3_intersects(const godot_rect3 *p_self, const godot_rect3 *p_with); + +godot_bool GDAPI godot_rect3_encloses(const godot_rect3 *p_self, const godot_rect3 *p_with); + +godot_rect3 GDAPI godot_rect3_merge(const godot_rect3 *p_self, const godot_rect3 *p_with); + +godot_rect3 GDAPI godot_rect3_intersection(const godot_rect3 *p_self, const godot_rect3 *p_with); + +godot_bool GDAPI godot_rect3_intersects_plane(const godot_rect3 *p_self, const godot_plane *p_plane); + +godot_bool GDAPI godot_rect3_intersects_segment(const godot_rect3 *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to); + +godot_bool GDAPI godot_rect3_has_point(const godot_rect3 *p_self, const godot_vector3 *p_point); + +godot_vector3 GDAPI godot_rect3_get_support(const godot_rect3 *p_self, const godot_vector3 *p_dir); + +godot_vector3 GDAPI godot_rect3_get_longest_axis(const godot_rect3 *p_self); + +godot_int GDAPI godot_rect3_get_longest_axis_index(const godot_rect3 *p_self); + +godot_real GDAPI godot_rect3_get_longest_axis_size(const godot_rect3 *p_self); + +godot_vector3 GDAPI godot_rect3_get_shortest_axis(const godot_rect3 *p_self); + +godot_int GDAPI godot_rect3_get_shortest_axis_index(const godot_rect3 *p_self); + +godot_real GDAPI godot_rect3_get_shortest_axis_size(const godot_rect3 *p_self); + +godot_rect3 GDAPI godot_rect3_expand(const godot_rect3 *p_self, const godot_vector3 *p_to_point); + +godot_rect3 GDAPI godot_rect3_grow(const godot_rect3 *p_self, const godot_real p_by); + +godot_vector3 GDAPI godot_rect3_get_endpoint(const godot_rect3 *p_self, const godot_int p_idx); + +godot_bool GDAPI godot_rect3_operator_equal(const godot_rect3 *p_self, const godot_rect3 *p_b); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_RECT3_H diff --git a/modules/gdnative/include/gdnative/rid.h b/modules/gdnative/include/gdnative/rid.h new file mode 100644 index 0000000000..d9b5336fc9 --- /dev/null +++ b/modules/gdnative/include/gdnative/rid.h @@ -0,0 +1,64 @@ +/*************************************************************************/ +/* rid.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_RID_H +#define GODOT_RID_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define GODOT_RID_SIZE sizeof(void *) + +#ifndef GODOT_CORE_API_GODOT_RID_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_RID_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_RID_SIZE]; +} godot_rid; +#endif + +#include + +void GDAPI godot_rid_new(godot_rid *r_dest); + +godot_int GDAPI godot_rid_get_id(const godot_rid *p_self); + +void GDAPI godot_rid_new_with_resource(godot_rid *r_dest, const godot_object *p_from); + +godot_bool GDAPI godot_rid_operator_equal(const godot_rid *p_self, const godot_rid *p_b); + +godot_bool GDAPI godot_rid_operator_less(const godot_rid *p_self, const godot_rid *p_b); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_RID_H diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h new file mode 100644 index 0000000000..aca23a81d8 --- /dev/null +++ b/modules/gdnative/include/gdnative/string.h @@ -0,0 +1,228 @@ +/*************************************************************************/ +/* string.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_STRING_H +#define GODOT_STRING_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define GODOT_STRING_SIZE sizeof(void *) + +#ifndef GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_STRING_SIZE]; +} godot_string; +#endif + +#include +#include + +void GDAPI godot_string_new(godot_string *r_dest); +void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src); +void GDAPI godot_string_new_data(godot_string *r_dest, const char *p_contents, const int p_size); +void GDAPI godot_string_new_unicode_data(godot_string *r_dest, const wchar_t *p_contents, const int p_size); + +void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *p_size); + +wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx); +const char GDAPI *godot_string_c_str(const godot_string *p_self); +const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_self); + +godot_bool GDAPI godot_string_operator_equal(const godot_string *p_self, const godot_string *p_b); +godot_bool GDAPI godot_string_operator_less(const godot_string *p_self, const godot_string *p_b); +godot_string GDAPI godot_string_operator_plus(const godot_string *p_self, const godot_string *p_b); + +/* Standard size stuff */ + +godot_int GDAPI godot_string_length(const godot_string *p_self); + +/* Helpers */ + +godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string); +godot_bool GDAPI godot_string_begins_with_char_array(const godot_string *p_self, const char *p_char_array); +godot_array GDAPI godot_string_bigrams(const godot_string *p_self); +godot_string GDAPI godot_string_chr(wchar_t p_character); +godot_bool GDAPI godot_string_ends_with(const godot_string *p_self, const godot_string *p_string); +godot_int GDAPI godot_string_find(const godot_string *p_self, godot_string p_what); +godot_int GDAPI godot_string_find_from(const godot_string *p_self, godot_string p_what, godot_int p_from); +godot_int GDAPI godot_string_findmk(const godot_string *p_self, const godot_array *p_keys); +godot_int GDAPI godot_string_findmk_from(const godot_string *p_self, const godot_array *p_keys, godot_int p_from); +godot_int GDAPI godot_string_findmk_from_in_place(const godot_string *p_self, const godot_array *p_keys, godot_int p_from, godot_int *r_key); +godot_int GDAPI godot_string_findn(const godot_string *p_self, godot_string p_what); +godot_int GDAPI godot_string_findn_from(const godot_string *p_self, godot_string p_what, godot_int p_from); +godot_int GDAPI godot_string_find_last(const godot_string *p_self, godot_string p_what); +godot_string GDAPI godot_string_format(const godot_string *p_self, const godot_variant *p_values); +godot_string GDAPI godot_string_format_with_custom_placeholder(const godot_string *p_self, const godot_variant *p_values, const char *p_placeholder); +godot_string GDAPI godot_string_hex_encode_buffer(const uint8_t *p_buffer, godot_int p_len); +godot_int GDAPI godot_string_hex_to_int(const godot_string *p_self); +godot_int GDAPI godot_string_hex_to_int_without_prefix(const godot_string *p_self); +godot_string GDAPI godot_string_insert(const godot_string *p_self, godot_int p_at_pos, godot_string p_string); +godot_bool GDAPI godot_string_is_numeric(const godot_string *p_self); +godot_bool GDAPI godot_string_is_subsequence_of(const godot_string *p_self, const godot_string *p_string); +godot_bool GDAPI godot_string_is_subsequence_ofi(const godot_string *p_self, const godot_string *p_string); +godot_string GDAPI godot_string_lpad(const godot_string *p_self, godot_int p_min_length); +godot_string GDAPI godot_string_lpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character); +godot_bool GDAPI godot_string_match(const godot_string *p_self, const godot_string *p_wildcard); +godot_bool GDAPI godot_string_matchn(const godot_string *p_self, const godot_string *p_wildcard); +godot_string GDAPI godot_string_md5(const uint8_t *p_md5); +godot_string GDAPI godot_string_num(double p_num); +godot_string GDAPI godot_string_num_int64(int64_t p_num, godot_int p_base); +godot_string GDAPI godot_string_num_int64_capitalized(int64_t p_num, godot_int p_base, godot_bool p_capitalize_hex); +godot_string GDAPI godot_string_num_real(double p_num); +godot_string GDAPI godot_string_num_scientific(double p_num); +godot_string GDAPI godot_string_num_with_decimals(double p_num, godot_int p_decimals); +godot_string GDAPI godot_string_pad_decimals(const godot_string *p_self, godot_int p_digits); +godot_string GDAPI godot_string_pad_zeros(const godot_string *p_self, godot_int p_digits); +godot_string GDAPI godot_string_replace_first(const godot_string *p_self, godot_string p_key, godot_string p_with); +godot_string GDAPI godot_string_replace(const godot_string *p_self, godot_string p_key, godot_string p_with); +godot_string GDAPI godot_string_replacen(const godot_string *p_self, godot_string p_key, godot_string p_with); +godot_int GDAPI godot_string_rfind(const godot_string *p_self, godot_string p_what); +godot_int GDAPI godot_string_rfindn(const godot_string *p_self, godot_string p_what); +godot_int GDAPI godot_string_rfind_from(const godot_string *p_self, godot_string p_what, godot_int p_from); +godot_int GDAPI godot_string_rfindn_from(const godot_string *p_self, godot_string p_what, godot_int p_from); +godot_string GDAPI godot_string_rpad(const godot_string *p_self, godot_int p_min_length); +godot_string GDAPI godot_string_rpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character); +godot_real GDAPI godot_string_similarity(const godot_string *p_self, const godot_string *p_string); +godot_string GDAPI godot_string_sprintf(const godot_string *p_self, const godot_array *p_values, godot_bool *p_error); +godot_string GDAPI godot_string_substr(const godot_string *p_self, godot_int p_from, godot_int p_chars); +double GDAPI godot_string_to_double(const godot_string *p_self); +godot_real GDAPI godot_string_to_float(const godot_string *p_self); +godot_int GDAPI godot_string_to_int(const godot_string *p_self); + +godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_self); +godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_string *p_self); +godot_string GDAPI godot_string_capitalize(const godot_string *p_self); +double GDAPI godot_string_char_to_double(const char *p_what); +godot_int GDAPI godot_string_char_to_int(const char *p_what); +int64_t GDAPI godot_string_wchar_to_int(const wchar_t *p_str); +godot_int GDAPI godot_string_char_to_int_with_len(const char *p_what, godot_int p_len); +int64_t GDAPI godot_string_char_to_int64_with_len(const wchar_t *p_str, int p_len); +int64_t GDAPI godot_string_hex_to_int64(const godot_string *p_self); +int64_t GDAPI godot_string_hex_to_int64_with_prefix(const godot_string *p_self); +int64_t GDAPI godot_string_to_int64(const godot_string *p_self); +double GDAPI godot_string_unicode_char_to_double(const wchar_t *p_str, const wchar_t **r_end); + +godot_int GDAPI godot_string_get_slice_count(const godot_string *p_self, godot_string p_splitter); +godot_string GDAPI godot_string_get_slice(const godot_string *p_self, godot_string p_splitter, godot_int p_slice); +godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, wchar_t p_splitter, godot_int p_slice); + +godot_array GDAPI godot_string_split(const godot_string *p_self, const godot_string *p_splitter); +godot_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, const godot_string *p_splitter); +godot_array GDAPI godot_string_split_floats(const godot_string *p_self, const godot_string *p_splitter); +godot_array GDAPI godot_string_split_floats_allows_empty(const godot_string *p_self, const godot_string *p_splitter); +godot_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const godot_array *p_splitters); +godot_array GDAPI godot_string_split_floats_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters); +godot_array GDAPI godot_string_split_ints(const godot_string *p_self, const godot_string *p_splitter); +godot_array GDAPI godot_string_split_ints_allows_empty(const godot_string *p_self, const godot_string *p_splitter); +godot_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const godot_array *p_splitters); +godot_array GDAPI godot_string_split_ints_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters); +godot_array GDAPI godot_string_split_spaces(const godot_string *p_self); + +wchar_t GDAPI godot_string_char_lowercase(wchar_t p_char); +wchar_t GDAPI godot_string_char_uppercase(wchar_t p_char); +godot_string GDAPI godot_string_to_lower(const godot_string *p_self); +godot_string GDAPI godot_string_to_upper(const godot_string *p_self); + +godot_string GDAPI godot_string_get_basename(const godot_string *p_self); +godot_string GDAPI godot_string_get_extension(const godot_string *p_self); +godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos); +wchar_t GDAPI godot_string_ord_at(const godot_string *p_self, godot_int p_idx); +godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godot_string *p_file); +godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_pos); +godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bool p_left, godot_bool p_right); +godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self); + +void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars); + +void GDAPI godot_string_ascii(godot_string *p_self, char *result); +void GDAPI godot_string_ascii_extended(godot_string *p_self, char *result); +void GDAPI godot_string_utf8(godot_string *p_self, char *result); +godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8); +godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len); +godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8); +godot_string GDAPI godot_string_chars_to_utf8_with_len(const char *p_utf8, godot_int p_len); + +uint32_t GDAPI godot_string_hash(const godot_string *p_self); +uint64_t GDAPI godot_string_hash64(const godot_string *p_self); +uint32_t GDAPI godot_string_hash_chars(const char *p_cstr); +uint32_t GDAPI godot_string_hash_chars_with_len(const char *p_cstr, godot_int p_len); +uint32_t GDAPI godot_string_hash_utf8_chars(const wchar_t *p_str); +uint32_t GDAPI godot_string_hash_utf8_chars_with_len(const wchar_t *p_str, godot_int p_len); +godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self); +godot_string GDAPI godot_string_md5_text(const godot_string *p_self); +godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self); +godot_string GDAPI godot_string_sha256_text(const godot_string *p_self); + +godot_bool godot_string_empty(const godot_string *p_self); + +// path functions +godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self); +godot_string GDAPI godot_string_get_file(const godot_string *p_self); +godot_string GDAPI godot_string_humanize_size(size_t p_size); +godot_bool GDAPI godot_string_is_abs_path(const godot_string *p_self); +godot_bool GDAPI godot_string_is_rel_path(const godot_string *p_self); +godot_bool GDAPI godot_string_is_resource_file(const godot_string *p_self); +godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_string *p_path); +godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const godot_string *p_path); +godot_string GDAPI godot_string_simplify_path(const godot_string *p_self); + +godot_string GDAPI godot_string_c_escape(const godot_string *p_self); +godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self); +godot_string GDAPI godot_string_c_unescape(const godot_string *p_self); +godot_string GDAPI godot_string_http_escape(const godot_string *p_self); +godot_string GDAPI godot_string_http_unescape(const godot_string *p_self); +godot_string GDAPI godot_string_json_escape(const godot_string *p_self); +godot_string GDAPI godot_string_word_wrap(const godot_string *p_self, godot_int p_chars_per_line); +godot_string GDAPI godot_string_xml_escape(const godot_string *p_self); +godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_self); +godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self); + +godot_string GDAPI godot_string_percent_decode(const godot_string *p_self); +godot_string GDAPI godot_string_percent_encode(const godot_string *p_self); + +godot_bool GDAPI godot_string_is_valid_float(const godot_string *p_self); +godot_bool GDAPI godot_string_is_valid_hex_number(const godot_string *p_self, godot_bool p_with_prefix); +godot_bool GDAPI godot_string_is_valid_html_color(const godot_string *p_self); +godot_bool GDAPI godot_string_is_valid_identifier(const godot_string *p_self); +godot_bool GDAPI godot_string_is_valid_integer(const godot_string *p_self); +godot_bool GDAPI godot_string_is_valid_ip_address(const godot_string *p_self); + +void GDAPI godot_string_destroy(godot_string *p_self); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_STRING_H diff --git a/modules/gdnative/include/gdnative/transform.h b/modules/gdnative/include/gdnative/transform.h new file mode 100644 index 0000000000..656afae129 --- /dev/null +++ b/modules/gdnative/include/gdnative/transform.h @@ -0,0 +1,100 @@ +/*************************************************************************/ +/* transform.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_TRANSFORM_H +#define GODOT_TRANSFORM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define GODOT_TRANSFORM_SIZE 48 + +#ifndef GODOT_CORE_API_GODOT_TRANSFORM_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_TRANSFORM_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_TRANSFORM_SIZE]; +} godot_transform; +#endif + +#include +#include +#include +#include + +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); +void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin); + +godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self); +void GDAPI godot_transform_set_basis(godot_transform *p_self, godot_basis *p_v); + +godot_vector3 GDAPI godot_transform_get_origin(const godot_transform *p_self); +void GDAPI godot_transform_set_origin(godot_transform *p_self, godot_vector3 *p_v); + +godot_string GDAPI godot_transform_as_string(const godot_transform *p_self); + +godot_transform GDAPI godot_transform_inverse(const godot_transform *p_self); + +godot_transform GDAPI godot_transform_affine_inverse(const godot_transform *p_self); + +godot_transform GDAPI godot_transform_orthonormalized(const godot_transform *p_self); + +godot_transform GDAPI godot_transform_rotated(const godot_transform *p_self, const godot_vector3 *p_axis, const godot_real p_phi); + +godot_transform GDAPI godot_transform_scaled(const godot_transform *p_self, const godot_vector3 *p_scale); + +godot_transform GDAPI godot_transform_translated(const godot_transform *p_self, const godot_vector3 *p_ofs); + +godot_transform GDAPI godot_transform_looking_at(const godot_transform *p_self, const godot_vector3 *p_target, const godot_vector3 *p_up); + +godot_plane GDAPI godot_transform_xform_plane(const godot_transform *p_self, const godot_plane *p_v); + +godot_plane GDAPI godot_transform_xform_inv_plane(const godot_transform *p_self, const godot_plane *p_v); + +void GDAPI godot_transform_new_identity(godot_transform *r_dest); + +godot_bool GDAPI godot_transform_operator_equal(const godot_transform *p_self, const godot_transform *p_b); + +godot_transform GDAPI godot_transform_operator_multiply(const godot_transform *p_self, const godot_transform *p_b); + +godot_vector3 GDAPI godot_transform_xform_vector3(const godot_transform *p_self, const godot_vector3 *p_v); + +godot_vector3 GDAPI godot_transform_xform_inv_vector3(const godot_transform *p_self, const godot_vector3 *p_v); + +godot_rect3 GDAPI godot_transform_xform_rect3(const godot_transform *p_self, const godot_rect3 *p_v); + +godot_rect3 GDAPI godot_transform_xform_inv_rect3(const godot_transform *p_self, const godot_rect3 *p_v); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_TRANSFORM_H diff --git a/modules/gdnative/include/gdnative/transform2d.h b/modules/gdnative/include/gdnative/transform2d.h new file mode 100644 index 0000000000..a945868b17 --- /dev/null +++ b/modules/gdnative/include/gdnative/transform2d.h @@ -0,0 +1,99 @@ +/*************************************************************************/ +/* transform2d.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_TRANSFORM2D_H +#define GODOT_TRANSFORM2D_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define GODOT_TRANSFORM2D_SIZE 24 + +#ifndef GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_TRANSFORM2D_SIZE]; +} godot_transform2d; +#endif + +#include +#include +#include + +void GDAPI godot_transform2d_new(godot_transform2d *r_dest, const godot_real p_rot, const godot_vector2 *p_pos); +void GDAPI godot_transform2d_new_axis_origin(godot_transform2d *r_dest, const godot_vector2 *p_x_axis, const godot_vector2 *p_y_axis, const godot_vector2 *p_origin); + +godot_string GDAPI godot_transform2d_as_string(const godot_transform2d *p_self); + +godot_transform2d GDAPI godot_transform2d_inverse(const godot_transform2d *p_self); + +godot_transform2d GDAPI godot_transform2d_affine_inverse(const godot_transform2d *p_self); + +godot_real GDAPI godot_transform2d_get_rotation(const godot_transform2d *p_self); + +godot_vector2 GDAPI godot_transform2d_get_origin(const godot_transform2d *p_self); + +godot_vector2 GDAPI godot_transform2d_get_scale(const godot_transform2d *p_self); + +godot_transform2d GDAPI godot_transform2d_orthonormalized(const godot_transform2d *p_self); + +godot_transform2d GDAPI godot_transform2d_rotated(const godot_transform2d *p_self, const godot_real p_phi); + +godot_transform2d GDAPI godot_transform2d_scaled(const godot_transform2d *p_self, const godot_vector2 *p_scale); + +godot_transform2d GDAPI godot_transform2d_translated(const godot_transform2d *p_self, const godot_vector2 *p_offset); + +godot_vector2 GDAPI godot_transform2d_xform_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v); + +godot_vector2 GDAPI godot_transform2d_xform_inv_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v); + +godot_vector2 GDAPI godot_transform2d_basis_xform_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v); + +godot_vector2 GDAPI godot_transform2d_basis_xform_inv_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v); + +godot_transform2d GDAPI godot_transform2d_interpolate_with(const godot_transform2d *p_self, const godot_transform2d *p_m, const godot_real p_c); + +godot_bool GDAPI godot_transform2d_operator_equal(const godot_transform2d *p_self, const godot_transform2d *p_b); + +godot_transform2d GDAPI godot_transform2d_operator_multiply(const godot_transform2d *p_self, const godot_transform2d *p_b); + +void GDAPI godot_transform2d_new_identity(godot_transform2d *r_dest); + +godot_rect2 GDAPI godot_transform2d_xform_rect2(const godot_transform2d *p_self, const godot_rect2 *p_v); + +godot_rect2 GDAPI godot_transform2d_xform_inv_rect2(const godot_transform2d *p_self, const godot_rect2 *p_v); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_TRANSFORM2D_H diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h new file mode 100644 index 0000000000..969506585d --- /dev/null +++ b/modules/gdnative/include/gdnative/variant.h @@ -0,0 +1,201 @@ +/*************************************************************************/ +/* variant.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_VARIANT_H +#define GODOT_VARIANT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define GODOT_VARIANT_SIZE (16 + sizeof(void *)) + +#ifndef GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_VARIANT_SIZE]; +} godot_variant; +#endif + +typedef enum godot_variant_type { + GODOT_VARIANT_TYPE_NIL, + + // atomic types + GODOT_VARIANT_TYPE_BOOL, + GODOT_VARIANT_TYPE_INT, + GODOT_VARIANT_TYPE_REAL, + GODOT_VARIANT_TYPE_STRING, + + // math types + + GODOT_VARIANT_TYPE_VECTOR2, // 5 + GODOT_VARIANT_TYPE_RECT2, + GODOT_VARIANT_TYPE_VECTOR3, + GODOT_VARIANT_TYPE_TRANSFORM2D, + GODOT_VARIANT_TYPE_PLANE, + GODOT_VARIANT_TYPE_QUAT, // 10 + GODOT_VARIANT_TYPE_RECT3, + GODOT_VARIANT_TYPE_BASIS, + GODOT_VARIANT_TYPE_TRANSFORM, + + // misc types + GODOT_VARIANT_TYPE_COLOR, + GODOT_VARIANT_TYPE_NODE_PATH, // 15 + GODOT_VARIANT_TYPE_RID, + GODOT_VARIANT_TYPE_OBJECT, + GODOT_VARIANT_TYPE_DICTIONARY, + GODOT_VARIANT_TYPE_ARRAY, // 20 + + // arrays + GODOT_VARIANT_TYPE_POOL_BYTE_ARRAY, + GODOT_VARIANT_TYPE_POOL_INT_ARRAY, + GODOT_VARIANT_TYPE_POOL_REAL_ARRAY, + GODOT_VARIANT_TYPE_POOL_STRING_ARRAY, + GODOT_VARIANT_TYPE_POOL_VECTOR2_ARRAY, // 25 + GODOT_VARIANT_TYPE_POOL_VECTOR3_ARRAY, + GODOT_VARIANT_TYPE_POOL_COLOR_ARRAY, +} godot_variant_type; + +typedef enum godot_variant_call_error_error { + GODOT_CALL_ERROR_CALL_OK, + GODOT_CALL_ERROR_CALL_ERROR_INVALID_METHOD, + GODOT_CALL_ERROR_CALL_ERROR_INVALID_ARGUMENT, + GODOT_CALL_ERROR_CALL_ERROR_TOO_MANY_ARGUMENTS, + GODOT_CALL_ERROR_CALL_ERROR_TOO_FEW_ARGUMENTS, + GODOT_CALL_ERROR_CALL_ERROR_INSTANCE_IS_NULL, +} godot_variant_call_error_error; + +typedef struct godot_variant_call_error { + godot_variant_call_error_error error; + int argument; + godot_variant_type expected; +} godot_variant_call_error; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_v); + +void GDAPI godot_variant_new_copy(godot_variant *r_dest, const godot_variant *p_src); + +void GDAPI godot_variant_new_nil(godot_variant *r_dest); + +void GDAPI godot_variant_new_bool(godot_variant *p_v, const godot_bool p_b); +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_vector2(godot_variant *r_dest, const godot_vector2 *p_v2); +void GDAPI godot_variant_new_rect2(godot_variant *r_dest, const godot_rect2 *p_rect2); +void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3 *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); +void GDAPI godot_variant_new_rect3(godot_variant *r_dest, const godot_rect3 *p_rect3); +void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis); +void GDAPI godot_variant_new_transform(godot_variant *r_dest, const godot_transform *p_trans); +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_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_pool_byte_array(godot_variant *r_dest, const godot_pool_byte_array *p_pba); +void GDAPI godot_variant_new_pool_int_array(godot_variant *r_dest, const godot_pool_int_array *p_pia); +void GDAPI godot_variant_new_pool_real_array(godot_variant *r_dest, const godot_pool_real_array *p_pra); +void GDAPI godot_variant_new_pool_string_array(godot_variant *r_dest, const godot_pool_string_array *p_psa); +void GDAPI godot_variant_new_pool_vector2_array(godot_variant *r_dest, const godot_pool_vector2_array *p_pv2a); +void GDAPI godot_variant_new_pool_vector3_array(godot_variant *r_dest, const godot_pool_vector3_array *p_pv3a); +void GDAPI godot_variant_new_pool_color_array(godot_variant *r_dest, const godot_pool_color_array *p_pca); + +godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_self); +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_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_self); +godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_self); +godot_vector3 GDAPI godot_variant_as_vector3(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); +godot_rect3 GDAPI godot_variant_as_rect3(const godot_variant *p_self); +godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_self); +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_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_pool_byte_array GDAPI godot_variant_as_pool_byte_array(const godot_variant *p_self); +godot_pool_int_array GDAPI godot_variant_as_pool_int_array(const godot_variant *p_self); +godot_pool_real_array GDAPI godot_variant_as_pool_real_array(const godot_variant *p_self); +godot_pool_string_array GDAPI godot_variant_as_pool_string_array(const godot_variant *p_self); +godot_pool_vector2_array GDAPI godot_variant_as_pool_vector2_array(const godot_variant *p_self); +godot_pool_vector3_array GDAPI godot_variant_as_pool_vector3_array(const godot_variant *p_self); +godot_pool_color_array GDAPI godot_variant_as_pool_color_array(const godot_variant *p_self); + +godot_variant GDAPI godot_variant_call(godot_variant *p_self, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant_call_error *r_error); + +godot_bool GDAPI godot_variant_has_method(const godot_variant *p_self, const godot_string *p_method); + +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); + +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, godot_bool *r_valid); + +void GDAPI godot_variant_destroy(godot_variant *p_self); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/modules/gdnative/include/gdnative/vector2.h b/modules/gdnative/include/gdnative/vector2.h new file mode 100644 index 0000000000..0af4abae27 --- /dev/null +++ b/modules/gdnative/include/gdnative/vector2.h @@ -0,0 +1,128 @@ +/*************************************************************************/ +/* vector2.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_VECTOR2_H +#define GODOT_VECTOR2_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define GODOT_VECTOR2_SIZE 8 + +#ifndef GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_VECTOR2_SIZE]; +} godot_vector2; +#endif + +#include + +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_vector2 GDAPI godot_vector2_normalized(const godot_vector2 *p_self); + +godot_real GDAPI godot_vector2_length(const godot_vector2 *p_self); + +godot_real GDAPI godot_vector2_angle(const godot_vector2 *p_self); + +godot_real GDAPI godot_vector2_length_squared(const godot_vector2 *p_self); + +godot_bool GDAPI godot_vector2_is_normalized(const godot_vector2 *p_self); + +godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_self, const godot_vector2 *p_to); + +godot_real GDAPI godot_vector2_distance_squared_to(const godot_vector2 *p_self, const godot_vector2 *p_to); + +godot_real GDAPI godot_vector2_angle_to(const godot_vector2 *p_self, const godot_vector2 *p_to); + +godot_real GDAPI godot_vector2_angle_to_point(const godot_vector2 *p_self, const godot_vector2 *p_to); + +godot_vector2 GDAPI godot_vector2_linear_interpolate(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_real p_t); + +godot_vector2 GDAPI godot_vector2_cubic_interpolate(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_vector2 *p_pre_a, const godot_vector2 *p_post_b, const godot_real p_t); + +godot_vector2 GDAPI godot_vector2_rotated(const godot_vector2 *p_self, const godot_real p_phi); + +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_snapped(const godot_vector2 *p_self, const godot_vector2 *p_by); + +godot_real GDAPI godot_vector2_aspect(const godot_vector2 *p_self); + +godot_real GDAPI godot_vector2_dot(const godot_vector2 *p_self, const godot_vector2 *p_with); + +godot_vector2 GDAPI godot_vector2_slide(const godot_vector2 *p_self, const godot_vector2 *p_n); + +godot_vector2 GDAPI godot_vector2_bounce(const godot_vector2 *p_self, const godot_vector2 *p_n); + +godot_vector2 GDAPI godot_vector2_reflect(const godot_vector2 *p_self, const godot_vector2 *p_n); + +godot_vector2 GDAPI godot_vector2_abs(const godot_vector2 *p_self); + +godot_vector2 GDAPI godot_vector2_clamped(const godot_vector2 *p_self, const godot_real p_length); + +godot_vector2 GDAPI godot_vector2_operator_add(const godot_vector2 *p_self, const godot_vector2 *p_b); + +godot_vector2 GDAPI godot_vector2_operator_substract(const godot_vector2 *p_self, const godot_vector2 *p_b); + +godot_vector2 GDAPI godot_vector2_operator_multiply_vector(const godot_vector2 *p_self, const godot_vector2 *p_b); + +godot_vector2 GDAPI godot_vector2_operator_multiply_scalar(const godot_vector2 *p_self, const godot_real p_b); + +godot_vector2 GDAPI godot_vector2_operator_divide_vector(const godot_vector2 *p_self, const godot_vector2 *p_b); + +godot_vector2 GDAPI godot_vector2_operator_divide_scalar(const godot_vector2 *p_self, const godot_real p_b); + +godot_bool GDAPI godot_vector2_operator_equal(const godot_vector2 *p_self, const godot_vector2 *p_b); + +godot_bool GDAPI godot_vector2_operator_less(const godot_vector2 *p_self, const godot_vector2 *p_b); + +godot_vector2 GDAPI godot_vector2_operator_neg(const godot_vector2 *p_self); + +void GDAPI godot_vector2_set_x(godot_vector2 *p_self, const godot_real p_x); + +void GDAPI godot_vector2_set_y(godot_vector2 *p_self, const godot_real p_y); + +godot_real GDAPI godot_vector2_get_x(const godot_vector2 *p_self); + +godot_real GDAPI godot_vector2_get_y(const godot_vector2 *p_self); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_VECTOR2_H diff --git a/modules/gdnative/include/gdnative/vector3.h b/modules/gdnative/include/gdnative/vector3.h new file mode 100644 index 0000000000..a27d516ec5 --- /dev/null +++ b/modules/gdnative/include/gdnative/vector3.h @@ -0,0 +1,135 @@ +/*************************************************************************/ +/* vector3.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_VECTOR3_H +#define GODOT_VECTOR3_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define GODOT_VECTOR3_SIZE 12 + +#ifndef GODOT_CORE_API_GODOT_VECTOR3_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_VECTOR3_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_VECTOR3_SIZE]; +} godot_vector3; +#endif + +#include +#include + +typedef enum { + GODOT_VECTOR3_AXIS_X, + GODOT_VECTOR3_AXIS_Y, + GODOT_VECTOR3_AXIS_Z, +} godot_vector3_axis; + +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_int GDAPI godot_vector3_min_axis(const godot_vector3 *p_self); + +godot_int GDAPI godot_vector3_max_axis(const godot_vector3 *p_self); + +godot_real GDAPI godot_vector3_length(const godot_vector3 *p_self); + +godot_real GDAPI godot_vector3_length_squared(const godot_vector3 *p_self); + +godot_bool GDAPI godot_vector3_is_normalized(const godot_vector3 *p_self); + +godot_vector3 GDAPI godot_vector3_normalized(const godot_vector3 *p_self); + +godot_vector3 GDAPI godot_vector3_inverse(const godot_vector3 *p_self); + +godot_vector3 GDAPI godot_vector3_snapped(const godot_vector3 *p_self, const godot_vector3 *p_by); + +godot_vector3 GDAPI godot_vector3_rotated(const godot_vector3 *p_self, const godot_vector3 *p_axis, const godot_real p_phi); + +godot_vector3 GDAPI godot_vector3_linear_interpolate(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_real p_t); + +godot_vector3 GDAPI godot_vector3_cubic_interpolate(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_vector3 *p_pre_a, const godot_vector3 *p_post_b, const godot_real p_t); + +godot_real GDAPI godot_vector3_dot(const godot_vector3 *p_self, const godot_vector3 *p_b); + +godot_vector3 GDAPI godot_vector3_cross(const godot_vector3 *p_self, const godot_vector3 *p_b); + +godot_basis GDAPI godot_vector3_outer(const godot_vector3 *p_self, const godot_vector3 *p_b); + +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_floor(const godot_vector3 *p_self); + +godot_vector3 GDAPI godot_vector3_ceil(const godot_vector3 *p_self); + +godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_self, const godot_vector3 *p_b); + +godot_real GDAPI godot_vector3_distance_squared_to(const godot_vector3 *p_self, const godot_vector3 *p_b); + +godot_real GDAPI godot_vector3_angle_to(const godot_vector3 *p_self, const godot_vector3 *p_to); + +godot_vector3 GDAPI godot_vector3_slide(const godot_vector3 *p_self, const godot_vector3 *p_n); + +godot_vector3 GDAPI godot_vector3_bounce(const godot_vector3 *p_self, const godot_vector3 *p_n); + +godot_vector3 GDAPI godot_vector3_reflect(const godot_vector3 *p_self, const godot_vector3 *p_n); + +godot_vector3 GDAPI godot_vector3_operator_add(const godot_vector3 *p_self, const godot_vector3 *p_b); + +godot_vector3 GDAPI godot_vector3_operator_substract(const godot_vector3 *p_self, const godot_vector3 *p_b); + +godot_vector3 GDAPI godot_vector3_operator_multiply_vector(const godot_vector3 *p_self, const godot_vector3 *p_b); + +godot_vector3 GDAPI godot_vector3_operator_multiply_scalar(const godot_vector3 *p_self, const godot_real p_b); + +godot_vector3 GDAPI godot_vector3_operator_divide_vector(const godot_vector3 *p_self, const godot_vector3 *p_b); + +godot_vector3 GDAPI godot_vector3_operator_divide_scalar(const godot_vector3 *p_self, const godot_real p_b); + +godot_bool GDAPI godot_vector3_operator_equal(const godot_vector3 *p_self, const godot_vector3 *p_b); + +godot_bool GDAPI godot_vector3_operator_less(const godot_vector3 *p_self, const godot_vector3 *p_b); + +godot_vector3 GDAPI godot_vector3_operator_neg(const godot_vector3 *p_self); + +void GDAPI godot_vector3_set_axis(godot_vector3 *p_self, const godot_vector3_axis p_axis, const godot_real p_val); + +godot_real GDAPI godot_vector3_get_axis(const godot_vector3 *p_self, const godot_vector3_axis p_axis); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_VECTOR3_H diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h new file mode 100644 index 0000000000..96f213ead7 --- /dev/null +++ b/modules/gdnative/include/nativescript/godot_nativescript.h @@ -0,0 +1,227 @@ +/*************************************************************************/ +/* godot_nativescript.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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_NATIVESCRIPT_H +#define GODOT_NATIVESCRIPT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef GDAPI_BUILT_IN +#define GDAPI_EXPORT +#endif + +#ifdef _WIN32 +#if defined(GDAPI_EXPORT) +#define GDCALLINGCONV +#define GDAPI __declspec(dllexport) GDCALLINGCONV +#else +#define GDCALLINGCONV +#define GDAPI __declspec(dllimport) GDCALLINGCONV +#endif +#elif defined(__APPLE__) +#include "TargetConditionals.h" +#if TARGET_OS_IPHONE +#define GDCALLINGCONV +#define GDAPI +#elif TARGET_OS_MAC +#define GDCALLINGCONV __attribute__((sysv_abi)) +#define GDAPI GDCALLINGCONV +#endif +#else +#define GDCALLINGCONV __attribute__((sysv_abi, visibility("default"))) +#define GDAPI GDCALLINGCONV +#endif + +// This is for libraries *using* the header, NOT GODOT EXPOSING STUFF!! +#ifdef _WIN32 +#define GDN_EXPORT __declspec(dllexport) +#else +#define GDN_EXPORT +#endif + +#include +#include + +typedef enum { + GODOT_METHOD_RPC_MODE_DISABLED, + GODOT_METHOD_RPC_MODE_REMOTE, + GODOT_METHOD_RPC_MODE_SYNC, + GODOT_METHOD_RPC_MODE_MASTER, + GODOT_METHOD_RPC_MODE_SLAVE, +} godot_method_rpc_mode; + +typedef enum { + GODOT_PROPERTY_HINT_NONE, ///< no hint provided. + GODOT_PROPERTY_HINT_RANGE, ///< hint_text = "min,max,step,slider; //slider is optional" + GODOT_PROPERTY_HINT_EXP_RANGE, ///< hint_text = "min,max,step", exponential edit + GODOT_PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc" + GODOT_PROPERTY_HINT_EXP_EASING, /// exponential easing funciton (Math::ease) + GODOT_PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer) + GODOT_PROPERTY_HINT_SPRITE_FRAME, + GODOT_PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer) + GODOT_PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags) + GODOT_PROPERTY_HINT_LAYERS_2D_RENDER, + GODOT_PROPERTY_HINT_LAYERS_2D_PHYSICS, + GODOT_PROPERTY_HINT_LAYERS_3D_RENDER, + GODOT_PROPERTY_HINT_LAYERS_3D_PHYSICS, + GODOT_PROPERTY_HINT_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc," + GODOT_PROPERTY_HINT_DIR, ///< a directort path must be passed + GODOT_PROPERTY_HINT_GLOBAL_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc," + GODOT_PROPERTY_HINT_GLOBAL_DIR, ///< a directort path must be passed + GODOT_PROPERTY_HINT_RESOURCE_TYPE, ///< a resource object type + GODOT_PROPERTY_HINT_MULTILINE_TEXT, ///< used for string properties that can contain multiple lines + GODOT_PROPERTY_HINT_COLOR_NO_ALPHA, ///< used for ignoring alpha component when editing a color + GODOT_PROPERTY_HINT_IMAGE_COMPRESS_LOSSY, + GODOT_PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS, + GODOT_PROPERTY_HINT_OBJECT_ID, + GODOT_PROPERTY_HINT_TYPE_STRING, ///< a type string, the hint is the base type to choose + GODOT_PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE, ///< so something else can provide this (used in scripts) + GODOT_PROPERTY_HINT_METHOD_OF_VARIANT_TYPE, ///< a method of a type + GODOT_PROPERTY_HINT_METHOD_OF_BASE_TYPE, ///< a method of a base type + GODOT_PROPERTY_HINT_METHOD_OF_INSTANCE, ///< a method of an instance + GODOT_PROPERTY_HINT_METHOD_OF_SCRIPT, ///< a method of a script & base + GODOT_PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE, ///< a property of a type + GODOT_PROPERTY_HINT_PROPERTY_OF_BASE_TYPE, ///< a property of a base type + GODOT_PROPERTY_HINT_PROPERTY_OF_INSTANCE, ///< a property of an instance + GODOT_PROPERTY_HINT_PROPERTY_OF_SCRIPT, ///< a property of a script & base + GODOT_PROPERTY_HINT_MAX, +} godot_property_hint; + +typedef enum { + + GODOT_PROPERTY_USAGE_STORAGE = 1, + GODOT_PROPERTY_USAGE_EDITOR = 2, + GODOT_PROPERTY_USAGE_NETWORK = 4, + GODOT_PROPERTY_USAGE_EDITOR_HELPER = 8, + GODOT_PROPERTY_USAGE_CHECKABLE = 16, //used for editing global variables + GODOT_PROPERTY_USAGE_CHECKED = 32, //used for editing global variables + GODOT_PROPERTY_USAGE_INTERNATIONALIZED = 64, //hint for internationalized strings + GODOT_PROPERTY_USAGE_GROUP = 128, //used for grouping props in the editor + GODOT_PROPERTY_USAGE_CATEGORY = 256, + GODOT_PROPERTY_USAGE_STORE_IF_NONZERO = 512, //only store if nonzero + GODOT_PROPERTY_USAGE_STORE_IF_NONONE = 1024, //only store if false + GODOT_PROPERTY_USAGE_NO_INSTANCE_STATE = 2048, + GODOT_PROPERTY_USAGE_RESTART_IF_CHANGED = 4096, + GODOT_PROPERTY_USAGE_SCRIPT_VARIABLE = 8192, + GODOT_PROPERTY_USAGE_STORE_IF_NULL = 16384, + GODOT_PROPERTY_USAGE_ANIMATE_AS_TRIGGER = 32768, + GODOT_PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED = 65536, + + GODOT_PROPERTY_USAGE_DEFAULT = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_EDITOR | GODOT_PROPERTY_USAGE_NETWORK, + GODOT_PROPERTY_USAGE_DEFAULT_INTL = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_EDITOR | GODOT_PROPERTY_USAGE_NETWORK | GODOT_PROPERTY_USAGE_INTERNATIONALIZED, + GODOT_PROPERTY_USAGE_NOEDITOR = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_NETWORK, +} godot_property_usage_flags; + +typedef struct { + godot_method_rpc_mode rset_type; + + godot_int type; + godot_property_hint hint; + godot_string hint_string; + godot_property_usage_flags usage; + godot_variant default_value; +} godot_property_attributes; + +typedef struct { + // instance pointer, method_data - return user data + GDCALLINGCONV void *(*create_func)(godot_object *, void *); + void *method_data; + GDCALLINGCONV void (*free_func)(void *); +} godot_instance_create_func; + +typedef struct { + // instance pointer, method data, user data + GDCALLINGCONV void (*destroy_func)(godot_object *, void *, void *); + void *method_data; + GDCALLINGCONV void (*free_func)(void *); +} godot_instance_destroy_func; + +void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func); + +void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func); + +typedef struct { + godot_method_rpc_mode rpc_type; +} godot_method_attributes; + +typedef struct { + // instance pointer, method data, user data, num args, args - return result as varaint + GDCALLINGCONV godot_variant (*method)(godot_object *, void *, void *, int, godot_variant **); + void *method_data; + GDCALLINGCONV void (*free_func)(void *); +} godot_instance_method; + +void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method); + +typedef struct { + // instance pointer, method data, user data, value + GDCALLINGCONV void (*set_func)(godot_object *, void *, void *, godot_variant *); + void *method_data; + GDCALLINGCONV void (*free_func)(void *); +} godot_property_set_func; + +typedef struct { + // instance pointer, method data, user data, value + GDCALLINGCONV godot_variant (*get_func)(godot_object *, void *, void *); + void *method_data; + GDCALLINGCONV void (*free_func)(void *); +} godot_property_get_func; + +void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_property_attributes *p_attr, godot_property_set_func p_set_func, godot_property_get_func p_get_func); + +typedef struct { + godot_string name; + godot_int type; + godot_property_hint hint; + godot_string hint_string; + godot_property_usage_flags usage; + godot_variant default_value; +} godot_signal_argument; + +typedef struct { + godot_string name; + int num_args; + godot_signal_argument *args; + int num_default_args; + godot_variant *default_args; +} godot_signal; + +void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_signal *p_signal); + +void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/modules/gdnative/nativescript/SCsub b/modules/gdnative/nativescript/SCsub new file mode 100644 index 0000000000..e980e40e8e --- /dev/null +++ b/modules/gdnative/nativescript/SCsub @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +Import('env') + +mod_env = env.Clone() +mod_env.add_source_files(env.modules_sources, "*.cpp") +mod_env.Append(CPPPATH='#modules/gdnative') +mod_env.Append(CPPFLAGS=['-DGDAPI_BUILT_IN']) + +Export('mod_env') diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp new file mode 100644 index 0000000000..fdd5a2ea19 --- /dev/null +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -0,0 +1,487 @@ +/*************************************************************************/ +/* api_generator.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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 "api_generator.h" + +#ifdef TOOLS_ENABLED + +#include "class_db.h" +#include "core/global_constants.h" +#include "core/pair.h" +#include "core/project_settings.h" +#include "os/file_access.h" + +// helper stuff + +static Error save_file(const String &p_path, const List &p_content) { + + FileAccessRef file = FileAccess::open(p_path, FileAccess::WRITE); + + ERR_FAIL_COND_V(!file, ERR_FILE_CANT_WRITE); + + for (const List::Element *e = p_content.front(); e != NULL; e = e->next()) { + file->store_string(e->get()); + } + + file->close(); + + return OK; +} + +// helper stuff end + +struct MethodAPI { + String method_name; + String return_type; + + List argument_types; + List argument_names; + + Map default_arguments; + + int argument_count; + bool has_varargs; + bool is_editor; + bool is_noscript; + bool is_const; + bool is_reverse; + bool is_virtual; + bool is_from_script; +}; + +struct PropertyAPI { + String name; + String getter; + String setter; + String type; +}; + +struct ConstantAPI { + String constant_name; + int constant_value; +}; + +struct SignalAPI { + String name; + List argument_types; + List argument_names; + Map default_arguments; +}; + +struct EnumAPI { + String name; + List > values; +}; + +struct ClassAPI { + String class_name; + String super_class_name; + + ClassDB::APIType api_type; + + bool is_singleton; + bool is_instanciable; + // @Unclear + bool is_creatable; + bool is_reference; + + List methods; + List properties; + List constants; + List signals_; + List enums; +}; + +static String get_type_name(const PropertyInfo &info) { + if (info.type == Variant::INT && (info.usage & PROPERTY_USAGE_CLASS_IS_ENUM)) { + return String("enum.") + String(info.class_name).replace(".", "::"); + } + if (info.class_name != StringName()) { + return info.class_name; + } + if (info.hint == PROPERTY_HINT_RESOURCE_TYPE) { + return info.hint_string; + } + if (info.type == Variant::NIL && (info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) { + return "Variant"; + } + if (info.type == Variant::NIL) { + return "void"; + } + return Variant::get_type_name(info.type); +} + +/* + * Reads the entire Godot API to a list + */ +List generate_c_api_classes() { + + List api; + + List classes; + ClassDB::get_class_list(&classes); + + // Register global constants as a fake GlobalConstants singleton class + { + ClassAPI global_constants_api; + global_constants_api.class_name = L"GlobalConstants"; + global_constants_api.api_type = ClassDB::API_CORE; + global_constants_api.is_singleton = true; + global_constants_api.is_instanciable = false; + const int constants_count = GlobalConstants::get_global_constant_count(); + for (int i = 0; i < constants_count; ++i) { + ConstantAPI constant_api; + constant_api.constant_name = GlobalConstants::get_global_constant_name(i); + constant_api.constant_value = GlobalConstants::get_global_constant_value(i); + global_constants_api.constants.push_back(constant_api); + } + api.push_back(global_constants_api); + } + + for (List::Element *e = classes.front(); e != NULL; e = e->next()) { + StringName class_name = e->get(); + + ClassAPI class_api; + class_api.api_type = ClassDB::get_api_type(e->get()); + class_api.class_name = class_name; + class_api.super_class_name = ClassDB::get_parent_class(class_name); + { + String name = class_name; + if (name.begins_with("_")) { + name.remove(0); + } + class_api.is_singleton = ProjectSettings::get_singleton()->has_singleton(name); + } + class_api.is_instanciable = !class_api.is_singleton && ClassDB::can_instance(class_name); + + { + List inheriters; + ClassDB::get_inheriters_from_class("Reference", &inheriters); + bool is_reference = !!inheriters.find(class_name); + // @Unclear + class_api.is_reference = !class_api.is_singleton && is_reference; + } + + // constants + { + List constant; + ClassDB::get_integer_constant_list(class_name, &constant, true); + for (List::Element *c = constant.front(); c != NULL; c = c->next()) { + ConstantAPI constant_api; + constant_api.constant_name = c->get(); + constant_api.constant_value = ClassDB::get_integer_constant(class_name, c->get()); + + class_api.constants.push_back(constant_api); + } + } + + // signals + { + List signals_; + ClassDB::get_signal_list(class_name, &signals_, true); + + for (int i = 0; i < signals_.size(); i++) { + SignalAPI signal; + + MethodInfo method_info = signals_[i]; + signal.name = method_info.name; + + for (int j = 0; j < method_info.arguments.size(); j++) { + PropertyInfo argument = method_info.arguments[j]; + String type; + String name = argument.name; + + if (argument.name.find(":") != -1) { + type = argument.name.get_slice(":", 1); + name = argument.name.get_slice(":", 0); + } else { + type = get_type_name(argument); + } + + signal.argument_names.push_back(name); + signal.argument_types.push_back(type); + } + + Vector default_arguments = method_info.default_arguments; + + int default_start = signal.argument_names.size() - default_arguments.size(); + + for (int j = 0; j < default_arguments.size(); j++) { + signal.default_arguments[default_start + j] = default_arguments[j]; + } + + class_api.signals_.push_back(signal); + } + } + + //properties + { + List properties; + ClassDB::get_property_list(class_name, &properties, true); + + for (List::Element *p = properties.front(); p != NULL; p = p->next()) { + PropertyAPI property_api; + + property_api.name = p->get().name; + property_api.getter = ClassDB::get_property_getter(class_name, p->get().name); + property_api.setter = ClassDB::get_property_setter(class_name, p->get().name); + + if (p->get().name.find(":") != -1) { + property_api.type = p->get().name.get_slice(":", 1); + property_api.name = p->get().name.get_slice(":", 0); + } else { + property_api.type = get_type_name(p->get()); + } + + if (!property_api.setter.empty() || !property_api.getter.empty()) { + class_api.properties.push_back(property_api); + } + } + } + + //methods + { + List methods; + ClassDB::get_method_list(class_name, &methods, true); + + for (List::Element *m = methods.front(); m != NULL; m = m->next()) { + MethodAPI method_api; + MethodBind *method_bind = ClassDB::get_method(class_name, m->get().name); + MethodInfo &method_info = m->get(); + + //method name + method_api.method_name = m->get().name; + //method return type + if (method_api.method_name.find(":") != -1) { + method_api.return_type = method_api.method_name.get_slice(":", 1); + method_api.method_name = method_api.method_name.get_slice(":", 0); + } else { + method_api.return_type = get_type_name(m->get().return_val); + } + + method_api.argument_count = method_info.arguments.size(); + method_api.has_varargs = method_bind && method_bind->is_vararg(); + + // Method flags + if (method_info.flags) { + const uint32_t flags = method_info.flags; + method_api.is_editor = flags & METHOD_FLAG_EDITOR; + method_api.is_noscript = flags & METHOD_FLAG_NOSCRIPT; + method_api.is_const = flags & METHOD_FLAG_CONST; + method_api.is_reverse = flags & METHOD_FLAG_REVERSE; + method_api.is_virtual = flags & METHOD_FLAG_VIRTUAL; + method_api.is_from_script = flags & METHOD_FLAG_FROM_SCRIPT; + } + + method_api.is_virtual = method_api.is_virtual || method_api.method_name[0] == '_'; + + // method argument name and type + + for (int i = 0; i < method_api.argument_count; i++) { + String arg_name; + String arg_type; + PropertyInfo arg_info = method_info.arguments[i]; + + arg_name = arg_info.name; + + if (arg_info.name.find(":") != -1) { + arg_type = arg_info.name.get_slice(":", 1); + arg_name = arg_info.name.get_slice(":", 0); + } else if (arg_info.hint == PROPERTY_HINT_RESOURCE_TYPE) { + arg_type = arg_info.hint_string; + } else if (arg_info.type == Variant::NIL) { + arg_type = "Variant"; + } else { + arg_type = Variant::get_type_name(arg_info.type); + } + + method_api.argument_names.push_back(arg_name); + method_api.argument_types.push_back(arg_type); + + if (method_bind && method_bind->has_default_argument(i)) { + method_api.default_arguments[i] = method_bind->get_default_argument(i); + } + } + + class_api.methods.push_back(method_api); + } + } + + // enums + { + List enums; + List enum_names; + ClassDB::get_enum_list(class_name, &enum_names, true); + for (List::Element *E = enum_names.front(); E; E = E->next()) { + List value_names; + EnumAPI enum_api; + enum_api.name = E->get(); + ClassDB::get_enum_constants(class_name, E->get(), &value_names, true); + for (List::Element *val_e = value_names.front(); val_e; val_e = val_e->next()) { + int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), NULL); + enum_api.values.push_back(Pair(int_val, val_e->get())); + } + enum_api.values.sort_custom >(); + class_api.enums.push_back(enum_api); + } + } + + api.push_back(class_api); + } + + return api; +} + +/* + * Generates the JSON source from the API in p_api + */ +static List generate_c_api_json(const List &p_api) { + + // I'm sorry for the \t mess + + List source; + + source.push_back("[\n"); + + for (const List::Element *c = p_api.front(); c != NULL; c = c->next()) { + ClassAPI api = c->get(); + + source.push_back("\t{\n"); + + source.push_back("\t\t\"name\": \"" + api.class_name + "\",\n"); + source.push_back("\t\t\"base_class\": \"" + api.super_class_name + "\",\n"); + source.push_back(String("\t\t\"api_type\": \"") + (api.api_type == ClassDB::API_CORE ? "core" : (api.api_type == ClassDB::API_EDITOR ? "tools" : "none")) + "\",\n"); + source.push_back(String("\t\t\"singleton\": ") + (api.is_singleton ? "true" : "false") + ",\n"); + source.push_back(String("\t\t\"instanciable\": ") + (api.is_instanciable ? "true" : "false") + ",\n"); + source.push_back(String("\t\t\"is_reference\": ") + (api.is_reference ? "true" : "false") + ",\n"); + // @Unclear + // source.push_back(String("\t\t\"createable\": ") + (api.is_creatable ? "true" : "false") + ",\n"); + + source.push_back("\t\t\"constants\": {\n"); + for (List::Element *e = api.constants.front(); e; e = e->next()) { + source.push_back("\t\t\t\"" + e->get().constant_name + "\": " + String::num_int64(e->get().constant_value) + (e->next() ? "," : "") + "\n"); + } + source.push_back("\t\t},\n"); + + source.push_back("\t\t\"properties\": [\n"); + for (List::Element *e = api.properties.front(); e; e = e->next()) { + source.push_back("\t\t\t{\n"); + source.push_back("\t\t\t\t\"name\": \"" + e->get().name + "\",\n"); + source.push_back("\t\t\t\t\"type\": \"" + e->get().type + "\",\n"); + source.push_back("\t\t\t\t\"getter\": \"" + e->get().getter + "\",\n"); + source.push_back("\t\t\t\t\"setter\": \"" + e->get().setter + "\"\n"); + source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n"); + } + source.push_back("\t\t],\n"); + + source.push_back("\t\t\"signals\": [\n"); + for (List::Element *e = api.signals_.front(); e; e = e->next()) { + source.push_back("\t\t\t{\n"); + source.push_back("\t\t\t\t\"name\": \"" + e->get().name + "\",\n"); + source.push_back("\t\t\t\t\"arguments\": [\n"); + for (int i = 0; i < e->get().argument_names.size(); i++) { + source.push_back("\t\t\t\t\t{\n"); + source.push_back("\t\t\t\t\t\t\"name\": \"" + e->get().argument_names[i] + "\",\n"); + source.push_back("\t\t\t\t\t\t\"type\": \"" + e->get().argument_types[i] + "\",\n"); + source.push_back("\t\t\t\t\t\t\"default_value\": \"" + (e->get().default_arguments.has(i) ? (String)e->get().default_arguments[i] : "") + "\"\n"); + source.push_back(String("\t\t\t\t\t}") + ((i < e->get().argument_names.size() - 1) ? "," : "") + "\n"); + } + source.push_back("\t\t\t\t]\n"); + source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n"); + } + source.push_back("\t\t],\n"); + + source.push_back("\t\t\"methods\": [\n"); + for (List::Element *e = api.methods.front(); e; e = e->next()) { + source.push_back("\t\t\t{\n"); + source.push_back("\t\t\t\t\"name\": \"" + e->get().method_name + "\",\n"); + source.push_back("\t\t\t\t\"return_type\": \"" + e->get().return_type + "\",\n"); + source.push_back(String("\t\t\t\t\"is_editor\": ") + (e->get().is_editor ? "true" : "false") + ",\n"); + source.push_back(String("\t\t\t\t\"is_noscript\": ") + (e->get().is_noscript ? "true" : "false") + ",\n"); + source.push_back(String("\t\t\t\t\"is_const\": ") + (e->get().is_const ? "true" : "false") + ",\n"); + source.push_back(String("\t\t\t\t\"is_reverse\": ") + (e->get().is_reverse ? "true" : "false") + ",\n"); + source.push_back(String("\t\t\t\t\"is_virtual\": ") + (e->get().is_virtual ? "true" : "false") + ",\n"); + source.push_back(String("\t\t\t\t\"has_varargs\": ") + (e->get().has_varargs ? "true" : "false") + ",\n"); + source.push_back(String("\t\t\t\t\"is_from_script\": ") + (e->get().is_from_script ? "true" : "false") + ",\n"); + source.push_back("\t\t\t\t\"arguments\": [\n"); + for (int i = 0; i < e->get().argument_names.size(); i++) { + source.push_back("\t\t\t\t\t{\n"); + source.push_back("\t\t\t\t\t\t\"name\": \"" + e->get().argument_names[i] + "\",\n"); + source.push_back("\t\t\t\t\t\t\"type\": \"" + e->get().argument_types[i] + "\",\n"); + source.push_back(String("\t\t\t\t\t\t\"has_default_value\": ") + (e->get().default_arguments.has(i) ? "true" : "false") + ",\n"); + source.push_back("\t\t\t\t\t\t\"default_value\": \"" + (e->get().default_arguments.has(i) ? (String)e->get().default_arguments[i] : "") + "\"\n"); + source.push_back(String("\t\t\t\t\t}") + ((i < e->get().argument_names.size() - 1) ? "," : "") + "\n"); + } + source.push_back("\t\t\t\t]\n"); + source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n"); + } + source.push_back("\t\t],\n"); + + source.push_back("\t\t\"enums\": [\n"); + for (List::Element *e = api.enums.front(); e; e = e->next()) { + source.push_back("\t\t\t{\n"); + source.push_back("\t\t\t\t\"name\": \"" + e->get().name + "\",\n"); + source.push_back("\t\t\t\t\"values\": {\n"); + for (List >::Element *val_e = e->get().values.front(); val_e; val_e = val_e->next()) { + source.push_back("\t\t\t\t\t\"" + val_e->get().second + "\": " + itos(val_e->get().first)); + source.push_back(String((val_e->next() ? "," : "")) + "\n"); + } + source.push_back("\t\t\t\t}\n"); + source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n"); + } + source.push_back("\t\t]\n"); + + source.push_back(String("\t}") + (c->next() ? "," : "") + "\n"); + } + source.push_back("]"); + + return source; +} + +// + +#endif + +/* + * Saves the whole Godot API to a JSON file located at + * p_path + */ +Error generate_c_api(const String &p_path) { + +#ifndef TOOLS_ENABLED + return ERR_BUG; +#else + + List api = generate_c_api_classes(); + + List json_source = generate_c_api_json(api); + + return save_file(p_path, json_source); +#endif +} diff --git a/modules/gdnative/nativescript/api_generator.h b/modules/gdnative/nativescript/api_generator.h new file mode 100644 index 0000000000..56c2d786e6 --- /dev/null +++ b/modules/gdnative/nativescript/api_generator.h @@ -0,0 +1,38 @@ +/*************************************************************************/ +/* api_generator.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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 API_GENERATOR_H +#define API_GENERATOR_H + +#include "core/ustring.h" +#include "typedefs.h" + +Error generate_c_api(const String &p_path); + +#endif // API_GENERATOR_H diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp new file mode 100644 index 0000000000..61ac13b796 --- /dev/null +++ b/modules/gdnative/nativescript/godot_nativescript.cpp @@ -0,0 +1,205 @@ +/*************************************************************************/ +/* godot_nativescript.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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 "nativescript/godot_nativescript.h" + +#include "class_db.h" +#include "error_macros.h" +#include "gdnative/gdnative.h" +#include "global_constants.h" +#include "project_settings.h" +#include "variant.h" + +#include "nativescript.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern "C" void _native_script_hook() { +} + +#define NSL NativeScriptLanguage::get_singleton() + +// Script API + +void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) { + + String *s = (String *)p_gdnative_handle; + + Map *classes = &NSL->library_classes[*s]; + + NativeScriptDesc desc; + + desc.create_func = p_create_func; + desc.destroy_func = p_destroy_func; + desc.is_tool = false; + + desc.base = p_base; + + if (classes->has(p_base)) { + desc.base_data = &(*classes)[p_base]; + desc.base_native_type = desc.base_data->base_native_type; + } else { + desc.base_data = NULL; + desc.base_native_type = p_base; + } + + classes->insert(p_name, desc); +} + +void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) { + + String *s = (String *)p_gdnative_handle; + + Map *classes = &NSL->library_classes[*s]; + + NativeScriptDesc desc; + + desc.create_func = p_create_func; + desc.destroy_func = p_destroy_func; + desc.is_tool = true; + desc.base = p_base; + + if (classes->has(p_base)) { + desc.base_data = &(*classes)[p_base]; + desc.base_native_type = desc.base_data->base_native_type; + } else { + desc.base_data = NULL; + desc.base_native_type = p_base; + } + + classes->insert(p_name, desc); +} + +void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method) { + + String *s = (String *)p_gdnative_handle; + + Map::Element *E = NSL->library_classes[*s].find(p_name); + + if (!E) { + ERR_EXPLAIN("Attempt to register method on non-existant class!"); + ERR_FAIL(); + } + + NativeScriptDesc::Method method; + method.method = p_method; + method.rpc_mode = p_attr.rpc_type; + method.info = MethodInfo(p_function_name); + + E->get().methods.insert(p_function_name, method); +} + +void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_property_attributes *p_attr, godot_property_set_func p_set_func, godot_property_get_func p_get_func) { + + String *s = (String *)p_gdnative_handle; + + Map::Element *E = NSL->library_classes[*s].find(p_name); + + if (!E) { + ERR_EXPLAIN("Attempt to register method on non-existant class!"); + ERR_FAIL(); + } + + NativeScriptDesc::Property property; + property.default_value = *(Variant *)&p_attr->default_value; + property.getter = p_get_func; + property.rset_mode = p_attr->rset_type; + property.setter = p_set_func; + property.info = PropertyInfo((Variant::Type)p_attr->type, + p_path, + (PropertyHint)p_attr->hint, + *(String *)&p_attr->hint_string, + (PropertyUsageFlags)p_attr->usage); + + 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) { + + String *s = (String *)p_gdnative_handle; + + Map::Element *E = NSL->library_classes[*s].find(p_name); + + if (!E) { + ERR_EXPLAIN("Attempt to register method on non-existant class!"); + ERR_FAIL(); + } + + List args; + Vector default_args; + + for (int i = 0; i < p_signal->num_args; i++) { + PropertyInfo info; + + godot_signal_argument arg = p_signal->args[i]; + + info.hint = (PropertyHint)arg.hint; + info.hint_string = *(String *)&arg.hint_string; + info.name = *(String *)&arg.name; + info.type = (Variant::Type)arg.type; + info.usage = (PropertyUsageFlags)arg.usage; + + args.push_back(info); + } + + for (int i = 0; i < p_signal->num_default_args; i++) { + Variant *v; + godot_signal_argument attrib = p_signal->args[i]; + + v = (Variant *)&attrib.default_value; + + default_args.push_back(*v); + } + + MethodInfo method_info; + method_info.name = *(String *)&p_signal->name; + method_info.arguments = args; + method_info.default_arguments = default_args; + + NativeScriptDesc::Signal signal; + signal.signal = method_info; + + E->get().signals_.insert(*(String *)&p_signal->name, signal); +} + +void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance) { + Object *instance = (Object *)p_instance; + if (!instance) + return NULL; + if (instance->get_script_instance() && instance->get_script_instance()->get_language() == NativeScriptLanguage::get_singleton()) { + return ((NativeScriptInstance *)instance->get_script_instance())->userdata; + } + return NULL; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp new file mode 100644 index 0000000000..724b8390da --- /dev/null +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -0,0 +1,1215 @@ +/*************************************************************************/ +/* nativescript.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 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 "nativescript.h" + +#include "gdnative/gdnative.h" + +#include "global_constants.h" +#include "io/file_access_encrypted.h" +#include "os/file_access.h" +#include "os/os.h" +#include "project_settings.h" + +#include "scene/main/scene_tree.h" +#include "scene/resources/scene_format_text.h" + +#ifndef NO_THREADS +#include "os/thread.h" +#endif + +#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED) +#include "api_generator.h" +#endif + +#ifdef TOOLS_ENABLED +#include "editor/editor_node.h" +#endif + +////// Script stuff + +void NativeScript::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_class_name", "class_name"), &NativeScript::set_class_name); + ClassDB::bind_method(D_METHOD("get_class_name"), &NativeScript::get_class_name); + + ClassDB::bind_method(D_METHOD("set_library", "library"), &NativeScript::set_library); + ClassDB::bind_method(D_METHOD("get_library"), &NativeScript::get_library); + + ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "class_name"), "set_class_name", "get_class_name"); + ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library"); + + ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &NativeScript::_new, MethodInfo(Variant::OBJECT, "new")); +} + +#define NSL NativeScriptLanguage::get_singleton() + +#ifdef TOOLS_ENABLED + +void NativeScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) { + NativeScriptDesc *script_data = get_script_desc(); + + ERR_FAIL_COND(!script_data); + + List info; + get_script_property_list(&info); + Map values; + for (List::Element *E = info.front(); E; E = E->next()) { + Variant value; + get_property_default_value(E->get().name, value); + values[E->get().name] = value; + } + + p_placeholder->update(info, values); +} + +void NativeScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) { + placeholders.erase(p_placeholder); +} + +#endif + +void NativeScript::set_class_name(String p_class_name) { + class_name = p_class_name; +} + +String NativeScript::get_class_name() const { + return class_name; +} + +void NativeScript::set_library(Ref p_library) { + if (!library.is_null()) { + WARN_PRINT("library on NativeScript already set. Do nothing."); + return; + } + library = p_library; + lib_path = library->get_active_library_path(); + +#ifndef NO_THREADS + if (Thread::get_caller_id() != Thread::get_main_id()) { + NSL->defer_init_library(p_library, this); + } else +#endif + { + NSL->init_library(p_library); + NSL->register_script(this); + } +} + +Ref NativeScript::get_library() const { + return library; +} + +bool NativeScript::can_instance() const { + + NativeScriptDesc *script_data = get_script_desc(); + +#ifdef TOOLS_ENABLED + + return script_data || (!is_tool() && !ScriptServer::is_scripting_enabled()); +#else + return script_data; +#endif +} + +// TODO(karroffel): implement this +Ref