diff --git a/include/android/pandemonium_android.h b/include/android/pandemonium_android.h new file mode 100644 index 0000000..91c7aed --- /dev/null +++ b/include/android/pandemonium_android.h @@ -0,0 +1,56 @@ +/**************************************************************************/ +/* pandemonium_android.h */ +/**************************************************************************/ +/* This file is part of: */ +/* PANDEMONIUM ENGINE */ +/* https://pandemoniumengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* 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 PANDEMONIUM_ANDROID_H +#define PANDEMONIUM_ANDROID_H + +#include + +#ifdef __ANDROID__ +#include +#else +#define JNIEnv void +#define jobject void * +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +JNIEnv *GDAPI pandemonium_android_get_env(); +jobject GDAPI pandemonium_android_get_activity(); +jobject GDAPI pandemonium_android_get_surface(); +bool GDAPI pandemonium_android_is_activity_resumed(); + +#ifdef __cplusplus +} +#endif + +#endif // PANDEMONIUM_ANDROID_H diff --git a/include/nativescript/pandemonium_nativescript.h b/include/nativescript/pandemonium_nativescript.h new file mode 100644 index 0000000..7902f69 --- /dev/null +++ b/include/nativescript/pandemonium_nativescript.h @@ -0,0 +1,257 @@ +/**************************************************************************/ +/* pandemonium_nativescript.h */ +/**************************************************************************/ +/* This file is part of: */ +/* PANDEMONIUM ENGINE */ +/* https://pandemoniumengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* 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 PANDEMONIUM_NATIVESCRIPT_H +#define PANDEMONIUM_NATIVESCRIPT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + PANDEMONIUM_METHOD_RPC_MODE_DISABLED, + PANDEMONIUM_METHOD_RPC_MODE_REMOTE, + PANDEMONIUM_METHOD_RPC_MODE_MASTER, + PANDEMONIUM_METHOD_RPC_MODE_PUPPET, + PANDEMONIUM_METHOD_RPC_MODE_SLAVE = PANDEMONIUM_METHOD_RPC_MODE_PUPPET, + PANDEMONIUM_METHOD_RPC_MODE_REMOTESYNC, + PANDEMONIUM_METHOD_RPC_MODE_SYNC = PANDEMONIUM_METHOD_RPC_MODE_REMOTESYNC, + PANDEMONIUM_METHOD_RPC_MODE_MASTERSYNC, + PANDEMONIUM_METHOD_RPC_MODE_PUPPETSYNC, +} pandemonium_method_rpc_mode; + +typedef enum { + PANDEMONIUM_PROPERTY_HINT_NONE, ///< no hint provided. + PANDEMONIUM_PROPERTY_HINT_RANGE, ///< hint_text = "min,max,step,slider; //slider is optional" + PANDEMONIUM_PROPERTY_HINT_EXP_RANGE, ///< hint_text = "min,max,step", exponential edit + PANDEMONIUM_PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc" + PANDEMONIUM_PROPERTY_HINT_EXP_EASING, /// exponential easing function (Math::ease) + PANDEMONIUM_PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer) + PANDEMONIUM_PROPERTY_HINT_SPRITE_FRAME, // FIXME: Obsolete: drop whenever we can break compat + PANDEMONIUM_PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer) + PANDEMONIUM_PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags) + PANDEMONIUM_PROPERTY_HINT_LAYERS_2D_RENDER, + PANDEMONIUM_PROPERTY_HINT_LAYERS_2D_PHYSICS, + PANDEMONIUM_PROPERTY_HINT_LAYERS_2D_NAVIGATION, + PANDEMONIUM_PROPERTY_HINT_LAYERS_3D_RENDER, + PANDEMONIUM_PROPERTY_HINT_LAYERS_3D_PHYSICS, + PANDEMONIUM_PROPERTY_HINT_LAYERS_3D_NAVIGATION, + PANDEMONIUM_PROPERTY_HINT_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc," + PANDEMONIUM_PROPERTY_HINT_DIR, ///< a directory path must be passed + PANDEMONIUM_PROPERTY_HINT_GLOBAL_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc," + PANDEMONIUM_PROPERTY_HINT_GLOBAL_DIR, ///< a directory path must be passed + PANDEMONIUM_PROPERTY_HINT_RESOURCE_TYPE, ///< a resource object type + PANDEMONIUM_PROPERTY_HINT_MULTILINE_TEXT, ///< used for string properties that can contain multiple lines + PANDEMONIUM_PROPERTY_HINT_PLACEHOLDER_TEXT, ///< used to set a placeholder text for string properties + PANDEMONIUM_PROPERTY_HINT_COLOR_NO_ALPHA, ///< used for ignoring alpha component when editing a color + PANDEMONIUM_PROPERTY_HINT_IMAGE_COMPRESS_LOSSY, + PANDEMONIUM_PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS, + PANDEMONIUM_PROPERTY_HINT_OBJECT_ID, + PANDEMONIUM_PROPERTY_HINT_TYPE_STRING, ///< a type string, the hint is the base type to choose + PANDEMONIUM_PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE, ///< so something else can provide this (used in scripts) + PANDEMONIUM_PROPERTY_HINT_METHOD_OF_VARIANT_TYPE, ///< a method of a type + PANDEMONIUM_PROPERTY_HINT_METHOD_OF_BASE_TYPE, ///< a method of a base type + PANDEMONIUM_PROPERTY_HINT_METHOD_OF_INSTANCE, ///< a method of an instance + PANDEMONIUM_PROPERTY_HINT_METHOD_OF_SCRIPT, ///< a method of a script & base + PANDEMONIUM_PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE, ///< a property of a type + PANDEMONIUM_PROPERTY_HINT_PROPERTY_OF_BASE_TYPE, ///< a property of a base type + PANDEMONIUM_PROPERTY_HINT_PROPERTY_OF_INSTANCE, ///< a property of an instance + PANDEMONIUM_PROPERTY_HINT_PROPERTY_OF_SCRIPT, ///< a property of a script & base + PANDEMONIUM_PROPERTY_HINT_OBJECT_TOO_BIG, ///< object is too big to send + PANDEMONIUM_PROPERTY_HINT_NODE_PATH_VALID_TYPES, + PANDEMONIUM_PROPERTY_HINT_SAVE_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,". This opens a save dialog + PANDEMONIUM_PROPERTY_HINT_ENUM_SUGGESTION, ///< hint_text= "val1,val2,val3,etc" + PANDEMONIUM_PROPERTY_HINT_LOCALE_ID, + PANDEMONIUM_PROPERTY_HINT_MAX, +} pandemonium_property_hint; + +typedef enum { + + PANDEMONIUM_PROPERTY_USAGE_STORAGE = 1, + PANDEMONIUM_PROPERTY_USAGE_EDITOR = 2, + PANDEMONIUM_PROPERTY_USAGE_NETWORK = 4, + PANDEMONIUM_PROPERTY_USAGE_EDITOR_HELPER = 8, + PANDEMONIUM_PROPERTY_USAGE_CHECKABLE = 16, //used for editing global variables + PANDEMONIUM_PROPERTY_USAGE_CHECKED = 32, //used for editing global variables + PANDEMONIUM_PROPERTY_USAGE_INTERNATIONALIZED = 64, //hint for internationalized strings + PANDEMONIUM_PROPERTY_USAGE_GROUP = 128, //used for grouping props in the editor + PANDEMONIUM_PROPERTY_USAGE_CATEGORY = 256, + PANDEMONIUM_PROPERTY_USAGE_STORE_IF_NONZERO = 512, // FIXME: Obsolete: drop whenever we can break compat + PANDEMONIUM_PROPERTY_USAGE_STORE_IF_NONONE = 1024, // FIXME: Obsolete: drop whenever we can break compat + PANDEMONIUM_PROPERTY_USAGE_NO_INSTANCE_STATE = 2048, + PANDEMONIUM_PROPERTY_USAGE_RESTART_IF_CHANGED = 4096, + PANDEMONIUM_PROPERTY_USAGE_SCRIPT_VARIABLE = 8192, + PANDEMONIUM_PROPERTY_USAGE_STORE_IF_NULL = 16384, + PANDEMONIUM_PROPERTY_USAGE_ANIMATE_AS_TRIGGER = 32768, + PANDEMONIUM_PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED = 65536, + + PANDEMONIUM_PROPERTY_USAGE_DEFAULT = PANDEMONIUM_PROPERTY_USAGE_STORAGE | PANDEMONIUM_PROPERTY_USAGE_EDITOR | PANDEMONIUM_PROPERTY_USAGE_NETWORK, + PANDEMONIUM_PROPERTY_USAGE_DEFAULT_INTL = PANDEMONIUM_PROPERTY_USAGE_STORAGE | PANDEMONIUM_PROPERTY_USAGE_EDITOR | PANDEMONIUM_PROPERTY_USAGE_NETWORK | PANDEMONIUM_PROPERTY_USAGE_INTERNATIONALIZED, + PANDEMONIUM_PROPERTY_USAGE_NOEDITOR = PANDEMONIUM_PROPERTY_USAGE_STORAGE | PANDEMONIUM_PROPERTY_USAGE_NETWORK, +} pandemonium_property_usage_flags; + +typedef struct { + pandemonium_method_rpc_mode rset_type; + + pandemonium_int type; + pandemonium_property_hint hint; + pandemonium_string hint_string; + pandemonium_property_usage_flags usage; + pandemonium_variant default_value; +} pandemonium_property_attributes; + +typedef struct { + // instance pointer, method_data - return user data + GDCALLINGCONV void *(*create_func)(pandemonium_object *, void *); + void *method_data; + GDCALLINGCONV void (*free_func)(void *); +} pandemonium_instance_create_func; + +typedef struct { + // instance pointer, method data, user data + GDCALLINGCONV void (*destroy_func)(pandemonium_object *, void *, void *); + void *method_data; + GDCALLINGCONV void (*free_func)(void *); +} pandemonium_instance_destroy_func; + +void GDAPI pandemonium_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, pandemonium_instance_create_func p_create_func, pandemonium_instance_destroy_func p_destroy_func); + +void GDAPI pandemonium_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, pandemonium_instance_create_func p_create_func, pandemonium_instance_destroy_func p_destroy_func); + +typedef struct { + pandemonium_method_rpc_mode rpc_type; +} pandemonium_method_attributes; + +typedef struct { + // instance pointer, method data, user data, num args, args - return result as variant + GDCALLINGCONV pandemonium_variant (*method)(pandemonium_object *, void *, void *, int, pandemonium_variant **); + void *method_data; + GDCALLINGCONV void (*free_func)(void *); +} pandemonium_instance_method; + +void GDAPI pandemonium_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, pandemonium_method_attributes p_attr, pandemonium_instance_method p_method); + +typedef struct { + // instance pointer, method data, user data, value + GDCALLINGCONV void (*set_func)(pandemonium_object *, void *, void *, pandemonium_variant *); + void *method_data; + GDCALLINGCONV void (*free_func)(void *); +} pandemonium_property_set_func; + +typedef struct { + // instance pointer, method data, user data, value + GDCALLINGCONV pandemonium_variant (*get_func)(pandemonium_object *, void *, void *); + void *method_data; + GDCALLINGCONV void (*free_func)(void *); +} pandemonium_property_get_func; + +void GDAPI pandemonium_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, pandemonium_property_attributes *p_attr, pandemonium_property_set_func p_set_func, pandemonium_property_get_func p_get_func); + +typedef struct { + pandemonium_string name; + pandemonium_int type; + pandemonium_property_hint hint; + pandemonium_string hint_string; + pandemonium_property_usage_flags usage; + pandemonium_variant default_value; +} pandemonium_signal_argument; + +typedef struct { + pandemonium_string name; + int num_args; + pandemonium_signal_argument *args; + int num_default_args; + pandemonium_variant *default_args; +} pandemonium_signal; + +void GDAPI pandemonium_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const pandemonium_signal *p_signal); + +void GDAPI *pandemonium_nativescript_get_userdata(pandemonium_object *p_instance); + +/* + * + * + * NativeScript 1.1 + * + * + */ + +// method registering with argument names + +typedef struct { + pandemonium_string name; + + pandemonium_variant_type type; + pandemonium_property_hint hint; + pandemonium_string hint_string; +} pandemonium_method_arg; + +void GDAPI pandemonium_nativescript_set_method_argument_information(void *p_gdnative_handle, const char *p_name, const char *p_function_name, int p_num_args, const pandemonium_method_arg *p_args); + +// documentation + +void GDAPI pandemonium_nativescript_set_class_documentation(void *p_gdnative_handle, const char *p_name, pandemonium_string p_documentation); +void GDAPI pandemonium_nativescript_set_method_documentation(void *p_gdnative_handle, const char *p_name, const char *p_function_name, pandemonium_string p_documentation); +void GDAPI pandemonium_nativescript_set_property_documentation(void *p_gdnative_handle, const char *p_name, const char *p_path, pandemonium_string p_documentation); +void GDAPI pandemonium_nativescript_set_signal_documentation(void *p_gdnative_handle, const char *p_name, const char *p_signal_name, pandemonium_string p_documentation); + +// type tag API + +void GDAPI pandemonium_nativescript_set_global_type_tag(int p_idx, const char *p_name, const void *p_type_tag); +const void GDAPI *pandemonium_nativescript_get_global_type_tag(int p_idx, const char *p_name); + +void GDAPI pandemonium_nativescript_set_type_tag(void *p_gdnative_handle, const char *p_name, const void *p_type_tag); +const void GDAPI *pandemonium_nativescript_get_type_tag(const pandemonium_object *p_object); + +// instance binding API + +typedef struct { + GDCALLINGCONV void *(*alloc_instance_binding_data)(void *, const void *, pandemonium_object *); + GDCALLINGCONV void (*free_instance_binding_data)(void *, void *); + GDCALLINGCONV void (*refcount_incremented_instance_binding)(void *, pandemonium_object *); + GDCALLINGCONV bool (*refcount_decremented_instance_binding)(void *, pandemonium_object *); + void *data; + GDCALLINGCONV void (*free_func)(void *); +} pandemonium_instance_binding_functions; + +int GDAPI pandemonium_nativescript_register_instance_binding_data_functions(pandemonium_instance_binding_functions p_binding_functions); +void GDAPI pandemonium_nativescript_unregister_instance_binding_data_functions(int p_idx); + +void GDAPI *pandemonium_nativescript_get_instance_binding_data(int p_idx, pandemonium_object *p_object); + +void GDAPI pandemonium_nativescript_profiling_add_data(const char *p_signature, uint64_t p_time); + +#ifdef __cplusplus +} +#endif + +#endif // PANDEMONIUM_NATIVESCRIPT_H diff --git a/include/net/pandemonium_net.h b/include/net/pandemonium_net.h new file mode 100644 index 0000000..f7b2117 --- /dev/null +++ b/include/net/pandemonium_net.h @@ -0,0 +1,117 @@ +/**************************************************************************/ +/* pandemonium_net.h */ +/**************************************************************************/ +/* This file is part of: */ +/* PANDEMONIUM ENGINE */ +/* https://pandemoniumengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* 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 PANDEMONIUM_NET_H +#define PANDEMONIUM_NET_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// For future versions of the API we should only add new functions at the end of the structure and use the +// version info to detect whether a call is available + +// Use these to populate version in your plugin +#define PANDEMONIUM_NET_API_MAJOR 3 +#define PANDEMONIUM_NET_API_MINOR 1 + +typedef struct { + pandemonium_gdnative_api_version version; /* version of our API */ + pandemonium_object *data; /* User reference */ + + /* This is StreamPeer */ + pandemonium_error (*get_data)(void *user, uint8_t *p_buffer, int p_bytes); + pandemonium_error (*get_partial_data)(void *user, uint8_t *p_buffer, int p_bytes, int *r_received); + pandemonium_error (*put_data)(void *user, const uint8_t *p_data, int p_bytes); + pandemonium_error (*put_partial_data)(void *user, const uint8_t *p_data, int p_bytes, int *r_sent); + + int (*get_available_bytes)(const void *user); + + void *next; /* For extension? */ +} pandemonium_net_stream_peer; + +/* Binds a StreamPeerGDNative to the provided interface */ +void pandemonium_net_bind_stream_peer(pandemonium_object *p_obj, const pandemonium_net_stream_peer *p_interface); + +typedef struct { + pandemonium_gdnative_api_version version; /* version of our API */ + + pandemonium_object *data; /* User reference */ + + /* This is PacketPeer */ + pandemonium_error (*get_packet)(void *, const uint8_t **, int *); + pandemonium_error (*put_packet)(void *, const uint8_t *, int); + pandemonium_int (*get_available_packet_count)(const void *); + pandemonium_int (*get_max_packet_size)(const void *); + + void *next; /* For extension? */ +} pandemonium_net_packet_peer; + +/* Binds a PacketPeerGDNative to the provided interface */ +void GDAPI pandemonium_net_bind_packet_peer(pandemonium_object *p_obj, const pandemonium_net_packet_peer *); + +typedef struct { + pandemonium_gdnative_api_version version; /* version of our API */ + + pandemonium_object *data; /* User reference */ + + /* This is PacketPeer */ + pandemonium_error (*get_packet)(void *, const uint8_t **, int *); + pandemonium_error (*put_packet)(void *, const uint8_t *, int); + pandemonium_int (*get_available_packet_count)(const void *); + pandemonium_int (*get_max_packet_size)(const void *); + + /* This is NetworkedMultiplayerPeer */ + void (*set_transfer_mode)(void *, pandemonium_int); + pandemonium_int (*get_transfer_mode)(const void *); + // 0 = broadcast, 1 = server, <0 = all but abs(value) + void (*set_target_peer)(void *, pandemonium_int); + pandemonium_int (*get_packet_peer)(const void *); + pandemonium_bool (*is_server)(const void *); + void (*poll)(void *); + // Must be > 0, 1 is for server + int32_t (*get_unique_id)(const void *); + void (*set_refuse_new_connections)(void *, pandemonium_bool); + pandemonium_bool (*is_refusing_new_connections)(const void *); + pandemonium_int (*get_connection_status)(const void *); + + void *next; /* For extension? Or maybe not... */ +} pandemonium_net_multiplayer_peer; + +/* Binds a MultiplayerPeerGDNative to the provided interface */ +void GDAPI pandemonium_net_bind_multiplayer_peer(pandemonium_object *p_obj, const pandemonium_net_multiplayer_peer *); + +#ifdef __cplusplus +} +#endif + +#endif // PANDEMONIUM_NET_H diff --git a/include/pluginscript/pandemonium_pluginscript.h b/include/pluginscript/pandemonium_pluginscript.h new file mode 100644 index 0000000..9ff6dd5 --- /dev/null +++ b/include/pluginscript/pandemonium_pluginscript.h @@ -0,0 +1,172 @@ +/**************************************************************************/ +/* pandemonium_pluginscript.h */ +/**************************************************************************/ +/* This file is part of: */ +/* PANDEMONIUM ENGINE */ +/* https://pandemoniumengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* 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 PANDEMONIUM_PLUGINSCRIPT_H +#define PANDEMONIUM_PLUGINSCRIPT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void pandemonium_pluginscript_instance_data; +typedef void pandemonium_pluginscript_script_data; +typedef void pandemonium_pluginscript_language_data; + +// --- Instance --- + +// TODO: use pandemonium_string_name for faster lookup ? +typedef struct { + pandemonium_pluginscript_instance_data *(*init)(pandemonium_pluginscript_script_data *p_data, pandemonium_object *p_owner); + void (*finish)(pandemonium_pluginscript_instance_data *p_data); + + pandemonium_bool (*set_prop)(pandemonium_pluginscript_instance_data *p_data, const pandemonium_string *p_name, const pandemonium_variant *p_value); + pandemonium_bool (*get_prop)(pandemonium_pluginscript_instance_data *p_data, const pandemonium_string *p_name, pandemonium_variant *r_ret); + + pandemonium_variant (*call_method)(pandemonium_pluginscript_instance_data *p_data, + const pandemonium_string_name *p_method, const pandemonium_variant **p_args, + int p_argcount, pandemonium_variant_call_error *r_error); + + void (*notification)(pandemonium_pluginscript_instance_data *p_data, int p_notification); + // TODO: could this rpc mode stuff be moved to the pandemonium_pluginscript_script_manifest ? + pandemonium_method_rpc_mode (*get_rpc_mode)(pandemonium_pluginscript_instance_data *p_data, const pandemonium_string *p_method); + pandemonium_method_rpc_mode (*get_rset_mode)(pandemonium_pluginscript_instance_data *p_data, const pandemonium_string *p_variable); + + //this is used by script languages that keep a reference counter of their own + //you can make make Ref<> not die when it reaches zero, so deleting the reference + //depends entirely from the script. + // Note: You can set those function pointer to NULL if not needed. + void (*refcount_incremented)(pandemonium_pluginscript_instance_data *p_data); + bool (*refcount_decremented)(pandemonium_pluginscript_instance_data *p_data); // return true if it can die +} pandemonium_pluginscript_instance_desc; + +// --- Script --- + +typedef struct { + pandemonium_pluginscript_script_data *data; + pandemonium_string_name name; + pandemonium_bool is_tool; + pandemonium_string_name base; + + // Member lines format: {: } + pandemonium_dictionary member_lines; + // Method info dictionary format + // { + // name: + // args: [] + // default_args: [] + // return: + // flags: + // rpc_mode: + // } + pandemonium_array methods; + // Same format than for methods + pandemonium_array signals; + // Property info dictionary format + // { + // name: + // type: + // hint: + // hint_string: + // usage: + // default_value: + // rset_mode: + // } + pandemonium_array properties; +} pandemonium_pluginscript_script_manifest; + +typedef struct { + pandemonium_pluginscript_script_manifest (*init)(pandemonium_pluginscript_language_data *p_data, const pandemonium_string *p_path, const pandemonium_string *p_source, pandemonium_error *r_error); + void (*finish)(pandemonium_pluginscript_script_data *p_data); + pandemonium_pluginscript_instance_desc instance_desc; +} pandemonium_pluginscript_script_desc; + +// --- Language --- + +typedef struct { + pandemonium_string_name signature; + pandemonium_int call_count; + pandemonium_int total_time; // In microseconds + pandemonium_int self_time; // In microseconds +} pandemonium_pluginscript_profiling_data; + +typedef struct { + const char *name; + const char *type; + const char *extension; + const char **recognized_extensions; // NULL terminated array + pandemonium_pluginscript_language_data *(*init)(); + void (*finish)(pandemonium_pluginscript_language_data *p_data); + const char **reserved_words; // NULL terminated array + const char **comment_delimiters; // NULL terminated array + const char **string_delimiters; // NULL terminated array + pandemonium_bool has_named_classes; + pandemonium_bool supports_builtin_mode; + + pandemonium_string (*get_template_source_code)(pandemonium_pluginscript_language_data *p_data, const pandemonium_string *p_class_name, const pandemonium_string *p_base_class_name); + pandemonium_bool (*validate)(pandemonium_pluginscript_language_data *p_data, const pandemonium_string *p_script, int *r_line_error, int *r_col_error, pandemonium_string *r_test_error, const pandemonium_string *p_path, pandemonium_pool_string_array *r_functions); + int (*find_function)(pandemonium_pluginscript_language_data *p_data, const pandemonium_string *p_function, const pandemonium_string *p_code); // Can be NULL + pandemonium_string (*make_function)(pandemonium_pluginscript_language_data *p_data, const pandemonium_string *p_class, const pandemonium_string *p_name, const pandemonium_pool_string_array *p_args); + pandemonium_error (*complete_code)(pandemonium_pluginscript_language_data *p_data, const pandemonium_string *p_code, const pandemonium_string *p_path, pandemonium_object *p_owner, pandemonium_array *r_options, pandemonium_bool *r_force, pandemonium_string *r_call_hint); + void (*auto_indent_code)(pandemonium_pluginscript_language_data *p_data, pandemonium_string *p_code, int p_from_line, int p_to_line); + + void (*add_global_constant)(pandemonium_pluginscript_language_data *p_data, const pandemonium_string *p_variable, const pandemonium_variant *p_value); + pandemonium_string (*debug_get_error)(pandemonium_pluginscript_language_data *p_data); + int (*debug_get_stack_level_count)(pandemonium_pluginscript_language_data *p_data); + int (*debug_get_stack_level_line)(pandemonium_pluginscript_language_data *p_data, int p_level); + pandemonium_string (*debug_get_stack_level_function)(pandemonium_pluginscript_language_data *p_data, int p_level); + pandemonium_string (*debug_get_stack_level_source)(pandemonium_pluginscript_language_data *p_data, int p_level); + void (*debug_get_stack_level_locals)(pandemonium_pluginscript_language_data *p_data, int p_level, pandemonium_pool_string_array *p_locals, pandemonium_array *p_values, int p_max_subitems, int p_max_depth); + void (*debug_get_stack_level_members)(pandemonium_pluginscript_language_data *p_data, int p_level, pandemonium_pool_string_array *p_members, pandemonium_array *p_values, int p_max_subitems, int p_max_depth); + void (*debug_get_globals)(pandemonium_pluginscript_language_data *p_data, pandemonium_pool_string_array *p_locals, pandemonium_array *p_values, int p_max_subitems, int p_max_depth); + pandemonium_string (*debug_parse_stack_level_expression)(pandemonium_pluginscript_language_data *p_data, int p_level, const pandemonium_string *p_expression, int p_max_subitems, int p_max_depth); + + // TODO: could this stuff be moved to the pandemonium_pluginscript_language_desc ? + void (*get_public_functions)(pandemonium_pluginscript_language_data *p_data, pandemonium_array *r_functions); + void (*get_public_constants)(pandemonium_pluginscript_language_data *p_data, pandemonium_dictionary *r_constants); + + void (*profiling_start)(pandemonium_pluginscript_language_data *p_data); + void (*profiling_stop)(pandemonium_pluginscript_language_data *p_data); + int (*profiling_get_accumulated_data)(pandemonium_pluginscript_language_data *p_data, pandemonium_pluginscript_profiling_data *r_info, int p_info_max); + int (*profiling_get_frame_data)(pandemonium_pluginscript_language_data *p_data, pandemonium_pluginscript_profiling_data *r_info, int p_info_max); + void (*profiling_frame)(pandemonium_pluginscript_language_data *p_data); + + pandemonium_pluginscript_script_desc script_desc; +} pandemonium_pluginscript_language_desc; + +void GDAPI pandemonium_pluginscript_register_language(const pandemonium_pluginscript_language_desc *language_desc); + +#ifdef __cplusplus +} +#endif + +#endif // PANDEMONIUM_PLUGINSCRIPT_H diff --git a/include/videodecoder/pandemonium_videodecoder.h b/include/videodecoder/pandemonium_videodecoder.h new file mode 100644 index 0000000..8636f2f --- /dev/null +++ b/include/videodecoder/pandemonium_videodecoder.h @@ -0,0 +1,75 @@ +/**************************************************************************/ +/* pandemonium_videodecoder.h */ +/**************************************************************************/ +/* This file is part of: */ +/* PANDEMONIUM ENGINE */ +/* https://pandemoniumengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* 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 PANDEMONIUM_VIDEODECODER_H +#define PANDEMONIUM_VIDEODECODER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PANDEMONIUMAV_API_MAJOR 0 +#define PANDEMONIUMAV_API_MINOR 1 + +typedef struct +{ + pandemonium_gdnative_api_version version; + void *next; + void *(*constructor)(pandemonium_object *); + void (*destructor)(void *); + const char *(*get_plugin_name)(); + const char **(*get_supported_extensions)(int *count); + pandemonium_bool (*open_file)(void *, void *); // data struct, and a FileAccess pointer + pandemonium_real (*get_length)(const void *); + pandemonium_real (*get_playback_position)(const void *); + void (*seek)(void *, pandemonium_real); + void (*set_audio_track)(void *, pandemonium_int); + void (*update)(void *, pandemonium_real); + pandemonium_pool_byte_array *(*get_videoframe)(void *); + pandemonium_int (*get_audioframe)(void *, float *, int); + pandemonium_int (*get_channels)(const void *); + pandemonium_int (*get_mix_rate)(const void *); + pandemonium_vector2 (*get_texture_size)(const void *); +} pandemonium_videodecoder_interface_gdnative; + +typedef int (*GDNativeAudioMixCallback)(void *, const float *, int); + +// FileAccess wrappers for custom FFmpeg IO +pandemonium_int GDAPI pandemonium_videodecoder_file_read(void *file_ptr, uint8_t *buf, int buf_size); +int64_t GDAPI pandemonium_videodecoder_file_seek(void *file_ptr, int64_t pos, int whence); +void GDAPI pandemonium_videodecoder_register_decoder(const pandemonium_videodecoder_interface_gdnative *p_interface); + +#ifdef __cplusplus +} +#endif + +#endif // PANDEMONIUM_VIDEODECODER_H diff --git a/nativescript/pandemonium_nativescript.cpp b/nativescript/pandemonium_nativescript.cpp new file mode 100644 index 0000000..3b50394 --- /dev/null +++ b/nativescript/pandemonium_nativescript.cpp @@ -0,0 +1,322 @@ +/**************************************************************************/ +/* pandemonium_nativescript.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* PANDEMONIUM ENGINE */ +/* https://pandemoniumengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "nativescript/pandemonium_nativescript.h" + +#include "core/object/class_db.h" +#include "core/error/error_macros.h" +#include "core/global_constants.h" +#include "core/config/project_settings.h" +#include "core/variant/variant.h" +#include "gdnative/gdnative.h" + +#include "nativescript.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern "C" void _native_script_hook() { +} + +#define NSL NativeScriptLanguage::get_singleton() + +// Script API + +void GDAPI pandemonium_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, pandemonium_instance_create_func p_create_func, pandemonium_instance_destroy_func p_destroy_func) { + String *s = (String *)p_gdnative_handle; + + RBMap *classes = &NSL->library_classes[*s]; + + NativeScriptDesc desc; + + desc.create_func = p_create_func; + desc.destroy_func = p_destroy_func; + desc.is_tool = false; + + desc.base = p_base; + + if (classes->has(p_base)) { + desc.base_data = &(*classes)[p_base]; + desc.base_native_type = desc.base_data->base_native_type; + } else { + desc.base_data = nullptr; + desc.base_native_type = p_base; + } + + classes->insert(p_name, desc); +} + +void GDAPI pandemonium_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, pandemonium_instance_create_func p_create_func, pandemonium_instance_destroy_func p_destroy_func) { + String *s = (String *)p_gdnative_handle; + + RBMap *classes = &NSL->library_classes[*s]; + + NativeScriptDesc desc; + + desc.create_func = p_create_func; + desc.destroy_func = p_destroy_func; + desc.is_tool = true; + desc.base = p_base; + + if (classes->has(p_base)) { + desc.base_data = &(*classes)[p_base]; + desc.base_native_type = desc.base_data->base_native_type; + } else { + desc.base_data = nullptr; + desc.base_native_type = p_base; + } + + classes->insert(p_name, desc); +} + +void GDAPI pandemonium_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, pandemonium_method_attributes p_attr, pandemonium_instance_method p_method) { + String *s = (String *)p_gdnative_handle; + + RBMap::Element *E = NSL->library_classes[*s].find(p_name); + ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class."); + + NativeScriptDesc::Method method; + method.method = p_method; + method.rpc_mode = p_attr.rpc_type; + method.info = MethodInfo(p_function_name); + + E->get().methods.insert(p_function_name, method); +} + +void GDAPI pandemonium_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, pandemonium_property_attributes *p_attr, pandemonium_property_set_func p_set_func, pandemonium_property_get_func p_get_func) { + String *s = (String *)p_gdnative_handle; + + RBMap::Element *E = NSL->library_classes[*s].find(p_name); + ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class."); + + NativeScriptDesc::Property property; + property.default_value = *(Variant *)&p_attr->default_value; + property.getter = p_get_func; + property.rset_mode = p_attr->rset_type; + property.setter = p_set_func; + property.info = PropertyInfo((Variant::Type)p_attr->type, + p_path, + (PropertyHint)p_attr->hint, + *(String *)&p_attr->hint_string, + (PropertyUsageFlags)p_attr->usage); + + E->get().properties.insert(p_path, property); +} + +void GDAPI pandemonium_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const pandemonium_signal *p_signal) { + String *s = (String *)p_gdnative_handle; + + RBMap::Element *E = NSL->library_classes[*s].find(p_name); + ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class."); + + List args; + Vector default_args; + + for (int i = 0; i < p_signal->num_args; i++) { + PropertyInfo info; + + pandemonium_signal_argument arg = p_signal->args[i]; + + info.hint = (PropertyHint)arg.hint; + info.hint_string = *(String *)&arg.hint_string; + info.name = *(String *)&arg.name; + info.type = (Variant::Type)arg.type; + info.usage = (PropertyUsageFlags)arg.usage; + + args.push_back(info); + } + + for (int i = 0; i < p_signal->num_default_args; i++) { + Variant *v; + pandemonium_signal_argument attrib = p_signal->args[i]; + + v = (Variant *)&attrib.default_value; + + default_args.push_back(*v); + } + + MethodInfo method_info; + method_info.name = *(String *)&p_signal->name; + method_info.arguments = args; + method_info.default_arguments = default_args; + + NativeScriptDesc::Signal signal; + signal.signal = method_info; + + E->get().signals_.insert(*(String *)&p_signal->name, signal); +} + +void GDAPI *pandemonium_nativescript_get_userdata(pandemonium_object *p_instance) { + Object *instance = (Object *)p_instance; + if (!instance) { + return nullptr; + } + if (instance->get_script_instance() && instance->get_script_instance()->get_language() == NativeScriptLanguage::get_singleton()) { + return ((NativeScriptInstance *)instance->get_script_instance())->userdata; + } + return nullptr; +} + +/* + * + * + * NativeScript 1.1 + * + * + */ + +void GDAPI pandemonium_nativescript_set_method_argument_information(void *p_gdnative_handle, const char *p_name, const char *p_function_name, int p_num_args, const pandemonium_method_arg *p_args) { + String *s = (String *)p_gdnative_handle; + + RBMap::Element *E = NSL->library_classes[*s].find(p_name); + ERR_FAIL_COND_MSG(!E, "Attempted to add argument information for a method on a non-existent class."); + + RBMap::Element *method = E->get().methods.find(p_function_name); + ERR_FAIL_COND_MSG(!method, "Attempted to add argument information to non-existent method."); + + MethodInfo *method_information = &method->get().info; + + List args; + + for (int i = 0; i < p_num_args; i++) { + pandemonium_method_arg arg = p_args[i]; + String name = *(String *)&arg.name; + String hint_string = *(String *)&arg.hint_string; + + Variant::Type type = (Variant::Type)arg.type; + PropertyHint hint = (PropertyHint)arg.hint; + + args.push_back(PropertyInfo(type, p_name, hint, hint_string)); + } + + method_information->arguments = args; +} + +void GDAPI pandemonium_nativescript_set_class_documentation(void *p_gdnative_handle, const char *p_name, pandemonium_string p_documentation) { + String *s = (String *)p_gdnative_handle; + + RBMap::Element *E = NSL->library_classes[*s].find(p_name); + ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a non-existent class."); + + E->get().documentation = *(String *)&p_documentation; +} + +void GDAPI pandemonium_nativescript_set_method_documentation(void *p_gdnative_handle, const char *p_name, const char *p_function_name, pandemonium_string p_documentation) { + String *s = (String *)p_gdnative_handle; + + RBMap::Element *E = NSL->library_classes[*s].find(p_name); + ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a method on a non-existent class."); + + RBMap::Element *method = E->get().methods.find(p_function_name); + ERR_FAIL_COND_MSG(!method, "Attempted to add documentation to non-existent method."); + + method->get().documentation = *(String *)&p_documentation; +} + +void GDAPI pandemonium_nativescript_set_property_documentation(void *p_gdnative_handle, const char *p_name, const char *p_path, pandemonium_string p_documentation) { + String *s = (String *)p_gdnative_handle; + + RBMap::Element *E = NSL->library_classes[*s].find(p_name); + ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a property on a non-existent class."); + + OrderedHashMap::Element property = E->get().properties.find(p_path); + ERR_FAIL_COND_MSG(!property, "Attempted to add documentation to non-existent property."); + + property.get().documentation = *(String *)&p_documentation; +} + +void GDAPI pandemonium_nativescript_set_signal_documentation(void *p_gdnative_handle, const char *p_name, const char *p_signal_name, pandemonium_string p_documentation) { + String *s = (String *)p_gdnative_handle; + + RBMap::Element *E = NSL->library_classes[*s].find(p_name); + ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a signal on a non-existent class."); + + RBMap::Element *signal = E->get().signals_.find(p_signal_name); + ERR_FAIL_COND_MSG(!signal, "Attempted to add documentation to non-existent signal."); + + signal->get().documentation = *(String *)&p_documentation; +} + +void GDAPI pandemonium_nativescript_set_global_type_tag(int p_idx, const char *p_name, const void *p_type_tag) { + NativeScriptLanguage::get_singleton()->set_global_type_tag(p_idx, StringName(p_name), p_type_tag); +} + +const void GDAPI *pandemonium_nativescript_get_global_type_tag(int p_idx, const char *p_name) { + return NativeScriptLanguage::get_singleton()->get_global_type_tag(p_idx, StringName(p_name)); +} + +void GDAPI pandemonium_nativescript_set_type_tag(void *p_gdnative_handle, const char *p_name, const void *p_type_tag) { + String *s = (String *)p_gdnative_handle; + + RBMap::Element *E = NSL->library_classes[*s].find(p_name); + ERR_FAIL_COND_MSG(!E, "Attempted to set type tag on a non-existent class."); + + E->get().type_tag = p_type_tag; +} + +const void GDAPI *pandemonium_nativescript_get_type_tag(const pandemonium_object *p_object) { + const Object *o = (Object *)p_object; + + if (!o->get_script_instance()) { + return nullptr; + } else { + NativeScript *script = Object::cast_to(o->get_script_instance()->get_script().ptr()); + if (!script) { + return nullptr; + } + + if (script->get_script_desc()) { + return script->get_script_desc()->type_tag; + } + } + + return nullptr; +} + +int GDAPI pandemonium_nativescript_register_instance_binding_data_functions(pandemonium_instance_binding_functions p_binding_functions) { + return NativeScriptLanguage::get_singleton()->register_binding_functions(p_binding_functions); +} + +void GDAPI pandemonium_nativescript_unregister_instance_binding_data_functions(int p_idx) { + NativeScriptLanguage::get_singleton()->unregister_binding_functions(p_idx); +} + +void GDAPI *pandemonium_nativescript_get_instance_binding_data(int p_idx, pandemonium_object *p_object) { + return NativeScriptLanguage::get_singleton()->get_instance_binding_data(p_idx, (Object *)p_object); +} + +void GDAPI pandemonium_nativescript_profiling_add_data(const char *p_signature, uint64_t p_time) { + NativeScriptLanguage::get_singleton()->profiling_add_data(StringName(p_signature), p_time); +} + +#ifdef __cplusplus +} +#endif