diff options
71 files changed, 2448 insertions, 1300 deletions
diff --git a/modules/dlscript/api_generator.h b/modules/dlscript/api_generator.h deleted file mode 100644 index 4a8354e9d6..0000000000 --- a/modules/dlscript/api_generator.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef API_GENERATOR_H -#define API_GENERATOR_H - -#include "core/ustring.h" -#include "typedefs.h" - -Error generate_c_api(const String &p_path); - -#endif // API_GENERATOR_H diff --git a/modules/dlscript/godot/godot_basis.cpp b/modules/dlscript/godot/godot_basis.cpp deleted file mode 100644 index 813a531de5..0000000000 --- a/modules/dlscript/godot/godot_basis.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#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 deleted file mode 100644 index 43efd65ea2..0000000000 --- a/modules/dlscript/godot/godot_basis.h +++ /dev/null @@ -1,34 +0,0 @@ -#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 deleted file mode 100644 index 7e49565d40..0000000000 --- a/modules/dlscript/godot/godot_color.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#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 deleted file mode 100644 index 72e16a2c5a..0000000000 --- a/modules/dlscript/godot/godot_color.h +++ /dev/null @@ -1,29 +0,0 @@ -#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.h b/modules/dlscript/godot/godot_dictionary.h deleted file mode 100644 index 5f86cbca5a..0000000000 --- a/modules/dlscript/godot/godot_dictionary.h +++ /dev/null @@ -1,51 +0,0 @@ -#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_node_path.h b/modules/dlscript/godot/godot_node_path.h deleted file mode 100644 index 04f1e70c1d..0000000000 --- a/modules/dlscript/godot/godot_node_path.h +++ /dev/null @@ -1,39 +0,0 @@ -#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); -void GDAPI godot_node_path_copy(godot_node_path *p_np, const godot_node_path *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 deleted file mode 100644 index 883aeb6282..0000000000 --- a/modules/dlscript/godot/godot_plane.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#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 deleted file mode 100644 index 1323ef4075..0000000000 --- a/modules/dlscript/godot/godot_plane.h +++ /dev/null @@ -1,37 +0,0 @@ -#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_quat.cpp b/modules/dlscript/godot/godot_quat.cpp deleted file mode 100644 index 9bd2eb0639..0000000000 --- a/modules/dlscript/godot/godot_quat.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "godot_quat.h" - -#include "math/quat.h" - -#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 deleted file mode 100644 index 4e3253c4e5..0000000000 --- a/modules/dlscript/godot/godot_quat.h +++ /dev/null @@ -1,33 +0,0 @@ -#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 deleted file mode 100644 index 8e60811114..0000000000 --- a/modules/dlscript/godot/godot_rect2.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#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 deleted file mode 100644 index a3b19bdb7e..0000000000 --- a/modules/dlscript/godot/godot_rect2.h +++ /dev/null @@ -1,31 +0,0 @@ -#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 deleted file mode 100644 index 3c442a278b..0000000000 --- a/modules/dlscript/godot/godot_rect3.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#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 deleted file mode 100644 index b9279616d1..0000000000 --- a/modules/dlscript/godot/godot_rect3.h +++ /dev/null @@ -1,31 +0,0 @@ -#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 deleted file mode 100644 index a36a2e64a3..0000000000 --- a/modules/dlscript/godot/godot_rid.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#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 deleted file mode 100644 index f20c0d4dae..0000000000 --- a/modules/dlscript/godot/godot_rid.h +++ /dev/null @@ -1,28 +0,0 @@ -#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 deleted file mode 100644 index 97d0985a50..0000000000 --- a/modules/dlscript/godot/godot_string.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "godot_string.h" - -#include "string_db.h" -#include "ustring.h" - -#include <string.h> - -#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 deleted file mode 100644 index 73b366d9cd..0000000000 --- a/modules/dlscript/godot/godot_string.h +++ /dev/null @@ -1,42 +0,0 @@ -#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 deleted file mode 100644 index c8da519f6b..0000000000 --- a/modules/dlscript/godot/godot_transform.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "godot_transform.h" - -#include "math/transform.h" - -#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 deleted file mode 100644 index 54af78d5b9..0000000000 --- a/modules/dlscript/godot/godot_transform.h +++ /dev/null @@ -1,29 +0,0 @@ -#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 deleted file mode 100644 index 39fa0e7363..0000000000 --- a/modules/dlscript/godot/godot_transform2d.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#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 deleted file mode 100644 index 7403954527..0000000000 --- a/modules/dlscript/godot/godot_transform2d.h +++ /dev/null @@ -1,48 +0,0 @@ -#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/SCsub b/modules/gdnative/SCsub index ac13319a1d..ac13319a1d 100644 --- a/modules/dlscript/SCsub +++ b/modules/gdnative/SCsub diff --git a/modules/dlscript/api_generator.cpp b/modules/gdnative/api_generator.cpp index 1de3f6d520..f5d010f0a2 100644 --- a/modules/dlscript/api_generator.cpp +++ b/modules/gdnative/api_generator.cpp @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* api_generator.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "api_generator.h" #ifdef TOOLS_ENABLED diff --git a/modules/gdnative/api_generator.h b/modules/gdnative/api_generator.h new file mode 100644 index 0000000000..a108d7a7b6 --- /dev/null +++ b/modules/gdnative/api_generator.h @@ -0,0 +1,38 @@ +/*************************************************************************/ +/* api_generator.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef API_GENERATOR_H +#define API_GENERATOR_H + +#include "core/ustring.h" +#include "typedefs.h" + +Error generate_c_api(const String &p_path); + +#endif // API_GENERATOR_H diff --git a/modules/dlscript/config.py b/modules/gdnative/config.py index 9f57b9bb74..9f57b9bb74 100644 --- a/modules/dlscript/config.py +++ b/modules/gdnative/config.py diff --git a/modules/dlscript/dl_script.cpp b/modules/gdnative/gdnative.cpp index fa082d7b94..43b309ae36 100644 --- a/modules/dlscript/dl_script.cpp +++ b/modules/gdnative/gdnative.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* dl_script.cpp */ +/* gdnative.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "dl_script.h" +#include "gdnative.h" #include "global_config.h" #include "global_constants.h" @@ -48,8 +48,8 @@ Error NativeLibrary::initialize(NativeLibrary *&p_native_lib, const StringName p_path) { - if (DLScriptLanguage::get_singleton()->initialized_libraries.has(p_path)) { - p_native_lib = DLScriptLanguage::get_singleton()->initialized_libraries[p_path]; + if (GDNativeScriptLanguage::get_singleton()->initialized_libraries.has(p_path)) { + p_native_lib = GDNativeScriptLanguage::get_singleton()->initialized_libraries[p_path]; return OK; } @@ -68,13 +68,13 @@ Error NativeLibrary::initialize(NativeLibrary *&p_native_lib, const StringName p // Get the method void *library_init; - error = OS::get_singleton()->get_dynamic_library_symbol_handle(lib->handle, DLScriptLanguage::get_init_symbol_name(), library_init); + error = OS::get_singleton()->get_dynamic_library_symbol_handle(lib->handle, GDNativeScriptLanguage::get_init_symbol_name(), library_init); if (error) return error; ERR_FAIL_COND_V(!library_init, ERR_BUG); - void (*library_init_fpointer)(godot_dlscript_init_options *) = (void (*)(godot_dlscript_init_options *))library_init; + void (*library_init_fpointer)(godot_native_init_options *) = (void (*)(godot_native_init_options *))library_init; - godot_dlscript_init_options options; + godot_native_init_options options; options.in_editor = SceneTree::get_singleton()->is_editor_hint(); /* @@ -85,14 +85,14 @@ Error NativeLibrary::initialize(NativeLibrary *&p_native_lib, const StringName p library_init_fpointer(&options); // Catch errors? - DLScriptLanguage::get_singleton()->initialized_libraries[p_path] = lib; + GDNativeScriptLanguage::get_singleton()->initialized_libraries[p_path] = lib; return OK; } Error NativeLibrary::terminate(NativeLibrary *&p_native_lib) { - if (!DLScriptLanguage::get_singleton()->initialized_libraries.has(p_native_lib->path)) { + if (!GDNativeScriptLanguage::get_singleton()->initialized_libraries.has(p_native_lib->path)) { OS::get_singleton()->close_dynamic_library(p_native_lib->handle); p_native_lib->handle = 0; return OK; @@ -100,18 +100,18 @@ Error NativeLibrary::terminate(NativeLibrary *&p_native_lib) { Error error = OK; void *library_terminate; - error = OS::get_singleton()->get_dynamic_library_symbol_handle(p_native_lib->handle, DLScriptLanguage::get_terminate_symbol_name(), library_terminate); + error = OS::get_singleton()->get_dynamic_library_symbol_handle(p_native_lib->handle, GDNativeScriptLanguage::get_terminate_symbol_name(), library_terminate); if (error) return OK; // no terminate? okay, not that important lol - void (*library_terminate_pointer)(godot_dlscript_terminate_options *) = (void (*)(godot_dlscript_terminate_options *))library_terminate; + void (*library_terminate_pointer)(godot_native_terminate_options *) = (void (*)(godot_native_terminate_options *))library_terminate; - godot_dlscript_terminate_options options; + godot_native_terminate_options options; options.in_editor = SceneTree::get_singleton()->is_editor_hint(); library_terminate_pointer(&options); - DLScriptLanguage::get_singleton()->initialized_libraries.erase(p_native_lib->path); + GDNativeScriptLanguage::get_singleton()->initialized_libraries.erase(p_native_lib->path); OS::get_singleton()->close_dynamic_library(p_native_lib->handle); p_native_lib->handle = 0; @@ -122,12 +122,13 @@ Error NativeLibrary::terminate(NativeLibrary *&p_native_lib) { // Script #ifdef TOOLS_ENABLED -void DLScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) { +void GDNativeScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) { + ERR_FAIL_COND(!script_data); List<PropertyInfo> pinfo; Map<StringName, Variant> values; - for (Map<StringName, DLScriptData::Property>::Element *E = script_data->properties.front(); E; E = E->next()) { + for (Map<StringName, GDNativeScriptData::Property>::Element *E = script_data->properties.front(); E; E = E->next()) { PropertyInfo p = E->get().info; p.name = String(E->key()); pinfo.push_back(p); @@ -137,24 +138,24 @@ void DLScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) { p_placeholder->update(pinfo, values); } -void DLScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) { +void GDNativeScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) { placeholders.erase(p_placeholder); } #endif -bool DLScript::can_instance() const { -#ifdef DLSCRIPT_EDITOR_FEATURES +bool GDNativeScript::can_instance() const { +#ifdef TOOLS_ENABLED return script_data || (!is_tool() && !ScriptServer::is_scripting_enabled()); #else // allow defaultlibrary without editor features if (!library.is_valid()) { - String path = GLOBAL_GET("dlscript/default_dllibrary"); + String path = GLOBAL_GET("gdnative/default_gdnativelibrary"); RES lib = ResourceLoader::load(path); - if (lib.is_valid() && lib->cast_to<DLLibrary>()) { + if (lib.is_valid() && lib->cast_to<GDNativeLibrary>()) { return true; } } @@ -165,28 +166,27 @@ bool DLScript::can_instance() const { // change to true enable in editor stuff. } -Ref<Script> DLScript::get_base_script() const { - Ref<DLScript> base_script; +Ref<Script> GDNativeScript::get_base_script() const { + Ref<GDNativeScript> base_script; base_script->library = library; base_script->script_data = script_data; base_script->script_name = script_data->base; return base_script; } -StringName DLScript::get_instance_base_type() const { +StringName GDNativeScript::get_instance_base_type() const { return script_data->base_native_type; } -ScriptInstance *DLScript::instance_create(Object *p_this) { +ScriptInstance *GDNativeScript::instance_create(Object *p_this) { #ifdef TOOLS_ENABLED -// find a good way to initialize stuff in the editor -#ifdef DLSCRIPT_EDITOR_FEATURES + // find a good way to initialize stuff in the editor if (!ScriptServer::is_scripting_enabled() && !is_tool()) { // placeholder, for nodes. But for tools we want the real thing - PlaceHolderScriptInstance *sins = memnew(PlaceHolderScriptInstance(DLScriptLanguage::singleton, Ref<Script>((Script *)this), p_this)); + PlaceHolderScriptInstance *sins = memnew(PlaceHolderScriptInstance(GDNativeScriptLanguage::singleton, Ref<Script>((Script *)this), p_this)); placeholders.insert(sins); if (!library.is_valid()) @@ -210,26 +210,25 @@ ScriptInstance *DLScript::instance_create(Object *p_this) { return sins; } -#endif #endif if (!library.is_valid()) { - String path = GLOBAL_GET("dlscript/default_dllibrary"); + String path = GLOBAL_GET("gdnative/default_gdnativelibrary"); RES lib = ResourceLoader::load(path); - if (lib.is_valid() && lib->cast_to<DLLibrary>()) { + if (lib.is_valid() && lib->cast_to<GDNativeLibrary>()) { set_library(lib); } } - DLInstance *new_instance = memnew(DLInstance); + GDNativeInstance *new_instance = memnew(GDNativeInstance); new_instance->owner = p_this; - new_instance->script = Ref<DLScript>(this); + new_instance->script = Ref<GDNativeScript>(this); -#ifndef DLSCRIPT_EDITOR_FEATURES +#ifndef TOOLS_ENABLED if (!ScriptServer::is_scripting_enabled()) { new_instance->userdata = 0; } else { @@ -243,26 +242,26 @@ ScriptInstance *DLScript::instance_create(Object *p_this) { return new_instance; } -bool DLScript::instance_has(const Object *p_this) const { +bool GDNativeScript::instance_has(const Object *p_this) const { return instances.has((Object *)p_this); // TODO } -bool DLScript::has_source_code() const { +bool GDNativeScript::has_source_code() const { return false; } -String DLScript::get_source_code() const { +String GDNativeScript::get_source_code() const { return ""; } -Error DLScript::reload(bool p_keep_state) { +Error GDNativeScript::reload(bool p_keep_state) { return FAILED; } -bool DLScript::has_method(const StringName &p_method) const { +bool GDNativeScript::has_method(const StringName &p_method) const { if (!script_data) return false; - DLScriptData *data = script_data; + GDNativeScriptData *data = script_data; while (data) { if (data->methods.has(p_method)) @@ -274,10 +273,10 @@ bool DLScript::has_method(const StringName &p_method) const { return false; } -MethodInfo DLScript::get_method_info(const StringName &p_method) const { +MethodInfo GDNativeScript::get_method_info(const StringName &p_method) const { if (!script_data) return MethodInfo(); - DLScriptData *data = script_data; + GDNativeScriptData *data = script_data; while (data) { if (data->methods.has(p_method)) @@ -290,14 +289,14 @@ MethodInfo DLScript::get_method_info(const StringName &p_method) const { return MethodInfo(); } -void DLScript::get_script_method_list(List<MethodInfo> *p_list) const { +void GDNativeScript::get_script_method_list(List<MethodInfo> *p_list) const { if (!script_data) return; Set<MethodInfo> methods; - DLScriptData *data = script_data; + GDNativeScriptData *data = script_data; while (data) { - for (Map<StringName, DLScriptData::Method>::Element *E = data->methods.front(); E; E = E->next()) { + for (Map<StringName, GDNativeScriptData::Method>::Element *E = data->methods.front(); E; E = E->next()) { methods.insert(E->get().info); } data = data->base_data; @@ -308,14 +307,14 @@ void DLScript::get_script_method_list(List<MethodInfo> *p_list) const { } } -void DLScript::get_script_property_list(List<PropertyInfo> *p_list) const { +void GDNativeScript::get_script_property_list(List<PropertyInfo> *p_list) const { if (!script_data) return; Set<PropertyInfo> properties; - DLScriptData *data = script_data; + GDNativeScriptData *data = script_data; while (data) { - for (Map<StringName, DLScriptData::Property>::Element *E = data->properties.front(); E; E = E->next()) { + for (Map<StringName, GDNativeScriptData::Property>::Element *E = data->properties.front(); E; E = E->next()) { properties.insert(E->get().info); } data = data->base_data; @@ -326,10 +325,10 @@ void DLScript::get_script_property_list(List<PropertyInfo> *p_list) const { } } -bool DLScript::get_property_default_value(const StringName &p_property, Variant &r_value) const { +bool GDNativeScript::get_property_default_value(const StringName &p_property, Variant &r_value) const { if (!script_data) return false; - DLScriptData *data = script_data; + GDNativeScriptData *data = script_data; while (data) { if (data->properties.has(p_property)) { @@ -343,24 +342,24 @@ bool DLScript::get_property_default_value(const StringName &p_property, Variant return false; } -bool DLScript::is_tool() const { +bool GDNativeScript::is_tool() const { ERR_FAIL_COND_V(!script_data, false); return script_data->is_tool; } -String DLScript::get_node_type() const { +String GDNativeScript::get_node_type() const { return ""; // ? } -ScriptLanguage *DLScript::get_language() const { - return DLScriptLanguage::singleton; +ScriptLanguage *GDNativeScript::get_language() const { + return GDNativeScriptLanguage::singleton; } -bool DLScript::has_script_signal(const StringName &p_signal) const { +bool GDNativeScript::has_script_signal(const StringName &p_signal) const { if (!script_data) return false; - DLScriptData *data = script_data; + GDNativeScriptData *data = script_data; while (data) { if (data->signals_.has(p_signal)) { @@ -373,16 +372,16 @@ bool DLScript::has_script_signal(const StringName &p_signal) const { return false; } -void DLScript::get_script_signal_list(List<MethodInfo> *r_signals) const { +void GDNativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const { if (!script_data) return; Set<MethodInfo> signals_; - DLScriptData *data = script_data; + GDNativeScriptData *data = script_data; while (data) { - for (Map<StringName, DLScriptData::Signal>::Element *S = data->signals_.front(); S; S = S->next()) { + for (Map<StringName, GDNativeScriptData::Signal>::Element *S = data->signals_.front(); S; S = S->next()) { signals_.insert(S->get().signal); } @@ -394,11 +393,11 @@ void DLScript::get_script_signal_list(List<MethodInfo> *r_signals) const { } } -Ref<DLLibrary> DLScript::get_library() const { +Ref<GDNativeLibrary> GDNativeScript::get_library() const { return library; } -void DLScript::set_library(Ref<DLLibrary> p_library) { +void GDNativeScript::set_library(Ref<GDNativeLibrary> p_library) { library = p_library; #ifdef TOOLS_ENABLED @@ -415,15 +414,15 @@ void DLScript::set_library(Ref<DLLibrary> p_library) { } } -StringName DLScript::get_script_name() const { +StringName GDNativeScript::get_script_name() const { return script_name; } -void DLScript::set_script_name(StringName p_script_name) { +void GDNativeScript::set_script_name(StringName p_script_name) { script_name = p_script_name; if (library.is_valid()) { -#ifdef DLSCRIPT_EDITOR_FEATURES +#ifdef TOOLS_ENABLED if (!library->native_library) { library->_initialize(); } @@ -435,31 +434,31 @@ void DLScript::set_script_name(StringName p_script_name) { } } -void DLScript::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_library"), &DLScript::get_library); - ClassDB::bind_method(D_METHOD("set_library", "library"), &DLScript::set_library); - ClassDB::bind_method(D_METHOD("get_script_name"), &DLScript::get_script_name); - ClassDB::bind_method(D_METHOD("set_script_name", "script_name"), &DLScript::set_script_name); +void GDNativeScript::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_library"), &GDNativeScript::get_library); + ClassDB::bind_method(D_METHOD("set_library", "library"), &GDNativeScript::set_library); + ClassDB::bind_method(D_METHOD("get_script_name"), &GDNativeScript::get_script_name); + ClassDB::bind_method(D_METHOD("set_script_name", "script_name"), &GDNativeScript::set_script_name); - ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "DLLibrary"), "set_library", "get_library"); + ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library"); ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "script_name"), "set_script_name", "get_script_name"); } -DLScript::DLScript() { +GDNativeScript::GDNativeScript() { script_data = NULL; - DLScriptLanguage::get_singleton()->script_list.insert(this); + GDNativeScriptLanguage::get_singleton()->script_list.insert(this); } -DLScript::~DLScript() { +GDNativeScript::~GDNativeScript() { //hmm - DLScriptLanguage::get_singleton()->script_list.erase(this); + GDNativeScriptLanguage::get_singleton()->script_list.erase(this); } // Library -DLLibrary *DLLibrary::currently_initialized_library = NULL; +GDNativeLibrary *GDNativeLibrary::currently_initialized_library = NULL; -DLLibrary *DLLibrary::get_currently_initialized_library() { +GDNativeLibrary *GDNativeLibrary::get_currently_initialized_library() { return currently_initialized_library; } @@ -479,7 +478,7 @@ static const char *_dl_platforms_info[] = { NULL // Finishing condition }; -void DLLibrary::set_platform_file(StringName p_platform, String p_file) { +void GDNativeLibrary::set_platform_file(StringName p_platform, String p_file) { if (p_file.empty()) { platform_files.erase(p_platform); } else { @@ -487,7 +486,7 @@ void DLLibrary::set_platform_file(StringName p_platform, String p_file) { } } -String DLLibrary::get_platform_file(StringName p_platform) const { +String GDNativeLibrary::get_platform_file(StringName p_platform) const { if (platform_files.has(p_platform)) { return platform_files[p_platform]; } else { @@ -495,7 +494,7 @@ String DLLibrary::get_platform_file(StringName p_platform) const { } } -Error DLLibrary::_initialize() { +Error GDNativeLibrary::_initialize() { _THREAD_SAFE_METHOD_ // Get the file @@ -529,24 +528,24 @@ Error DLLibrary::_initialize() { StringName path = GlobalConfig::get_singleton()->globalize_path(platform_file); - DLLibrary::currently_initialized_library = this; + GDNativeLibrary::currently_initialized_library = this; Error ret = NativeLibrary::initialize(native_library, path); native_library->dllib = this; - DLLibrary::currently_initialized_library = NULL; + GDNativeLibrary::currently_initialized_library = NULL; return ret; } -Error DLLibrary::_terminate() { +Error GDNativeLibrary::_terminate() { ERR_FAIL_COND_V(!native_library, ERR_BUG); ERR_FAIL_COND_V(!native_library->handle, ERR_BUG); // de-init stuff - for (Map<StringName, DLScriptData *>::Element *E = native_library->scripts.front(); E; E = E->next()) { - for (Map<StringName, DLScriptData::Method>::Element *M = E->get()->methods.front(); M; M = M->next()) { + for (Map<StringName, GDNativeScriptData *>::Element *E = native_library->scripts.front(); E; E = E->next()) { + for (Map<StringName, GDNativeScriptData::Method>::Element *M = E->get()->methods.front(); M; M = M->next()) { if (M->get().method.free_func) { M->get().method.free_func(M->get().method.method_data); } @@ -558,7 +557,7 @@ Error DLLibrary::_terminate() { E->get()->destroy_func.free_func(E->get()->destroy_func.method_data); } - for (Set<DLScript *>::Element *S = DLScriptLanguage::get_singleton()->script_list.front(); S; S = S->next()) { + for (Set<GDNativeScript *>::Element *S = GDNativeScriptLanguage::get_singleton()->script_list.front(); S; S = S->next()) { if (S->get()->script_data == E->get()) { S->get()->script_data = NULL; } @@ -574,15 +573,15 @@ Error DLLibrary::_terminate() { return ret; } -void DLLibrary::_register_script(const StringName p_name, const StringName p_base, godot_instance_create_func p_instance_func, godot_instance_destroy_func p_destroy_func) { +void GDNativeLibrary::_register_script(const StringName p_name, const StringName p_base, godot_instance_create_func p_instance_func, godot_instance_destroy_func p_destroy_func) { ERR_FAIL_COND(!native_library); ERR_FAIL_COND(native_library->scripts.has(p_name)); - DLScriptData *s = memnew(DLScriptData); + GDNativeScriptData *s = memnew(GDNativeScriptData); s->base = p_base; s->create_func = p_instance_func; s->destroy_func = p_destroy_func; - Map<StringName, DLScriptData *>::Element *E = native_library->scripts.find(p_base); + Map<StringName, GDNativeScriptData *>::Element *E = native_library->scripts.find(p_base); if (E) { s->base_data = E->get(); s->base_native_type = s->base_data->base_native_type; @@ -598,16 +597,16 @@ void DLLibrary::_register_script(const StringName p_name, const StringName p_bas native_library->scripts.insert(p_name, s); } -void DLLibrary::_register_tool_script(const StringName p_name, const StringName p_base, godot_instance_create_func p_instance_func, godot_instance_destroy_func p_destroy_func) { +void GDNativeLibrary::_register_tool_script(const StringName p_name, const StringName p_base, godot_instance_create_func p_instance_func, godot_instance_destroy_func p_destroy_func) { ERR_FAIL_COND(!native_library); ERR_FAIL_COND(native_library->scripts.has(p_name)); - DLScriptData *s = memnew(DLScriptData); + GDNativeScriptData *s = memnew(GDNativeScriptData); s->base = p_base; s->create_func = p_instance_func; s->destroy_func = p_destroy_func; s->is_tool = true; - Map<StringName, DLScriptData *>::Element *E = native_library->scripts.find(p_base); + Map<StringName, GDNativeScriptData *>::Element *E = native_library->scripts.find(p_base); if (E) { s->base_data = E->get(); s->base_native_type = s->base_data->base_native_type; @@ -623,23 +622,23 @@ void DLLibrary::_register_tool_script(const StringName p_name, const StringName native_library->scripts.insert(p_name, s); } -void DLLibrary::_register_script_method(const StringName p_name, const StringName p_method, godot_method_attributes p_attr, godot_instance_method p_func, MethodInfo p_info) { +void GDNativeLibrary::_register_script_method(const StringName p_name, const StringName p_method, godot_method_attributes p_attr, godot_instance_method p_func, MethodInfo p_info) { ERR_FAIL_COND(!native_library); ERR_FAIL_COND(!native_library->scripts.has(p_name)); p_info.name = p_method; - DLScriptData::Method method; + GDNativeScriptData::Method method; - method = DLScriptData::Method(p_func, p_info, p_attr.rpc_type); + method = GDNativeScriptData::Method(p_func, p_info, p_attr.rpc_type); native_library->scripts[p_name]->methods.insert(p_method, method); } -void DLLibrary::_register_script_property(const StringName p_name, const String p_path, godot_property_attributes *p_attr, godot_property_set_func p_setter, godot_property_get_func p_getter) { +void GDNativeLibrary::_register_script_property(const StringName p_name, const String p_path, godot_property_attributes *p_attr, godot_property_set_func p_setter, godot_property_get_func p_getter) { ERR_FAIL_COND(!native_library); ERR_FAIL_COND(!native_library->scripts.has(p_name)); - DLScriptData::Property p; + GDNativeScriptData::Property p; PropertyInfo pi; pi.name = p_path; @@ -647,18 +646,18 @@ void DLLibrary::_register_script_property(const StringName p_name, const String if (p_attr != NULL) { pi = PropertyInfo((Variant::Type)p_attr->type, p_path, (PropertyHint)p_attr->hint, *(String *)&p_attr->hint_string, p_attr->usage); - p = DLScriptData::Property(p_setter, p_getter, pi, *(Variant *)&p_attr->default_value, p_attr->rset_type); + p = GDNativeScriptData::Property(p_setter, p_getter, pi, *(Variant *)&p_attr->default_value, p_attr->rset_type); } native_library->scripts[p_name]->properties.insert(p_path, p); } -void DLLibrary::_register_script_signal(const StringName p_name, const godot_signal *p_signal) { +void GDNativeLibrary::_register_script_signal(const StringName p_name, const godot_signal *p_signal) { ERR_FAIL_COND(!native_library); ERR_FAIL_COND(!native_library->scripts.has(p_name)); ERR_FAIL_COND(!p_signal); - DLScriptData::Signal signal; + GDNativeScriptData::Signal signal; signal.signal.name = *(String *)&p_signal->name; @@ -698,7 +697,7 @@ void DLLibrary::_register_script_signal(const StringName p_name, const godot_sig native_library->scripts[p_name]->signals_.insert(*(String *)&p_signal->name, signal); } -DLScriptData *DLLibrary::get_script_data(const StringName p_name) { +GDNativeScriptData *GDNativeLibrary::get_script_data(const StringName p_name) { ERR_FAIL_COND_V(!native_library, NULL); ERR_FAIL_COND_V(!native_library->scripts.has(p_name), NULL); @@ -706,7 +705,7 @@ DLScriptData *DLLibrary::get_script_data(const StringName p_name) { return native_library->scripts[p_name]; } -bool DLLibrary::_set(const StringName &p_name, const Variant &p_value) { +bool GDNativeLibrary::_set(const StringName &p_name, const Variant &p_value) { String name = p_name; if (name.begins_with("platform/")) { set_platform_file(name.get_slice("/", 1), p_value); @@ -715,7 +714,7 @@ bool DLLibrary::_set(const StringName &p_name, const Variant &p_value) { return false; } -bool DLLibrary::_get(const StringName &p_name, Variant &r_ret) const { +bool GDNativeLibrary::_get(const StringName &p_name, Variant &r_ret) const { String name = p_name; if (name.begins_with("platform/")) { r_ret = get_platform_file(name.get_slice("/", 1)); @@ -724,7 +723,7 @@ bool DLLibrary::_get(const StringName &p_name, Variant &r_ret) const { return false; } -void DLLibrary::_get_property_list(List<PropertyInfo> *p_list) const { +void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const { char **platform_info = (char **)_dl_platforms_info; Set<String> registered_platform_names; @@ -769,20 +768,20 @@ void DLLibrary::_get_property_list(List<PropertyInfo> *p_list) const { } } -void DLLibrary::_notification(int what) { +void GDNativeLibrary::_notification(int what) { // TODO } -void DLLibrary::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_platform_file", "platform", "file"), &DLLibrary::set_platform_file); - ClassDB::bind_method(D_METHOD("get_platform_file", "platform"), &DLLibrary::get_platform_file); +void GDNativeLibrary::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_platform_file", "platform", "file"), &GDNativeLibrary::set_platform_file); + ClassDB::bind_method(D_METHOD("get_platform_file", "platform"), &GDNativeLibrary::get_platform_file); } -DLLibrary::DLLibrary() { +GDNativeLibrary::GDNativeLibrary() { native_library = NULL; } -DLLibrary::~DLLibrary() { +GDNativeLibrary::~GDNativeLibrary() { if (!native_library) { return; @@ -795,7 +794,7 @@ DLLibrary::~DLLibrary() { // Instance -bool DLInstance::set(const StringName &p_name, const Variant &p_value) { +bool GDNativeInstance::set(const StringName &p_name, const Variant &p_value) { if (!script->script_data) return false; if (script->script_data->properties.has(p_name)) { @@ -805,7 +804,7 @@ bool DLInstance::set(const StringName &p_name, const Variant &p_value) { return false; } -bool DLInstance::get(const StringName &p_name, Variant &r_ret) const { +bool GDNativeInstance::get(const StringName &p_name, Variant &r_ret) const { if (!script->script_data) return false; if (script->script_data->properties.has(p_name)) { @@ -816,12 +815,12 @@ bool DLInstance::get(const StringName &p_name, Variant &r_ret) const { return false; } -void DLInstance::get_property_list(List<PropertyInfo> *p_properties) const { +void GDNativeInstance::get_property_list(List<PropertyInfo> *p_properties) const { script->get_script_property_list(p_properties); // TODO: dynamic properties } -Variant::Type DLInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const { +Variant::Type GDNativeInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const { if (script->script_data->properties.has(p_name)) { *r_is_valid = true; return script->script_data->properties[p_name].info.type; @@ -830,20 +829,20 @@ Variant::Type DLInstance::get_property_type(const StringName &p_name, bool *r_is return Variant::NIL; } -void DLInstance::get_method_list(List<MethodInfo> *p_list) const { +void GDNativeInstance::get_method_list(List<MethodInfo> *p_list) const { script->get_script_method_list(p_list); } -bool DLInstance::has_method(const StringName &p_method) const { +bool GDNativeInstance::has_method(const StringName &p_method) const { return script->has_method(p_method); } -Variant DLInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) { +Variant GDNativeInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) { // TODO: validated methods & errors - DLScriptData *data_ptr = script->script_data; + GDNativeScriptData *data_ptr = script->script_data; while (data_ptr) { - Map<StringName, DLScriptData::Method>::Element *E = data_ptr->methods.find(p_method); + Map<StringName, GDNativeScriptData::Method>::Element *E = data_ptr->methods.find(p_method); if (E) { godot_variant result = E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, p_argcount, (godot_variant **)p_args); return *(Variant *)&result; @@ -854,12 +853,12 @@ Variant DLInstance::call(const StringName &p_method, const Variant **p_args, int return Variant(); } -void DLInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) { +void GDNativeInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) { // TODO: validated methods & errors - DLScriptData *data_ptr = script->script_data; + GDNativeScriptData *data_ptr = script->script_data; while (data_ptr) { - Map<StringName, DLScriptData::Method>::Element *E = data_ptr->methods.find(p_method); + Map<StringName, GDNativeScriptData::Method>::Element *E = data_ptr->methods.find(p_method); if (E) { E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, p_argcount, (godot_variant **)p_args); } @@ -867,7 +866,7 @@ void DLInstance::call_multilevel(const StringName &p_method, const Variant **p_a } } -void DLInstance::_ml_call_reversed(DLScriptData *data_ptr, const StringName &p_method, const Variant **p_args, int p_argcount) { +void GDNativeInstance::_ml_call_reversed(GDNativeScriptData *data_ptr, const StringName &p_method, const Variant **p_args, int p_argcount) { // TODO: validated methods & errors if (data_ptr->base_data) @@ -875,34 +874,34 @@ void DLInstance::_ml_call_reversed(DLScriptData *data_ptr, const StringName &p_m // Variant::CallError ce; - Map<StringName, DLScriptData::Method>::Element *E = data_ptr->methods.find(p_method); + Map<StringName, GDNativeScriptData::Method>::Element *E = data_ptr->methods.find(p_method); if (E) { E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, p_argcount, (godot_variant **)p_args); } } -void DLInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) { +void GDNativeInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) { if (script.ptr() && script->script_data) { _ml_call_reversed(script->script_data, p_method, p_args, p_argcount); } } -void DLInstance::notification(int p_notification) { +void GDNativeInstance::notification(int p_notification) { Variant value = p_notification; const Variant *args[1] = { &value }; - call_multilevel(DLScriptLanguage::singleton->strings._notification, args, 1); + call_multilevel(GDNativeScriptLanguage::singleton->strings._notification, args, 1); } -Ref<Script> DLInstance::get_script() const { +Ref<Script> GDNativeInstance::get_script() const { return script; } -ScriptLanguage *DLInstance::get_language() { - return DLScriptLanguage::singleton; +ScriptLanguage *GDNativeInstance::get_language() { + return GDNativeScriptLanguage::singleton; } -ScriptInstance::RPCMode DLInstance::get_rpc_mode(const StringName &p_method) const { - DLScriptData::Method m = script->script_data->methods[p_method]; +ScriptInstance::RPCMode GDNativeInstance::get_rpc_mode(const StringName &p_method) const { + GDNativeScriptData::Method m = script->script_data->methods[p_method]; switch (m.rpc_mode) { case GODOT_METHOD_RPC_MODE_DISABLED: return RPC_MODE_DISABLED; @@ -919,8 +918,8 @@ ScriptInstance::RPCMode DLInstance::get_rpc_mode(const StringName &p_method) con } } -ScriptInstance::RPCMode DLInstance::get_rset_mode(const StringName &p_variable) const { - DLScriptData::Property p = script->script_data->properties[p_variable]; +ScriptInstance::RPCMode GDNativeInstance::get_rset_mode(const StringName &p_variable) const { + GDNativeScriptData::Property p = script->script_data->properties[p_variable]; switch (p.rset_mode) { case GODOT_METHOD_RPC_MODE_DISABLED: return RPC_MODE_DISABLED; @@ -937,12 +936,12 @@ ScriptInstance::RPCMode DLInstance::get_rset_mode(const StringName &p_variable) } } -DLInstance::DLInstance() { +GDNativeInstance::GDNativeInstance() { owner = NULL; userdata = NULL; } -DLInstance::~DLInstance() { +GDNativeInstance::~GDNativeInstance() { if (script.is_valid()) { if (owner) { script->instances.erase(owner); @@ -959,31 +958,31 @@ DLInstance::~DLInstance() { // Language -DLScriptLanguage *DLScriptLanguage::singleton = NULL; +GDNativeScriptLanguage *GDNativeScriptLanguage::singleton = NULL; -String DLScriptLanguage::get_name() const { - return "DLScript"; +String GDNativeScriptLanguage::get_name() const { + return "Native"; } void _add_reload_node() { #ifdef TOOLS_ENABLED - DLReloadNode *rn = memnew(DLReloadNode); + GDNativeReloadNode *rn = memnew(GDNativeReloadNode); EditorNode::get_singleton()->add_child(rn); #endif } -void DLScriptLanguage::init() { +void GDNativeScriptLanguage::init() { // TODO: Expose globals - GLOBAL_DEF("dlscript/default_dllibrary", ""); - PropertyInfo prop_info(Variant::STRING, "dlscript/default_dllibrary", PROPERTY_HINT_FILE, "tres,res,dllib"); - GlobalConfig::get_singleton()->set_custom_property_info("dlscript/default_dllibrary", prop_info); + GLOBAL_DEF("gdnative/default_gdnativelibrary", ""); + PropertyInfo prop_info(Variant::STRING, "gdnative/default_gdnativelibrary", PROPERTY_HINT_FILE, "tres,res,dllib"); + GlobalConfig::get_singleton()->set_custom_property_info("gdnative/default_gdnativelibrary", prop_info); // generate bindings #if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED) List<String> args = OS::get_singleton()->get_cmdline_args(); - List<String>::Element *E = args.find("--dlscript-generate-json-api"); + List<String>::Element *E = args.find("--gdnative-generate-json-api"); if (E && E->next()) { if (generate_c_api(E->next()->get()) != OK) { @@ -999,162 +998,160 @@ void DLScriptLanguage::init() { #endif } -String DLScriptLanguage::get_type() const { - return "DLScript"; +String GDNativeScriptLanguage::get_type() const { + return "Native"; } -String DLScriptLanguage::get_extension() const { - return "dl"; +String GDNativeScriptLanguage::get_extension() const { + return "gdn"; } -Error DLScriptLanguage::execute_file(const String &p_path) { +Error GDNativeScriptLanguage::execute_file(const String &p_path) { return OK; // ?? } -void DLScriptLanguage::finish() { +void GDNativeScriptLanguage::finish() { // cleanup is for noobs } // scons doesn't want to link in the api source so we need to call a dummy function to cause it to link extern "C" void _api_anchor(); -void DLScriptLanguage::_compile_dummy_for_the_api() { +void GDNativeScriptLanguage::_compile_dummy_for_the_api() { _api_anchor(); } -Ref<Script> DLScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const { - DLScript *src = memnew(DLScript); +Ref<Script> GDNativeScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const { + GDNativeScript *src = memnew(GDNativeScript); src->set_script_name(p_class_name); - return Ref<DLScript>(src); + return Ref<GDNativeScript>(src); } -bool DLScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions) const { +bool GDNativeScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions) const { return false; // TODO } -Script *DLScriptLanguage::create_script() const { - DLScript *scr = memnew(DLScript); +Script *GDNativeScriptLanguage::create_script() const { + GDNativeScript *scr = memnew(GDNativeScript); return scr; } -bool DLScriptLanguage::has_named_classes() const { +bool GDNativeScriptLanguage::has_named_classes() const { return true; } -int DLScriptLanguage::find_function(const String &p_function, const String &p_code) const { +int GDNativeScriptLanguage::find_function(const String &p_function, const String &p_code) const { return -1; // No source code! } -String DLScriptLanguage::make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const { +String GDNativeScriptLanguage::make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const { return ""; // No source code! } -void DLScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) { +void GDNativeScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) { // TODO TODO TODO } // TODO: Any debugging? (research) -String DLScriptLanguage::debug_get_error() const { +String GDNativeScriptLanguage::debug_get_error() const { return ""; } -int DLScriptLanguage::debug_get_stack_level_count() const { +int GDNativeScriptLanguage::debug_get_stack_level_count() const { return 1; // ? } -int DLScriptLanguage::debug_get_stack_level_line(int p_level) const { +int GDNativeScriptLanguage::debug_get_stack_level_line(int p_level) const { return -1; } -String DLScriptLanguage::debug_get_stack_level_function(int p_level) const { +String GDNativeScriptLanguage::debug_get_stack_level_function(int p_level) const { return "[native code]"; // ? } -String DLScriptLanguage::debug_get_stack_level_source(int p_level) const { +String GDNativeScriptLanguage::debug_get_stack_level_source(int p_level) const { return ""; } -void DLScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {} +void GDNativeScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {} -void DLScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {} +void GDNativeScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {} -String DLScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) { +String GDNativeScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) { return ""; // ?? } -void DLScriptLanguage::reload_all_scripts() { +void GDNativeScriptLanguage::reload_all_scripts() { // @Todo } -void DLScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) { +void GDNativeScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) { // @Todo OS::get_singleton()->print("reload tool scripts\n"); } -void DLScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("dl"); // Container file format +void GDNativeScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const { + p_extensions->push_back("gdn"); // Container file format } -void DLScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const { +void GDNativeScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const { } -void DLScriptLanguage::get_public_constants(List<Pair<String, Variant> > *p_constants) const { +void GDNativeScriptLanguage::get_public_constants(List<Pair<String, Variant> > *p_constants) const { } // TODO: all profilling -void DLScriptLanguage::profiling_start() { +void GDNativeScriptLanguage::profiling_start() { } -void DLScriptLanguage::profiling_stop() { +void GDNativeScriptLanguage::profiling_stop() { } -int DLScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) { +int GDNativeScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) { return 0; } -int DLScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) { +int GDNativeScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) { return 0; } -void DLScriptLanguage::frame() { +void GDNativeScriptLanguage::frame() { } -String DLScriptLanguage::get_init_symbol_name() { - return "godot_dlscript_init"; // TODO: Maybe make some internal function which would do the actual stuff +String GDNativeScriptLanguage::get_init_symbol_name() { + return "godot_native_init"; // TODO: Maybe make some internal function which would do the actual stuff } -String DLScriptLanguage::get_terminate_symbol_name() { - return "godot_dlscript_terminate"; +String GDNativeScriptLanguage::get_terminate_symbol_name() { + return "godot_native_terminate"; } -DLScriptLanguage::DLScriptLanguage() { +GDNativeScriptLanguage::GDNativeScriptLanguage() { ERR_FAIL_COND(singleton); strings._notification = StringName("_notification"); singleton = this; initialized_libraries = Map<StringName, NativeLibrary *>(); } -DLScriptLanguage::~DLScriptLanguage() { +GDNativeScriptLanguage::~GDNativeScriptLanguage() { singleton = NULL; } // DLReloadNode -void DLReloadNode::_bind_methods() { - ClassDB::bind_method("_notification", &DLReloadNode::_notification); +void GDNativeReloadNode::_bind_methods() { + ClassDB::bind_method("_notification", &GDNativeReloadNode::_notification); } -void DLReloadNode::_notification(int p_what) { +void GDNativeReloadNode::_notification(int p_what) { #ifdef TOOLS_ENABLED switch (p_what) { case MainLoop::NOTIFICATION_WM_FOCUS_IN: { - // break; // For now. - Set<NativeLibrary *> libs_to_reload; - for (Map<StringName, NativeLibrary *>::Element *L = DLScriptLanguage::get_singleton()->initialized_libraries.front(); L; L = L->next()) { + for (Map<StringName, NativeLibrary *>::Element *L = GDNativeScriptLanguage::get_singleton()->initialized_libraries.front(); L; L = L->next()) { // check if file got modified at all // @Todo @@ -1163,16 +1160,16 @@ void DLReloadNode::_notification(int p_what) { for (Set<NativeLibrary *>::Element *L = libs_to_reload.front(); L; L = L->next()) { - DLLibrary *lib = L->get()->dllib; + GDNativeLibrary *lib = L->get()->dllib; lib->_terminate(); lib->_initialize(); // update placeholders (if any) - DLScript *script = NULL; + GDNativeScript *script = NULL; - for (Set<DLScript *>::Element *S = DLScriptLanguage::get_singleton()->script_list.front(); S; S = S->next()) { + for (Set<GDNativeScript *>::Element *S = GDNativeScriptLanguage::get_singleton()->script_list.front(); S; S = S->next()) { if (lib->native_library->scripts.has(S->get()->get_script_name())) { script = S->get(); script->script_data = lib->get_script_data(script->get_script_name()); @@ -1203,35 +1200,35 @@ void DLReloadNode::_notification(int p_what) { // Resource loader/saver -RES ResourceFormatLoaderDLScript::load(const String &p_path, const String &p_original_path, Error *r_error) { +RES ResourceFormatLoaderGDNativeScript::load(const String &p_path, const String &p_original_path, Error *r_error) { ResourceFormatLoaderText rsflt; return rsflt.load(p_path, p_original_path, r_error); } -void ResourceFormatLoaderDLScript::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("dl"); +void ResourceFormatLoaderGDNativeScript::get_recognized_extensions(List<String> *p_extensions) const { + p_extensions->push_back("gdn"); } -bool ResourceFormatLoaderDLScript::handles_type(const String &p_type) const { - return (p_type == "Script" || p_type == "DLScript"); +bool ResourceFormatLoaderGDNativeScript::handles_type(const String &p_type) const { + return (p_type == "Script" || p_type == "Native"); } -String ResourceFormatLoaderDLScript::get_resource_type(const String &p_path) const { +String ResourceFormatLoaderGDNativeScript::get_resource_type(const String &p_path) const { String el = p_path.get_extension().to_lower(); - if (el == "dl") - return "DLScript"; + if (el == "gdn") + return "Native"; return ""; } -Error ResourceFormatSaverDLScript::save(const String &p_path, const RES &p_resource, uint32_t p_flags) { +Error ResourceFormatSaverGDNativeScript::save(const String &p_path, const RES &p_resource, uint32_t p_flags) { ResourceFormatSaverText rfst; return rfst.save(p_path, p_resource, p_flags); } -bool ResourceFormatSaverDLScript::recognize(const RES &p_resource) const { - return p_resource->cast_to<DLScript>() != NULL; +bool ResourceFormatSaverGDNativeScript::recognize(const RES &p_resource) const { + return p_resource->cast_to<GDNativeScript>() != NULL; } -void ResourceFormatSaverDLScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const { - if (p_resource->cast_to<DLScript>()) { - p_extensions->push_back("dl"); +void ResourceFormatSaverGDNativeScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const { + if (p_resource->cast_to<GDNativeScript>()) { + p_extensions->push_back("gdn"); } } diff --git a/modules/dlscript/dl_script.h b/modules/gdnative/gdnative.h index 630ce21883..89270b4e26 100644 --- a/modules/dlscript/dl_script.h +++ b/modules/gdnative/gdnative.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* dl_script.h */ +/* gdnative.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,8 +27,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef DL_SCRIPT_H -#define DL_SCRIPT_H +#ifndef GDNATIVE_H +#define GDNATIVE_H #include "io/resource_loader.h" #include "io/resource_saver.h" @@ -40,26 +40,22 @@ #include "godot.h" -#ifdef TOOLS_ENABLED -#define DLSCRIPT_EDITOR_FEATURES -#endif - -class DLScriptData; -class DLLibrary; +class GDNativeScriptData; +class GDNativeLibrary; struct NativeLibrary { StringName path; void *handle; - DLLibrary *dllib; + GDNativeLibrary *dllib; - Map<StringName, DLScriptData *> scripts; + Map<StringName, GDNativeScriptData *> scripts; static Error initialize(NativeLibrary *&p_native_lib, const StringName p_path); static Error terminate(NativeLibrary *&p_native_lib); }; -struct DLScriptData { +struct GDNativeScriptData { /* typedef void* (InstanceFunc)(godot_object* instance); typedef void (DestroyFunc)(godot_object* instance,void* userdata); typedef godot_variant (MethodFunc)(godot_object *instance, void *userdata, void *method_data, int arg_count,godot_variant **args); @@ -111,18 +107,18 @@ struct DLScriptData { Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals StringName base; StringName base_native_type; - DLScriptData *base_data; + GDNativeScriptData *base_data; godot_instance_create_func create_func; godot_instance_destroy_func destroy_func; bool is_tool; - DLScriptData() { + GDNativeScriptData() { base = StringName(); base_data = NULL; is_tool = false; } - DLScriptData(StringName p_base, godot_instance_create_func p_instance, godot_instance_destroy_func p_free) { + GDNativeScriptData(StringName p_base, godot_instance_create_func p_instance, godot_instance_destroy_func p_free) { base = p_base; base_data = NULL; create_func = p_instance; @@ -131,16 +127,16 @@ struct DLScriptData { } }; -class DLLibrary; +class GDNativeLibrary; -class DLScript : public Script { - GDCLASS(DLScript, Script); +class GDNativeScript : public Script { + GDCLASS(GDNativeScript, Script); - Ref<DLLibrary> library; + Ref<GDNativeLibrary> library; StringName script_name; StringName base_native_type; Set<Object *> instances; - DLScriptData *script_data; + GDNativeScriptData *script_data; #ifdef TOOLS_ENABLED Set<PlaceHolderScriptInstance *> placeholders; @@ -148,10 +144,10 @@ class DLScript : public Script { virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder); #endif - friend class DLInstance; - friend class DLScriptLanguage; - friend class DLReloadNode; - friend class DLLibrary; + friend class GDNativeInstance; + friend class GDNativeScriptLanguage; + friend class GDNativeReloadNode; + friend class GDNativeLibrary; protected: static void _bind_methods(); @@ -188,32 +184,32 @@ public: virtual void get_script_method_list(List<MethodInfo> *p_list) const; virtual void get_script_property_list(List<PropertyInfo> *p_list) const; - Ref<DLLibrary> get_library() const; - void set_library(Ref<DLLibrary> p_library); + Ref<GDNativeLibrary> get_library() const; + void set_library(Ref<GDNativeLibrary> p_library); StringName get_script_name() const; void set_script_name(StringName p_script_name); - DLScript(); - ~DLScript(); + GDNativeScript(); + ~GDNativeScript(); }; -class DLLibrary : public Resource { +class GDNativeLibrary : public Resource { _THREAD_SAFE_CLASS_ - GDCLASS(DLLibrary, Resource); - OBJ_SAVE_TYPE(DLLibrary); + GDCLASS(GDNativeLibrary, Resource); + OBJ_SAVE_TYPE(GDNativeLibrary); Map<StringName, String> platform_files; NativeLibrary *native_library; - static DLLibrary *currently_initialized_library; + static GDNativeLibrary *currently_initialized_library; protected: - friend class DLScript; + friend class GDNativeScript; friend class NativeLibrary; - friend class DLReloadNode; + friend class GDNativeReloadNode; - DLScriptData *get_script_data(const StringName p_name); + GDNativeScriptData *get_script_data(const StringName p_name); bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; @@ -225,7 +221,7 @@ public: Error _initialize(); Error _terminate(); - static DLLibrary *get_currently_initialized_library(); + static GDNativeLibrary *get_currently_initialized_library(); void _register_script(const StringName p_name, const StringName p_base, godot_instance_create_func p_instance_func, godot_instance_destroy_func p_destroy_func); void _register_tool_script(const StringName p_name, const StringName p_base, godot_instance_create_func p_instance_func, godot_instance_destroy_func p_destroy_func); @@ -236,18 +232,18 @@ public: void set_platform_file(StringName p_platform, String p_file); String get_platform_file(StringName p_platform) const; - DLLibrary(); - ~DLLibrary(); + GDNativeLibrary(); + ~GDNativeLibrary(); }; -class DLInstance : public ScriptInstance { - friend class DLScript; +class GDNativeInstance : public ScriptInstance { + friend class GDNativeScript; Object *owner; - Ref<DLScript> script; + Ref<GDNativeScript> script; void *userdata; - void _ml_call_reversed(DLScriptData *data_ptr, const StringName &p_method, const Variant **p_args, int p_argcount); + void _ml_call_reversed(GDNativeScriptData *data_ptr, const StringName &p_method, const Variant **p_args, int p_argcount); public: _FORCE_INLINE_ Object *get_owner() { return owner; } @@ -280,19 +276,19 @@ public: virtual RPCMode get_rpc_mode(const StringName &p_method) const; virtual RPCMode get_rset_mode(const StringName &p_variable) const; - DLInstance(); - ~DLInstance(); + GDNativeInstance(); + ~GDNativeInstance(); }; -class DLReloadNode; +class GDNativeReloadNode; -class DLScriptLanguage : public ScriptLanguage { - friend class DLScript; - friend class DLInstance; - friend class DLReloadNode; - friend class DLLibrary; +class GDNativeScriptLanguage : public ScriptLanguage { + friend class GDNativeScript; + friend class GDNativeInstance; + friend class GDNativeReloadNode; + friend class GDNativeLibrary; - static DLScriptLanguage *singleton; + static GDNativeScriptLanguage *singleton; Variant *_global_array; // @Unused necessary? Vector<Variant> global_array; // @Unused necessary? @@ -303,7 +299,7 @@ class DLScriptLanguage : public ScriptLanguage { Mutex *lock; - Set<DLScript *> script_list; + Set<GDNativeScript *> script_list; bool profiling; uint64_t script_frame_time; @@ -317,7 +313,7 @@ class DLScriptLanguage : public ScriptLanguage { public: Map<StringName, NativeLibrary *> initialized_libraries; - _FORCE_INLINE_ static DLScriptLanguage *get_singleton() { return singleton; } + _FORCE_INLINE_ static GDNativeScriptLanguage *get_singleton() { return singleton; } virtual String get_name() const; @@ -391,18 +387,18 @@ public: /* HACKER FUNCTIONS */ void _compile_dummy_for_the_api(); - DLScriptLanguage(); - ~DLScriptLanguage(); + GDNativeScriptLanguage(); + ~GDNativeScriptLanguage(); }; -class DLReloadNode : public Node { - GDCLASS(DLReloadNode, Node) +class GDNativeReloadNode : public Node { + GDCLASS(GDNativeReloadNode, Node) public: static void _bind_methods(); void _notification(int p_what); }; -class ResourceFormatLoaderDLScript : public ResourceFormatLoader { +class ResourceFormatLoaderGDNativeScript : public ResourceFormatLoader { public: virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL); virtual void get_recognized_extensions(List<String> *p_extensions) const; @@ -410,12 +406,10 @@ public: virtual String get_resource_type(const String &p_path) const; }; -class ResourceFormatSaverDLScript : public ResourceFormatSaver { +class ResourceFormatSaverGDNativeScript : public ResourceFormatSaver { virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0); virtual bool recognize(const RES &p_resource) const; virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const; }; -// ugly, but hey - -#endif // DL_SCRIPT_H +#endif // GDNATIVE_H diff --git a/modules/dlscript/godot.cpp b/modules/gdnative/godot.cpp index 623f7f0149..5ad716d0cd 100644 --- a/modules/dlscript/godot.cpp +++ b/modules/gdnative/godot.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* godot_c.cpp */ +/* godot.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -30,7 +30,7 @@ #include "godot.h" #include "class_db.h" -#include "dl_script.h" +#include "gdnative.h" #include "global_config.h" #include "global_constants.h" #include "variant.h" @@ -126,7 +126,7 @@ void GDAPI godot_method_bind_varcall(godot_method_bind *p_method_bind) // Script API void GDAPI godot_script_register_class(const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) { - DLLibrary *library = DLLibrary::get_currently_initialized_library(); + GDNativeLibrary *library = GDNativeLibrary::get_currently_initialized_library(); if (!library) { ERR_EXPLAIN("Attempt to register script after initializing library!"); ERR_FAIL(); @@ -135,7 +135,7 @@ void GDAPI godot_script_register_class(const char *p_name, const char *p_base, g } void GDAPI godot_script_register_tool_class(const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) { - DLLibrary *library = DLLibrary::get_currently_initialized_library(); + GDNativeLibrary *library = GDNativeLibrary::get_currently_initialized_library(); if (!library) { ERR_EXPLAIN("Attempt to register script after initializing library!"); ERR_FAIL(); @@ -144,7 +144,7 @@ void GDAPI godot_script_register_tool_class(const char *p_name, const char *p_ba } void GDAPI godot_script_register_method(const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method) { - DLLibrary *library = DLLibrary::get_currently_initialized_library(); + GDNativeLibrary *library = GDNativeLibrary::get_currently_initialized_library(); if (!library) { ERR_EXPLAIN("Attempt to register script after initializing library!"); ERR_FAIL(); @@ -153,7 +153,7 @@ void GDAPI godot_script_register_method(const char *p_name, const char *p_functi } void GDAPI godot_script_register_property(const char *p_name, const char *p_path, godot_property_attributes *p_attr, godot_property_set_func p_set_func, godot_property_get_func p_get_func) { - DLLibrary *library = DLLibrary::get_currently_initialized_library(); + GDNativeLibrary *library = GDNativeLibrary::get_currently_initialized_library(); if (!library) { ERR_EXPLAIN("Attempt to register script after initializing library!"); ERR_FAIL(); @@ -163,7 +163,7 @@ void GDAPI godot_script_register_property(const char *p_name, const char *p_path } void GDAPI godot_script_register_signal(const char *p_name, const godot_signal *p_signal) { - DLLibrary *library = DLLibrary::get_currently_initialized_library(); + GDNativeLibrary *library = GDNativeLibrary::get_currently_initialized_library(); if (!library) { ERR_EXPLAIN("Attempt to register script after initializing library!"); ERR_FAIL(); @@ -172,12 +172,12 @@ void GDAPI godot_script_register_signal(const char *p_name, const godot_signal * library->_register_script_signal(p_name, p_signal); } -void GDAPI *godot_dlinstance_get_userdata(godot_object *p_instance) { +void GDAPI *godot_native_get_userdata(godot_object *p_instance) { Object *instance = (Object *)p_instance; if (!instance) return NULL; - if (instance->get_script_instance() && instance->get_script_instance()->get_language() == DLScriptLanguage::get_singleton()) { - return ((DLInstance *)instance->get_script_instance())->get_userdata(); + if (instance->get_script_instance() && instance->get_script_instance()->get_language() == GDNativeScriptLanguage::get_singleton()) { + return ((GDNativeInstance *)instance->get_script_instance())->get_userdata(); } return NULL; } @@ -185,7 +185,7 @@ void GDAPI *godot_dlinstance_get_userdata(godot_object *p_instance) { godot_dictionary GDAPI godot_get_global_constants() { godot_dictionary constants; godot_dictionary_new(&constants); - Dictionary *p_constants = (Dictionary*)&constants; + Dictionary *p_constants = (Dictionary *)&constants; const int constants_count = GlobalConstants::get_global_constant_count(); for (int i = 0; i < constants_count; ++i) { const char *name = GlobalConstants::get_global_constant_name(i); diff --git a/modules/dlscript/godot.h b/modules/gdnative/godot.h index 124a752876..45ac64feee 100644 --- a/modules/dlscript/godot.h +++ b/modules/gdnative/godot.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* godot_c.h */ +/* godot.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -217,16 +217,16 @@ void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_obj ////// Script API -typedef struct godot_dlscript_init_options { +typedef struct godot_native_init_options { godot_bool in_editor; uint64_t core_api_hash; uint64_t editor_api_hash; uint64_t no_api_hash; -} godot_dlscript_init_options; +} godot_native_init_options; -typedef struct godot_dlscript_terminate_options { +typedef struct godot_native_terminate_options { godot_bool in_editor; -} godot_dlscript_terminate_options; +} godot_native_terminate_options; typedef enum godot_method_rpc_mode { GODOT_METHOD_RPC_MODE_DISABLED, @@ -374,7 +374,7 @@ typedef struct godot_signal { void GDAPI godot_script_register_signal(const char *p_name, const godot_signal *p_signal); -void GDAPI *godot_dlinstance_get_userdata(godot_object *p_instance); +void GDAPI *godot_native_get_userdata(godot_object *p_instance); godot_dictionary GDAPI godot_get_global_constants(); diff --git a/modules/dlscript/godot/godot_array.cpp b/modules/gdnative/godot/godot_array.cpp index 21ad97ca78..6c55c5d048 100644 --- a/modules/dlscript/godot/godot_array.cpp +++ b/modules/gdnative/godot/godot_array.cpp @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* godot_array.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "godot_array.h" #include "core/array.h" diff --git a/modules/dlscript/godot/godot_array.h b/modules/gdnative/godot/godot_array.h index 544e95a2ed..b92ebb834f 100644 --- a/modules/dlscript/godot/godot_array.h +++ b/modules/gdnative/godot/godot_array.h @@ -1,5 +1,35 @@ -#ifndef GODOT_DLSCRIPT_ARRAY_H -#define GODOT_DLSCRIPT_ARRAY_H +/*************************************************************************/ +/* godot_array.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef GODOT_ARRAY_H +#define GODOT_ARRAY_H #ifdef __cplusplus extern "C" { @@ -85,4 +115,4 @@ void GDAPI godot_array_destroy(godot_array *p_arr); } #endif -#endif // GODOT_DLSCRIPT_ARRAY_H +#endif // GODOT_ARRAY_H diff --git a/modules/gdnative/godot/godot_basis.cpp b/modules/gdnative/godot/godot_basis.cpp new file mode 100644 index 0000000000..4322acc401 --- /dev/null +++ b/modules/gdnative/godot/godot_basis.cpp @@ -0,0 +1,87 @@ +/*************************************************************************/ +/* godot_basis.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "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/gdnative/godot/godot_basis.h b/modules/gdnative/godot/godot_basis.h new file mode 100644 index 0000000000..a8f19bfde5 --- /dev/null +++ b/modules/gdnative/godot/godot_basis.h @@ -0,0 +1,63 @@ +/*************************************************************************/ +/* godot_basis.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_BASIS_H +#define GODOT_BASIS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <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_BASIS_H diff --git a/modules/gdnative/godot/godot_color.cpp b/modules/gdnative/godot/godot_color.cpp new file mode 100644 index 0000000000..203ce672fa --- /dev/null +++ b/modules/gdnative/godot/godot_color.cpp @@ -0,0 +1,63 @@ +/*************************************************************************/ +/* godot_color.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "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/gdnative/godot/godot_color.h b/modules/gdnative/godot/godot_color.h new file mode 100644 index 0000000000..b99a062a66 --- /dev/null +++ b/modules/gdnative/godot/godot_color.h @@ -0,0 +1,58 @@ +/*************************************************************************/ +/* godot_color.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_COLOR_H +#define GODOT_COLOR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <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_COLOR_H diff --git a/modules/dlscript/godot/godot_dictionary.cpp b/modules/gdnative/godot/godot_dictionary.cpp index 9147b17307..16d08e58e2 100644 --- a/modules/dlscript/godot/godot_dictionary.cpp +++ b/modules/gdnative/godot/godot_dictionary.cpp @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* godot_dictionary.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "godot_dictionary.h" #include "core/dictionary.h" diff --git a/modules/gdnative/godot/godot_dictionary.h b/modules/gdnative/godot/godot_dictionary.h new file mode 100644 index 0000000000..3f7c504880 --- /dev/null +++ b/modules/gdnative/godot/godot_dictionary.h @@ -0,0 +1,80 @@ +/*************************************************************************/ +/* godot_dictionary.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_DICTIONARY_H +#define GODOT_DICTIONARY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <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_DICTIONARY_H diff --git a/modules/dlscript/godot/godot_image.cpp b/modules/gdnative/godot/godot_image.cpp index 362d1aa3e6..ae8290afc2 100644 --- a/modules/dlscript/godot/godot_image.cpp +++ b/modules/gdnative/godot/godot_image.cpp @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* godot_image.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "godot_image.h" #include "image.h" diff --git a/modules/dlscript/godot/godot_image.h b/modules/gdnative/godot/godot_image.h index 78593f21a7..c43dd45148 100644 --- a/modules/dlscript/godot/godot_image.h +++ b/modules/gdnative/godot/godot_image.h @@ -1,5 +1,34 @@ -#ifndef GODOT_DLSCRIPT_IMAGE_H -#define GODOT_DLSCRIPT_IMAGE_H +/*************************************************************************/ +/* godot_image.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_IMAGE_H +#define GODOT_IMAGE_H #ifdef __cplusplus extern "C" { @@ -92,4 +121,4 @@ void GDAPI godot_image_destroy(godot_image *p_img); } #endif -#endif // GODOT_DLSCRIPT_IMAGE_H +#endif // GODOT_IMAGE_H diff --git a/modules/dlscript/godot/godot_input_event.cpp b/modules/gdnative/godot/godot_input_event.cpp index b50ed8a22d..0401c96a88 100644 --- a/modules/dlscript/godot/godot_input_event.cpp +++ b/modules/gdnative/godot/godot_input_event.cpp @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* godot_input_event.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "godot_input_event.h" #include "os/input_event.h" diff --git a/modules/dlscript/godot/godot_input_event.h b/modules/gdnative/godot/godot_input_event.h index bfda18bf7c..b0a133e3d9 100644 --- a/modules/dlscript/godot/godot_input_event.h +++ b/modules/gdnative/godot/godot_input_event.h @@ -1,5 +1,34 @@ -#ifndef GODOT_DLSCRIPT_INPUT_EVENT_H -#define GODOT_DLSCRIPT_INPUT_EVENT_H +/*************************************************************************/ +/* godot_input_event.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_INPUT_EVENT_H +#define GODOT_INPUT_EVENT_H #ifdef __cplusplus extern "C" { @@ -203,4 +232,4 @@ float GDAPI *godot_input_event_screen_drag_get_speed_y(godot_input_event *p_even } #endif -#endif // GODOT_DLSCRIPT_INPUT_EVENT_H +#endif // GODOT_INPUT_EVENT_H diff --git a/modules/dlscript/godot/godot_node_path.cpp b/modules/gdnative/godot/godot_node_path.cpp index 8b79175e44..a2c9e11699 100644 --- a/modules/dlscript/godot/godot_node_path.cpp +++ b/modules/gdnative/godot/godot_node_path.cpp @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* godot_node_path.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "godot_node_path.h" #include "path_db.h" diff --git a/modules/gdnative/godot/godot_node_path.h b/modules/gdnative/godot/godot_node_path.h new file mode 100644 index 0000000000..c5f313d190 --- /dev/null +++ b/modules/gdnative/godot/godot_node_path.h @@ -0,0 +1,68 @@ +/*************************************************************************/ +/* godot_node_path.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_NODE_PATH_H +#define GODOT_NODE_PATH_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <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); +void GDAPI godot_node_path_copy(godot_node_path *p_np, const godot_node_path *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_NODE_PATH_H diff --git a/modules/gdnative/godot/godot_plane.cpp b/modules/gdnative/godot/godot_plane.cpp new file mode 100644 index 0000000000..38329ef709 --- /dev/null +++ b/modules/gdnative/godot/godot_plane.cpp @@ -0,0 +1,77 @@ +/*************************************************************************/ +/* godot_plane.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "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/gdnative/godot/godot_plane.h b/modules/gdnative/godot/godot_plane.h new file mode 100644 index 0000000000..c98e45c9cb --- /dev/null +++ b/modules/gdnative/godot/godot_plane.h @@ -0,0 +1,66 @@ +/*************************************************************************/ +/* godot_plane.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_PLANE_H +#define GODOT_PLANE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <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_PLANE_H diff --git a/modules/dlscript/godot/godot_pool_arrays.cpp b/modules/gdnative/godot/godot_pool_arrays.cpp index 3fb030f835..93e9a9e9dc 100644 --- a/modules/dlscript/godot/godot_pool_arrays.cpp +++ b/modules/gdnative/godot/godot_pool_arrays.cpp @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* godot_pool_arrays.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "godot_pool_arrays.h" #include "array.h" diff --git a/modules/dlscript/godot/godot_pool_arrays.h b/modules/gdnative/godot/godot_pool_arrays.h index 77b6c3dde0..ec9185f6f3 100644 --- a/modules/dlscript/godot/godot_pool_arrays.h +++ b/modules/gdnative/godot/godot_pool_arrays.h @@ -1,5 +1,34 @@ -#ifndef GODOT_DLSCRIPT_POOL_ARRAYS_H -#define GODOT_DLSCRIPT_POOL_ARRAYS_H +/*************************************************************************/ +/* godot_pool_arrays.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_POOL_ARRAYS_H +#define GODOT_POOL_ARRAYS_H #ifdef __cplusplus extern "C" { @@ -253,4 +282,4 @@ void GDAPI godot_pool_color_array_destroy(godot_pool_color_array *p_pca); } #endif -#endif // GODOT_DLSCRIPT_POOL_ARRAYS_H +#endif // GODOT_POOL_ARRAYS_H diff --git a/modules/gdnative/godot/godot_quat.cpp b/modules/gdnative/godot/godot_quat.cpp new file mode 100644 index 0000000000..7c3a71dfc0 --- /dev/null +++ b/modules/gdnative/godot/godot_quat.cpp @@ -0,0 +1,106 @@ +/*************************************************************************/ +/* godot_quat.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "godot_quat.h" + +#include "math/quat.h" + +#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/gdnative/godot/godot_quat.h b/modules/gdnative/godot/godot_quat.h new file mode 100644 index 0000000000..35b1acd3ed --- /dev/null +++ b/modules/gdnative/godot/godot_quat.h @@ -0,0 +1,62 @@ +/*************************************************************************/ +/* godot_quat.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_QUAT_H +#define GODOT_QUAT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <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_QUAT_H diff --git a/modules/gdnative/godot/godot_rect2.cpp b/modules/gdnative/godot/godot_rect2.cpp new file mode 100644 index 0000000000..b19096b79e --- /dev/null +++ b/modules/gdnative/godot/godot_rect2.cpp @@ -0,0 +1,77 @@ +/*************************************************************************/ +/* godot_rect2.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "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/gdnative/godot/godot_rect2.h b/modules/gdnative/godot/godot_rect2.h new file mode 100644 index 0000000000..e9e4a26897 --- /dev/null +++ b/modules/gdnative/godot/godot_rect2.h @@ -0,0 +1,60 @@ +/*************************************************************************/ +/* godot_rect2.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_RECT2_H +#define GODOT_RECT2_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <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_RECT3_H diff --git a/modules/gdnative/godot/godot_rect3.cpp b/modules/gdnative/godot/godot_rect3.cpp new file mode 100644 index 0000000000..96c5d17b1a --- /dev/null +++ b/modules/gdnative/godot/godot_rect3.cpp @@ -0,0 +1,77 @@ +/*************************************************************************/ +/* godot_rect3.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "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/gdnative/godot/godot_rect3.h b/modules/gdnative/godot/godot_rect3.h new file mode 100644 index 0000000000..562ac8379e --- /dev/null +++ b/modules/gdnative/godot/godot_rect3.h @@ -0,0 +1,60 @@ +/*************************************************************************/ +/* godot_rect3.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_RECT3_H +#define GODOT_RECT3_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <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_RECT3_H diff --git a/modules/gdnative/godot/godot_rid.cpp b/modules/gdnative/godot/godot_rid.cpp new file mode 100644 index 0000000000..fff31e3992 --- /dev/null +++ b/modules/gdnative/godot/godot_rid.cpp @@ -0,0 +1,65 @@ +/*************************************************************************/ +/* godot_rid.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "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/gdnative/godot/godot_rid.h b/modules/gdnative/godot/godot_rid.h new file mode 100644 index 0000000000..e00c8f89ad --- /dev/null +++ b/modules/gdnative/godot/godot_rid.h @@ -0,0 +1,57 @@ +/*************************************************************************/ +/* godot_rid.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_RID_H +#define GODOT_RID_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <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_RID_H diff --git a/modules/gdnative/godot/godot_string.cpp b/modules/gdnative/godot/godot_string.cpp new file mode 100644 index 0000000000..2a78b2c96f --- /dev/null +++ b/modules/gdnative/godot/godot_string.cpp @@ -0,0 +1,112 @@ +/*************************************************************************/ +/* godot_string.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "godot_string.h" + +#include "string_db.h" +#include "ustring.h" + +#include <string.h> + +#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/gdnative/godot/godot_string.h b/modules/gdnative/godot/godot_string.h new file mode 100644 index 0000000000..7cde482cce --- /dev/null +++ b/modules/gdnative/godot/godot_string.h @@ -0,0 +1,71 @@ +/*************************************************************************/ +/* godot_string.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_STRING_H +#define GODOT_STRING_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <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_STRING_H diff --git a/modules/gdnative/godot/godot_transform.cpp b/modules/gdnative/godot/godot_transform.cpp new file mode 100644 index 0000000000..681c2b049a --- /dev/null +++ b/modules/gdnative/godot/godot_transform.cpp @@ -0,0 +1,71 @@ +/*************************************************************************/ +/* godot_transform.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "godot_transform.h" + +#include "math/transform.h" + +#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/gdnative/godot/godot_transform.h b/modules/gdnative/godot/godot_transform.h new file mode 100644 index 0000000000..93817ffbf2 --- /dev/null +++ b/modules/gdnative/godot/godot_transform.h @@ -0,0 +1,58 @@ +/*************************************************************************/ +/* godot_transform.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_TRANSFORM_H +#define GODOT_TRANSFORM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <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_TRANSFORM_H diff --git a/modules/gdnative/godot/godot_transform2d.cpp b/modules/gdnative/godot/godot_transform2d.cpp new file mode 100644 index 0000000000..ffc7167559 --- /dev/null +++ b/modules/gdnative/godot/godot_transform2d.cpp @@ -0,0 +1,88 @@ +/*************************************************************************/ +/* godot_transform2d.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "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/gdnative/godot/godot_transform2d.h b/modules/gdnative/godot/godot_transform2d.h new file mode 100644 index 0000000000..ae0569dbe8 --- /dev/null +++ b/modules/gdnative/godot/godot_transform2d.h @@ -0,0 +1,77 @@ +/*************************************************************************/ +/* godot_transform2d.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_TRANSFORM2D_H +#define GODOT_TRANSFORM2D_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <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/gdnative/godot/godot_variant.cpp index 3681f89753..2214f85056 100644 --- a/modules/dlscript/godot/godot_variant.cpp +++ b/modules/gdnative/godot/godot_variant.cpp @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* godot_variant.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "godot_variant.h" #include "../godot.h" diff --git a/modules/dlscript/godot/godot_variant.h b/modules/gdnative/godot/godot_variant.h index 1ff5ba4a57..6f98b32363 100644 --- a/modules/dlscript/godot/godot_variant.h +++ b/modules/gdnative/godot/godot_variant.h @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* godot_variant.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef GODOT_VARIANT_H #define GODOT_VARIANT_H diff --git a/modules/dlscript/godot/godot_vector2.cpp b/modules/gdnative/godot/godot_vector2.cpp index 0664da186e..dce4c03b5d 100644 --- a/modules/dlscript/godot/godot_vector2.cpp +++ b/modules/gdnative/godot/godot_vector2.cpp @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* godot_vector2.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "godot_vector2.h" #include "math/math_2d.h" diff --git a/modules/dlscript/godot/godot_vector2.h b/modules/gdnative/godot/godot_vector2.h index 63da367e4f..afda8aa10b 100644 --- a/modules/dlscript/godot/godot_vector2.h +++ b/modules/gdnative/godot/godot_vector2.h @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* godot_vector2.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef GODOT_VECTOR2_H #define GODOT_VECTOR2_H diff --git a/modules/dlscript/godot/godot_vector3.cpp b/modules/gdnative/godot/godot_vector3.cpp index 34005cbcb8..f08bfbcf06 100644 --- a/modules/dlscript/godot/godot_vector3.cpp +++ b/modules/gdnative/godot/godot_vector3.cpp @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* godot_vector3.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "godot_vector3.h" #include "math/vector3.h" diff --git a/modules/dlscript/godot/godot_vector3.h b/modules/gdnative/godot/godot_vector3.h index 7fe93e3fd5..b7dc40965d 100644 --- a/modules/dlscript/godot/godot_vector3.h +++ b/modules/gdnative/godot/godot_vector3.h @@ -1,3 +1,32 @@ +/*************************************************************************/ +/* godot_vector3.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef GODOT_VECTOR3_H #define GODOT_VECTOR3_H diff --git a/modules/dlscript/register_types.cpp b/modules/gdnative/register_types.cpp index 2ec6b89cbf..8789c9a267 100644 --- a/modules/dlscript/register_types.cpp +++ b/modules/gdnative/register_types.cpp @@ -28,43 +28,39 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "register_types.h" -#include "dl_script.h" +#include "gdnative.h" #include "io/resource_loader.h" #include "io/resource_saver.h" -DLScriptLanguage *script_language_dl = NULL; -ResourceFormatLoaderDLScript *resource_loader_dl = NULL; -ResourceFormatSaverDLScript *resource_saver_dl = NULL; +GDNativeScriptLanguage *script_language_gdn = NULL; +ResourceFormatLoaderGDNativeScript *resource_loader_gdn = NULL; +ResourceFormatSaverGDNativeScript *resource_saver_gdn = NULL; //ResourceFormatLoaderDLLibrary *resource_loader_dllib=NULL; -void register_dlscript_types() { +void register_gdnative_types() { - ClassDB::register_class<DLLibrary>(); - ClassDB::register_class<DLScript>(); + ClassDB::register_class<GDNativeLibrary>(); + ClassDB::register_class<GDNativeScript>(); - script_language_dl = memnew(DLScriptLanguage); - //script_language_gd->init(); - ScriptServer::register_language(script_language_dl); - resource_loader_dl = memnew(ResourceFormatLoaderDLScript); - ResourceLoader::add_resource_format_loader(resource_loader_dl); - resource_saver_dl = memnew(ResourceFormatSaverDLScript); - ResourceSaver::add_resource_format_saver(resource_saver_dl); - - // resource_loader_dllib=memnew( ResourceFormatLoaderDLLibrary ); - // ResourceLoader::add_resource_format_loader(resource_loader_gd); + script_language_gdn = memnew(GDNativeScriptLanguage); + ScriptServer::register_language(script_language_gdn); + resource_loader_gdn = memnew(ResourceFormatLoaderGDNativeScript); + ResourceLoader::add_resource_format_loader(resource_loader_gdn); + resource_saver_gdn = memnew(ResourceFormatSaverGDNativeScript); + ResourceSaver::add_resource_format_saver(resource_saver_gdn); } -void unregister_dlscript_types() { +void unregister_gdnative_types() { - ScriptServer::unregister_language(script_language_dl); + ScriptServer::unregister_language(script_language_gdn); - if (script_language_dl) - memdelete(script_language_dl); + if (script_language_gdn) + memdelete(script_language_gdn); - if (resource_loader_dl) - memdelete(resource_loader_dl); + if (resource_loader_gdn) + memdelete(resource_loader_gdn); - if (resource_saver_dl) - memdelete(resource_saver_dl); + if (resource_saver_gdn) + memdelete(resource_saver_gdn); } diff --git a/modules/dlscript/register_types.h b/modules/gdnative/register_types.h index 1968986718..48e778cb2c 100644 --- a/modules/dlscript/register_types.h +++ b/modules/gdnative/register_types.h @@ -27,5 +27,5 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -void register_dlscript_types(); -void unregister_dlscript_types(); +void register_gdnative_types(); +void unregister_gdnative_types(); |