diff options
Diffstat (limited to 'modules/dlscript/godot')
38 files changed, 4051 insertions, 0 deletions
diff --git a/modules/dlscript/godot/godot_array.cpp b/modules/dlscript/godot/godot_array.cpp new file mode 100644 index 0000000000..21ad97ca78 --- /dev/null +++ b/modules/dlscript/godot/godot_array.cpp @@ -0,0 +1,271 @@ +#include "godot_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 *p_arr) { + Array *a = (Array *)p_arr; + memnew_placement(a, Array); +} + +void GDAPI godot_array_new_pool_color_array(godot_array *p_arr, const godot_pool_color_array *p_pca) { + Array *a = (Array *)p_arr; + PoolVector<Color> *pca = (PoolVector<Color> *)p_pca; + memnew_placement(a, Array); + a->resize(pca->size()); + + for (size_t i = 0; i < a->size(); i++) { + Variant v = pca->operator[](i); + a->operator[](i) = v; + } +} + +void GDAPI godot_array_new_pool_vector3_array(godot_array *p_arr, const godot_pool_vector3_array *p_pv3a) { + Array *a = (Array *)p_arr; + PoolVector<Vector3> *pca = (PoolVector<Vector3> *)p_pv3a; + memnew_placement(a, Array); + a->resize(pca->size()); + + for (size_t i = 0; i < a->size(); i++) { + Variant v = pca->operator[](i); + a->operator[](i) = v; + } +} + +void GDAPI godot_array_new_pool_vector2_array(godot_array *p_arr, const godot_pool_vector2_array *p_pv2a) { + Array *a = (Array *)p_arr; + PoolVector<Vector2> *pca = (PoolVector<Vector2> *)p_pv2a; + memnew_placement(a, Array); + a->resize(pca->size()); + + for (size_t i = 0; i < a->size(); i++) { + Variant v = pca->operator[](i); + a->operator[](i) = v; + } +} + +void GDAPI godot_array_new_pool_string_array(godot_array *p_arr, const godot_pool_string_array *p_psa) { + Array *a = (Array *)p_arr; + PoolVector<String> *pca = (PoolVector<String> *)p_psa; + memnew_placement(a, Array); + a->resize(pca->size()); + + for (size_t i = 0; i < a->size(); i++) { + Variant v = pca->operator[](i); + a->operator[](i) = v; + } +} + +void GDAPI godot_array_new_pool_real_array(godot_array *p_arr, const godot_pool_real_array *p_pra) { + Array *a = (Array *)p_arr; + PoolVector<godot_real> *pca = (PoolVector<godot_real> *)p_pra; + memnew_placement(a, Array); + a->resize(pca->size()); + + for (size_t i = 0; i < a->size(); i++) { + Variant v = pca->operator[](i); + a->operator[](i) = v; + } +} + +void GDAPI godot_array_new_pool_int_array(godot_array *p_arr, const godot_pool_int_array *p_pia) { + Array *a = (Array *)p_arr; + PoolVector<godot_int> *pca = (PoolVector<godot_int> *)p_pia; + memnew_placement(a, Array); + a->resize(pca->size()); + + for (size_t i = 0; i < a->size(); i++) { + Variant v = pca->operator[](i); + a->operator[](i) = v; + } +} + +void GDAPI godot_array_new_pool_byte_array(godot_array *p_arr, const godot_pool_byte_array *p_pba) { + Array *a = (Array *)p_arr; + PoolVector<uint8_t> *pca = (PoolVector<uint8_t> *)p_pba; + memnew_placement(a, Array); + a->resize(pca->size()); + + for (size_t i = 0; i < a->size(); i++) { + Variant v = pca->operator[](i); + a->operator[](i) = v; + } +} + +void GDAPI godot_array_set(godot_array *p_arr, const godot_int p_idx, const godot_variant *p_value) { + Array *a = (Array *)p_arr; + Variant *val = (Variant *)p_value; + a->operator[](p_idx) = *val; +} + +godot_variant GDAPI *godot_array_get(godot_array *p_arr, const godot_int p_idx) { + Array *a = (Array *)p_arr; + return (godot_variant *)&a->operator[](p_idx); +} + +void GDAPI godot_array_append(godot_array *p_arr, const godot_variant *p_value) { + Array *a = (Array *)p_arr; + Variant *val = (Variant *)p_value; + a->append(*val); +} + +void GDAPI godot_array_clear(godot_array *p_arr) { + Array *a = (Array *)p_arr; + a->clear(); +} + +godot_int GDAPI godot_array_count(godot_array *p_arr, const godot_variant *p_value) { + Array *a = (Array *)p_arr; + Variant *val = (Variant *)p_value; + return a->count(*val); +} + +godot_bool GDAPI godot_array_empty(const godot_array *p_arr) { + Array *a = (Array *)p_arr; + return a->empty(); +} + +void GDAPI godot_array_erase(godot_array *p_arr, const godot_variant *p_value) { + Array *a = (Array *)p_arr; + Variant *val = (Variant *)p_value; + a->erase(*val); +} + +godot_variant GDAPI godot_array_front(const godot_array *p_arr) { + Array *a = (Array *)p_arr; + godot_variant v; + Variant *val = (Variant *)&v; + memnew_placement(val, Variant); + *val = a->front(); + return v; +} + +godot_variant GDAPI godot_array_back(const godot_array *p_arr) { + Array *a = (Array *)p_arr; + godot_variant v; + Variant *val = (Variant *)&v; + memnew_placement(val, Variant); + *val = a->back(); + return v; +} + +godot_int GDAPI godot_array_find(const godot_array *p_arr, const godot_variant *p_what, const godot_int p_from) { + Array *a = (Array *)p_arr; + Variant *val = (Variant *)p_what; + return a->find(*val, p_from); +} + +godot_int GDAPI godot_array_find_last(const godot_array *p_arr, const godot_variant *p_what) { + Array *a = (Array *)p_arr; + Variant *val = (Variant *)p_what; + return a->find_last(*val); +} + +godot_bool GDAPI godot_array_has(const godot_array *p_arr, const godot_variant *p_value) { + Array *a = (Array *)p_arr; + Variant *val = (Variant *)p_value; + return a->has(*val); +} + +uint32_t GDAPI godot_array_hash(const godot_array *p_arr) { + Array *a = (Array *)p_arr; + return a->hash(); +} + +void GDAPI godot_array_insert(godot_array *p_arr, const godot_int p_pos, const godot_variant *p_value) { + Array *a = (Array *)p_arr; + Variant *val = (Variant *)p_value; + a->insert(p_pos, *val); +} + +void GDAPI godot_array_invert(godot_array *p_arr) { + Array *a = (Array *)p_arr; + a->invert(); +} + +godot_bool GDAPI godot_array_is_shared(const godot_array *p_arr) { + Array *a = (Array *)p_arr; + return false; // @Todo how do I do it? +} + +godot_variant GDAPI godot_array_pop_back(godot_array *p_arr) { + Array *a = (Array *)p_arr; + godot_variant v; + Variant *val = (Variant *)&v; + memnew_placement(val, Variant); + *val = a->pop_back(); + return v; +} + +godot_variant GDAPI godot_array_pop_front(godot_array *p_arr) { + Array *a = (Array *)p_arr; + godot_variant v; + Variant *val = (Variant *)&v; + memnew_placement(val, Variant); + *val = a->pop_front(); + return v; +} + +void GDAPI godot_array_push_back(godot_array *p_arr, const godot_variant *p_value) { + Array *a = (Array *)p_arr; + Variant *val = (Variant *)p_value; + a->push_back(*val); +} + +void GDAPI godot_array_push_front(godot_array *p_arr, const godot_variant *p_value) { + Array *a = (Array *)p_arr; + Variant *val = (Variant *)p_value; + a->push_front(*val); +} + +void GDAPI godot_array_remove(godot_array *p_arr, const godot_int p_idx) { + Array *a = (Array *)p_arr; + a->remove(p_idx); +} + +void GDAPI godot_array_resize(godot_array *p_arr, const godot_int p_size) { + Array *a = (Array *)p_arr; + a->resize(p_size); +} + +godot_int GDAPI godot_array_rfind(const godot_array *p_arr, const godot_variant *p_what, const godot_int p_from) { + Array *a = (Array *)p_arr; + Variant *val = (Variant *)p_what; + return a->rfind(*val, p_from); +} + +godot_int GDAPI godot_array_size(const godot_array *p_arr) { + Array *a = (Array *)p_arr; + return a->size(); +} + +void GDAPI godot_array_sort(godot_array *p_arr) { + Array *a = (Array *)p_arr; + a->sort(); +} + +void GDAPI godot_array_sort_custom(godot_array *p_arr, godot_object *p_obj, const godot_string *p_func) { + Array *a = (Array *)p_arr; + String *func = (String *)p_func; + a->sort_custom((Object *)p_obj, *func); +} + +void GDAPI godot_array_destroy(godot_array *p_arr) { + ((Array *)p_arr)->~Array(); +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_array.h b/modules/dlscript/godot/godot_array.h new file mode 100644 index 0000000000..544e95a2ed --- /dev/null +++ b/modules/dlscript/godot/godot_array.h @@ -0,0 +1,88 @@ +#ifndef GODOT_DLSCRIPT_ARRAY_H +#define GODOT_DLSCRIPT_ARRAY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_ARRAY_TYPE_DEFINED +typedef struct godot_array { + uint8_t _dont_touch_that[8]; +} godot_array; +#endif + +#include "../godot.h" + +#include "godot_pool_arrays.h" +#include "godot_variant.h" + +void GDAPI godot_array_new(godot_array *p_arr); +void GDAPI godot_array_new_pool_color_array(godot_array *p_arr, const godot_pool_color_array *p_pca); +void GDAPI godot_array_new_pool_vector3_array(godot_array *p_arr, const godot_pool_vector3_array *p_pv3a); +void GDAPI godot_array_new_pool_vector2_array(godot_array *p_arr, const godot_pool_vector2_array *p_pv2a); +void GDAPI godot_array_new_pool_string_array(godot_array *p_arr, const godot_pool_string_array *p_psa); +void GDAPI godot_array_new_pool_real_array(godot_array *p_arr, const godot_pool_real_array *p_pra); +void GDAPI godot_array_new_pool_int_array(godot_array *p_arr, const godot_pool_int_array *p_pia); +void GDAPI godot_array_new_pool_byte_array(godot_array *p_arr, const godot_pool_byte_array *p_pba); + +void GDAPI godot_array_set(godot_array *p_arr, const godot_int p_idx, const godot_variant *p_value); + +godot_variant GDAPI *godot_array_get(godot_array *p_arr, const godot_int p_idx); + +void GDAPI godot_array_append(godot_array *p_arr, const godot_variant *p_value); + +void GDAPI godot_array_clear(godot_array *p_arr); + +godot_int GDAPI godot_array_count(godot_array *p_arr, const godot_variant *p_value); + +godot_bool GDAPI godot_array_empty(const godot_array *p_arr); + +void GDAPI godot_array_erase(godot_array *p_arr, const godot_variant *p_value); + +godot_variant GDAPI godot_array_front(const godot_array *p_arr); + +godot_variant GDAPI godot_array_back(const godot_array *p_arr); + +godot_int GDAPI godot_array_find(const godot_array *p_arr, const godot_variant *p_what, const godot_int p_from); + +godot_int GDAPI godot_array_find_last(const godot_array *p_arr, const godot_variant *p_what); + +godot_bool GDAPI godot_array_has(const godot_array *p_arr, const godot_variant *p_value); + +uint32_t GDAPI godot_array_hash(const godot_array *p_arr); + +void GDAPI godot_array_insert(godot_array *p_arr, const godot_int p_pos, const godot_variant *p_value); + +void GDAPI godot_array_invert(godot_array *p_arr); + +godot_bool GDAPI godot_array_is_shared(const godot_array *p_arr); + +godot_variant GDAPI godot_array_pop_back(godot_array *p_arr); + +godot_variant GDAPI godot_array_pop_front(godot_array *p_arr); + +void GDAPI godot_array_push_back(godot_array *p_arr, const godot_variant *p_value); + +void GDAPI godot_array_push_front(godot_array *p_arr, const godot_variant *p_value); + +void GDAPI godot_array_remove(godot_array *p_arr, const godot_int p_idx); + +void GDAPI godot_array_resize(godot_array *p_arr, const godot_int p_size); + +godot_int GDAPI godot_array_rfind(const godot_array *p_arr, const godot_variant *p_what, const godot_int p_from); + +godot_int GDAPI godot_array_size(const godot_array *p_arr); + +void GDAPI godot_array_sort(godot_array *p_arr); + +void GDAPI godot_array_sort_custom(godot_array *p_arr, godot_object *p_obj, const godot_string *p_func); + +void GDAPI godot_array_destroy(godot_array *p_arr); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DLSCRIPT_ARRAY_H diff --git a/modules/dlscript/godot/godot_basis.cpp b/modules/dlscript/godot/godot_basis.cpp new file mode 100644 index 0000000000..813a531de5 --- /dev/null +++ b/modules/dlscript/godot/godot_basis.cpp @@ -0,0 +1,58 @@ +#include "godot_basis.h" + +#include "math/matrix3.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _basis_api_anchor() { +} + +void GDAPI godot_basis_new(godot_basis *p_basis) { + Basis *basis = (Basis *)p_basis; + *basis = Basis(); +} + +void GDAPI godot_basis_new_with_euler_quat(godot_basis *p_basis, const godot_quat *p_euler) { + Basis *basis = (Basis *)p_basis; + Quat *euler = (Quat *)p_euler; + *basis = Basis(*euler); +} + +void GDAPI godot_basis_new_with_euler(godot_basis *p_basis, const godot_vector3 *p_euler) { + Basis *basis = (Basis *)p_basis; + Vector3 *euler = (Vector3 *)p_euler; + *basis = Basis(*euler); +} + +godot_quat GDAPI godot_basis_as_quat(const godot_basis *p_basis) { + const Basis *basis = (const Basis *)p_basis; + godot_quat quat; + Quat *p_quat = (Quat *)&quat; + *p_quat = basis->operator Quat(); + return quat; +} + +godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_basis) { + const Basis *basis = (const Basis *)p_basis; + godot_vector3 euler; + Vector3 *p_euler = (Vector3 *)&euler; + *p_euler = basis->get_euler(); + return euler; +} + +/* + * p_elements is a pointer to an array of 3 (!!) vector3 + */ +void GDAPI godot_basis_get_elements(godot_basis *p_basis, godot_vector3 *p_elements) { + Basis *basis = (Basis *)p_basis; + Vector3 *elements = (Vector3 *)p_elements; + elements[0] = basis->elements[0]; + elements[1] = basis->elements[1]; + elements[2] = basis->elements[2]; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_basis.h b/modules/dlscript/godot/godot_basis.h new file mode 100644 index 0000000000..43efd65ea2 --- /dev/null +++ b/modules/dlscript/godot/godot_basis.h @@ -0,0 +1,34 @@ +#ifndef GODOT_DLSCRIPT_BASIS_H +#define GODOT_DLSCRIPT_BASIS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_BASIS_TYPE_DEFINED +typedef struct godot_basis { + uint8_t _dont_touch_that[36]; +} godot_basis; +#endif + +#include "../godot.h" + +void GDAPI godot_basis_new(godot_basis *p_basis); +void GDAPI godot_basis_new_with_euler_quat(godot_basis *p_basis, const godot_quat *p_euler); +void GDAPI godot_basis_new_with_euler(godot_basis *p_basis, const godot_vector3 *p_euler); + +godot_quat GDAPI godot_basis_as_quat(const godot_basis *p_basis); +godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_basis); + +/* + * p_elements is a pointer to an array of 3 (!!) vector3 + */ +void GDAPI godot_basis_get_elements(godot_basis *p_basis, godot_vector3 *p_elements); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DLSCRIPT_BASIS_H diff --git a/modules/dlscript/godot/godot_color.cpp b/modules/dlscript/godot/godot_color.cpp new file mode 100644 index 0000000000..7e49565d40 --- /dev/null +++ b/modules/dlscript/godot/godot_color.cpp @@ -0,0 +1,34 @@ +#include "godot_color.h" + +#include "color.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _color_api_anchor() { +} + +void GDAPI godot_color_new(godot_color *p_color) { + Color *color = (Color *)p_color; + *color = Color(); +} + +void GDAPI godot_color_new_rgba(godot_color *p_color, const godot_real r, const godot_real g, const godot_real b, const godot_real a) { + Color *color = (Color *)p_color; + *color = Color(r, g, b, a); +} + +uint32_t GDAPI godot_color_get_32(const godot_color *p_color) { + const Color *color = (const Color *)p_color; + return color->to_32(); +} + +float GDAPI *godot_color_index(godot_color *p_color, const godot_int idx) { + Color *color = (Color *)p_color; + return &color->operator[](idx); +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_color.h b/modules/dlscript/godot/godot_color.h new file mode 100644 index 0000000000..72e16a2c5a --- /dev/null +++ b/modules/dlscript/godot/godot_color.h @@ -0,0 +1,29 @@ +#ifndef GODOT_DLSCRIPT_COLOR_H +#define GODOT_DLSCRIPT_COLOR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_COLOR_TYPE_DEFINED +typedef struct godot_color { + uint8_t _dont_touch_that[16]; +} godot_color; +#endif + +#include "../godot.h" + +void GDAPI godot_color_new(godot_color *p_color); +void GDAPI godot_color_new_rgba(godot_color *p_color, const godot_real r, const godot_real g, const godot_real b, const godot_real a); + +uint32_t GDAPI godot_color_get_32(const godot_color *p_color); + +float GDAPI *godot_color_index(godot_color *p_color, const godot_int idx); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DLSCRIPT_COLOR_H diff --git a/modules/dlscript/godot/godot_dictionary.cpp b/modules/dlscript/godot/godot_dictionary.cpp new file mode 100644 index 0000000000..9147b17307 --- /dev/null +++ b/modules/dlscript/godot/godot_dictionary.cpp @@ -0,0 +1,109 @@ +#include "godot_dictionary.h" + +#include "core/dictionary.h" + +#include "core/os/memory.h" + +#include "core/io/json.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _dictionary_api_anchor() { +} + +void GDAPI godot_dictionary_new(godot_dictionary *p_dict) { + Dictionary *dict = (Dictionary *)p_dict; + memnew_placement(dict, Dictionary); +} + +void GDAPI godot_dictionary_clear(godot_dictionary *p_dict) { + Dictionary *dict = (Dictionary *)p_dict; + dict->clear(); +} + +godot_bool GDAPI godot_dictionary_empty(const godot_dictionary *p_dict) { + const Dictionary *dict = (const Dictionary *)p_dict; + return dict->empty(); +} + +void GDAPI godot_dictionary_erase(godot_dictionary *p_dict, const godot_variant *p_key) { + Dictionary *dict = (Dictionary *)p_dict; + Variant *key = (Variant *)p_key; + dict->erase(*key); +} + +godot_bool GDAPI godot_dictionary_has(const godot_dictionary *p_dict, const godot_variant *p_key) { + const Dictionary *dict = (const Dictionary *)p_dict; + const Variant *key = (const Variant *)p_key; + return dict->has(*key); +} + +godot_bool GDAPI godot_dictionary_has_all(const godot_dictionary *p_dict, const godot_array *p_keys) { + const Dictionary *dict = (const Dictionary *)p_dict; + const Array *keys = (const Array *)p_keys; + return dict->has_all(*keys); +} + +uint32_t GDAPI godot_dictionary_hash(const godot_dictionary *p_dict) { + const Dictionary *dict = (const Dictionary *)p_dict; + return dict->hash(); +} + +godot_array GDAPI godot_dictionary_keys(const godot_dictionary *p_dict) { + godot_array a; + godot_array_new(&a); + const Dictionary *dict = (const Dictionary *)p_dict; + Array *array = (Array *)&a; + *array = dict->keys(); + return a; +} + +godot_int GDAPI godot_dictionary_parse_json(godot_dictionary *p_dict, const godot_string *p_json) { + Dictionary *dict = (Dictionary *)p_dict; + const String *json = (const String *)p_json; + Variant ret; + int err_line; + String err_str; + int err = (int)JSON::parse(*json, ret, err_str, err_line); + *dict = ret; + return err; +} + +godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_dict, const godot_variant *p_key) { + Dictionary *dict = (Dictionary *)p_dict; + Variant *key = (Variant *)p_key; + return (godot_variant *)&dict->operator[](*key); +} + +godot_int GDAPI godot_dictionary_size(const godot_dictionary *p_dict) { + const Dictionary *dict = (const Dictionary *)p_dict; + return dict->size(); +} + +godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_dict) { + const Dictionary *dict = (const Dictionary *)p_dict; + godot_string str; + godot_string_new(&str); + String *s = (String *)&str; + *s = JSON::print(Variant(*dict)); + return str; +} + +godot_array GDAPI godot_dictionary_values(const godot_dictionary *p_dict) { + godot_array a; + godot_array_new(&a); + const Dictionary *dict = (const Dictionary *)p_dict; + Array *array = (Array *)&a; + *array = dict->values(); + return a; +} + +void GDAPI godot_dictionary_destroy(godot_dictionary *p_dict) { + ((Dictionary *)p_dict)->~Dictionary(); +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_dictionary.h b/modules/dlscript/godot/godot_dictionary.h new file mode 100644 index 0000000000..5f86cbca5a --- /dev/null +++ b/modules/dlscript/godot/godot_dictionary.h @@ -0,0 +1,51 @@ +#ifndef GODOT_DLSCRIPT_DICTIONARY_H +#define GODOT_DLSCRIPT_DICTIONARY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_DICITIONARY_TYPE_DEFINED +typedef struct godot_dictionary { + uint8_t _dont_touch_that[8]; +} godot_dictionary; +#endif + +#include "godot_array.h" +#include "godot_variant.h" + +void GDAPI godot_dictionary_new(godot_dictionary *p_dict); + +void GDAPI godot_dictionary_clear(godot_dictionary *p_dict); + +godot_bool GDAPI godot_dictionary_empty(const godot_dictionary *p_dict); + +void GDAPI godot_dictionary_erase(godot_dictionary *p_dict, const godot_variant *p_key); + +godot_bool GDAPI godot_dictionary_has(const godot_dictionary *p_dict, const godot_variant *p_key); + +godot_bool GDAPI godot_dictionary_has_all(const godot_dictionary *p_dict, const godot_array *p_keys); + +uint32_t GDAPI godot_dictionary_hash(const godot_dictionary *p_dict); + +godot_array GDAPI godot_dictionary_keys(const godot_dictionary *p_dict); + +godot_int GDAPI godot_dictionary_parse_json(godot_dictionary *p_dict, const godot_string *p_json); + +godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_dict, const godot_variant *p_key); + +godot_int GDAPI godot_dictionary_size(const godot_dictionary *p_dict); + +godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_dict); + +godot_array GDAPI godot_dictionary_values(const godot_dictionary *p_dict); + +void GDAPI godot_dictionary_destroy(godot_dictionary *p_dict); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DLSCRIPT_DICTIONARY_H diff --git a/modules/dlscript/godot/godot_image.cpp b/modules/dlscript/godot/godot_image.cpp new file mode 100644 index 0000000000..362d1aa3e6 --- /dev/null +++ b/modules/dlscript/godot/godot_image.cpp @@ -0,0 +1,85 @@ +#include "godot_image.h" + +#include "image.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _image_api_anchor() { +} + +#define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr) + +void GDAPI godot_image_new(godot_image *p_img) { + Image *img = (Image *)p_img; + memnew_placement_custom(img, Image, Image()); +} + +void GDAPI godot_image_new_with_png_jpg(godot_image *p_img, const uint8_t *p_mem_png_jpg, int p_len) { + Image *img = (Image *)p_img; + memnew_placement_custom(img, Image, Image(p_mem_png_jpg, p_len)); +} + +void GDAPI godot_image_new_with_xpm(godot_image *p_img, const char **p_xpm) { + Image *img = (Image *)p_img; + memnew_placement_custom(img, Image, Image(p_xpm)); +} + +void GDAPI godot_image_new_with_size_format(godot_image *p_img, int p_width, int p_height, bool p_use_mipmaps, godot_image_format p_format) { + Image *img = (Image *)p_img; + memnew_placement_custom(img, Image, Image(p_width, p_height, p_use_mipmaps, (Image::Format)p_format)); +} + +void GDAPI godot_image_new_with_size_format_data(godot_image *p_img, int p_width, int p_height, bool p_use_mipmaps, godot_image_format p_format, godot_pool_byte_array *p_data) { + Image *img = (Image *)p_img; + PoolVector<uint8_t> *data = (PoolVector<uint8_t> *)p_data; + memnew_placement_custom(img, Image, Image(p_width, p_height, p_use_mipmaps, (Image::Format)p_format, *data)); +} + +godot_pool_byte_array GDAPI godot_image_get_data(godot_image *p_img) { + Image *img = (Image *)p_img; + PoolVector<uint8_t> cpp_data = img->get_data(); + godot_pool_byte_array *data = (godot_pool_byte_array *)&cpp_data; + return *data; +} + +godot_error GDAPI godot_image_load(godot_image *p_img, const godot_string *p_path) { + Image *img = (Image *)p_img; + String *path = (String *)p_path; + return (godot_error)img->load(*path); +} + +godot_error GDAPI godot_image_save_png(godot_image *p_img, const godot_string *p_path) { + Image *img = (Image *)p_img; + String *path = (String *)p_path; + return (godot_error)img->save_png(*path); +} + +int GDAPI godot_image_get_width(const godot_image *p_img) { + Image *img = (Image *)p_img; + return img->get_width(); +} + +int GDAPI godot_image_get_height(const godot_image *p_img) { + Image *img = (Image *)p_img; + return img->get_height(); +} + +godot_bool GDAPI godot_image_has_mipmaps(const godot_image *p_img) { + Image *img = (Image *)p_img; + return img->has_mipmaps(); +} + +int GDAPI godot_image_get_mipmap_count(const godot_image *p_img) { + Image *img = (Image *)p_img; + return img->get_mipmap_count(); +} + +void GDAPI godot_image_destroy(godot_image *p_img) { + ((Image *)p_img)->~Image(); +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_image.h b/modules/dlscript/godot/godot_image.h new file mode 100644 index 0000000000..78593f21a7 --- /dev/null +++ b/modules/dlscript/godot/godot_image.h @@ -0,0 +1,95 @@ +#ifndef GODOT_DLSCRIPT_IMAGE_H +#define GODOT_DLSCRIPT_IMAGE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_IMAGE_TYPE_DEFINED +typedef struct godot_image { + uint8_t _dont_touch_that[32]; +} godot_image; +#endif + +#include "godot_pool_arrays.h" + +#include "../godot.h" + +// This is a copypasta of the C++ enum inside the Image class +// There's no neat way of automatically updating the C enum / using the C++ enum directly +// if somebody knows a way feel free to open a PR or open an issue (or ask for Karroffel or bojidar-bg on IRC) + +enum godot_image_format { + + GODOT_IMAGE_FORMAT_L8, //luminance + GODOT_IMAGE_FORMAT_LA8, //luminance-alpha + GODOT_IMAGE_FORMAT_R8, + GODOT_IMAGE_FORMAT_RG8, + GODOT_IMAGE_FORMAT_RGB8, + GODOT_IMAGE_FORMAT_RGBA8, + GODOT_IMAGE_FORMAT_RGB565, //16 bit + GODOT_IMAGE_FORMAT_RGBA4444, + GODOT_IMAGE_FORMAT_RGBA5551, + GODOT_IMAGE_FORMAT_RF, //float + GODOT_IMAGE_FORMAT_RGF, + GODOT_IMAGE_FORMAT_RGBF, + GODOT_IMAGE_FORMAT_RGBAF, + GODOT_IMAGE_FORMAT_RH, //half float + GODOT_IMAGE_FORMAT_RGH, + GODOT_IMAGE_FORMAT_RGBH, + GODOT_IMAGE_FORMAT_RGBAH, + GODOT_IMAGE_FORMAT_DXT1, //s3tc bc1 + GODOT_IMAGE_FORMAT_DXT3, //bc2 + GODOT_IMAGE_FORMAT_DXT5, //bc3 + GODOT_IMAGE_FORMAT_ATI1, //bc4 + GODOT_IMAGE_FORMAT_ATI2, //bc5 + GODOT_IMAGE_FORMAT_BPTC_RGBA, //btpc bc6h + GODOT_IMAGE_FORMAT_BPTC_RGBF, //float / + GODOT_IMAGE_FORMAT_BPTC_RGBFU, //unsigned float + GODOT_IMAGE_FORMAT_PVRTC2, //pvrtc + GODOT_IMAGE_FORMAT_PVRTC2A, + GODOT_IMAGE_FORMAT_PVRTC4, + GODOT_IMAGE_FORMAT_PVRTC4A, + GODOT_IMAGE_FORMAT_ETC, //etc1 + GODOT_IMAGE_FORMAT_ETC2_R11, //etc2 + GODOT_IMAGE_FORMAT_ETC2_R11S, //signed, NOT srgb. + GODOT_IMAGE_FORMAT_ETC2_RG11, + GODOT_IMAGE_FORMAT_ETC2_RG11S, + GODOT_IMAGE_FORMAT_ETC2_RGB8, + GODOT_IMAGE_FORMAT_ETC2_RGBA8, + GODOT_IMAGE_FORMAT_ETC2_RGB8A1, + GODOT_IMAGE_FORMAT_MAX +}; +typedef enum godot_image_format godot_image_format; + +void GDAPI godot_image_new(godot_image *p_img); +// p_len can be -1 +void GDAPI godot_image_new_with_png_jpg(godot_image *p_img, const uint8_t *p_mem_png_jpg, int p_len); +void GDAPI godot_image_new_with_xpm(godot_image *p_img, const char **p_xpm); + +void GDAPI godot_image_new_with_size_format(godot_image *p_img, int p_width, int p_height, bool p_use_mipmaps, godot_image_format p_format); +void GDAPI godot_image_new_with_size_format_data(godot_image *p_img, int p_width, int p_height, bool p_use_mipmaps, godot_image_format p_format, godot_pool_byte_array *p_data); + +godot_pool_byte_array GDAPI godot_image_get_data(godot_image *p_img); + +godot_error GDAPI godot_image_load(godot_image *p_img, const godot_string *p_path); +godot_error GDAPI godot_image_save_png(godot_image *p_img, const godot_string *p_path); + +int GDAPI godot_image_get_width(const godot_image *p_img); +int GDAPI godot_image_get_height(const godot_image *p_img); +godot_bool GDAPI godot_image_has_mipmaps(const godot_image *p_img); +int GDAPI godot_image_get_mipmap_count(const godot_image *p_img); + +// @Incomplete +// I think it's too complex for the binding authors to implement the image class anew, so we should definitely +// export all methods here. That takes a while so it's on my @Todo list + +void GDAPI godot_image_destroy(godot_image *p_img); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DLSCRIPT_IMAGE_H diff --git a/modules/dlscript/godot/godot_input_event.cpp b/modules/dlscript/godot/godot_input_event.cpp new file mode 100644 index 0000000000..b50ed8a22d --- /dev/null +++ b/modules/dlscript/godot/godot_input_event.cpp @@ -0,0 +1,280 @@ +#include "godot_input_event.h" + +#include "os/input_event.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _input_event_api_anchor() { +} + +void GDAPI godot_input_event_new(godot_input_event *p_ie) { + InputEvent *ie = (InputEvent *)p_ie; + *ie = InputEvent(); +} + +godot_bool GDAPI godot_input_event_is_pressed(const godot_input_event *p_ie) { + const InputEvent *ie = (const InputEvent *)p_ie; + return ie->is_pressed(); +} + +godot_bool GDAPI godot_input_event_is_action(const godot_input_event *p_ie, const godot_string *p_action) { + const InputEvent *ie = (const InputEvent *)p_ie; + const String *action = (const String *)p_action; + return ie->is_action(*action); +} + +godot_bool GDAPI godot_input_event_is_action_pressed(const godot_input_event *p_ie, const godot_string *p_action) { + const InputEvent *ie = (const InputEvent *)p_ie; + const String *action = (const String *)p_action; + return ie->is_action_pressed(*action); +} + +godot_bool GDAPI godot_input_event_is_action_released(const godot_input_event *p_ie, const godot_string *p_action) { + const InputEvent *ie = (const InputEvent *)p_ie; + const String *action = (const String *)p_action; + return ie->is_action_released(*action); +} + +godot_bool GDAPI godot_input_event_is_echo(const godot_input_event *p_ie) { + const InputEvent *ie = (const InputEvent *)p_ie; + return ie->is_echo(); +} + +void GDAPI godot_input_event_set_as_action(godot_input_event *p_ie, const godot_string *p_action, const godot_bool p_pressed) { + InputEvent *ie = (InputEvent *)p_ie; + const String *action = (const String *)p_action; + return ie->set_as_action(*action, p_pressed); +} + +godot_string GDAPI godot_input_event_as_string(const godot_input_event *p_ie) { + const InputEvent *ie = (const InputEvent *)p_ie; + godot_string str; + String *s = (String *)&str; + memnew_placement(s, String); + *s = (String)*ie; + return str; +} + +uint32_t GDAPI *godot_input_event_get_id(godot_input_event *p_ie) { + InputEvent *ie = (InputEvent *)p_ie; + return &ie->ID; +} + +godot_input_event_type GDAPI *godot_input_event_get_type(godot_input_event *p_ie) { + InputEvent *ie = (InputEvent *)p_ie; + return (godot_input_event_type *)&ie->type; +} + +godot_int GDAPI *godot_input_event_get_device(godot_input_event *p_ie) { + InputEvent *ie = (InputEvent *)p_ie; + return &ie->device; +} + +static InputModifierState *_get_mod_for_type(InputEvent *ie) { + switch (ie->type) { + case InputEvent::MOUSE_BUTTON: + return &ie->mouse_button.mod; + case InputEvent::MOUSE_MOTION: + return &ie->mouse_motion.mod; + case InputEvent::KEY: + return &ie->key.mod; + default: + return 0; + } +} + +godot_bool GDAPI *godot_input_event_mod_get_alt(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + InputModifierState *mod = _get_mod_for_type(ie); + return &mod->alt; +} + +godot_bool GDAPI *godot_input_event_mod_get_ctrl(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + InputModifierState *mod = _get_mod_for_type(ie); + return &mod->control; +} + +godot_bool GDAPI *godot_input_event_mod_get_command(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + InputModifierState *mod = _get_mod_for_type(ie); + return &mod->command; +} + +godot_bool GDAPI *godot_input_event_mod_get_shift(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + InputModifierState *mod = _get_mod_for_type(ie); + return &mod->shift; +} + +godot_bool GDAPI *godot_input_event_mod_get_meta(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + InputModifierState *mod = _get_mod_for_type(ie); + return &mod->meta; +} + +uint32_t GDAPI *godot_input_event_key_get_scancode(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->key.scancode; +} + +uint32_t GDAPI *godot_input_event_key_get_unicode(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->key.unicode; +} + +godot_bool GDAPI *godot_input_event_key_get_pressed(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->key.pressed; +} + +godot_bool GDAPI *godot_input_event_key_get_echo(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->key.echo; +} + +float GDAPI *godot_input_event_mouse_get_x(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->mouse_button.x; +} + +float GDAPI *godot_input_event_mouse_get_y(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->mouse_button.y; +} + +float GDAPI *godot_input_event_mouse_get_global_x(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->mouse_button.global_x; +} + +float GDAPI *godot_input_event_mouse_get_global_y(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->mouse_button.global_y; +} + +godot_int GDAPI *godot_input_event_mouse_get_button_mask(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->mouse_button.button_mask; +} + +godot_int GDAPI *godot_input_event_mouse_button_get_button_index(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->mouse_button.button_index; +} + +godot_bool GDAPI *godot_input_event_mouse_button_get_pressed(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->mouse_button.pressed; +} + +godot_bool GDAPI *godot_input_event_mouse_button_get_doubleclick(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->mouse_button.doubleclick; +} + +float GDAPI *godot_input_event_mouse_motion_get_relative_x(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->mouse_motion.relative_x; +} + +float GDAPI *godot_input_event_mouse_motion_get_relative_y(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->mouse_motion.relative_y; +} + +float GDAPI *godot_input_event_mouse_motion_get_speed_x(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->mouse_motion.speed_x; +} + +float GDAPI *godot_input_event_mouse_motion_get_speed_y(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->mouse_motion.speed_y; +} + +godot_int GDAPI *godot_input_event_joypad_motion_get_axis(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->joy_motion.axis; +} + +float GDAPI *godot_input_event_joypad_motion_get_axis_value(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->joy_motion.axis_value; +} + +godot_int GDAPI *godot_input_event_joypad_button_get_button_index(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->joy_button.button_index; +} + +godot_bool GDAPI *godot_input_event_joypad_button_get_pressed(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->joy_button.pressed; +} + +float GDAPI *godot_input_event_joypad_button_get_pressure(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->joy_button.pressure; +} + +godot_int GDAPI *godot_input_event_screen_touch_get_index(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->screen_touch.index; +} + +float GDAPI *godot_input_event_screen_touch_get_x(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->screen_touch.x; +} + +float GDAPI *godot_input_event_screen_touch_get_y(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->screen_touch.y; +} + +godot_bool GDAPI *godot_input_event_screen_touch_get_pressed(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->screen_touch.pressed; +} + +godot_int GDAPI *godot_input_event_screen_drag_get_index(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->screen_drag.index; +} + +float GDAPI *godot_input_event_screen_drag_get_x(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->screen_drag.x; +} + +float GDAPI *godot_input_event_screen_drag_get_y(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->screen_drag.y; +} + +float GDAPI *godot_input_event_screen_drag_get_relative_x(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->screen_drag.relative_x; +} + +float GDAPI *godot_input_event_screen_drag_get_relative_y(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->screen_drag.relative_y; +} + +float GDAPI *godot_input_event_screen_drag_get_speed_x(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->screen_drag.speed_x; +} + +float GDAPI *godot_input_event_screen_drag_get_speed_y(godot_input_event *p_event) { + InputEvent *ie = (InputEvent *)p_event; + return &ie->screen_drag.speed_y; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_input_event.h b/modules/dlscript/godot/godot_input_event.h new file mode 100644 index 0000000000..bfda18bf7c --- /dev/null +++ b/modules/dlscript/godot/godot_input_event.h @@ -0,0 +1,206 @@ +#ifndef GODOT_DLSCRIPT_INPUT_EVENT_H +#define GODOT_DLSCRIPT_INPUT_EVENT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_INPUT_EVENT_TYPE_DEFINED +typedef struct godot_input_event { + uint8_t _dont_touch_that[56]; +} godot_input_event; +#endif + +enum godot_input_event_type { + GODOT_INPUT_EVENT_TYPE_NONE, + GODOT_INPUT_EVENT_TYPE_KEY, + GODOT_INPUT_EVENT_TYPE_MOUSE_MOTION, + GODOT_INPUT_EVENT_TYPE_MOUSE_BUTTON, + GODOT_INPUT_EVENT_TYPE_JOYPAD_MOTION, + GODOT_INPUT_EVENT_TYPE_JOYPAD_BUTTON, + GODOT_INPUT_EVENT_TYPE_SCREEN_TOUCH, + GODOT_INPUT_EVENT_TYPE_SCREEN_DRAG, + GODOT_INPUT_EVENT_TYPE_ACTION, + GODOT_INPUT_EVENT_TYPE_TYPE_MAX +}; +typedef enum godot_input_event_type godot_input_event_type; + +enum { + GODOT_BUTTON_LEFT = 1, + GODOT_BUTTON_RIGHT = 2, + GODOT_BUTTON_MIDDLE = 3, + GODOT_BUTTON_WHEEL_UP = 4, + GODOT_BUTTON_WHEEL_DOWN = 5, + GODOT_BUTTON_WHEEL_LEFT = 6, + GODOT_BUTTON_WHEEL_RIGHT = 7, + GODOT_BUTTON_MASK_LEFT = (1 << (GODOT_BUTTON_LEFT - 1)), + GODOT_BUTTON_MASK_RIGHT = (1 << (GODOT_BUTTON_RIGHT - 1)), + GODOT_BUTTON_MASK_MIDDLE = (1 << (GODOT_BUTTON_MIDDLE - 1)), + +}; + +enum { + + GODOT_JOY_BUTTON_0 = 0, + GODOT_JOY_BUTTON_1 = 1, + GODOT_JOY_BUTTON_2 = 2, + GODOT_JOY_BUTTON_3 = 3, + GODOT_JOY_BUTTON_4 = 4, + GODOT_JOY_BUTTON_5 = 5, + GODOT_JOY_BUTTON_6 = 6, + GODOT_JOY_BUTTON_7 = 7, + GODOT_JOY_BUTTON_8 = 8, + GODOT_JOY_BUTTON_9 = 9, + GODOT_JOY_BUTTON_10 = 10, + GODOT_JOY_BUTTON_11 = 11, + GODOT_JOY_BUTTON_12 = 12, + GODOT_JOY_BUTTON_13 = 13, + GODOT_JOY_BUTTON_14 = 14, + GODOT_JOY_BUTTON_15 = 15, + GODOT_JOY_BUTTON_MAX = 16, + + GODOT_JOY_L = GODOT_JOY_BUTTON_4, + GODOT_JOY_R = GODOT_JOY_BUTTON_5, + GODOT_JOY_L2 = GODOT_JOY_BUTTON_6, + GODOT_JOY_R2 = GODOT_JOY_BUTTON_7, + GODOT_JOY_L3 = GODOT_JOY_BUTTON_8, + GODOT_JOY_R3 = GODOT_JOY_BUTTON_9, + GODOT_JOY_SELECT = GODOT_JOY_BUTTON_10, + GODOT_JOY_START = GODOT_JOY_BUTTON_11, + GODOT_JOY_DPAD_UP = GODOT_JOY_BUTTON_12, + GODOT_JOY_DPAD_DOWN = GODOT_JOY_BUTTON_13, + GODOT_JOY_DPAD_LEFT = GODOT_JOY_BUTTON_14, + GODOT_JOY_DPAD_RIGHT = GODOT_JOY_BUTTON_15, + + // a little history about game controllers (who copied who) + + GODOT_JOY_SNES_B = GODOT_JOY_BUTTON_0, + GODOT_JOY_SNES_A = GODOT_JOY_BUTTON_1, + GODOT_JOY_SNES_Y = GODOT_JOY_BUTTON_2, + GODOT_JOY_SNES_X = GODOT_JOY_BUTTON_3, + + GODOT_JOY_SONY_CIRCLE = GODOT_JOY_SNES_A, + GODOT_JOY_SONY_X = GODOT_JOY_SNES_B, + GODOT_JOY_SONY_SQUARE = GODOT_JOY_SNES_Y, + GODOT_JOY_SONY_TRIANGLE = GODOT_JOY_SNES_X, + + GODOT_JOY_SEGA_B = GODOT_JOY_SNES_A, + GODOT_JOY_SEGA_A = GODOT_JOY_SNES_B, + GODOT_JOY_SEGA_X = GODOT_JOY_SNES_Y, + GODOT_JOY_SEGA_Y = GODOT_JOY_SNES_X, + + GODOT_JOY_XBOX_B = GODOT_JOY_SEGA_B, + GODOT_JOY_XBOX_A = GODOT_JOY_SEGA_A, + GODOT_JOY_XBOX_X = GODOT_JOY_SEGA_X, + GODOT_JOY_XBOX_Y = GODOT_JOY_SEGA_Y, + + GODOT_JOY_DS_A = GODOT_JOY_SNES_A, + GODOT_JOY_DS_B = GODOT_JOY_SNES_B, + GODOT_JOY_DS_X = GODOT_JOY_SNES_X, + GODOT_JOY_DS_Y = GODOT_JOY_SNES_Y, + + GODOT_JOY_WII_C = GODOT_JOY_BUTTON_5, + GODOT_JOY_WII_Z = GODOT_JOY_BUTTON_6, + + GODOT_JOY_WII_MINUS = GODOT_JOY_BUTTON_9, + GODOT_JOY_WII_PLUS = GODOT_JOY_BUTTON_10, + + // end of history + + GODOT_JOY_AXIS_0 = 0, + GODOT_JOY_AXIS_1 = 1, + GODOT_JOY_AXIS_2 = 2, + GODOT_JOY_AXIS_3 = 3, + GODOT_JOY_AXIS_4 = 4, + GODOT_JOY_AXIS_5 = 5, + GODOT_JOY_AXIS_6 = 6, + GODOT_JOY_AXIS_7 = 7, + GODOT_JOY_AXIS_MAX = 8, + + GODOT_JOY_ANALOG_0_X = GODOT_JOY_AXIS_0, + GODOT_JOY_ANALOG_0_Y = GODOT_JOY_AXIS_1, + + GODOT_JOY_ANALOG_1_X = GODOT_JOY_AXIS_2, + GODOT_JOY_ANALOG_1_Y = GODOT_JOY_AXIS_3, + + GODOT_JOY_ANALOG_2_X = GODOT_JOY_AXIS_4, + GODOT_JOY_ANALOG_2_Y = GODOT_JOY_AXIS_5, + + GODOT_JOY_ANALOG_L2 = GODOT_JOY_AXIS_6, + GODOT_JOY_ANALOG_R2 = GODOT_JOY_AXIS_7, +}; + +#include "../godot.h" + +void GDAPI godot_input_event_new(godot_input_event *p_ie); + +godot_bool GDAPI godot_input_event_is_pressed(const godot_input_event *p_ie); +godot_bool GDAPI godot_input_event_is_action(const godot_input_event *p_ie, const godot_string *p_action); +godot_bool GDAPI godot_input_event_is_action_pressed(const godot_input_event *p_ie, const godot_string *p_action); +godot_bool GDAPI godot_input_event_is_action_released(const godot_input_event *p_ie, const godot_string *p_action); +godot_bool GDAPI godot_input_event_is_echo(const godot_input_event *p_ie); +void GDAPI godot_input_event_set_as_action(godot_input_event *p_ie, const godot_string *p_action, const godot_bool p_pressed); + +godot_string GDAPI godot_input_event_as_string(const godot_input_event *p_ie); + +// Note: +// We're returning pointers to the fields in the unions. +// This is because I'm too lazy to write setter functions + +uint32_t GDAPI *godot_input_event_get_id(godot_input_event *p_ie); +godot_input_event_type GDAPI *godot_input_event_get_type(godot_input_event *p_ie); +godot_int GDAPI *godot_input_event_get_device(godot_input_event *p_ie); + +godot_bool GDAPI *godot_input_event_mod_get_alt(godot_input_event *p_event); +godot_bool GDAPI *godot_input_event_mod_get_ctrl(godot_input_event *p_event); +godot_bool GDAPI *godot_input_event_mod_get_command(godot_input_event *p_event); +godot_bool GDAPI *godot_input_event_mod_get_shift(godot_input_event *p_event); +godot_bool GDAPI *godot_input_event_mod_get_meta(godot_input_event *p_event); + +uint32_t GDAPI *godot_input_event_key_get_scancode(godot_input_event *p_event); +uint32_t GDAPI *godot_input_event_key_get_unicode(godot_input_event *p_event); +godot_bool GDAPI *godot_input_event_key_get_pressed(godot_input_event *p_event); +godot_bool GDAPI *godot_input_event_key_get_echo(godot_input_event *p_event); + +float GDAPI *godot_input_event_mouse_get_x(godot_input_event *p_event); +float GDAPI *godot_input_event_mouse_get_y(godot_input_event *p_event); +float GDAPI *godot_input_event_mouse_get_global_x(godot_input_event *p_event); +float GDAPI *godot_input_event_mouse_get_global_y(godot_input_event *p_event); +godot_int GDAPI *godot_input_event_mouse_get_button_mask(godot_input_event *p_event); + +godot_int GDAPI *godot_input_event_mouse_button_get_button_index(godot_input_event *p_event); +godot_bool GDAPI *godot_input_event_mouse_button_get_pressed(godot_input_event *p_event); +godot_bool GDAPI *godot_input_event_mouse_button_get_doubleclick(godot_input_event *p_event); + +float GDAPI *godot_input_event_mouse_motion_get_relative_x(godot_input_event *p_event); +float GDAPI *godot_input_event_mouse_motion_get_relative_y(godot_input_event *p_event); +float GDAPI *godot_input_event_mouse_motion_get_speed_x(godot_input_event *p_event); +float GDAPI *godot_input_event_mouse_motion_get_speed_y(godot_input_event *p_event); + +godot_int GDAPI *godot_input_event_joypad_motion_get_axis(godot_input_event *p_event); +float GDAPI *godot_input_event_joypad_motion_get_axis_value(godot_input_event *p_event); + +godot_int GDAPI *godot_input_event_joypad_button_get_button_index(godot_input_event *p_event); +godot_bool GDAPI *godot_input_event_joypad_button_get_pressed(godot_input_event *p_event); +float GDAPI *godot_input_event_joypad_button_get_pressure(godot_input_event *p_event); + +godot_int GDAPI *godot_input_event_screen_touch_get_index(godot_input_event *p_event); +float GDAPI *godot_input_event_screen_touch_get_x(godot_input_event *p_event); +float GDAPI *godot_input_event_screen_touch_get_y(godot_input_event *p_event); +godot_bool GDAPI *godot_input_event_screen_touch_get_pressed(godot_input_event *p_event); + +godot_int GDAPI *godot_input_event_screen_drag_get_index(godot_input_event *p_event); +float GDAPI *godot_input_event_screen_drag_get_x(godot_input_event *p_event); +float GDAPI *godot_input_event_screen_drag_get_y(godot_input_event *p_event); +float GDAPI *godot_input_event_screen_drag_get_relative_x(godot_input_event *p_event); +float GDAPI *godot_input_event_screen_drag_get_relative_y(godot_input_event *p_event); +float GDAPI *godot_input_event_screen_drag_get_speed_x(godot_input_event *p_event); +float GDAPI *godot_input_event_screen_drag_get_speed_y(godot_input_event *p_event); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DLSCRIPT_INPUT_EVENT_H diff --git a/modules/dlscript/godot/godot_node_path.cpp b/modules/dlscript/godot/godot_node_path.cpp new file mode 100644 index 0000000000..cc0652c75b --- /dev/null +++ b/modules/dlscript/godot/godot_node_path.cpp @@ -0,0 +1,87 @@ +#include "godot_node_path.h" + +#include "path_db.h" + +#include <memory.h> // why is there no <cmemory> btw? + +#ifdef __cplusplus +extern "C" { +#endif + +void _node_path_api_anchor() { +} + +#define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr) + +// @Bug ? +// Do I need to memnew_placement when returning strings? + +void GDAPI godot_node_path_new(godot_node_path *p_np, const godot_string *p_from) { + NodePath *np = (NodePath *)p_np; + String *from = (String *)p_from; + memnew_placement_custom(np, NodePath, NodePath(*from)); +} + +godot_string GDAPI godot_node_path_get_name(const godot_node_path *p_np, const godot_int p_idx) { + const NodePath *np = (const NodePath *)p_np; + godot_string str; + String *s = (String *)&str; + memnew_placement(s, String); + *s = np->get_name(p_idx); + return str; +} + +godot_int GDAPI godot_node_path_get_name_count(const godot_node_path *p_np) { + const NodePath *np = (const NodePath *)p_np; + return np->get_name_count(); +} + +godot_string GDAPI godot_node_path_get_property(const godot_node_path *p_np) { + const NodePath *np = (const NodePath *)p_np; + godot_string str; + String *s = (String *)&str; + memnew_placement(s, String); + *s = np->get_property(); + return str; +} + +godot_string GDAPI godot_node_path_get_subname(const godot_node_path *p_np, const godot_int p_idx) { + const NodePath *np = (const NodePath *)p_np; + godot_string str; + String *s = (String *)&str; + memnew_placement(s, String); + *s = np->get_subname(p_idx); + return str; +} + +godot_int GDAPI godot_node_path_get_subname_count(const godot_node_path *p_np) { + const NodePath *np = (const NodePath *)p_np; + return np->get_subname_count(); +} + +godot_bool GDAPI godot_node_path_is_absolute(const godot_node_path *p_np) { + const NodePath *np = (const NodePath *)p_np; + return np->is_absolute(); +} + +godot_bool GDAPI godot_node_path_is_empty(const godot_node_path *p_np) { + const NodePath *np = (const NodePath *)p_np; + return np->is_empty(); +} + +godot_string GDAPI godot_node_path_as_string(const godot_node_path *p_np) { + const NodePath *np = (const NodePath *)p_np; + godot_string str; + String *s = (String *)&str; + memnew_placement(s, String); + *s = *np; + return str; +} + +void GDAPI godot_node_path_destroy(godot_node_path *p_np) { + ((NodePath *)p_np)->~NodePath(); +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_node_path.h b/modules/dlscript/godot/godot_node_path.h new file mode 100644 index 0000000000..b322e55d83 --- /dev/null +++ b/modules/dlscript/godot/godot_node_path.h @@ -0,0 +1,38 @@ +#ifndef GODOT_DLSCRIPT_NODE_PATH_H +#define GODOT_DLSCRIPT_NODE_PATH_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_NODE_PATH_TYPE_DEFINED +typedef struct godot_node_path { + uint8_t _dont_touch_that[8]; +} godot_node_path; +#endif + +#include "../godot.h" + +void GDAPI godot_node_path_new(godot_node_path *p_np, const godot_string *p_from); + +godot_string GDAPI godot_node_path_get_name(const godot_node_path *p_np, const godot_int p_idx); +godot_int GDAPI godot_node_path_get_name_count(const godot_node_path *p_np); + +godot_string GDAPI godot_node_path_get_property(const godot_node_path *p_np); +godot_string GDAPI godot_node_path_get_subname(const godot_node_path *p_np, const godot_int p_idx); +godot_int GDAPI godot_node_path_get_subname_count(const godot_node_path *p_np); + +godot_bool GDAPI godot_node_path_is_absolute(const godot_node_path *p_np); +godot_bool GDAPI godot_node_path_is_empty(const godot_node_path *p_np); + +godot_string GDAPI godot_node_path_as_string(const godot_node_path *p_np); + +void GDAPI godot_node_path_destroy(godot_node_path *p_np); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DLSCRIPT_NODE_PATH_H diff --git a/modules/dlscript/godot/godot_plane.cpp b/modules/dlscript/godot/godot_plane.cpp new file mode 100644 index 0000000000..883aeb6282 --- /dev/null +++ b/modules/dlscript/godot/godot_plane.cpp @@ -0,0 +1,48 @@ +#include "godot_plane.h" + +#include "math/plane.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _plane_api_anchor() { +} + +void GDAPI godot_plane_new(godot_plane *p_pl) { + Plane *pl = (Plane *)p_pl; + *pl = Plane(); +} + +void GDAPI godot_plane_new_with_normal(godot_plane *p_pl, const godot_vector3 *p_normal, const godot_real p_d) { + Plane *pl = (Plane *)p_pl; + const Vector3 *normal = (const Vector3 *)p_normal; + *pl = Plane(*normal, p_d); +} + +void GDAPI godot_plane_set_normal(godot_plane *p_pl, const godot_vector3 *p_normal) { + Plane *pl = (Plane *)p_pl; + const Vector3 *normal = (const Vector3 *)p_normal; + pl->set_normal(*normal); +} + +godot_vector3 godot_plane_get_normal(const godot_plane *p_pl) { + const Plane *pl = (const Plane *)p_pl; + const Vector3 normal = pl->get_normal(); + godot_vector3 *v3 = (godot_vector3 *)&normal; + return *v3; +} + +void GDAPI godot_plane_set_d(godot_plane *p_pl, const godot_real p_d) { + Plane *pl = (Plane *)p_pl; + pl->d = p_d; +} + +godot_real GDAPI godot_plane_get_d(const godot_plane *p_pl) { + const Plane *pl = (const Plane *)p_pl; + return pl->d; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_plane.h b/modules/dlscript/godot/godot_plane.h new file mode 100644 index 0000000000..1323ef4075 --- /dev/null +++ b/modules/dlscript/godot/godot_plane.h @@ -0,0 +1,37 @@ +#ifndef GODOT_DLSCRIPT_PLANE_H +#define GODOT_DLSCRIPT_PLANE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_PLANE_TYPE_DEFINED +typedef struct godot_plane { + uint8_t _dont_touch_that[16]; +} godot_plane; +#endif + +#include "godot_vector3.h" + +void GDAPI godot_plane_new(godot_plane *p_pl); +void GDAPI godot_plane_new_with_normal(godot_plane *p_pl, const godot_vector3 *p_normal, const godot_real p_d); + +// @Incomplete +// These are additional valid constructors +// _FORCE_INLINE_ Plane(const Vector3 &p_normal, real_t p_d); +// _FORCE_INLINE_ Plane(const Vector3 &p_point, const Vector3& p_normal); +// _FORCE_INLINE_ Plane(const Vector3 &p_point1, const Vector3 &p_point2,const Vector3 &p_point3,ClockDirection p_dir = CLOCKWISE); + +void GDAPI godot_plane_set_normal(godot_plane *p_pl, const godot_vector3 *p_normal); +godot_vector3 GDAPI godot_plane_get_normal(const godot_plane *p_pl); + +godot_real GDAPI godot_plane_get_d(const godot_plane *p_pl); +void GDAPI godot_plane_set_d(godot_plane *p_pl, const godot_real p_d); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DLSCRIPT_PLANE_H diff --git a/modules/dlscript/godot/godot_pool_arrays.cpp b/modules/dlscript/godot/godot_pool_arrays.cpp new file mode 100644 index 0000000000..3fb030f835 --- /dev/null +++ b/modules/dlscript/godot/godot_pool_arrays.cpp @@ -0,0 +1,558 @@ +#include "godot_pool_arrays.h" + +#include "array.h" +#include "dvector.h" +#include "variant.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 *p_pba) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + memnew_placement(pba, PoolVector<uint8_t>); +} + +void GDAPI godot_pool_byte_array_new_with_array(godot_pool_byte_array *p_pba, const godot_array *p_a) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + Array *a = (Array *)p_a; + memnew_placement(pba, PoolVector<uint8_t>); + + pba->resize(a->size()); + for (size_t i = 0; i < a->size(); i++) { + pba->set(i, (*a)[i]); + } +} + +void GDAPI godot_pool_byte_array_append(godot_pool_byte_array *p_pba, const uint8_t p_data) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + pba->append(p_data); +} + +void GDAPI godot_pool_byte_array_append_array(godot_pool_byte_array *p_pba, const godot_pool_byte_array *p_array) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + PoolVector<uint8_t> *array = (PoolVector<uint8_t> *)p_array; + pba->append_array(*array); +} + +int GDAPI godot_pool_byte_array_insert(godot_pool_byte_array *p_pba, const godot_int p_idx, const uint8_t p_data) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + return pba->insert(p_idx, p_data); +} + +void GDAPI godot_pool_byte_array_invert(godot_pool_byte_array *p_pba) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + pba->invert(); +} + +void GDAPI godot_pool_byte_array_push_back(godot_pool_byte_array *p_pba, const uint8_t p_data) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + pba->push_back(p_data); +} + +void GDAPI godot_pool_byte_array_remove(godot_pool_byte_array *p_pba, const godot_int p_idx) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + pba->remove(p_idx); +} + +void GDAPI godot_pool_byte_array_resize(godot_pool_byte_array *p_pba, const godot_int p_size) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + pba->resize(p_size); +} + +void GDAPI godot_pool_byte_array_set(godot_pool_byte_array *p_pba, const godot_int p_idx, const uint8_t p_data) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + pba->set(p_idx, p_data); +} + +uint8_t GDAPI godot_pool_byte_array_get(godot_pool_byte_array *p_pba, const godot_int p_idx) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + return pba->get(p_idx); +} + +godot_int GDAPI godot_pool_byte_array_size(godot_pool_byte_array *p_pba) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + return pba->size(); +} + +void GDAPI godot_pool_byte_array_destroy(godot_pool_byte_array *p_pba) { + ((PoolVector<uint8_t> *)p_pba)->~PoolVector(); +} + +// int + +void GDAPI godot_pool_int_array_new(godot_pool_int_array *p_pba) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + memnew_placement(pba, PoolVector<uint8_t>); +} + +void GDAPI godot_pool_int_array_new_with_array(godot_pool_int_array *p_pba, const godot_array *p_a) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + Array *a = (Array *)p_a; + memnew_placement(pba, PoolVector<uint8_t>); + + pba->resize(a->size()); + for (size_t i = 0; i < a->size(); i++) { + pba->set(i, (*a)[i]); + } +} + +void GDAPI godot_pool_int_array_append(godot_pool_int_array *p_pba, const godot_int p_data) { + PoolVector<godot_int> *pba = (PoolVector<godot_int> *)p_pba; + pba->append(p_data); +} + +void GDAPI godot_pool_int_array_append_array(godot_pool_int_array *p_pba, const godot_pool_int_array *p_array) { + PoolVector<godot_int> *pba = (PoolVector<godot_int> *)p_pba; + PoolVector<godot_int> *array = (PoolVector<godot_int> *)p_array; + pba->append_array(*array); +} + +int GDAPI godot_pool_int_array_insert(godot_pool_int_array *p_pba, const godot_int p_idx, const godot_int p_data) { + PoolVector<godot_int> *pba = (PoolVector<godot_int> *)p_pba; + return pba->insert(p_idx, p_data); +} + +void GDAPI godot_pool_int_array_invert(godot_pool_int_array *p_pba) { + PoolVector<godot_int> *pba = (PoolVector<godot_int> *)p_pba; + pba->invert(); +} + +void GDAPI godot_pool_int_array_push_back(godot_pool_int_array *p_pba, const godot_int p_data) { + PoolVector<godot_int> *pba = (PoolVector<godot_int> *)p_pba; + pba->push_back(p_data); +} + +void GDAPI godot_pool_int_array_remove(godot_pool_int_array *p_pba, const godot_int p_idx) { + PoolVector<godot_int> *pba = (PoolVector<godot_int> *)p_pba; + pba->remove(p_idx); +} + +void GDAPI godot_pool_int_array_resize(godot_pool_int_array *p_pba, const godot_int p_size) { + PoolVector<godot_int> *pba = (PoolVector<godot_int> *)p_pba; + pba->resize(p_size); +} + +void GDAPI godot_pool_int_array_set(godot_pool_int_array *p_pba, const godot_int p_idx, const godot_int p_data) { + PoolVector<godot_int> *pba = (PoolVector<godot_int> *)p_pba; + pba->set(p_idx, p_data); +} + +godot_int GDAPI godot_pool_int_array_get(godot_pool_int_array *p_pba, const godot_int p_idx) { + PoolVector<godot_int> *pba = (PoolVector<godot_int> *)p_pba; + return pba->get(p_idx); +} + +godot_int GDAPI godot_pool_int_array_size(godot_pool_int_array *p_pba) { + PoolVector<godot_int> *pba = (PoolVector<godot_int> *)p_pba; + return pba->size(); +} + +void GDAPI godot_pool_int_array_destroy(godot_pool_int_array *p_pba) { + ((PoolVector<godot_int> *)p_pba)->~PoolVector(); +} + +// real + +void GDAPI godot_pool_real_array_new(godot_pool_real_array *p_pba) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + memnew_placement(pba, PoolVector<uint8_t>); +} + +void GDAPI godot_pool_real_array_new_with_array(godot_pool_real_array *p_pba, const godot_array *p_a) { + PoolVector<uint8_t> *pba = (PoolVector<uint8_t> *)p_pba; + Array *a = (Array *)p_a; + memnew_placement(pba, PoolVector<uint8_t>); + + pba->resize(a->size()); + for (size_t i = 0; i < a->size(); i++) { + pba->set(i, (*a)[i]); + } +} + +void GDAPI godot_pool_real_array_append(godot_pool_real_array *p_pba, const godot_real p_data) { + PoolVector<godot_real> *pba = (PoolVector<godot_real> *)p_pba; + pba->append(p_data); +} + +void GDAPI godot_pool_real_array_append_array(godot_pool_real_array *p_pba, const godot_pool_real_array *p_array) { + PoolVector<godot_real> *pba = (PoolVector<godot_real> *)p_pba; + PoolVector<godot_real> *array = (PoolVector<godot_real> *)p_array; + pba->append_array(*array); +} + +int GDAPI godot_pool_real_array_insert(godot_pool_real_array *p_pba, const godot_int p_idx, const godot_real p_data) { + PoolVector<godot_real> *pba = (PoolVector<godot_real> *)p_pba; + return pba->insert(p_idx, p_data); +} + +void GDAPI godot_pool_real_array_invert(godot_pool_real_array *p_pba) { + PoolVector<godot_real> *pba = (PoolVector<godot_real> *)p_pba; + pba->invert(); +} + +void GDAPI godot_pool_real_array_push_back(godot_pool_real_array *p_pba, const godot_real p_data) { + PoolVector<godot_real> *pba = (PoolVector<godot_real> *)p_pba; + pba->push_back(p_data); +} + +void GDAPI godot_pool_real_array_remove(godot_pool_real_array *p_pba, const godot_int p_idx) { + PoolVector<godot_real> *pba = (PoolVector<godot_real> *)p_pba; + pba->remove(p_idx); +} + +void GDAPI godot_pool_real_array_resize(godot_pool_real_array *p_pba, const godot_int p_size) { + PoolVector<godot_int> *pba = (PoolVector<godot_int> *)p_pba; + pba->resize(p_size); +} + +void GDAPI godot_pool_real_array_set(godot_pool_real_array *p_pba, const godot_int p_idx, const godot_real p_data) { + PoolVector<godot_real> *pba = (PoolVector<godot_real> *)p_pba; + pba->set(p_idx, p_data); +} + +godot_real GDAPI godot_pool_real_array_get(godot_pool_real_array *p_pba, const godot_int p_idx) { + PoolVector<godot_real> *pba = (PoolVector<godot_real> *)p_pba; + return pba->get(p_idx); +} + +godot_int GDAPI godot_pool_real_array_size(godot_pool_real_array *p_pba) { + PoolVector<godot_real> *pba = (PoolVector<godot_real> *)p_pba; + return pba->size(); +} + +void GDAPI godot_pool_real_array_destroy(godot_pool_real_array *p_pba) { + ((PoolVector<godot_real> *)p_pba)->~PoolVector(); +} + +// string + +void GDAPI godot_pool_string_array_new(godot_pool_string_array *p_pba) { + PoolVector<String> *pba = (PoolVector<String> *)p_pba; + memnew_placement(pba, PoolVector<String>); +} + +void GDAPI godot_pool_string_array_new_with_array(godot_pool_string_array *p_pba, const godot_array *p_a) { + PoolVector<String> *pba = (PoolVector<String> *)p_pba; + Array *a = (Array *)p_a; + memnew_placement(pba, PoolVector<String>); + + pba->resize(a->size()); + for (size_t i = 0; i < a->size(); i++) { + pba->set(i, (*a)[i]); + } +} + +void GDAPI godot_pool_string_array_append(godot_pool_string_array *p_pba, const godot_string *p_data) { + PoolVector<String> *pba = (PoolVector<String> *)p_pba; + String &s = *(String *)p_data; + pba->append(s); +} + +void GDAPI godot_pool_string_array_append_array(godot_pool_string_array *p_pba, const godot_pool_string_array *p_array) { + PoolVector<String> *pba = (PoolVector<String> *)p_pba; + PoolVector<String> *array = (PoolVector<String> *)p_array; + pba->append_array(*array); +} + +int GDAPI godot_pool_string_array_insert(godot_pool_string_array *p_pba, const godot_int p_idx, const godot_string *p_data) { + PoolVector<String> *pba = (PoolVector<String> *)p_pba; + String &s = *(String *)p_data; + return pba->insert(p_idx, s); +} + +void GDAPI godot_pool_string_array_invert(godot_pool_string_array *p_pba) { + PoolVector<String> *pba = (PoolVector<String> *)p_pba; + pba->invert(); +} + +void GDAPI godot_pool_string_array_push_back(godot_pool_string_array *p_pba, const godot_string *p_data) { + PoolVector<String> *pba = (PoolVector<String> *)p_pba; + String &s = *(String *)p_data; + pba->push_back(s); +} + +void GDAPI godot_pool_string_array_remove(godot_pool_string_array *p_pba, const godot_int p_idx) { + PoolVector<String> *pba = (PoolVector<String> *)p_pba; + pba->remove(p_idx); +} + +void GDAPI godot_pool_string_array_resize(godot_pool_string_array *p_pba, const godot_int p_size) { + PoolVector<String> *pba = (PoolVector<String> *)p_pba; + pba->resize(p_size); +} + +void GDAPI godot_pool_string_array_set(godot_pool_string_array *p_pba, const godot_int p_idx, const godot_string *p_data) { + PoolVector<String> *pba = (PoolVector<String> *)p_pba; + String &s = *(String *)p_data; + pba->set(p_idx, s); +} + +godot_string GDAPI godot_pool_string_array_get(godot_pool_string_array *p_pba, const godot_int p_idx) { + PoolVector<String> *pba = (PoolVector<String> *)p_pba; + godot_string str; + String *s = (String *)&str; + memnew_placement(s, String); + *s = pba->get(p_idx); + return str; +} + +godot_int GDAPI godot_pool_string_array_size(godot_pool_string_array *p_pba) { + PoolVector<String> *pba = (PoolVector<String> *)p_pba; + return pba->size(); +} + +void GDAPI godot_pool_string_array_destroy(godot_pool_string_array *p_pba) { + ((PoolVector<String> *)p_pba)->~PoolVector(); +} + +// vector2 + +void GDAPI godot_pool_vector2_array_new(godot_pool_vector2_array *p_pba) { + PoolVector<Vector2> *pba = (PoolVector<Vector2> *)p_pba; + memnew_placement(pba, PoolVector<Vector2>); +} + +void GDAPI godot_pool_vector2_array_new_with_array(godot_pool_vector2_array *p_pba, const godot_array *p_a) { + PoolVector<Vector2> *pba = (PoolVector<Vector2> *)p_pba; + Array *a = (Array *)p_a; + memnew_placement(pba, PoolVector<Vector2>); + + pba->resize(a->size()); + for (size_t i = 0; i < a->size(); i++) { + pba->set(i, (*a)[i]); + } +} + +void GDAPI godot_pool_vector2_array_append(godot_pool_vector2_array *p_pba, const godot_vector2 *p_data) { + PoolVector<Vector2> *pba = (PoolVector<Vector2> *)p_pba; + Vector2 &s = *(Vector2 *)p_data; + pba->append(s); +} + +void GDAPI godot_pool_vector2_array_append_array(godot_pool_vector2_array *p_pba, const godot_pool_vector2_array *p_array) { + PoolVector<Vector2> *pba = (PoolVector<Vector2> *)p_pba; + PoolVector<Vector2> *array = (PoolVector<Vector2> *)p_array; + pba->append_array(*array); +} + +int GDAPI godot_pool_vector2_array_insert(godot_pool_vector2_array *p_pba, const godot_int p_idx, const godot_vector2 *p_data) { + PoolVector<Vector2> *pba = (PoolVector<Vector2> *)p_pba; + Vector2 &s = *(Vector2 *)p_data; + return pba->insert(p_idx, s); +} + +void GDAPI godot_pool_vector2_array_invert(godot_pool_vector2_array *p_pba) { + PoolVector<Vector2> *pba = (PoolVector<Vector2> *)p_pba; + pba->invert(); +} + +void GDAPI godot_pool_vector2_array_push_back(godot_pool_vector2_array *p_pba, const godot_vector2 *p_data) { + PoolVector<Vector2> *pba = (PoolVector<Vector2> *)p_pba; + Vector2 &s = *(Vector2 *)p_data; + pba->push_back(s); +} + +void GDAPI godot_pool_vector2_array_remove(godot_pool_vector2_array *p_pba, const godot_int p_idx) { + PoolVector<Vector2> *pba = (PoolVector<Vector2> *)p_pba; + pba->remove(p_idx); +} + +void GDAPI godot_pool_vector2_array_resize(godot_pool_vector2_array *p_pba, const godot_int p_size) { + PoolVector<Vector2> *pba = (PoolVector<Vector2> *)p_pba; + pba->resize(p_size); +} + +void GDAPI godot_pool_vector2_array_set(godot_pool_vector2_array *p_pba, const godot_int p_idx, const godot_vector2 *p_data) { + PoolVector<Vector2> *pba = (PoolVector<Vector2> *)p_pba; + Vector2 &s = *(Vector2 *)p_data; + pba->set(p_idx, s); +} + +godot_vector2 GDAPI godot_pool_vector2_array_get(godot_pool_vector2_array *p_pba, const godot_int p_idx) { + PoolVector<Vector2> *pba = (PoolVector<Vector2> *)p_pba; + godot_vector2 v; + Vector2 *s = (Vector2 *)&v; + *s = pba->get(p_idx); + return v; +} + +godot_int GDAPI godot_pool_vector2_array_size(godot_pool_vector2_array *p_pba) { + PoolVector<Vector2> *pba = (PoolVector<Vector2> *)p_pba; + return pba->size(); +} + +void GDAPI godot_pool_vector2_array_destroy(godot_pool_vector2_array *p_pba) { + ((PoolVector<Vector2> *)p_pba)->~PoolVector(); +} + +// vector3 + +void GDAPI godot_pool_vector3_array_new(godot_pool_vector3_array *p_pba) { + PoolVector<Vector3> *pba = (PoolVector<Vector3> *)p_pba; + memnew_placement(pba, PoolVector<Vector3>); +} + +void GDAPI godot_pool_vector3_array_new_with_array(godot_pool_vector3_array *p_pba, const godot_array *p_a) { + PoolVector<Vector3> *pba = (PoolVector<Vector3> *)p_pba; + Array *a = (Array *)p_a; + memnew_placement(pba, PoolVector<Vector3>); + + pba->resize(a->size()); + for (size_t i = 0; i < a->size(); i++) { + pba->set(i, (*a)[i]); + } +} + +void GDAPI godot_pool_vector3_array_append(godot_pool_vector3_array *p_pba, const godot_vector3 *p_data) { + PoolVector<Vector3> *pba = (PoolVector<Vector3> *)p_pba; + Vector3 &s = *(Vector3 *)p_data; + pba->append(s); +} + +void GDAPI godot_pool_vector3_array_append_array(godot_pool_vector3_array *p_pba, const godot_pool_vector3_array *p_array) { + PoolVector<Vector3> *pba = (PoolVector<Vector3> *)p_pba; + PoolVector<Vector3> *array = (PoolVector<Vector3> *)p_array; + pba->append_array(*array); +} + +int GDAPI godot_pool_vector3_array_insert(godot_pool_vector3_array *p_pba, const godot_int p_idx, const godot_vector3 *p_data) { + PoolVector<Vector3> *pba = (PoolVector<Vector3> *)p_pba; + Vector3 &s = *(Vector3 *)p_data; + return pba->insert(p_idx, s); +} + +void GDAPI godot_pool_vector3_array_invert(godot_pool_vector3_array *p_pba) { + PoolVector<Vector3> *pba = (PoolVector<Vector3> *)p_pba; + pba->invert(); +} + +void GDAPI godot_pool_vector3_array_push_back(godot_pool_vector3_array *p_pba, const godot_vector3 *p_data) { + PoolVector<Vector3> *pba = (PoolVector<Vector3> *)p_pba; + Vector3 &s = *(Vector3 *)p_data; + pba->push_back(s); +} + +void GDAPI godot_pool_vector3_array_remove(godot_pool_vector3_array *p_pba, const godot_int p_idx) { + PoolVector<Vector3> *pba = (PoolVector<Vector3> *)p_pba; + pba->remove(p_idx); +} + +void GDAPI godot_pool_vector3_array_resize(godot_pool_vector3_array *p_pba, const godot_int p_size) { + PoolVector<Vector3> *pba = (PoolVector<Vector3> *)p_pba; + pba->resize(p_size); +} + +void GDAPI godot_pool_vector3_array_set(godot_pool_vector3_array *p_pba, const godot_int p_idx, const godot_vector3 *p_data) { + PoolVector<Vector3> *pba = (PoolVector<Vector3> *)p_pba; + Vector3 &s = *(Vector3 *)p_data; + pba->set(p_idx, s); +} + +godot_vector3 GDAPI godot_pool_vector3_array_get(godot_pool_vector3_array *p_pba, const godot_int p_idx) { + PoolVector<Vector3> *pba = (PoolVector<Vector3> *)p_pba; + godot_vector3 v; + Vector3 *s = (Vector3 *)&v; + *s = pba->get(p_idx); + return v; +} + +godot_int GDAPI godot_pool_vector3_array_size(godot_pool_vector3_array *p_pba) { + PoolVector<Vector3> *pba = (PoolVector<Vector3> *)p_pba; + return pba->size(); +} + +void GDAPI godot_pool_vector3_array_destroy(godot_pool_vector3_array *p_pba) { + ((PoolVector<Vector3> *)p_pba)->~PoolVector(); +} + +// color + +void GDAPI godot_pool_color_array_new(godot_pool_color_array *p_pba) { + PoolVector<Color> *pba = (PoolVector<Color> *)p_pba; + memnew_placement(pba, PoolVector<Color>); +} + +void GDAPI godot_pool_color_array_new_with_array(godot_pool_color_array *p_pba, const godot_array *p_a) { + PoolVector<Color> *pba = (PoolVector<Color> *)p_pba; + Array *a = (Array *)p_a; + memnew_placement(pba, PoolVector<Color>); + + pba->resize(a->size()); + for (size_t i = 0; i < a->size(); i++) { + pba->set(i, (*a)[i]); + } +} + +void GDAPI godot_pool_color_array_append(godot_pool_color_array *p_pba, const godot_color *p_data) { + PoolVector<Color> *pba = (PoolVector<Color> *)p_pba; + Color &s = *(Color *)p_data; + pba->append(s); +} + +void GDAPI godot_pool_color_array_append_array(godot_pool_color_array *p_pba, const godot_pool_color_array *p_array) { + PoolVector<Color> *pba = (PoolVector<Color> *)p_pba; + PoolVector<Color> *array = (PoolVector<Color> *)p_array; + pba->append_array(*array); +} + +int GDAPI godot_pool_color_array_insert(godot_pool_color_array *p_pba, const godot_int p_idx, const godot_color *p_data) { + PoolVector<Color> *pba = (PoolVector<Color> *)p_pba; + Color &s = *(Color *)p_data; + return pba->insert(p_idx, s); +} + +void GDAPI godot_pool_color_array_invert(godot_pool_color_array *p_pba) { + PoolVector<Color> *pba = (PoolVector<Color> *)p_pba; + pba->invert(); +} + +void GDAPI godot_pool_color_array_push_back(godot_pool_color_array *p_pba, const godot_color *p_data) { + PoolVector<Color> *pba = (PoolVector<Color> *)p_pba; + Color &s = *(Color *)p_data; + pba->push_back(s); +} + +void GDAPI godot_pool_color_array_remove(godot_pool_color_array *p_pba, const godot_int p_idx) { + PoolVector<Color> *pba = (PoolVector<Color> *)p_pba; + pba->remove(p_idx); +} + +void GDAPI godot_pool_color_array_resize(godot_pool_color_array *p_pba, const godot_int p_size) { + PoolVector<Color> *pba = (PoolVector<Color> *)p_pba; + pba->resize(p_size); +} + +void GDAPI godot_pool_color_array_set(godot_pool_color_array *p_pba, const godot_int p_idx, const godot_color *p_data) { + PoolVector<Color> *pba = (PoolVector<Color> *)p_pba; + Color &s = *(Color *)p_data; + pba->set(p_idx, s); +} + +godot_color GDAPI godot_pool_color_array_get(godot_pool_color_array *p_pba, const godot_int p_idx) { + PoolVector<Color> *pba = (PoolVector<Color> *)p_pba; + godot_color v; + Color *s = (Color *)&v; + *s = pba->get(p_idx); + return v; +} + +godot_int GDAPI godot_pool_color_array_size(godot_pool_color_array *p_pba) { + PoolVector<Color> *pba = (PoolVector<Color> *)p_pba; + return pba->size(); +} + +void GDAPI godot_pool_color_array_destroy(godot_pool_color_array *p_pba) { + ((PoolVector<Color> *)p_pba)->~PoolVector(); +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_pool_arrays.h b/modules/dlscript/godot/godot_pool_arrays.h new file mode 100644 index 0000000000..77b6c3dde0 --- /dev/null +++ b/modules/dlscript/godot/godot_pool_arrays.h @@ -0,0 +1,256 @@ +#ifndef GODOT_DLSCRIPT_POOL_ARRAYS_H +#define GODOT_DLSCRIPT_POOL_ARRAYS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +/////// PoolByteArray + +#ifndef GODOT_CORE_API_GODOT_POOL_BYTE_ARRAY_TYPE_DEFINED +typedef struct godot_pool_byte_array { + uint8_t _dont_touch_that[8]; +} godot_pool_byte_array; +#endif + +/////// PoolIntArray + +#ifndef GODOT_CORE_API_GODOT_POOL_INT_ARRAY_TYPE_DEFINED +typedef struct godot_pool_int_array { + uint8_t _dont_touch_that[8]; +} godot_pool_int_array; +#endif + +/////// PoolRealArray + +#ifndef GODOT_CORE_API_GODOT_POOL_REAL_ARRAY_TYPE_DEFINED +typedef struct godot_pool_real_array { + uint8_t _dont_touch_that[8]; +} godot_pool_real_array; +#endif + +/////// PoolStringArray + +#ifndef GODOT_CORE_API_GODOT_POOL_STRING_ARRAY_TYPE_DEFINED +typedef struct godot_pool_string_array { + uint8_t _dont_touch_that[8]; +} godot_pool_string_array; +#endif + +/////// PoolVector2Array + +#ifndef GODOT_CORE_API_GODOT_POOL_VECTOR2_ARRAY_TYPE_DEFINED +typedef struct godot_pool_vector2_array { + uint8_t _dont_touch_that[8]; +} godot_pool_vector2_array; +#endif + +/////// PoolVector3Array + +#ifndef GODOT_CORE_API_GODOT_POOL_VECTOR3_ARRAY_TYPE_DEFINED +typedef struct godot_pool_vector3_array { + uint8_t _dont_touch_that[8]; +} godot_pool_vector3_array; +#endif + +/////// PoolColorArray + +#ifndef GODOT_CORE_API_GODOT_POOL_COLOR_ARRAY_TYPE_DEFINED +typedef struct godot_pool_color_array { + uint8_t _dont_touch_that[8]; +} godot_pool_color_array; +#endif + +#include "../godot.h" + +#include "godot_array.h" + +// byte + +void GDAPI godot_pool_byte_array_new(godot_pool_byte_array *p_pba); +void GDAPI godot_pool_byte_array_new_with_array(godot_pool_byte_array *p_pba, const godot_array *p_a); + +void GDAPI godot_pool_byte_array_append(godot_pool_byte_array *p_pba, const uint8_t p_data); + +void GDAPI godot_pool_byte_array_append_array(godot_pool_byte_array *p_pba, const godot_pool_byte_array *p_array); + +int GDAPI godot_pool_byte_array_insert(godot_pool_byte_array *p_pba, const godot_int p_idx, const uint8_t p_data); + +void GDAPI godot_pool_byte_array_invert(godot_pool_byte_array *p_pba); + +void GDAPI godot_pool_byte_array_push_back(godot_pool_byte_array *p_pba, const uint8_t p_data); + +void GDAPI godot_pool_byte_array_remove(godot_pool_byte_array *p_pba, const godot_int p_idx); + +void GDAPI godot_pool_byte_array_resize(godot_pool_byte_array *p_pba, const godot_int p_size); + +void GDAPI godot_pool_byte_array_set(godot_pool_byte_array *p_pba, const godot_int p_idx, const uint8_t p_data); +uint8_t GDAPI godot_pool_byte_array_get(godot_pool_byte_array *p_pba, const godot_int p_idx); + +godot_int GDAPI godot_pool_byte_array_size(godot_pool_byte_array *p_pba); + +void GDAPI godot_pool_byte_array_destroy(godot_pool_byte_array *p_pba); + +// int + +void GDAPI godot_pool_int_array_new(godot_pool_int_array *p_pia); +void GDAPI godot_pool_int_array_new_with_array(godot_pool_int_array *p_pia, const godot_array *p_a); + +void GDAPI godot_pool_int_array_append(godot_pool_int_array *p_pia, const godot_int p_data); + +void GDAPI godot_pool_int_array_append_array(godot_pool_int_array *p_pia, const godot_pool_int_array *p_array); + +int GDAPI godot_pool_int_array_insert(godot_pool_int_array *p_pia, const godot_int p_idx, const godot_int p_data); + +void GDAPI godot_pool_int_array_invert(godot_pool_int_array *p_pia); + +void GDAPI godot_pool_int_array_push_back(godot_pool_int_array *p_pia, const godot_int p_data); + +void GDAPI godot_pool_int_array_remove(godot_pool_int_array *p_pia, const godot_int p_idx); + +void GDAPI godot_pool_int_array_resize(godot_pool_int_array *p_pia, const godot_int p_size); + +void GDAPI godot_pool_int_array_set(godot_pool_int_array *p_pia, const godot_int p_idx, const godot_int p_data); +godot_int GDAPI godot_pool_int_array_get(godot_pool_int_array *p_pia, const godot_int p_idx); + +godot_int GDAPI godot_pool_int_array_size(godot_pool_int_array *p_pia); + +void GDAPI godot_pool_int_array_destroy(godot_pool_int_array *p_pia); + +// real + +void GDAPI godot_pool_real_array_new(godot_pool_real_array *p_pra); +void GDAPI godot_pool_real_array_new_with_array(godot_pool_real_array *p_pra, const godot_array *p_a); + +void GDAPI godot_pool_real_array_append(godot_pool_real_array *p_pra, const godot_real p_data); + +void GDAPI godot_pool_real_array_append_array(godot_pool_real_array *p_pra, const godot_pool_real_array *p_array); + +int GDAPI godot_pool_real_array_insert(godot_pool_real_array *p_pra, const godot_int p_idx, const godot_real p_data); + +void GDAPI godot_pool_real_array_invert(godot_pool_real_array *p_pra); + +void GDAPI godot_pool_real_array_push_back(godot_pool_real_array *p_pra, const godot_real p_data); + +void GDAPI godot_pool_real_array_remove(godot_pool_real_array *p_pra, const godot_int p_idx); + +void GDAPI godot_pool_real_array_resize(godot_pool_real_array *p_pra, const godot_int p_size); + +void GDAPI godot_pool_real_array_set(godot_pool_real_array *p_pra, const godot_int p_idx, const godot_real p_data); +godot_real GDAPI godot_pool_real_array_get(godot_pool_real_array *p_pra, const godot_int p_idx); + +godot_int GDAPI godot_pool_real_array_size(godot_pool_real_array *p_pra); + +void GDAPI godot_pool_real_array_destroy(godot_pool_real_array *p_pra); + +// string + +void GDAPI godot_pool_string_array_new(godot_pool_string_array *p_psa); +void GDAPI godot_pool_string_array_new_with_array(godot_pool_string_array *p_psa, const godot_array *p_a); + +void GDAPI godot_pool_string_array_append(godot_pool_string_array *p_psa, const godot_string *p_data); + +void GDAPI godot_pool_string_array_append_array(godot_pool_string_array *p_psa, const godot_pool_string_array *p_array); + +int GDAPI godot_pool_string_array_insert(godot_pool_string_array *p_psa, const godot_int p_idx, const godot_string *p_data); + +void GDAPI godot_pool_string_array_invert(godot_pool_string_array *p_psa); + +void GDAPI godot_pool_string_array_push_back(godot_pool_string_array *p_psa, const godot_string *p_data); + +void GDAPI godot_pool_string_array_remove(godot_pool_string_array *p_psa, const godot_int p_idx); + +void GDAPI godot_pool_string_array_resize(godot_pool_string_array *p_psa, const godot_int p_size); + +void GDAPI godot_pool_string_array_set(godot_pool_string_array *p_psa, const godot_int p_idx, const godot_string *p_data); +godot_string GDAPI godot_pool_string_array_get(godot_pool_string_array *p_psa, const godot_int p_idx); + +godot_int GDAPI godot_pool_string_array_size(godot_pool_string_array *p_psa); + +void GDAPI godot_pool_string_array_destroy(godot_pool_string_array *p_psa); + +// vector2 + +void GDAPI godot_pool_vector2_array_new(godot_pool_vector2_array *p_pv2a); +void GDAPI godot_pool_vector2_array_new_with_array(godot_pool_vector2_array *p_pv2a, const godot_array *p_a); + +void GDAPI godot_pool_vector2_array_append(godot_pool_vector2_array *p_pv2a, const godot_vector2 *p_data); + +void GDAPI godot_pool_vector2_array_append_array(godot_pool_vector2_array *p_pv2a, const godot_pool_vector2_array *p_array); + +int GDAPI godot_pool_vector2_array_insert(godot_pool_vector2_array *p_pv2a, const godot_int p_idx, const godot_vector2 *p_data); + +void GDAPI godot_pool_vector2_array_invert(godot_pool_vector2_array *p_pv2a); + +void GDAPI godot_pool_vector2_array_push_back(godot_pool_vector2_array *p_pv2a, const godot_vector2 *p_data); + +void GDAPI godot_pool_vector2_array_remove(godot_pool_vector2_array *p_pv2a, const godot_int p_idx); + +void GDAPI godot_pool_vector2_array_resize(godot_pool_vector2_array *p_pv2a, const godot_int p_size); + +void GDAPI godot_pool_vector2_array_set(godot_pool_vector2_array *p_pv2a, const godot_int p_idx, const godot_vector2 *p_data); +godot_vector2 GDAPI godot_pool_vector2_array_get(godot_pool_vector2_array *p_pv2a, const godot_int p_idx); + +godot_int GDAPI godot_pool_vector2_array_size(godot_pool_vector2_array *p_pv2a); + +void GDAPI godot_pool_vector2_array_destroy(godot_pool_vector2_array *p_pv2a); + +// vector3 + +void GDAPI godot_pool_vector3_array_new(godot_pool_vector3_array *p_pv3a); +void GDAPI godot_pool_vector3_array_new_with_array(godot_pool_vector3_array *p_pv3a, const godot_array *p_a); + +void GDAPI godot_pool_vector3_array_append(godot_pool_vector3_array *p_pv3a, const godot_vector3 *p_data); + +void GDAPI godot_pool_vector3_array_append_array(godot_pool_vector3_array *p_pv3a, const godot_pool_vector3_array *p_array); + +int GDAPI godot_pool_vector3_array_insert(godot_pool_vector3_array *p_pv3a, const godot_int p_idx, const godot_vector3 *p_data); + +void GDAPI godot_pool_vector3_array_invert(godot_pool_vector3_array *p_pv3a); + +void GDAPI godot_pool_vector3_array_push_back(godot_pool_vector3_array *p_pv3a, const godot_vector3 *p_data); + +void GDAPI godot_pool_vector3_array_remove(godot_pool_vector3_array *p_pv3a, const godot_int p_idx); + +void GDAPI godot_pool_vector3_array_resize(godot_pool_vector3_array *p_pv3a, const godot_int p_size); + +void GDAPI godot_pool_vector3_array_set(godot_pool_vector3_array *p_pv3a, const godot_int p_idx, const godot_vector3 *p_data); +godot_vector3 GDAPI godot_pool_vector3_array_get(godot_pool_vector3_array *p_pv3a, const godot_int p_idx); + +godot_int GDAPI godot_pool_vector3_array_size(godot_pool_vector3_array *p_pv3a); + +void GDAPI godot_pool_vector3_array_destroy(godot_pool_vector3_array *p_pv3a); + +// color + +void GDAPI godot_pool_color_array_new(godot_pool_color_array *p_pca); +void GDAPI godot_pool_color_array_new_with_array(godot_pool_color_array *p_pca, const godot_array *p_a); + +void GDAPI godot_pool_color_array_append(godot_pool_color_array *p_pca, const godot_color *p_data); + +void GDAPI godot_pool_color_array_append_array(godot_pool_color_array *p_pca, const godot_pool_color_array *p_array); + +int GDAPI godot_pool_color_array_insert(godot_pool_color_array *p_pca, const godot_int p_idx, const godot_color *p_data); + +void GDAPI godot_pool_color_array_invert(godot_pool_color_array *p_pca); + +void GDAPI godot_pool_color_array_push_back(godot_pool_color_array *p_pca, const godot_color *p_data); + +void GDAPI godot_pool_color_array_remove(godot_pool_color_array *p_pca, const godot_int p_idx); + +void GDAPI godot_pool_color_array_resize(godot_pool_color_array *p_pca, const godot_int p_size); + +void GDAPI godot_pool_color_array_set(godot_pool_color_array *p_pca, const godot_int p_idx, const godot_color *p_data); +godot_color GDAPI godot_pool_color_array_get(godot_pool_color_array *p_pca, const godot_int p_idx); + +godot_int GDAPI godot_pool_color_array_size(godot_pool_color_array *p_pca); + +void GDAPI godot_pool_color_array_destroy(godot_pool_color_array *p_pca); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DLSCRIPT_POOL_ARRAYS_H diff --git a/modules/dlscript/godot/godot_quat.cpp b/modules/dlscript/godot/godot_quat.cpp new file mode 100644 index 0000000000..5571614e07 --- /dev/null +++ b/modules/dlscript/godot/godot_quat.cpp @@ -0,0 +1,79 @@ +#include "godot_quat.h" + +#include "math/quat.h" + +#include <memory.h> // why is there no <cmemory> btw? + +#ifdef __cplusplus +extern "C" { +#endif + +void _quat_api_anchor() { +} + +void GDAPI godot_quat_new(godot_quat *p_quat) { + Quat *quat = (Quat *)p_quat; + *quat = Quat(); +} + +void GDAPI godot_quat_new_with_elements(godot_quat *p_quat, const godot_real x, const godot_real y, const godot_real z, const godot_real w) { + Quat *quat = (Quat *)p_quat; + *quat = Quat(x, y, z, w); +} + +void GDAPI godot_quat_new_with_rotation(godot_quat *p_quat, const godot_vector3 *p_axis, const godot_real p_angle) { + Quat *quat = (Quat *)p_quat; + const Vector3 *axis = (const Vector3 *)p_axis; + *quat = Quat(*axis, p_angle); +} + +void GDAPI godot_quat_new_with_shortest_arc(godot_quat *p_quat, const godot_vector3 *p_v0, const godot_vector3 *p_v1) { + Quat *quat = (Quat *)p_quat; + const Vector3 *v0 = (const Vector3 *)p_v0; + const Vector3 *v1 = (const Vector3 *)p_v1; + *quat = Quat(*v0, *v1); +} + +godot_vector3 GDAPI godot_quat_get_euler(const godot_quat *p_quat) { + Quat *quat = (Quat *)p_quat; + Vector3 euler = quat->get_euler(); + return *(godot_vector3 *)&euler; +} + +void GDAPI godot_quat_set_euler(godot_quat *p_quat, const godot_vector3 *p_euler) { + Quat *quat = (Quat *)p_quat; + const Vector3 *euler = (const Vector3 *)p_euler; + quat->set_euler(*euler); +} + +godot_real GDAPI *godot_quat_index(godot_quat *p_quat, const godot_int p_idx) { + Quat *quat = (Quat *)p_quat; + switch (p_idx) { + case 0: + return &quat->x; + case 1: + return &quat->y; + case 2: + return &quat->z; + default: + return &quat->y; + } +} + +godot_real GDAPI godot_quat_const_index(const godot_quat *p_quat, const godot_int p_idx) { + const Quat *quat = (const Quat *)p_quat; + switch (p_idx) { + case 0: + return quat->x; + case 1: + return quat->y; + case 2: + return quat->z; + default: + return quat->y; + } +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_quat.h b/modules/dlscript/godot/godot_quat.h new file mode 100644 index 0000000000..4e3253c4e5 --- /dev/null +++ b/modules/dlscript/godot/godot_quat.h @@ -0,0 +1,33 @@ +#ifndef GODOT_DLSCRIPT_QUAT_H +#define GODOT_DLSCRIPT_QUAT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_QUAT_TYPE_DEFINED +typedef struct godot_quat { + uint8_t _dont_touch_that[16]; +} godot_quat; +#endif + +#include "../godot.h" + +void GDAPI godot_quat_new(godot_quat *p_quat); +void GDAPI godot_quat_new_with_elements(godot_quat *p_quat, const godot_real x, const godot_real y, const godot_real z, const godot_real w); +void GDAPI godot_quat_new_with_rotation(godot_quat *p_quat, const godot_vector3 *p_axis, const godot_real p_angle); +void GDAPI godot_quat_new_with_shortest_arc(godot_quat *p_quat, const godot_vector3 *p_v0, const godot_vector3 *p_v1); + +godot_vector3 GDAPI godot_quat_get_euler(const godot_quat *p_quat); +void GDAPI godot_quat_set_euler(godot_quat *p_quat, const godot_vector3 *p_euler); + +godot_real GDAPI *godot_quat_index(godot_quat *p_quat, const godot_int p_idx); +godot_real GDAPI godot_quat_const_index(const godot_quat *p_quat, const godot_int p_idx); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DLSCRIPT_QUAT_H diff --git a/modules/dlscript/godot/godot_rect2.cpp b/modules/dlscript/godot/godot_rect2.cpp new file mode 100644 index 0000000000..8e60811114 --- /dev/null +++ b/modules/dlscript/godot/godot_rect2.cpp @@ -0,0 +1,48 @@ +#include "godot_rect2.h" + +#include "math/math_2d.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _rect2_api_anchor() { +} + +void GDAPI godot_rect2_new(godot_rect2 *p_rect) { + Rect2 *rect = (Rect2 *)p_rect; + *rect = Rect2(); +} + +void GDAPI godot_rect2_new_with_pos_and_size(godot_rect2 *p_rect, const godot_vector2 *p_pos, const godot_vector2 *p_size) { + Rect2 *rect = (Rect2 *)p_rect; + const Vector2 *pos = (const Vector2 *)p_pos; + const Vector2 *size = (const Vector2 *)p_size; + *rect = Rect2(*pos, *size); +} + +godot_vector2 GDAPI *godot_rect2_get_pos(godot_rect2 *p_rect) { + Rect2 *rect = (Rect2 *)p_rect; + return (godot_vector2 *)&rect->pos; +} + +void GDAPI godot_rect2_set_pos(godot_rect2 *p_rect, const godot_vector2 *p_pos) { + Rect2 *rect = (Rect2 *)p_rect; + const Vector2 *pos = (const Vector2 *)p_pos; + rect->pos = *pos; +} + +godot_vector2 GDAPI *godot_rect2_get_size(godot_rect2 *p_rect) { + Rect2 *rect = (Rect2 *)p_rect; + return (godot_vector2 *)&rect->size; +} + +void GDAPI godot_rect2_set_size(godot_rect2 *p_rect, const godot_vector2 *p_size) { + Rect2 *rect = (Rect2 *)p_rect; + const Vector2 *size = (const Vector2 *)p_size; + rect->size = *size; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_rect2.h b/modules/dlscript/godot/godot_rect2.h new file mode 100644 index 0000000000..a3b19bdb7e --- /dev/null +++ b/modules/dlscript/godot/godot_rect2.h @@ -0,0 +1,31 @@ +#ifndef GODOT_DLSCRIPT_RECT2_H +#define GODOT_DLSCRIPT_RECT2_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_RECT2_TYPE_DEFINED +typedef struct godot_rect2 { + uint8_t _dont_touch_that[16]; +} godot_rect2; +#endif + +#include "../godot.h" + +void GDAPI godot_rect2_new(godot_rect2 *p_rect); +void GDAPI godot_rect2_new_with_pos_and_size(godot_rect2 *p_rect, const godot_vector2 *p_pos, const godot_vector2 *p_size); + +godot_vector2 GDAPI *godot_rect2_get_pos(godot_rect2 *p_rect); +void GDAPI godot_rect2_set_pos(godot_rect2 *p_rect, const godot_vector2 *p_pos); + +godot_vector2 GDAPI *godot_rect2_get_size(godot_rect2 *p_rect); +void GDAPI godot_rect2_set_size(godot_rect2 *p_rect, const godot_vector2 *p_size); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DLSCRIPT_RECT3_H diff --git a/modules/dlscript/godot/godot_rect3.cpp b/modules/dlscript/godot/godot_rect3.cpp new file mode 100644 index 0000000000..3c442a278b --- /dev/null +++ b/modules/dlscript/godot/godot_rect3.cpp @@ -0,0 +1,48 @@ +#include "godot_rect3.h" + +#include "math/rect3.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _rect3_api_anchor() { +} + +void GDAPI godot_rect3_new(godot_rect3 *p_rect) { + Rect3 *rect = (Rect3 *)p_rect; + *rect = Rect3(); +} + +void GDAPI godot_rect3_new_with_pos_and_size(godot_rect3 *p_rect, const godot_vector3 *p_pos, const godot_vector3 *p_size) { + Rect3 *rect = (Rect3 *)p_rect; + const Vector3 *pos = (const Vector3 *)p_pos; + const Vector3 *size = (const Vector3 *)p_size; + *rect = Rect3(*pos, *size); +} + +godot_vector3 GDAPI *godot_rect3_get_pos(godot_rect3 *p_rect) { + Rect3 *rect = (Rect3 *)p_rect; + return (godot_vector3 *)&rect->pos; +} + +void GDAPI godot_rect3_set_pos(godot_rect3 *p_rect, const godot_vector3 *p_pos) { + Rect3 *rect = (Rect3 *)p_rect; + const Vector3 *pos = (const Vector3 *)p_pos; + rect->pos = *pos; +} + +godot_vector3 GDAPI *godot_rect3_get_size(godot_rect3 *p_rect) { + Rect3 *rect = (Rect3 *)p_rect; + return (godot_vector3 *)&rect->size; +} + +void GDAPI godot_rect3_set_size(godot_rect3 *p_rect, const godot_vector3 *p_size) { + Rect3 *rect = (Rect3 *)p_rect; + const Vector3 *size = (const Vector3 *)p_size; + rect->size = *size; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_rect3.h b/modules/dlscript/godot/godot_rect3.h new file mode 100644 index 0000000000..b9279616d1 --- /dev/null +++ b/modules/dlscript/godot/godot_rect3.h @@ -0,0 +1,31 @@ +#ifndef GODOT_DLSCRIPT_RECT3_H +#define GODOT_DLSCRIPT_RECT3_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_RECT3_TYPE_DEFINED +typedef struct godot_rect3 { + uint8_t _dont_touch_that[24]; +} godot_rect3; +#endif + +#include "../godot.h" + +void GDAPI godot_rect3_new(godot_rect3 *p_rect); +void GDAPI godot_rect3_new_with_pos_and_size(godot_rect3 *p_rect, const godot_vector3 *p_pos, const godot_vector3 *p_size); + +godot_vector3 GDAPI *godot_rect3_get_pos(godot_rect3 *p_rect); +void GDAPI godot_rect3_set_pos(godot_rect3 *p_rect, const godot_vector3 *p_pos); + +godot_vector3 GDAPI *godot_rect3_get_size(godot_rect3 *p_rect); +void GDAPI godot_rect3_set_size(godot_rect3 *p_rect, const godot_vector3 *p_size); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DLSCRIPT_RECT3_H diff --git a/modules/dlscript/godot/godot_rid.cpp b/modules/dlscript/godot/godot_rid.cpp new file mode 100644 index 0000000000..a36a2e64a3 --- /dev/null +++ b/modules/dlscript/godot/godot_rid.cpp @@ -0,0 +1,36 @@ +#include "godot_rid.h" + +#include "object.h" +#include "resource.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _rid_api_anchor() { +} + +void GDAPI godot_rid_new(godot_rid *p_rid, godot_object *p_from) { + + Resource *res_from = ((Object *)p_from)->cast_to<Resource>(); + + RID *rid = (RID *)p_rid; + memnew_placement(rid, RID); + + if (res_from) { + *rid = RID(res_from->get_rid()); + } +} + +uint32_t GDAPI godot_rid_get_rid(const godot_rid *p_rid) { + RID *rid = (RID *)p_rid; + return rid->get_id(); +} + +void GDAPI godot_rid_destroy(godot_rid *p_rid) { + ((RID *)p_rid)->~RID(); +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_rid.h b/modules/dlscript/godot/godot_rid.h new file mode 100644 index 0000000000..f20c0d4dae --- /dev/null +++ b/modules/dlscript/godot/godot_rid.h @@ -0,0 +1,28 @@ +#ifndef GODOT_DLSCRIPT_RID_H +#define GODOT_DLSCRIPT_RID_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_RID_TYPE_DEFINED +typedef struct godot_rid { + uint8_t _dont_touch_that[8]; +} godot_rid; +#endif + +#include "../godot.h" + +void GDAPI godot_rid_new(godot_rid *p_rid, godot_object *p_from); + +uint32_t GDAPI godot_rid_get_rid(const godot_rid *p_rid); + +void GDAPI godot_rid_destroy(godot_rid *p_rid); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DLSCRIPT_RID_H diff --git a/modules/dlscript/godot/godot_string.cpp b/modules/dlscript/godot/godot_string.cpp new file mode 100644 index 0000000000..1501743e02 --- /dev/null +++ b/modules/dlscript/godot/godot_string.cpp @@ -0,0 +1,83 @@ +#include "godot_string.h" + +#include "string_db.h" +#include "ustring.h" + +#include <memory.h> // why is there no <cmemory> btw? + +#ifdef __cplusplus +extern "C" { +#endif + +void _string_api_anchor() { +} + +void GDAPI godot_string_new(godot_string *p_str) { + String *p = (String *)p_str; + memnew_placement(p, String); + // *p = String(); // useless here +} + +void GDAPI godot_string_new_data(godot_string *p_str, const char *p_contents, const int p_size) { + String *p = (String *)p_str; + memnew_placement(p, String); + *p = String::utf8(p_contents, p_size); +} + +void GDAPI godot_string_get_data(const godot_string *p_str, wchar_t *p_dest, int *p_size) { + String *p = (String *)p_str; + if (p_size != NULL) { + *p_size = p->length(); + } + if (p_dest != NULL) { + memcpy(p_dest, p->ptr(), *p_size * sizeof(CharType)); + } +} + +void GDAPI godot_string_copy_string(const godot_string *p_dest, const godot_string *p_src) { + String *dest = (String *)p_dest; + String *src = (String *)p_src; + + *dest = *src; +} + +wchar_t GDAPI *godot_string_operator_index(godot_string *p_str, const godot_int p_idx) { + String *s = (String *)p_str; + return &(s->operator[](p_idx)); +} + +const wchar_t GDAPI *godot_string_c_str(const godot_string *p_str) { + const String *s = (const String *)p_str; + return s->c_str(); +} + +godot_bool GDAPI godot_string_operator_equal(const godot_string *p_a, const godot_string *p_b) { + String *a = (String *)p_a; + String *b = (String *)p_b; + return *a == *b; +} + +godot_bool GDAPI godot_string_operator_less(const godot_string *p_a, const godot_string *p_b) { + String *a = (String *)p_a; + String *b = (String *)p_b; + return *a < *b; +} + +void GDAPI godot_string_operator_plus(godot_string *p_dest, const godot_string *p_a, const godot_string *p_b) { + String *dest = (String *)p_dest; + const String *a = (String *)p_a; + const String *b = (String *)p_b; + + String tmp = *a + *b; + godot_string_new(p_dest); + *dest = tmp; +} + +void GDAPI godot_string_destroy(godot_string *p_str) { + String *p = (String *)p_str; + p->~String(); +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_string.h b/modules/dlscript/godot/godot_string.h new file mode 100644 index 0000000000..73b366d9cd --- /dev/null +++ b/modules/dlscript/godot/godot_string.h @@ -0,0 +1,42 @@ +#ifndef GODOT_DLSCRIPT_STRING_H +#define GODOT_DLSCRIPT_STRING_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED +typedef struct godot_string { + uint8_t _dont_touch_that[8]; +} godot_string; +#endif + +#include "../godot.h" + +void GDAPI godot_string_new(godot_string *p_str); +void GDAPI godot_string_new_data(godot_string *p_str, const char *p_contents, const int p_size); + +void GDAPI godot_string_get_data(const godot_string *p_str, wchar_t *p_dest, int *p_size); + +void GDAPI godot_string_copy_string(const godot_string *p_dest, const godot_string *p_src); + +wchar_t GDAPI *godot_string_operator_index(godot_string *p_str, const godot_int p_idx); +const wchar_t GDAPI *godot_string_c_str(const godot_string *p_str); + +godot_bool GDAPI godot_string_operator_equal(const godot_string *p_a, const godot_string *p_b); +godot_bool GDAPI godot_string_operator_less(const godot_string *p_a, const godot_string *p_b); +void GDAPI godot_string_operator_plus(godot_string *p_dest, const godot_string *p_a, const godot_string *p_b); + +// @Incomplete +// hmm, I guess exposing the whole API doesn't make much sense +// since the language used in the library has its own string funcs + +void GDAPI godot_string_destroy(godot_string *p_str); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DLSCRIPT_STRING_H diff --git a/modules/dlscript/godot/godot_transform.cpp b/modules/dlscript/godot/godot_transform.cpp new file mode 100644 index 0000000000..18d218e6c4 --- /dev/null +++ b/modules/dlscript/godot/godot_transform.cpp @@ -0,0 +1,44 @@ +#include "godot_transform.h" + +#include "math/transform.h" + +#include <memory.h> // why is there no <cmemory> btw? + +#ifdef __cplusplus +extern "C" { +#endif + +void _transform_api_anchor() { +} + +void GDAPI godot_transform_new(godot_transform *p_trans) { + Transform *trans = (Transform *)p_trans; + *trans = Transform(); +} + +void GDAPI godot_transform_new_with_basis(godot_transform *p_trans, const godot_basis *p_basis) { + Transform *trans = (Transform *)p_trans; + const Basis *basis = (const Basis *)p_basis; + *trans = Transform(*basis); +} + +void GDAPI godot_transform_new_with_basis_origin(godot_transform *p_trans, const godot_basis *p_basis, const godot_vector3 *p_origin) { + Transform *trans = (Transform *)p_trans; + const Basis *basis = (const Basis *)p_basis; + const Vector3 *origin = (const Vector3 *)p_origin; + *trans = Transform(*basis, *origin); +} + +godot_basis GDAPI *godot_transform_get_basis(godot_transform *p_trans) { + Transform *trans = (Transform *)p_trans; + return (godot_basis *)&trans->basis; +} + +godot_vector3 GDAPI *godot_transform_get_origin(godot_transform *p_trans) { + Transform *trans = (Transform *)p_trans; + return (godot_vector3 *)&trans->origin; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_transform.h b/modules/dlscript/godot/godot_transform.h new file mode 100644 index 0000000000..54af78d5b9 --- /dev/null +++ b/modules/dlscript/godot/godot_transform.h @@ -0,0 +1,29 @@ +#ifndef GODOT_DLSCRIPT_TRANSFORM_H +#define GODOT_DLSCRIPT_TRANSFORM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_TRANSFORM_TYPE_DEFINED +typedef struct godot_transform { + uint8_t _dont_touch_that[48]; +} godot_transform; +#endif + +#include "../godot.h" + +void GDAPI godot_transform_new(godot_transform *p_trans); +void GDAPI godot_transform_new_with_basis(godot_transform *p_trans, const godot_basis *p_basis); +void GDAPI godot_transform_new_with_basis_origin(godot_transform *p_trans, const godot_basis *p_basis, const godot_vector3 *p_origin); + +godot_basis GDAPI *godot_transform_get_basis(godot_transform *p_trans); +godot_vector3 GDAPI *godot_transform_get_origin(godot_transform *p_trans); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_DLSCRIPT_TRANSFORM_H diff --git a/modules/dlscript/godot/godot_transform2d.cpp b/modules/dlscript/godot/godot_transform2d.cpp new file mode 100644 index 0000000000..39fa0e7363 --- /dev/null +++ b/modules/dlscript/godot/godot_transform2d.cpp @@ -0,0 +1,59 @@ +#include "godot_transform2d.h" + +#include "../godot.h" + +#include "math/math_2d.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _transform2d_api_anchor() { +} + +void GDAPI godot_transform2d_new_identity(godot_transform2d *p_t) { + Transform2D *t = (Transform2D *)p_t; + *t = Transform2D(); +} + +void GDAPI godot_transform2d_new_elements(godot_transform2d *p_t, const godot_vector2 *p_a, const godot_vector2 *p_b, const godot_vector2 *p_c) { + Transform2D *t = (Transform2D *)p_t; + Vector2 *a = (Vector2 *)p_a; + Vector2 *b = (Vector2 *)p_b; + Vector2 *c = (Vector2 *)p_c; + *t = Transform2D(a->x, a->y, b->x, b->y, c->x, c->y); +} + +void GDAPI godot_transform2d_new(godot_transform2d *p_t, const godot_real p_rot, const godot_vector2 *p_pos) { + Transform2D *t = (Transform2D *)p_t; + Vector2 *pos = (Vector2 *)p_pos; + *t = Transform2D(p_rot, *pos); +} + +godot_vector2 const GDAPI *godot_transform2d_const_index(const godot_transform2d *p_t, const godot_int p_idx) { + const Transform2D *t = (const Transform2D *)p_t; + const Vector2 *e = &t->operator[](p_idx); + return (godot_vector2 const *)e; +} + +godot_vector2 GDAPI *godot_transform2d_index(godot_transform2d *p_t, const godot_int p_idx) { + Transform2D *t = (Transform2D *)p_t; + Vector2 *e = &t->operator[](p_idx); + return (godot_vector2 *)e; +} + +godot_vector2 GDAPI godot_transform2d_get_axis(const godot_transform2d *p_t, const godot_int p_axis) { + return *godot_transform2d_const_index(p_t, p_axis); +} + +void GDAPI godot_transform2d_set_axis(godot_transform2d *p_t, const godot_int p_axis, const godot_vector2 *p_vec) { + godot_vector2 *origin_v = godot_transform2d_index(p_t, p_axis); + *origin_v = *p_vec; +} + +// @Incomplete +// See header file + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_transform2d.h b/modules/dlscript/godot/godot_transform2d.h new file mode 100644 index 0000000000..7403954527 --- /dev/null +++ b/modules/dlscript/godot/godot_transform2d.h @@ -0,0 +1,48 @@ +#ifndef GODOT_TRANSFORM2D_H +#define GODOT_TRANSFORM2D_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED +typedef struct godot_transform2d { + uint8_t _dont_touch_that[24]; +} godot_transform2d; +#endif + +#include "../godot.h" + +#include "godot_vector2.h" + +void GDAPI godot_transform2d_new_identity(godot_transform2d *p_t); +void GDAPI godot_transform2d_new_elements(godot_transform2d *p_t, const godot_vector2 *p_a, const godot_vector2 *p_b, const godot_vector2 *p_c); +void GDAPI godot_transform2d_new(godot_transform2d *p_t, const godot_real p_rot, const godot_vector2 *p_pos); + +/* +godot_real GDAPI godot_transform2d_tdotx(const godot_transform2d *p_t, const godot_vector2 *p_v); +godot_real GDAPI godot_transform2d_tdoty(const godot_transform2d *p_t, const godot_vector2 *p_v); +*/ + +godot_vector2 const GDAPI *godot_transform2d_const_index(const godot_transform2d *p_t, const godot_int p_idx); +godot_vector2 GDAPI *godot_transform2d_index(godot_transform2d *p_t, const godot_int p_idx); + +godot_vector2 GDAPI godot_transform2d_get_axis(const godot_transform2d *p_t, const godot_int p_axis); +void GDAPI godot_transform2d_set_axis(godot_transform2d *p_t, const godot_int p_axis, const godot_vector2 *p_vec); + +/* +void GDAPI godot_transform2d_invert(godot_transform2d *p_t); +godot_transform2d GDAPI godot_transform2d_inverse(const godot_transform2d *p_t); +*/ + +// @Incomplete +// I feel like it should be enough to expose get and set, the whole logic can be done in the bindings. + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_TRANSFORM2D_H diff --git a/modules/dlscript/godot/godot_variant.cpp b/modules/dlscript/godot/godot_variant.cpp new file mode 100644 index 0000000000..e7c47ff9ff --- /dev/null +++ b/modules/dlscript/godot/godot_variant.cpp @@ -0,0 +1,466 @@ +#include "godot_variant.h" + +#include "../godot.h" + +#include "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) + +godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + return (godot_variant_type)v->get_type(); +} + +void GDAPI godot_variant_copy(godot_variant *p_dest, const godot_variant *p_src) { + Variant *dest = (Variant *)p_dest; + Variant *src = (Variant *)p_src; + *dest = *src; +} + +void GDAPI godot_variant_new_nil(godot_variant *p_v) { + Variant *v = (Variant *)p_v; + memnew_placement(v, Variant); +} + +void GDAPI godot_variant_new_bool(godot_variant *p_v, const godot_bool p_b) { + Variant *v = (Variant *)p_v; + memnew_placement_custom(v, Variant, Variant(p_b)); +} + +void GDAPI godot_variant_new_int(godot_variant *p_v, const uint64_t p_i) { + Variant *v = (Variant *)p_v; + memnew_placement_custom(v, Variant, Variant(p_i)); +} + +void GDAPI godot_variant_new_real(godot_variant *p_v, const double p_r) { + Variant *v = (Variant *)p_v; + memnew_placement_custom(v, Variant, Variant(p_r)); +} + +void GDAPI godot_variant_new_string(godot_variant *p_v, const godot_string *p_s) { + Variant *v = (Variant *)p_v; + String *s = (String *)p_s; + memnew_placement_custom(v, Variant, Variant(*s)); +} + +void GDAPI godot_variant_new_vector2(godot_variant *p_v, const godot_vector2 *p_v2) { + Variant *v = (Variant *)p_v; + Vector2 *v2 = (Vector2 *)p_v2; + memnew_placement_custom(v, Variant, Variant(*v2)); +} + +void GDAPI godot_variant_new_rect2(godot_variant *p_v, const godot_rect2 *p_rect2) { + Variant *v = (Variant *)p_v; + Rect2 *rect2 = (Rect2 *)p_rect2; + memnew_placement_custom(v, Variant, Variant(*rect2)); +} + +void GDAPI godot_variant_new_vector3(godot_variant *p_v, const godot_vector3 *p_v3) { + Variant *v = (Variant *)p_v; + Vector3 *v3 = (Vector3 *)p_v3; + memnew_placement_custom(v, Variant, Variant(*v3)); +} + +void GDAPI godot_variant_new_transform2d(godot_variant *p_v, const godot_transform2d *p_t2d) { + Variant *v = (Variant *)p_v; + Transform2D *t2d = (Transform2D *)p_t2d; + memnew_placement_custom(v, Variant, Variant(*t2d)); +} + +void GDAPI godot_variant_new_plane(godot_variant *p_v, const godot_plane *p_plane) { + Variant *v = (Variant *)p_v; + Plane *plane = (Plane *)p_plane; + memnew_placement_custom(v, Variant, Variant(*plane)); +} + +void GDAPI godot_variant_new_quat(godot_variant *p_v, const godot_quat *p_quat) { + Variant *v = (Variant *)p_v; + Quat *quat = (Quat *)p_quat; + memnew_placement_custom(v, Variant, Variant(*quat)); +} + +void GDAPI godot_variant_new_rect3(godot_variant *p_v, const godot_rect3 *p_rect3) { + Variant *v = (Variant *)p_v; + Rect3 *rect3 = (Rect3 *)p_rect3; + memnew_placement_custom(v, Variant, Variant(*rect3)); +} + +void GDAPI godot_variant_new_basis(godot_variant *p_v, const godot_basis *p_basis) { + Variant *v = (Variant *)p_v; + Basis *basis = (Basis *)p_basis; + memnew_placement_custom(v, Variant, Variant(*basis)); +} + +void GDAPI godot_variant_new_transform(godot_variant *p_v, const godot_transform *p_trans) { + Variant *v = (Variant *)p_v; + Transform *trans = (Transform *)p_trans; + memnew_placement_custom(v, Variant, Variant(*trans)); +} + +void GDAPI godot_variant_new_color(godot_variant *p_v, const godot_color *p_color) { + Variant *v = (Variant *)p_v; + Color *color = (Color *)p_color; + memnew_placement_custom(v, Variant, Variant(*color)); +} + +void GDAPI godot_variant_new_image(godot_variant *p_v, const godot_image *p_img) { + Variant *v = (Variant *)p_v; + Image *img = (Image *)p_img; + memnew_placement_custom(v, Variant, Variant(*img)); +} + +void GDAPI godot_variant_new_node_path(godot_variant *p_v, const godot_node_path *p_np) { + Variant *v = (Variant *)p_v; + NodePath *np = (NodePath *)p_np; + memnew_placement_custom(v, Variant, Variant(*np)); +} + +void GDAPI godot_variant_new_rid(godot_variant *p_v, const godot_rid *p_rid) { + Variant *v = (Variant *)p_v; + RID *rid = (RID *)p_rid; + memnew_placement_custom(v, Variant, Variant(*rid)); +} + +void GDAPI godot_variant_new_object(godot_variant *p_v, const godot_object *p_obj) { + Variant *v = (Variant *)p_v; + Object *obj = (Object *)p_obj; + memnew_placement_custom(v, Variant, Variant(obj)); +} + +void GDAPI godot_variant_new_input_event(godot_variant *p_v, const godot_input_event *p_event) { + Variant *v = (Variant *)p_v; + InputEvent *event = (InputEvent *)p_event; + memnew_placement_custom(v, Variant, Variant(*event)); +} + +void GDAPI godot_variant_new_dictionary(godot_variant *p_v, const godot_dictionary *p_dict) { + Variant *v = (Variant *)p_v; + Dictionary *dict = (Dictionary *)p_dict; + memnew_placement_custom(v, Variant, Variant(*dict)); +} + +void GDAPI godot_variant_new_array(godot_variant *p_v, const godot_array *p_arr) { + Variant *v = (Variant *)p_v; + Array *arr = (Array *)p_arr; + memnew_placement_custom(v, Variant, Variant(*arr)); +} + +void GDAPI godot_variant_new_pool_byte_array(godot_variant *p_v, const godot_pool_byte_array *p_pba) { + Variant *v = (Variant *)p_v; + PoolByteArray *pba = (PoolByteArray *)p_pba; + memnew_placement_custom(v, Variant, Variant(*pba)); +} + +void GDAPI godot_variant_new_pool_int_array(godot_variant *p_v, const godot_pool_int_array *p_pia) { + Variant *v = (Variant *)p_v; + PoolIntArray *pia = (PoolIntArray *)p_pia; + memnew_placement_custom(v, Variant, Variant(*pia)); +} + +void GDAPI godot_variant_new_pool_real_array(godot_variant *p_v, const godot_pool_real_array *p_pra) { + Variant *v = (Variant *)p_v; + PoolRealArray *pra = (PoolRealArray *)p_pra; + memnew_placement_custom(v, Variant, Variant(*pra)); +} + +void GDAPI godot_variant_new_pool_string_array(godot_variant *p_v, const godot_pool_string_array *p_psa) { + Variant *v = (Variant *)p_v; + PoolStringArray *psa = (PoolStringArray *)p_psa; + memnew_placement_custom(v, Variant, Variant(*psa)); +} + +void GDAPI godot_variant_new_pool_vector2_array(godot_variant *p_v, const godot_pool_vector2_array *p_pv2a) { + Variant *v = (Variant *)p_v; + PoolVector2Array *pv2a = (PoolVector2Array *)p_pv2a; + memnew_placement_custom(v, Variant, Variant(*pv2a)); +} + +void GDAPI godot_variant_new_pool_vector3_array(godot_variant *p_v, const godot_pool_vector3_array *p_pv3a) { + Variant *v = (Variant *)p_v; + PoolVector3Array *pv3a = (PoolVector3Array *)p_pv3a; + memnew_placement_custom(v, Variant, Variant(*pv3a)); +} + +void GDAPI godot_variant_new_pool_color_array(godot_variant *p_v, const godot_pool_color_array *p_pca) { + Variant *v = (Variant *)p_v; + PoolColorArray *pca = (PoolColorArray *)p_pca; + memnew_placement_custom(v, Variant, Variant(*pca)); +} + +godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + return v->operator bool(); +} + +uint64_t GDAPI godot_variant_as_int(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + return v->operator godot_int(); +} + +godot_real GDAPI godot_variant_as_real(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + return v->operator godot_real(); +} + +godot_string GDAPI godot_variant_as_string(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_string s; + godot_string_new(&s); + String *str = (String *)&s; + *str = v->operator String(); + return s; +} + +godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_vector2 v2; + Vector2 *vec2 = (Vector2 *)&v2; + *vec2 = *v; + return v2; +} + +godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_rect2 r2; + Rect2 *rect2 = (Rect2 *)&r2; + *rect2 = *v; + return r2; +} + +godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_vector3 v3; + Vector3 *vec3 = (Vector3 *)&v3; + *vec3 = *v; + return v3; +} + +godot_transform2d GDAPI godot_variant_as_transform2d(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_transform2d t2; + Transform2D *t = (Transform2D *)&t2; + *t = *v; + return t2; +} + +godot_plane GDAPI godot_variant_as_plane(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_plane p; + Plane *pl = (Plane *)&p; + *pl = *v; + return p; +} + +godot_quat GDAPI godot_variant_as_quat(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_quat q; + Quat *qt = (Quat *)&q; + *qt = *v; + return q; +} + +godot_rect3 GDAPI godot_variant_as_rect3(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_rect3 r; + Rect3 *r3 = (Rect3 *)&r; + *r3 = *v; + return r; +} + +godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_basis b; + Basis *bs = (Basis *)&b; + *bs = *v; + return b; +} + +godot_transform GDAPI godot_variant_as_transform(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_transform t; + Transform *tr = (Transform *)&t; + *tr = *v; + return t; +} + +godot_color GDAPI godot_variant_as_color(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_color c; + Color *col = (Color *)&c; + *col = *v; + return c; +} + +godot_image GDAPI godot_variant_as_image(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_image img; + godot_image_new(&img); + Image *i = (Image *)&img; + *i = *v; + return img; +} + +godot_node_path GDAPI godot_variant_as_node_path(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_node_path np; + memnew_placement_custom((NodePath *)&np, NodePath, NodePath((String)*v)); + return np; +} + +godot_rid GDAPI godot_variant_as_rid(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_rid rid; + memnew_placement_custom((RID *)&rid, RID, RID(*v)); + return rid; +} + +godot_object GDAPI *godot_variant_as_object(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_object *p = NULL; + Object **op = (Object **)&p; + *op = *v; + return p; +} + +godot_input_event GDAPI godot_variant_as_input_event(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_input_event ev; + InputEvent *event = (InputEvent *)&ev; + *event = *v; + return ev; +} + +godot_dictionary GDAPI godot_variant_as_dictionary(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_dictionary dict; + godot_dictionary_new(&dict); + Dictionary *d = (Dictionary *)&dict; + *d = *v; + return dict; +} + +godot_array GDAPI godot_variant_as_array(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_array array; + godot_array_new(&array); + Array *a = (Array *)&array; + *a = *v; + return array; +} + +godot_pool_byte_array GDAPI godot_variant_as_pool_byte_array(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_pool_byte_array pba; + godot_pool_byte_array_new(&pba); + PoolByteArray *p = (PoolByteArray *)&pba; + *p = *v; + return pba; +} + +godot_pool_int_array GDAPI godot_variant_as_pool_int_array(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_pool_int_array pba; + godot_pool_int_array_new(&pba); + PoolIntArray *p = (PoolIntArray *)&pba; + *p = *v; + return pba; +} + +godot_pool_real_array GDAPI godot_variant_as_pool_real_array(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_pool_real_array pba; + godot_pool_real_array_new(&pba); + PoolRealArray *p = (PoolRealArray *)&pba; + *p = *v; + return pba; +} + +godot_pool_string_array GDAPI godot_variant_as_pool_string_array(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_pool_string_array pba; + godot_pool_string_array_new(&pba); + PoolStringArray *p = (PoolStringArray *)&pba; + *p = *v; + return pba; +} + +godot_pool_vector2_array GDAPI godot_variant_as_pool_vector2_array(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_pool_vector2_array pba; + godot_pool_vector2_array_new(&pba); + PoolVector2Array *p = (PoolVector2Array *)&pba; + *p = *v; + return pba; +} + +godot_pool_vector3_array GDAPI godot_variant_as_pool_vector3_array(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_pool_vector3_array pba; + godot_pool_vector3_array_new(&pba); + PoolVector3Array *p = (PoolVector3Array *)&pba; + *p = *v; + return pba; +} + +godot_pool_color_array GDAPI godot_variant_as_pool_color_array(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + godot_pool_color_array pba; + godot_pool_color_array_new(&pba); + PoolColorArray *p = (PoolColorArray *)&pba; + *p = *v; + return pba; +} + +godot_variant GDAPI godot_variant_call(godot_variant *p_v, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount /*, godot_variant_call_error *r_error */) { + Variant *v = (Variant *)p_v; + String *method = (String *)p_method; + Variant **args = (Variant **)p_args; + godot_variant res; + memnew_placement_custom((Variant *)&res, Variant, Variant(v->call(*method, args, p_argcount))); + return res; +} + +godot_bool GDAPI godot_variant_has_method(godot_variant *p_v, const godot_string *p_method) { + Variant *v = (Variant *)p_v; + String *method = (String *)p_method; + return v->has_method(*method); +} + +godot_bool GDAPI godot_variant_operator_equal(const godot_variant *p_a, const godot_variant *p_b) { + const Variant *a = (const Variant *)p_a; + const Variant *b = (const Variant *)p_b; + return a->operator==(*b); +} + +godot_bool GDAPI godot_variant_operator_less(const godot_variant *p_a, const godot_variant *p_b) { + const Variant *a = (const Variant *)p_a; + const Variant *b = (const Variant *)p_b; + return a->operator<(*b); +} + +godot_bool GDAPI godot_variant_hash_compare(const godot_variant *p_a, const godot_variant *p_b) { + const Variant *a = (const Variant *)p_a; + const Variant *b = (const Variant *)p_b; + return a->hash_compare(*b); +} + +godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_v, godot_bool *p_valid) { + const Variant *v = (const Variant *)p_v; + bool &valid = *p_valid; + return v->booleanize(valid); +} + +void GDAPI godot_variant_destroy(godot_variant *p_v) { + ((Variant *)p_v)->~Variant(); +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_variant.h b/modules/dlscript/godot/godot_variant.h new file mode 100644 index 0000000000..0b91af863d --- /dev/null +++ b/modules/dlscript/godot/godot_variant.h @@ -0,0 +1,148 @@ +#ifndef GODOT_VARIANT_H +#define GODOT_VARIANT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED +typedef struct godot_variant { + uint8_t _dont_touch_that[24]; +} godot_variant; +#endif + +struct godot_transform2d; +typedef struct godot_transform2d godot_transform2d; + +#include "godot_array.h" +#include "godot_dictionary.h" +#include "godot_input_event.h" +#include "godot_node_path.h" +#include "godot_rid.h" +#include "godot_transform2d.h" + +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, //sorry naming convention fail :( not like it's used often + GODOT_VARIANT_TYPE_BASIS, + GODOT_VARIANT_TYPE_TRANSFORM, + + // misc types + GODOT_VARIANT_TYPE_COLOR, + GODOT_VARIANT_TYPE_IMAGE, // 15 + GODOT_VARIANT_TYPE_NODE_PATH, + GODOT_VARIANT_TYPE_RID, + GODOT_VARIANT_TYPE_OBJECT, + GODOT_VARIANT_TYPE_INPUT_EVENT, + GODOT_VARIANT_TYPE_DICTIONARY, // 20 + GODOT_VARIANT_TYPE_ARRAY, + + // 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, // 25 + GODOT_VARIANT_TYPE_POOL_VECTOR2_ARRAY, + GODOT_VARIANT_TYPE_POOL_VECTOR3_ARRAY, + GODOT_VARIANT_TYPE_POOL_COLOR_ARRAY, +} godot_variant_type; + +godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_v); + +void GDAPI godot_variant_copy(godot_variant *p_dest, const godot_variant *p_src); + +void GDAPI godot_variant_new_nil(godot_variant *p_v); + +void GDAPI godot_variant_new_bool(godot_variant *p_v, const godot_bool p_b); +void GDAPI godot_variant_new_int(godot_variant *p_v, const uint64_t p_i); +void GDAPI godot_variant_new_real(godot_variant *p_v, const double p_r); +void GDAPI godot_variant_new_string(godot_variant *p_v, const godot_string *p_s); +void GDAPI godot_variant_new_vector2(godot_variant *p_v, const godot_vector2 *p_v2); +void GDAPI godot_variant_new_rect2(godot_variant *p_v, const godot_rect2 *p_rect2); +void GDAPI godot_variant_new_vector3(godot_variant *p_v, const godot_vector3 *p_v3); +void GDAPI godot_variant_new_transform2d(godot_variant *p_v, const godot_transform2d *p_t2d); +void GDAPI godot_variant_new_plane(godot_variant *p_v, const godot_plane *p_plane); +void GDAPI godot_variant_new_quat(godot_variant *p_v, const godot_quat *p_quat); +void GDAPI godot_variant_new_rect3(godot_variant *p_v, const godot_rect3 *p_rect3); +void GDAPI godot_variant_new_basis(godot_variant *p_v, const godot_basis *p_basis); +void GDAPI godot_variant_new_transform(godot_variant *p_v, const godot_transform *p_trans); +void GDAPI godot_variant_new_color(godot_variant *p_v, const godot_color *p_color); +void GDAPI godot_variant_new_image(godot_variant *p_v, const godot_image *p_img); +void GDAPI godot_variant_new_node_path(godot_variant *p_v, const godot_node_path *p_np); +void GDAPI godot_variant_new_rid(godot_variant *p_v, const godot_rid *p_rid); +void GDAPI godot_variant_new_object(godot_variant *p_v, const godot_object *p_obj); +void GDAPI godot_variant_new_input_event(godot_variant *p_v, const godot_input_event *p_event); +void GDAPI godot_variant_new_dictionary(godot_variant *p_v, const godot_dictionary *p_dict); +void GDAPI godot_variant_new_array(godot_variant *p_v, const godot_array *p_arr); +void GDAPI godot_variant_new_pool_byte_array(godot_variant *p_v, const godot_pool_byte_array *p_pba); +void GDAPI godot_variant_new_pool_int_array(godot_variant *p_v, const godot_pool_int_array *p_pia); +void GDAPI godot_variant_new_pool_real_array(godot_variant *p_v, const godot_pool_real_array *p_pra); +void GDAPI godot_variant_new_pool_string_array(godot_variant *p_v, const godot_pool_string_array *p_psa); +void GDAPI godot_variant_new_pool_vector2_array(godot_variant *p_v, const godot_pool_vector2_array *p_pv2a); +void GDAPI godot_variant_new_pool_vector3_array(godot_variant *p_v, const godot_pool_vector3_array *p_pv3a); +void GDAPI godot_variant_new_pool_color_array(godot_variant *p_v, const godot_pool_color_array *p_pca); + +godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_v); +uint64_t GDAPI godot_variant_as_int(const godot_variant *p_v); +godot_real GDAPI godot_variant_as_real(const godot_variant *p_v); +godot_string GDAPI godot_variant_as_string(const godot_variant *p_v); +godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_v); +godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_v); +godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_v); +godot_transform2d GDAPI godot_variant_as_transform2d(const godot_variant *p_v); +godot_plane GDAPI godot_variant_as_plane(const godot_variant *p_v); +godot_quat GDAPI godot_variant_as_quat(const godot_variant *p_v); +godot_rect3 GDAPI godot_variant_as_rect3(const godot_variant *p_v); +godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_v); +godot_transform GDAPI godot_variant_as_transform(const godot_variant *p_v); +godot_color GDAPI godot_variant_as_color(const godot_variant *p_v); +godot_image GDAPI godot_variant_as_image(const godot_variant *p_v); +godot_node_path GDAPI godot_variant_as_node_path(const godot_variant *p_v); +godot_rid GDAPI godot_variant_as_rid(const godot_variant *p_v); +godot_object GDAPI *godot_variant_as_object(const godot_variant *p_v); +godot_input_event GDAPI godot_variant_as_input_event(const godot_variant *p_v); +godot_dictionary GDAPI godot_variant_as_dictionary(const godot_variant *p_v); +godot_array GDAPI godot_variant_as_array(const godot_variant *p_v); +godot_pool_byte_array GDAPI godot_variant_as_pool_byte_array(const godot_variant *p_v); +godot_pool_int_array GDAPI godot_variant_as_pool_int_array(const godot_variant *p_v); +godot_pool_real_array GDAPI godot_variant_as_pool_real_array(const godot_variant *p_v); +godot_pool_string_array GDAPI godot_variant_as_pool_string_array(const godot_variant *p_v); +godot_pool_vector2_array GDAPI godot_variant_as_pool_vector2_array(const godot_variant *p_v); +godot_pool_vector3_array GDAPI godot_variant_as_pool_vector3_array(const godot_variant *p_v); +godot_pool_color_array GDAPI godot_variant_as_pool_color_array(const godot_variant *p_v); + +godot_variant GDAPI godot_variant_call(godot_variant *p_v, 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(godot_variant *p_v, const godot_string *p_method); + +godot_bool GDAPI godot_variant_operator_equal(const godot_variant *p_a, const godot_variant *p_b); +godot_bool GDAPI godot_variant_operator_less(const godot_variant *p_a, const godot_variant *p_b); + +godot_bool GDAPI godot_variant_hash_compare(const godot_variant *p_a, const godot_variant *p_b); + +godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_v, godot_bool *p_valid); + +void GDAPI godot_variant_destroy(godot_variant *p_v); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/modules/dlscript/godot/godot_vector2.cpp b/modules/dlscript/godot/godot_vector2.cpp new file mode 100644 index 0000000000..0664da186e --- /dev/null +++ b/modules/dlscript/godot/godot_vector2.cpp @@ -0,0 +1,124 @@ +#include "godot_vector2.h" + +#include "math/math_2d.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _vector2_api_anchor() { +} + +void GDAPI godot_vector2_new(godot_vector2 *p_v, godot_real p_x, godot_real p_y) { + Vector2 *v = (Vector2 *)p_v; + v->x = p_x; + v->y = p_y; +} + +void GDAPI godot_vector2_set_x(godot_vector2 *p_v, const godot_real p_x) { + Vector2 *v = (Vector2 *)p_v; + v->x = p_x; +} + +void GDAPI godot_vector2_set_y(godot_vector2 *p_v, const godot_real p_y) { + Vector2 *v = (Vector2 *)p_v; + v->y = p_y; +} + +godot_real GDAPI godot_vector2_get_x(const godot_vector2 *p_v) { + Vector2 *v = (Vector2 *)p_v; + return v->x; +} +godot_real GDAPI godot_vector2_get_y(const godot_vector2 *p_v) { + Vector2 *v = (Vector2 *)p_v; + return v->y; +} + +void GDAPI godot_vector2_normalize(godot_vector2 *p_v) { + Vector2 *v = (Vector2 *)p_v; + v->normalize(); +} +void GDAPI godot_vector2_normalized(godot_vector2 *p_dest, const godot_vector2 *p_src) { + Vector2 *v = (Vector2 *)p_src; + Vector2 *d = (Vector2 *)p_dest; + + *d = v->normalized(); +} + +godot_real GDAPI godot_vector2_length(const godot_vector2 *p_v) { + Vector2 *v = (Vector2 *)p_v; + return v->length(); +} + +godot_real GDAPI godot_vector2_length_squared(const godot_vector2 *p_v) { + Vector2 *v = (Vector2 *)p_v; + return v->length_squared(); +} + +godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_a, const godot_vector2 *p_b) { + Vector2 *a = (Vector2 *)p_a; + Vector2 *b = (Vector2 *)p_b; + return a->distance_to(*b); +} + +godot_real GDAPI godot_vector2_distance_squared_to(const godot_vector2 *p_a, const godot_vector2 *p_b) { + Vector2 *a = (Vector2 *)p_a; + Vector2 *b = (Vector2 *)p_b; + return a->distance_squared_to(*b); +} + +void GDAPI godot_vector2_operator_add(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_vector2 *p_b) { + Vector2 *dest = (Vector2 *)p_dest; + const Vector2 *a = (Vector2 *)p_a; + const Vector2 *b = (Vector2 *)p_b; + *dest = *a + *b; +} + +void GDAPI godot_vector2_operator_subtract(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_vector2 *p_b) { + Vector2 *dest = (Vector2 *)p_dest; + const Vector2 *a = (Vector2 *)p_a; + const Vector2 *b = (Vector2 *)p_b; + *dest = *a - *b; +} + +void GDAPI godot_vector2_operator_multiply_vector(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_vector2 *p_b) { + Vector2 *dest = (Vector2 *)p_dest; + const Vector2 *a = (Vector2 *)p_a; + const Vector2 *b = (Vector2 *)p_b; + *dest = *a * *b; +} + +void GDAPI godot_vector2_operator_multiply_scalar(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_real p_b) { + Vector2 *dest = (Vector2 *)p_dest; + const Vector2 *a = (Vector2 *)p_a; + *dest = *a * p_b; +} + +void GDAPI godot_vector2_operator_divide_vector(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_vector2 *p_b) { + Vector2 *dest = (Vector2 *)p_dest; + const Vector2 *a = (Vector2 *)p_a; + const Vector2 *b = (Vector2 *)p_b; + *dest = *a / *b; +} + +void GDAPI godot_vector2_operator_divide_scalar(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_real p_b) { + Vector2 *dest = (Vector2 *)p_dest; + const Vector2 *a = (Vector2 *)p_a; + *dest = *a / p_b; +} + +godot_bool GDAPI godot_vector2_operator_equal(const godot_vector2 *p_a, const godot_vector2 *p_b) { + const Vector2 *a = (Vector2 *)p_a; + const Vector2 *b = (Vector2 *)p_b; + return *a == *b; +} + +godot_bool GDAPI godot_vector2_operator_less(const godot_vector2 *p_a, const godot_vector2 *p_b) { + const Vector2 *a = (Vector2 *)p_a; + const Vector2 *b = (Vector2 *)p_b; + return *a < *b; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_vector2.h b/modules/dlscript/godot/godot_vector2.h new file mode 100644 index 0000000000..63da367e4f --- /dev/null +++ b/modules/dlscript/godot/godot_vector2.h @@ -0,0 +1,78 @@ +#ifndef GODOT_VECTOR2_H +#define GODOT_VECTOR2_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED +typedef struct godot_vector2 { + uint8_t _dont_touch_that[8]; +} godot_vector2; +#endif + +#include "../godot.h" + +void GDAPI godot_vector2_new(godot_vector2 *p_v, const godot_real p_x, const godot_real p_y); + +void GDAPI godot_vector2_set_x(godot_vector2 *p_v, const godot_real p_x); +void GDAPI godot_vector2_set_y(godot_vector2 *p_v, const godot_real p_y); +godot_real GDAPI godot_vector2_get_x(const godot_vector2 *p_v); +godot_real GDAPI godot_vector2_get_y(const godot_vector2 *p_v); + +void GDAPI godot_vector2_normalize(godot_vector2 *p_v); +void GDAPI godot_vector2_normalized(godot_vector2 *p_dest, const godot_vector2 *p_src); + +godot_real GDAPI godot_vector2_length(const godot_vector2 *p_v); +godot_real GDAPI godot_vector2_length_squared(const godot_vector2 *p_v); + +godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_a, const godot_vector2 *p_b); +godot_real GDAPI godot_vector2_distance_squared_to(const godot_vector2 *p_a, const godot_vector2 *p_b); + +// @Incomplete +/* + * missing: + * + * angle_to + * angle_to_point + * dot + * cross_vector + * cross_scalar + * project + * plane_project + * clamped + * linear_interpolate + * cubic_interpolate + * cubic_interpolate_soft + * slide + * reflect + * angle + * abs + * rotated + * tangent + * floor + * snapped + * aspect + * + * + * to_string + */ + +void GDAPI godot_vector2_operator_add(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_vector2 *p_b); +void GDAPI godot_vector2_operator_subtract(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_vector2 *p_b); +void GDAPI godot_vector2_operator_multiply_vector(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_vector2 *p_b); +void GDAPI godot_vector2_operator_multiply_scalar(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_real p_b); +void GDAPI godot_vector2_operator_divide_vector(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_vector2 *p_b); +void GDAPI godot_vector2_operator_divide_scalar(godot_vector2 *p_dest, const godot_vector2 *p_a, const godot_real p_b); + +godot_bool GDAPI godot_vector2_operator_equal(const godot_vector2 *p_a, const godot_vector2 *p_b); +godot_bool GDAPI godot_vector2_operator_less(const godot_vector2 *p_a, const godot_vector2 *p_b); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_VECTOR2_H diff --git a/modules/dlscript/godot/godot_vector3.cpp b/modules/dlscript/godot/godot_vector3.cpp new file mode 100644 index 0000000000..34005cbcb8 --- /dev/null +++ b/modules/dlscript/godot/godot_vector3.cpp @@ -0,0 +1,150 @@ +#include "godot_vector3.h" + +#include "math/vector3.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void _vector3_api_anchor() { +} + +void GDAPI godot_vector3_new(godot_vector3 *p_v, const godot_real p_x, const godot_real p_y, const godot_real p_z) { + Vector3 *v = (Vector3 *)p_v; + *v = Vector3(p_x, p_y, p_z); +} + +void GDAPI godot_vector3_set_axis(godot_vector3 *p_v, const godot_int p_axis, const godot_real p_val) { + Vector3 *v = (Vector3 *)p_v; + v->set_axis(p_axis, p_val); +} + +godot_real GDAPI godot_vector3_get_axis(const godot_vector3 *p_v, const godot_int p_axis) { + Vector3 *v = (Vector3 *)p_v; + return v->get_axis(p_axis); +} + +godot_int GDAPI godot_vector3_min_axis(const godot_vector3 *p_v) { + Vector3 *v = (Vector3 *)p_v; + return v->min_axis(); +} + +godot_int GDAPI godot_vector3_max_axis(const godot_vector3 *p_v) { + Vector3 *v = (Vector3 *)p_v; + return v->max_axis(); +} + +godot_real GDAPI godot_vector3_length(const godot_vector3 *p_v) { + Vector3 *v = (Vector3 *)p_v; + return v->length(); +} + +godot_real GDAPI godot_vector3_length_squared(const godot_vector3 *p_v) { + Vector3 *v = (Vector3 *)p_v; + return v->length_squared(); +} + +void GDAPI godot_vector3_normalize(godot_vector3 *p_v) { + Vector3 *v = (Vector3 *)p_v; + v->normalize(); +} + +void GDAPI godot_vector3_normalized(godot_vector3 *p_dest, const godot_vector3 *p_src) { + Vector3 *src = (Vector3 *)p_src; + Vector3 *dest = (Vector3 *)p_dest; + *dest = src->normalized(); +} + +/* + * inverse + * zero + * snap + * snapped + * rotate + * rotated + * + * + * linear_interpolate + * cubic_interpolate + * cubic_interpolaten + * cross + * dot + * outer + * to_diagonal_matrix + * abs + * floor + * ceil + */ + +godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_a, const godot_vector3 *p_b) { + Vector3 *a = (Vector3 *)p_a; + Vector3 *b = (Vector3 *)p_b; + return a->distance_to(*b); +} + +godot_real GDAPI godot_vector3_distance_squared_to(const godot_vector3 *p_a, const godot_vector3 *p_b) { + Vector3 *a = (Vector3 *)p_a; + Vector3 *b = (Vector3 *)p_b; + return a->distance_squared_to(*b); +} + +/* + * slide + * reflect + */ + +void GDAPI godot_vector3_operator_add(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b) { + Vector3 *dest = (Vector3 *)p_dest; + Vector3 *a = (Vector3 *)p_a; + Vector3 *b = (Vector3 *)p_b; + *dest = *a + *b; +} + +void GDAPI godot_vector3_operator_subtract(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b) { + Vector3 *dest = (Vector3 *)p_dest; + Vector3 *a = (Vector3 *)p_a; + Vector3 *b = (Vector3 *)p_b; + *dest = *a - *b; +} + +void GDAPI godot_vector3_operator_multiply_vector(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b) { + Vector3 *dest = (Vector3 *)p_dest; + Vector3 *a = (Vector3 *)p_a; + Vector3 *b = (Vector3 *)p_b; + *dest = *a * *b; +} + +void GDAPI godot_vector3_operator_multiply_scalar(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_real p_b) { + Vector3 *dest = (Vector3 *)p_dest; + Vector3 *a = (Vector3 *)p_a; + *dest = *a * p_b; +} + +void GDAPI godot_vector3_operator_divide_vector(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b) { + Vector3 *dest = (Vector3 *)p_dest; + Vector3 *a = (Vector3 *)p_a; + Vector3 *b = (Vector3 *)p_b; + *dest = *a / *b; +} + +void GDAPI godot_vector3_operator_divide_scalar(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_real p_b) { + Vector3 *dest = (Vector3 *)p_dest; + Vector3 *a = (Vector3 *)p_a; + *dest = *a / p_b; +} + +godot_bool GDAPI godot_vector3_operator_equal(const godot_vector3 *p_a, const godot_vector3 *p_b) { + Vector3 *a = (Vector3 *)p_a; + Vector3 *b = (Vector3 *)p_b; + return *a == *b; +} + +godot_bool GDAPI godot_vector3_operator_less(const godot_vector3 *p_a, const godot_vector3 *p_b) { + Vector3 *a = (Vector3 *)p_a; + Vector3 *b = (Vector3 *)p_b; + return *a < *b; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/dlscript/godot/godot_vector3.h b/modules/dlscript/godot/godot_vector3.h new file mode 100644 index 0000000000..7fe93e3fd5 --- /dev/null +++ b/modules/dlscript/godot/godot_vector3.h @@ -0,0 +1,82 @@ +#ifndef GODOT_VECTOR3_H +#define GODOT_VECTOR3_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#ifndef GODOT_CORE_API_GODOT_VECTOR3_TYPE_DEFINED +typedef struct godot_vector3 { + uint8_t _dont_touch_that[12]; +} godot_vector3; +#endif + +#include "../godot.h" + +void GDAPI godot_vector3_new(godot_vector3 *p_v, const godot_real p_x, const godot_real p_y, const godot_real p_z); + +void GDAPI godot_vector3_set_axis(godot_vector3 *p_v, const godot_int p_axis, const godot_real p_val); +godot_real GDAPI godot_vector3_get_axis(const godot_vector3 *p_v, const godot_int p_axis); + +godot_int GDAPI godot_vector3_min_axis(const godot_vector3 *p_v); +godot_int GDAPI godot_vector3_max_axis(const godot_vector3 *p_v); + +godot_real GDAPI godot_vector3_length(const godot_vector3 *p_v); +godot_real GDAPI godot_vector3_length_squared(const godot_vector3 *p_v); + +void GDAPI godot_vector3_normalize(godot_vector3 *p_v); +void GDAPI godot_vector3_normalized(godot_vector3 *p_dest, const godot_vector3 *p_src); + +// @Incomplete + +/* + * inverse + * zero + * snap + * snapped + * rotate + * rotated + * + * + * linear_interpolate + * cubic_interpolate + * cubic_interpolaten + * cross + * dot + * outer + * to_diagonal_matrix + * abs + * floor + * ceil + */ + +godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_a, const godot_vector3 *p_b); +godot_real GDAPI godot_vector3_distance_squared_to(const godot_vector3 *p_a, const godot_vector3 *p_b); + +// @Incomplete +/* + * slide + * reflect + */ + +void GDAPI godot_vector3_operator_add(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b); +void GDAPI godot_vector3_operator_subtract(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b); +void GDAPI godot_vector3_operator_multiply_vector(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b); +void GDAPI godot_vector3_operator_multiply_scalar(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_real p_b); +void GDAPI godot_vector3_operator_divide_vector(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_vector3 *p_b); +void GDAPI godot_vector3_operator_divide_scalar(godot_vector3 *p_dest, const godot_vector3 *p_a, const godot_real p_b); + +godot_bool GDAPI godot_vector3_operator_equal(const godot_vector3 *p_a, const godot_vector3 *p_b); +godot_bool GDAPI godot_vector3_operator_less(const godot_vector3 *p_a, const godot_vector3 *p_b); + +/* + * to_string + */ + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_VECTOR3_H |