aboutsummaryrefslogtreecommitdiff
path: root/modules/nativescript/godot_nativescript.h
diff options
context:
space:
mode:
authorKarroffel2017-07-14 01:44:14 +0200
committerKarroffel2017-07-24 04:23:37 +0200
commit534d62d2f4ea1ff4be11b50bc79684b5780e4615 (patch)
tree0d299c22cbffc2a353c126372a44f067914b71d0 /modules/nativescript/godot_nativescript.h
parent85aa0adeef6ab89e98105fdaa49f441e5763d970 (diff)
downloadgodot-534d62d2f4ea1ff4be11b50bc79684b5780e4615.tar.gz
godot-534d62d2f4ea1ff4be11b50bc79684b5780e4615.tar.zst
godot-534d62d2f4ea1ff4be11b50bc79684b5780e4615.zip
[GDNative] new GDNative API
This adds GDNative as a separate class type. It can be used to interface with native libraries by using "native calls", which can be registered by modules (and in future other GDNative libraries?). It also reworks the currently called "GDNativeScript" into a "NativeScript" that just makes use of the new GDNative instead of it being the component that implements that functionality.
Diffstat (limited to '')
-rw-r--r--modules/nativescript/godot_nativescript.h (renamed from modules/gdnative/godot.h)267
1 files changed, 27 insertions, 240 deletions
diff --git a/modules/gdnative/godot.h b/modules/nativescript/godot_nativescript.h
index 1d8699829..cfd445086 100644
--- a/modules/gdnative/godot.h
+++ b/modules/nativescript/godot_nativescript.h
@@ -27,8 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GODOT_C_H
-#define GODOT_C_H
+#ifndef GODOT_NATIVESCRIPT_H
+#define GODOT_NATIVESCRIPT_H
+
+#include <godot/gdnative.h>
#ifdef __cplusplus
extern "C" {
@@ -70,203 +72,7 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
-#define GODOT_API_VERSION 1
-
-////// Error
-
-typedef enum godot_error {
- GODOT_OK,
- GODOT_FAILED, ///< Generic fail error
- GODOT_ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable
- GODOT_ERR_UNCONFIGURED, ///< The object being used hasnt been properly set up yet
- GODOT_ERR_UNAUTHORIZED, ///< Missing credentials for requested resource
- GODOT_ERR_PARAMETER_RANGE_ERROR, ///< Parameter given out of range (5)
- GODOT_ERR_OUT_OF_MEMORY, ///< Out of memory
- GODOT_ERR_FILE_NOT_FOUND,
- GODOT_ERR_FILE_BAD_DRIVE,
- GODOT_ERR_FILE_BAD_PATH,
- GODOT_ERR_FILE_NO_PERMISSION, // (10)
- GODOT_ERR_FILE_ALREADY_IN_USE,
- GODOT_ERR_FILE_CANT_OPEN,
- GODOT_ERR_FILE_CANT_WRITE,
- GODOT_ERR_FILE_CANT_READ,
- GODOT_ERR_FILE_UNRECOGNIZED, // (15)
- GODOT_ERR_FILE_CORRUPT,
- GODOT_ERR_FILE_MISSING_DEPENDENCIES,
- GODOT_ERR_FILE_EOF,
- GODOT_ERR_CANT_OPEN, ///< Can't open a resource/socket/file
- GODOT_ERR_CANT_CREATE, // (20)
- GODOT_ERR_QUERY_FAILED,
- GODOT_ERR_ALREADY_IN_USE,
- GODOT_ERR_LOCKED, ///< resource is locked
- GODOT_ERR_TIMEOUT,
- GODOT_ERR_CANT_CONNECT, // (25)
- GODOT_ERR_CANT_RESOLVE,
- GODOT_ERR_CONNECTION_ERROR,
- GODOT_ERR_CANT_AQUIRE_RESOURCE,
- GODOT_ERR_CANT_FORK,
- GODOT_ERR_INVALID_DATA, ///< Data passed is invalid (30)
- GODOT_ERR_INVALID_PARAMETER, ///< Parameter passed is invalid
- GODOT_ERR_ALREADY_EXISTS, ///< When adding, item already exists
- GODOT_ERR_DOES_NOT_EXIST, ///< When retrieving/erasing, it item does not exist
- GODOT_ERR_DATABASE_CANT_READ, ///< database is full
- GODOT_ERR_DATABASE_CANT_WRITE, ///< database is full (35)
- GODOT_ERR_COMPILATION_FAILED,
- GODOT_ERR_METHOD_NOT_FOUND,
- GODOT_ERR_LINK_FAILED,
- GODOT_ERR_SCRIPT_FAILED,
- GODOT_ERR_CYCLIC_LINK, // (40)
- GODOT_ERR_INVALID_DECLARATION,
- GODOT_ERR_DUPLICATE_SYMBOL,
- GODOT_ERR_PARSE_ERROR,
- GODOT_ERR_BUSY,
- GODOT_ERR_SKIP, // (45)
- GODOT_ERR_HELP, ///< user requested help!!
- GODOT_ERR_BUG, ///< a bug in the software certainly happened, due to a double check failing or unexpected behavior.
- GODOT_ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames
- GODOT_ERR_OMFG_THIS_IS_VERY_VERY_BAD, ///< shit happens, has never been used, though
- GODOT_ERR_WTF = GODOT_ERR_OMFG_THIS_IS_VERY_VERY_BAD ///< short version of the above
-} godot_error;
-
-////// bool
-
-typedef bool godot_bool;
-
-#define GODOT_TRUE 1
-#define GODOT_FALSE 0
-
-/////// int
-
-typedef int godot_int;
-
-/////// real
-
-typedef float godot_real;
-
-/////// Object (forward declared)
-typedef void godot_object;
-
-/////// Brute force forward declarations for the rest
-typedef struct godot_variant godot_variant;
-typedef struct godot_string godot_string;
-typedef struct godot_vector2 godot_vector2;
-typedef struct godot_rect2 godot_rect2;
-typedef struct godot_vector3 godot_vector3;
-typedef struct godot_transform2d godot_transform2d;
-typedef struct godot_plane godot_plane;
-typedef struct godot_quat godot_quat;
-typedef struct godot_rect3 godot_rect3;
-typedef struct godot_basis godot_basis;
-typedef struct godot_transform godot_transform;
-typedef struct godot_color godot_color;
-typedef struct godot_node_path godot_node_path;
-typedef struct godot_rid godot_rid;
-typedef struct godot_dictionary godot_dictionary;
-typedef struct godot_array godot_array;
-typedef struct godot_pool_byte_array godot_pool_byte_array;
-typedef struct godot_pool_int_array godot_pool_int_array;
-typedef struct godot_pool_real_array godot_pool_real_array;
-typedef struct godot_pool_string_array godot_pool_string_array;
-typedef struct godot_pool_vector2_array godot_pool_vector2_array;
-typedef struct godot_pool_vector3_array godot_pool_vector3_array;
-typedef struct godot_pool_color_array godot_pool_color_array;
-
-/////// String
-
-#include "godot/godot_string.h"
-
-////// Vector2
-
-#include "godot/godot_vector2.h"
-
-////// Rect2
-
-#include "godot/godot_rect2.h"
-
-////// Vector3
-
-#include "godot/godot_vector3.h"
-
-////// Transform2D
-
-#include "godot/godot_transform2d.h"
-
-/////// Plane
-
-#include "godot/godot_plane.h"
-
-/////// Quat
-
-#include "godot/godot_quat.h"
-
-/////// Rect3
-
-#include "godot/godot_rect3.h"
-
-/////// Basis
-
-#include "godot/godot_basis.h"
-
-/////// Transform
-
-#include "godot/godot_transform.h"
-
-/////// Color
-
-#include "godot/godot_color.h"
-
-/////// NodePath
-
-#include "godot/godot_node_path.h"
-
-/////// RID
-
-#include "godot/godot_rid.h"
-
-/////// Dictionary
-
-#include "godot/godot_dictionary.h"
-
-/////// Array
-
-#include "godot/godot_array.h"
-
-// single API file for Pool*Array
-#include "godot/godot_pool_arrays.h"
-
-void GDAPI godot_object_destroy(godot_object *p_o);
-
-////// Variant
-
-#include "godot/godot_variant.h"
-
-////// Singleton API
-
-godot_object GDAPI *godot_global_get_singleton(char *p_name); // result shouldn't be freed
-
-////// MethodBind API
-
-typedef struct godot_method_bind {
- uint8_t _dont_touch_that[1]; // TODO
-} godot_method_bind;
-
-godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname);
-void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_object *p_instance, const void **p_args, void *p_ret);
-godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, godot_object *p_instance, const godot_variant **p_args, const int p_arg_count, godot_variant_call_error *p_call_error);
-////// Script API
-
-typedef struct godot_native_init_options {
- godot_bool in_editor;
- uint64_t core_api_hash;
- uint64_t editor_api_hash;
- uint64_t no_api_hash;
-} godot_native_init_options;
-
-typedef struct godot_native_terminate_options {
- godot_bool in_editor;
-} godot_native_terminate_options;
-
-typedef enum godot_method_rpc_mode {
+typedef enum {
GODOT_METHOD_RPC_MODE_DISABLED,
GODOT_METHOD_RPC_MODE_REMOTE,
GODOT_METHOD_RPC_MODE_SYNC,
@@ -274,11 +80,7 @@ typedef enum godot_method_rpc_mode {
GODOT_METHOD_RPC_MODE_SLAVE,
} godot_method_rpc_mode;
-typedef struct godot_method_attributes {
- godot_method_rpc_mode rpc_type;
-} godot_method_attributes;
-
-typedef enum godot_property_hint {
+typedef enum {
GODOT_PROPERTY_HINT_NONE, ///< no hint provided.
GODOT_PROPERTY_HINT_RANGE, ///< hint_text = "min,max,step,slider; //slider is optional"
GODOT_PROPERTY_HINT_EXP_RANGE, ///< hint_text = "min,max,step", exponential edit
@@ -315,7 +117,7 @@ typedef enum godot_property_hint {
GODOT_PROPERTY_HINT_MAX,
} godot_property_hint;
-typedef enum godot_property_usage_flags {
+typedef enum {
GODOT_PROPERTY_USAGE_STORAGE = 1,
GODOT_PROPERTY_USAGE_EDITOR = 2,
@@ -340,7 +142,7 @@ typedef enum godot_property_usage_flags {
GODOT_PROPERTY_USAGE_NOEDITOR = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_NETWORK,
} godot_property_usage_flags;
-typedef struct godot_property_attributes {
+typedef struct {
godot_method_rpc_mode rset_type;
godot_int type;
@@ -350,50 +152,54 @@ typedef struct godot_property_attributes {
godot_variant default_value;
} godot_property_attributes;
-typedef struct godot_instance_create_func {
+typedef struct {
// instance pointer, method_data - return user data
GDCALLINGCONV void *(*create_func)(godot_object *, void *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
} godot_instance_create_func;
-typedef struct godot_instance_destroy_func {
+typedef struct {
// instance pointer, method data, user data
GDCALLINGCONV void (*destroy_func)(godot_object *, void *, void *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
} godot_instance_destroy_func;
-void GDAPI godot_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);
+void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func);
-void GDAPI godot_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);
+void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func);
+
+typedef struct {
+ godot_method_rpc_mode rpc_type;
+} godot_method_attributes;
-typedef struct godot_instance_method {
+typedef struct {
// instance pointer, method data, user data, num args, args - return result as varaint
GDCALLINGCONV godot_variant (*method)(godot_object *, void *, void *, int, godot_variant **);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
} godot_instance_method;
-void GDAPI godot_script_register_method(const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method);
+void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method);
-typedef struct godot_property_set_func {
+typedef struct {
// instance pointer, method data, user data, value
- GDCALLINGCONV void (*set_func)(godot_object *, void *, void *, godot_variant);
+ GDCALLINGCONV void (*set_func)(godot_object *, void *, void *, godot_variant *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
} godot_property_set_func;
-typedef struct godot_property_get_func {
+typedef struct {
// instance pointer, method data, user data, value
GDCALLINGCONV godot_variant (*get_func)(godot_object *, void *, void *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
} godot_property_get_func;
-void GDAPI godot_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);
+void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_property_attributes *p_attr, godot_property_set_func p_set_func, godot_property_get_func p_get_func);
-typedef struct godot_signal_argument {
+typedef struct {
godot_string name;
godot_int type;
godot_property_hint hint;
@@ -402,7 +208,7 @@ typedef struct godot_signal_argument {
godot_variant default_value;
} godot_signal_argument;
-typedef struct godot_signal {
+typedef struct {
godot_string name;
int num_args;
godot_signal_argument *args;
@@ -410,31 +216,12 @@ typedef struct godot_signal {
godot_variant *default_args;
} godot_signal;
-void GDAPI godot_script_register_signal(const char *p_name, const godot_signal *p_signal);
-
-void GDAPI *godot_native_get_userdata(godot_object *p_instance);
-
-// Calling convention?
-typedef godot_object *(*godot_class_constructor)();
-
-godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname);
+void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_signal *p_signal);
-godot_dictionary GDAPI godot_get_global_constants();
-
-////// System Functions
-
-//using these will help Godot track how much memory is in use in debug mode
-void GDAPI *godot_alloc(int p_bytes);
-void GDAPI *godot_realloc(void *p_ptr, int p_bytes);
-void GDAPI godot_free(void *p_ptr);
-
-//print using Godot's error handler list
-void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line);
-void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line);
-void GDAPI godot_print(const godot_string *p_message);
+void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance);
#ifdef __cplusplus
}
#endif
-#endif // GODOT_C_H
+#endif