diff options
Diffstat (limited to 'modules/gdnative')
26 files changed, 1133 insertions, 238 deletions
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub index c92c3f30a2..acfb83bc10 100644 --- a/modules/gdnative/SCsub +++ b/modules/gdnative/SCsub @@ -28,7 +28,7 @@ def _build_gdnative_api_struct_header(api): '\textern const godot_gdnative_ext_{0}_api_struct *_gdnative_wrapper_{0}_api_struct;'.format(name)) gdnative_api_init_macro.append('\t_gdnative_wrapper_api_struct = options->api_struct;') - gdnative_api_init_macro.append('\tfor (int i = 0; i < _gdnative_wrapper_api_struct->num_extensions; i++) { ') + gdnative_api_init_macro.append('\tfor (unsigned int i = 0; i < _gdnative_wrapper_api_struct->num_extensions; i++) { ') gdnative_api_init_macro.append('\t\tswitch (_gdnative_wrapper_api_struct->extensions[i]->type) {') for name in api['extensions']: @@ -66,19 +66,30 @@ def _build_gdnative_api_struct_header(api): out += ['};', ''] - for name in api['extensions']: - out += [ - 'typedef struct godot_gdnative_ext_' + name + '_api_struct {', + + def generate_extension_struct(name, ext, include_version=True): + ret_val = [] + if ext['next']: + ret_val += generate_extension_struct(name, ext['next']) + + ret_val += [ + 'typedef struct godot_gdnative_ext_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_api_struct {', '\tunsigned int type;', '\tgodot_gdnative_api_version version;', '\tconst godot_gdnative_api_struct *next;' ] - for funcdef in api['extensions'][name]['api']: + for funcdef in ext['api']: args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']]) - out.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args)) + ret_val.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args)) + + ret_val += ['} godot_gdnative_ext_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_api_struct;', ''] + + return ret_val - out += ['} godot_gdnative_ext_' + name + '_api_struct;', ''] + + for name in api['extensions']: + out += generate_extension_struct(name, api['extensions'][name], False) out += [ 'typedef struct godot_gdnative_core_api_struct {', @@ -113,18 +124,35 @@ def _build_gdnative_api_struct_source(api): '' ] - for name in api['extensions']: - out += [ - 'extern const godot_gdnative_ext_' + name + '_api_struct api_extension_' + name + '_struct = {', - '\tGDNATIVE_EXT_' + api['extensions'][name]['type'] + ',', - '\t{' + str(api['extensions'][name]['version']['major']) + ', ' + str(api['extensions'][name]['version']['minor']) + '},', - '\tNULL,' + def get_extension_struct_name(name, ext, include_version=True): + return 'godot_gdnative_ext_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_api_struct' + + def get_extension_struct_instance_name(name, ext, include_version=True): + return 'api_extension_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_struct' + + def get_extension_struct_definition(name, ext, include_version=True): + + ret_val = [] + + if ext['next']: + ret_val += get_extension_struct_definition(name, ext['next']) + + ret_val += [ + 'extern const ' + get_extension_struct_name(name, ext, include_version) + ' ' + get_extension_struct_instance_name(name, ext, include_version) + ' = {', + '\tGDNATIVE_EXT_' + ext['type'] + ',', + '\t{' + str(ext['version']['major']) + ', ' + str(ext['version']['minor']) + '},', + '\t' + ('NULL' if not ext['next'] else ('(const godot_gdnative_api_struct *)&' + get_extension_struct_instance_name(name, ext['next']))) + ',' ] - for funcdef in api['extensions'][name]['api']: - out.append('\t%s,' % funcdef['name']) + for funcdef in ext['api']: + ret_val.append('\t%s,' % funcdef['name']) + + ret_val += ['};\n'] - out += ['};\n'] + return ret_val + + for name in api['extensions']: + out += get_extension_struct_definition(name, api['extensions'][name], False) out += ['', 'const godot_gdnative_api_struct *gdnative_extensions_pointers[] = {'] diff --git a/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml b/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml index e4ffa76d36..bceb4f1f4c 100644 --- a/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml +++ b/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ARVRInterfaceGDNative" inherits="ARVRInterface" category="Core" version="3.0-beta"> +<class name="ARVRInterfaceGDNative" inherits="ARVRInterface" category="Core" version="3.0-stable"> <brief_description> GDNative wrapper for an ARVR interface </brief_description> diff --git a/modules/gdnative/doc_classes/GDNative.xml b/modules/gdnative/doc_classes/GDNative.xml index 83953cef49..7e4d956604 100644 --- a/modules/gdnative/doc_classes/GDNative.xml +++ b/modules/gdnative/doc_classes/GDNative.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GDNative" inherits="Reference" category="Core" version="3.0-beta"> +<class name="GDNative" inherits="Reference" category="Core" version="3.0-stable"> <brief_description> </brief_description> <description> diff --git a/modules/gdnative/doc_classes/GDNativeLibrary.xml b/modules/gdnative/doc_classes/GDNativeLibrary.xml index 14bd0e9654..a6874c9ae8 100644 --- a/modules/gdnative/doc_classes/GDNativeLibrary.xml +++ b/modules/gdnative/doc_classes/GDNativeLibrary.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GDNativeLibrary" inherits="Resource" category="Core" version="3.0-beta"> +<class name="GDNativeLibrary" inherits="Resource" category="Core" version="3.0-stable"> <brief_description> </brief_description> <description> diff --git a/modules/gdnative/doc_classes/NativeScript.xml b/modules/gdnative/doc_classes/NativeScript.xml index 3f6025d02f..6a71cd8d4d 100644 --- a/modules/gdnative/doc_classes/NativeScript.xml +++ b/modules/gdnative/doc_classes/NativeScript.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="NativeScript" inherits="Script" category="Core" version="3.0-beta"> +<class name="NativeScript" inherits="Script" category="Core" version="3.1-dev"> <brief_description> </brief_description> <description> @@ -9,10 +9,46 @@ <demos> </demos> <methods> + <method name="get_class_documentation" qualifiers="const"> + <return type="String"> + </return> + <description> + Returns the documentation string that was previously set with [code]godot_nativescript_set_class_documentation[/code]. + </description> + </method> + <method name="get_method_documentation" qualifiers="const"> + <return type="String"> + </return> + <argument index="0" name="method" type="String"> + </argument> + <description> + Returns the documentation string that was previously set with [code]godot_nativescript_set_method_documentation[/code]. + </description> + </method> + <method name="get_property_documentation" qualifiers="const"> + <return type="String"> + </return> + <argument index="0" name="path" type="String"> + </argument> + <description> + Returns the documentation string that was previously set with [code]godot_nativescript_set_property_documentation[/code]. + </description> + </method> + <method name="get_signal_documentation" qualifiers="const"> + <return type="String"> + </return> + <argument index="0" name="signal_name" type="String"> + </argument> + <description> + Returns the documentation string that was previously set with [code]godot_nativescript_set_signal_documentation[/code]. + </description> + </method> <method name="new" qualifiers="vararg"> <return type="Object"> </return> <description> + Constructs a new object of the base type with a script of this type already attached. + [i]Note[/i]: Any arguments passed to this function will be ignored and not passed to the native constructor function. This will change with in a future API extension. </description> </method> </methods> diff --git a/modules/gdnative/doc_classes/PluginScript.xml b/modules/gdnative/doc_classes/PluginScript.xml index 1a2141247a..fbdd8f09e6 100644 --- a/modules/gdnative/doc_classes/PluginScript.xml +++ b/modules/gdnative/doc_classes/PluginScript.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PluginScript" inherits="Script" category="Core" version="3.0-beta"> +<class name="PluginScript" inherits="Script" category="Core" version="3.0-stable"> <brief_description> </brief_description> <description> diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index 1379083b42..42c3028f2c 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -181,13 +181,23 @@ bool GDNative::initialize() { godot_gdnative_init_fn library_init_fpointer; library_init_fpointer = (godot_gdnative_init_fn)library_init; + static uint64_t core_api_hash = 0; + static uint64_t editor_api_hash = 0; + static uint64_t no_api_hash = 0; + + if (!(core_api_hash || editor_api_hash || no_api_hash)) { + core_api_hash = ClassDB::get_api_hash(ClassDB::API_CORE); + editor_api_hash = ClassDB::get_api_hash(ClassDB::API_EDITOR); + no_api_hash = ClassDB::get_api_hash(ClassDB::API_NONE); + } + godot_gdnative_init_options options; options.api_struct = &api_struct; options.in_editor = Engine::get_singleton()->is_editor_hint(); - options.core_api_hash = ClassDB::get_api_hash(ClassDB::API_CORE); - options.editor_api_hash = ClassDB::get_api_hash(ClassDB::API_EDITOR); - options.no_api_hash = ClassDB::get_api_hash(ClassDB::API_NONE); + options.core_api_hash = core_api_hash; + options.editor_api_hash = editor_api_hash; + options.no_api_hash = no_api_hash; options.report_version_mismatch = &_gdnative_report_version_mismatch; options.report_loading_error = &_gdnative_report_loading_error; options.gd_native_library = (godot_object *)(get_library().ptr()); diff --git a/modules/gdnative/gdnative/pool_arrays.cpp b/modules/gdnative/gdnative/pool_arrays.cpp index 6e014905a3..6688be1a0d 100644 --- a/modules/gdnative/gdnative/pool_arrays.cpp +++ b/modules/gdnative/gdnative/pool_arrays.cpp @@ -700,6 +700,10 @@ void GDAPI godot_pool_color_array_destroy(godot_pool_color_array *p_self) { // read accessor functions // +godot_pool_byte_array_read_access GDAPI *godot_pool_byte_array_read_access_copy(const godot_pool_byte_array_read_access *p_other) { + PoolVector<uint8_t>::Read *other = (PoolVector<uint8_t>::Read *)p_other; + return (godot_pool_byte_array_read_access *)memnew(PoolVector<uint8_t>::Read(*other)); +} const uint8_t GDAPI *godot_pool_byte_array_read_access_ptr(const godot_pool_byte_array_read_access *p_read) { const PoolVector<uint8_t>::Read *read = (const PoolVector<uint8_t>::Read *)p_read; return read->ptr(); @@ -713,6 +717,10 @@ void GDAPI godot_pool_byte_array_read_access_destroy(godot_pool_byte_array_read_ memdelete((PoolVector<uint8_t>::Read *)p_read); } +godot_pool_int_array_read_access GDAPI *godot_pool_int_array_read_access_copy(const godot_pool_int_array_read_access *p_other) { + PoolVector<godot_int>::Read *other = (PoolVector<godot_int>::Read *)p_other; + return (godot_pool_int_array_read_access *)memnew(PoolVector<godot_int>::Read(*other)); +} const godot_int GDAPI *godot_pool_int_array_read_access_ptr(const godot_pool_int_array_read_access *p_read) { const PoolVector<godot_int>::Read *read = (const PoolVector<godot_int>::Read *)p_read; return read->ptr(); @@ -726,6 +734,10 @@ void GDAPI godot_pool_int_array_read_access_destroy(godot_pool_int_array_read_ac memdelete((PoolVector<godot_int>::Read *)p_read); } +godot_pool_real_array_read_access GDAPI *godot_pool_real_array_read_access_copy(const godot_pool_real_array_read_access *p_other) { + PoolVector<godot_real>::Read *other = (PoolVector<godot_real>::Read *)p_other; + return (godot_pool_real_array_read_access *)memnew(PoolVector<godot_real>::Read(*other)); +} const godot_real GDAPI *godot_pool_real_array_read_access_ptr(const godot_pool_real_array_read_access *p_read) { const PoolVector<godot_real>::Read *read = (const PoolVector<godot_real>::Read *)p_read; return read->ptr(); @@ -739,6 +751,10 @@ void GDAPI godot_pool_real_array_read_access_destroy(godot_pool_real_array_read_ memdelete((PoolVector<godot_real>::Read *)p_read); } +godot_pool_string_array_read_access GDAPI *godot_pool_string_array_read_access_copy(const godot_pool_string_array_read_access *p_other) { + PoolVector<String>::Read *other = (PoolVector<String>::Read *)p_other; + return (godot_pool_string_array_read_access *)memnew(PoolVector<String>::Read(*other)); +} const godot_string GDAPI *godot_pool_string_array_read_access_ptr(const godot_pool_string_array_read_access *p_read) { const PoolVector<String>::Read *read = (const PoolVector<String>::Read *)p_read; return (const godot_string *)read->ptr(); @@ -752,6 +768,10 @@ void GDAPI godot_pool_string_array_read_access_destroy(godot_pool_string_array_r memdelete((PoolVector<String>::Read *)p_read); } +godot_pool_vector2_array_read_access GDAPI *godot_pool_vector2_array_read_access_copy(const godot_pool_vector2_array_read_access *p_other) { + PoolVector<Vector2>::Read *other = (PoolVector<Vector2>::Read *)p_other; + return (godot_pool_vector2_array_read_access *)memnew(PoolVector<Vector2>::Read(*other)); +} const godot_vector2 GDAPI *godot_pool_vector2_array_read_access_ptr(const godot_pool_vector2_array_read_access *p_read) { const PoolVector<Vector2>::Read *read = (const PoolVector<Vector2>::Read *)p_read; return (const godot_vector2 *)read->ptr(); @@ -765,6 +785,10 @@ void GDAPI godot_pool_vector2_array_read_access_destroy(godot_pool_vector2_array memdelete((PoolVector<Vector2>::Read *)p_read); } +godot_pool_vector3_array_read_access GDAPI *godot_pool_vector3_array_read_access_copy(const godot_pool_vector3_array_read_access *p_other) { + PoolVector<Vector3>::Read *other = (PoolVector<Vector3>::Read *)p_other; + return (godot_pool_vector3_array_read_access *)memnew(PoolVector<Vector3>::Read(*other)); +} const godot_vector3 GDAPI *godot_pool_vector3_array_read_access_ptr(const godot_pool_vector3_array_read_access *p_read) { const PoolVector<Vector3>::Read *read = (const PoolVector<Vector3>::Read *)p_read; return (const godot_vector3 *)read->ptr(); @@ -778,6 +802,10 @@ void GDAPI godot_pool_vector3_array_read_access_destroy(godot_pool_vector3_array memdelete((PoolVector<Vector2>::Read *)p_read); } +godot_pool_color_array_read_access GDAPI *godot_pool_color_array_read_access_copy(const godot_pool_color_array_read_access *p_other) { + PoolVector<Color>::Read *other = (PoolVector<Color>::Read *)p_other; + return (godot_pool_color_array_read_access *)memnew(PoolVector<Color>::Read(*other)); +} const godot_color GDAPI *godot_pool_color_array_read_access_ptr(const godot_pool_color_array_read_access *p_read) { const PoolVector<Color>::Read *read = (const PoolVector<Color>::Read *)p_read; return (const godot_color *)read->ptr(); @@ -795,6 +823,10 @@ void GDAPI godot_pool_color_array_read_access_destroy(godot_pool_color_array_rea // write accessor functions // +godot_pool_byte_array_write_access GDAPI *godot_pool_byte_array_write_access_copy(const godot_pool_byte_array_write_access *p_other) { + PoolVector<uint8_t>::Write *other = (PoolVector<uint8_t>::Write *)p_other; + return (godot_pool_byte_array_write_access *)memnew(PoolVector<uint8_t>::Write(*other)); +} uint8_t GDAPI *godot_pool_byte_array_write_access_ptr(const godot_pool_byte_array_write_access *p_write) { PoolVector<uint8_t>::Write *write = (PoolVector<uint8_t>::Write *)p_write; return write->ptr(); @@ -808,6 +840,10 @@ void GDAPI godot_pool_byte_array_write_access_destroy(godot_pool_byte_array_writ memdelete((PoolVector<uint8_t>::Write *)p_write); } +godot_pool_int_array_write_access GDAPI *godot_pool_int_array_write_access_copy(const godot_pool_int_array_write_access *p_other) { + PoolVector<godot_int>::Write *other = (PoolVector<godot_int>::Write *)p_other; + return (godot_pool_int_array_write_access *)memnew(PoolVector<godot_int>::Write(*other)); +} godot_int GDAPI *godot_pool_int_array_write_access_ptr(const godot_pool_int_array_write_access *p_write) { PoolVector<godot_int>::Write *write = (PoolVector<godot_int>::Write *)p_write; return write->ptr(); @@ -821,6 +857,10 @@ void GDAPI godot_pool_int_array_write_access_destroy(godot_pool_int_array_write_ memdelete((PoolVector<godot_int>::Write *)p_write); } +godot_pool_real_array_write_access GDAPI *godot_pool_real_array_write_access_copy(const godot_pool_real_array_write_access *p_other) { + PoolVector<godot_real>::Write *other = (PoolVector<godot_real>::Write *)p_other; + return (godot_pool_real_array_write_access *)memnew(PoolVector<godot_real>::Write(*other)); +} godot_real GDAPI *godot_pool_real_array_write_access_ptr(const godot_pool_real_array_write_access *p_write) { PoolVector<godot_real>::Write *write = (PoolVector<godot_real>::Write *)p_write; return write->ptr(); @@ -834,6 +874,10 @@ void GDAPI godot_pool_real_array_write_access_destroy(godot_pool_real_array_writ memdelete((PoolVector<godot_real>::Write *)p_write); } +godot_pool_string_array_write_access GDAPI *godot_pool_string_array_write_access_copy(const godot_pool_string_array_write_access *p_other) { + PoolVector<String>::Write *other = (PoolVector<String>::Write *)p_other; + return (godot_pool_string_array_write_access *)memnew(PoolVector<String>::Write(*other)); +} godot_string GDAPI *godot_pool_string_array_write_access_ptr(const godot_pool_string_array_write_access *p_write) { PoolVector<String>::Write *write = (PoolVector<String>::Write *)p_write; return (godot_string *)write->ptr(); @@ -847,6 +891,10 @@ void GDAPI godot_pool_string_array_write_access_destroy(godot_pool_string_array_ memdelete((PoolVector<String>::Write *)p_write); } +godot_pool_vector2_array_write_access GDAPI *godot_pool_vector2_array_write_access_copy(const godot_pool_vector2_array_write_access *p_other) { + PoolVector<Vector2>::Write *other = (PoolVector<Vector2>::Write *)p_other; + return (godot_pool_vector2_array_write_access *)memnew(PoolVector<Vector2>::Write(*other)); +} godot_vector2 GDAPI *godot_pool_vector2_array_write_access_ptr(const godot_pool_vector2_array_write_access *p_write) { PoolVector<Vector2>::Write *write = (PoolVector<Vector2>::Write *)p_write; return (godot_vector2 *)write->ptr(); @@ -860,6 +908,10 @@ void GDAPI godot_pool_vector2_array_write_access_destroy(godot_pool_vector2_arra memdelete((PoolVector<Vector2>::Write *)p_write); } +godot_pool_vector3_array_write_access GDAPI *godot_pool_vector3_array_write_access_copy(const godot_pool_vector3_array_write_access *p_other) { + PoolVector<Vector3>::Write *other = (PoolVector<Vector3>::Write *)p_other; + return (godot_pool_vector3_array_write_access *)memnew(PoolVector<Vector3>::Write(*other)); +} godot_vector3 GDAPI *godot_pool_vector3_array_write_access_ptr(const godot_pool_vector3_array_write_access *p_write) { PoolVector<Vector3>::Write *write = (PoolVector<Vector3>::Write *)p_write; return (godot_vector3 *)write->ptr(); @@ -873,6 +925,10 @@ void GDAPI godot_pool_vector3_array_write_access_destroy(godot_pool_vector3_arra memdelete((PoolVector<Vector3>::Write *)p_write); } +godot_pool_color_array_write_access GDAPI *godot_pool_color_array_write_access_copy(const godot_pool_color_array_write_access *p_other) { + PoolVector<Color>::Write *other = (PoolVector<Color>::Write *)p_other; + return (godot_pool_color_array_write_access *)memnew(PoolVector<Color>::Write(*other)); +} godot_color GDAPI *godot_pool_color_array_write_access_ptr(const godot_pool_color_array_write_access *p_write) { PoolVector<Color>::Write *write = (PoolVector<Color>::Write *)p_write; return (godot_color *)write->ptr(); diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp index 350dc540f7..7f5dbc12be 100644 --- a/modules/gdnative/gdnative/string.cpp +++ b/modules/gdnative/gdnative/string.cpp @@ -40,6 +40,24 @@ extern "C" { #endif +godot_int GDAPI godot_char_string_length(const godot_char_string *p_cs) { + const CharString *cs = (const CharString *)p_cs; + + return cs->length(); +} + +const char GDAPI *godot_char_string_get_data(const godot_char_string *p_cs) { + const CharString *cs = (const CharString *)p_cs; + + return cs->get_data(); +} + +void GDAPI godot_char_string_destroy(godot_char_string *p_cs) { + CharString *cs = (CharString *)p_cs; + + cs->~CharString(); +} + void GDAPI godot_string_new(godot_string *r_dest) { String *dest = (String *)r_dest; memnew_placement(dest, String); @@ -51,35 +69,11 @@ void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src memnew_placement(dest, String(*src)); } -void GDAPI godot_string_new_data(godot_string *r_dest, const char *p_contents, const int p_size) { - String *dest = (String *)r_dest; - memnew_placement(dest, String(String::utf8(p_contents, p_size))); -} - -void GDAPI godot_string_new_unicode_data(godot_string *r_dest, const wchar_t *p_contents, const int p_size) { +void GDAPI godot_string_new_with_wide_string(godot_string *r_dest, const wchar_t *p_contents, const int p_size) { String *dest = (String *)r_dest; memnew_placement(dest, String(p_contents, p_size)); } -void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *p_size) { - String *self = (String *)p_self; - - if (p_size) { - // we have a length pointer, that means we either want to know - // the length or want to write *p_size bytes into a buffer - - CharString utf8_string = self->utf8(); - - int len = utf8_string.length(); - - if (p_dest) { - memcpy(p_dest, utf8_string.get_data(), *p_size); - } else { - *p_size = len; - } - } -} - wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx) { String *self = (String *)p_self; return &(self->operator[](p_idx)); @@ -90,7 +84,7 @@ wchar_t GDAPI godot_string_operator_index_const(const godot_string *p_self, cons return self->operator[](p_idx); } -const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_self) { +const wchar_t GDAPI *godot_string_wide_str(const godot_string *p_self) { const String *self = (const String *)p_self; return self->c_str(); } @@ -130,6 +124,26 @@ godot_int GDAPI godot_string_length(const godot_string *p_self) { /* Helpers */ +signed char GDAPI godot_string_casecmp_to(const godot_string *p_self, const godot_string *p_str) { + const String *self = (const String *)p_self; + const String *str = (const String *)p_str; + + return self->casecmp_to(*str); +} + +signed char GDAPI godot_string_nocasecmp_to(const godot_string *p_self, const godot_string *p_str) { + const String *self = (const String *)p_self; + const String *str = (const String *)p_str; + + return self->nocasecmp_to(*str); +} +signed char GDAPI godot_string_naturalnocasecmp_to(const godot_string *p_self, const godot_string *p_str) { + const String *self = (const String *)p_self; + const String *str = (const String *)p_str; + + return self->naturalnocasecmp_to(*str); +} + godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string) { const String *self = (const String *)p_self; const String *string = (const String *)p_string; @@ -534,7 +548,7 @@ godot_string GDAPI godot_string_capitalize(const godot_string *p_self) { memnew_placement(&result, String(self->capitalize())); return result; -}; +} godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -542,7 +556,7 @@ godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_se memnew_placement(&result, String(self->camelcase_to_underscore(false))); return result; -}; +} godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -550,45 +564,45 @@ godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_s memnew_placement(&result, String(self->camelcase_to_underscore())); return result; -}; +} double GDAPI godot_string_char_to_double(const char *p_what) { return String::to_double(p_what); -}; +} godot_int GDAPI godot_string_char_to_int(const char *p_what) { return String::to_int(p_what); -}; +} int64_t GDAPI godot_string_wchar_to_int(const wchar_t *p_str) { return String::to_int(p_str); -}; +} godot_int GDAPI godot_string_char_to_int_with_len(const char *p_what, godot_int p_len) { return String::to_int(p_what, p_len); -}; +} int64_t GDAPI godot_string_char_to_int64_with_len(const wchar_t *p_str, int p_len) { return String::to_int(p_str, p_len); -}; +} int64_t GDAPI godot_string_hex_to_int64(const godot_string *p_self) { const String *self = (const String *)p_self; return self->hex_to_int64(false); -}; +} int64_t GDAPI godot_string_hex_to_int64_with_prefix(const godot_string *p_self) { const String *self = (const String *)p_self; return self->hex_to_int64(); -}; +} int64_t GDAPI godot_string_to_int64(const godot_string *p_self) { const String *self = (const String *)p_self; return self->to_int64(); -}; +} double GDAPI godot_string_unicode_char_to_double(const wchar_t *p_str, const wchar_t **r_end) { return String::to_double(p_str, r_end); @@ -601,7 +615,7 @@ godot_string GDAPI godot_string_get_slice(const godot_string *p_self, godot_stri memnew_placement(&result, String(self->get_slice(*splitter, p_slice))); return result; -}; +} godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, wchar_t p_splitter, godot_int p_slice) { const String *self = (const String *)p_self; @@ -609,7 +623,7 @@ godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, wchar_t p memnew_placement(&result, String(self->get_slicec(p_splitter, p_slice))); return result; -}; +} godot_array GDAPI godot_string_split(const godot_string *p_self, const godot_string *p_splitter) { const String *self = (const String *)p_self; @@ -625,7 +639,7 @@ godot_array GDAPI godot_string_split(const godot_string *p_self, const godot_str } return result; -}; +} godot_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, const godot_string *p_splitter) { const String *self = (const String *)p_self; @@ -641,7 +655,7 @@ godot_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, con } return result; -}; +} godot_array GDAPI godot_string_split_floats(const godot_string *p_self, const godot_string *p_splitter) { const String *self = (const String *)p_self; @@ -657,7 +671,7 @@ godot_array GDAPI godot_string_split_floats(const godot_string *p_self, const go } return result; -}; +} godot_array GDAPI godot_string_split_floats_allows_empty(const godot_string *p_self, const godot_string *p_splitter) { const String *self = (const String *)p_self; @@ -673,7 +687,7 @@ godot_array GDAPI godot_string_split_floats_allows_empty(const godot_string *p_s } return result; -}; +} godot_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const godot_array *p_splitters) { const String *self = (const String *)p_self; @@ -696,7 +710,7 @@ godot_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const } return result; -}; +} godot_array GDAPI godot_string_split_floats_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) { const String *self = (const String *)p_self; @@ -719,7 +733,7 @@ godot_array GDAPI godot_string_split_floats_mk_allows_empty(const godot_string * } return result; -}; +} godot_array GDAPI godot_string_split_ints(const godot_string *p_self, const godot_string *p_splitter) { const String *self = (const String *)p_self; @@ -735,7 +749,7 @@ godot_array GDAPI godot_string_split_ints(const godot_string *p_self, const godo } return result; -}; +} godot_array GDAPI godot_string_split_ints_allows_empty(const godot_string *p_self, const godot_string *p_splitter) { const String *self = (const String *)p_self; @@ -751,7 +765,7 @@ godot_array GDAPI godot_string_split_ints_allows_empty(const godot_string *p_sel } return result; -}; +} godot_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const godot_array *p_splitters) { const String *self = (const String *)p_self; @@ -774,7 +788,7 @@ godot_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const g } return result; -}; +} godot_array GDAPI godot_string_split_ints_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) { const String *self = (const String *)p_self; @@ -797,7 +811,7 @@ godot_array GDAPI godot_string_split_ints_mk_allows_empty(const godot_string *p_ } return result; -}; +} godot_array GDAPI godot_string_split_spaces(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -812,22 +826,22 @@ godot_array GDAPI godot_string_split_spaces(const godot_string *p_self) { } return result; -}; +} godot_int GDAPI godot_string_get_slice_count(const godot_string *p_self, godot_string p_splitter) { const String *self = (const String *)p_self; String *splitter = (String *)&p_splitter; return self->get_slice_count(*splitter); -}; +} wchar_t GDAPI godot_string_char_lowercase(wchar_t p_char) { return String::char_lowercase(p_char); -}; +} wchar_t GDAPI godot_string_char_uppercase(wchar_t p_char) { return String::char_uppercase(p_char); -}; +} godot_string GDAPI godot_string_to_lower(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -835,7 +849,7 @@ godot_string GDAPI godot_string_to_lower(const godot_string *p_self) { memnew_placement(&result, String(self->to_lower())); return result; -}; +} godot_string GDAPI godot_string_to_upper(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -843,7 +857,7 @@ godot_string GDAPI godot_string_to_upper(const godot_string *p_self) { memnew_placement(&result, String(self->to_upper())); return result; -}; +} godot_string GDAPI godot_string_get_basename(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -851,7 +865,7 @@ godot_string GDAPI godot_string_get_basename(const godot_string *p_self) { memnew_placement(&result, String(self->get_basename())); return result; -}; +} godot_string GDAPI godot_string_get_extension(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -859,7 +873,7 @@ godot_string GDAPI godot_string_get_extension(const godot_string *p_self) { memnew_placement(&result, String(self->get_extension())); return result; -}; +} godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos) { const String *self = (const String *)p_self; @@ -867,13 +881,13 @@ godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos memnew_placement(&result, String(self->left(p_pos))); return result; -}; +} wchar_t GDAPI godot_string_ord_at(const godot_string *p_self, godot_int p_idx) { const String *self = (const String *)p_self; return self->ord_at(p_idx); -}; +} godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godot_string *p_file) { const String *self = (const String *)p_self; @@ -882,7 +896,7 @@ godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godo memnew_placement(&result, String(self->plus_file(*file))); return result; -}; +} godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_pos) { const String *self = (const String *)p_self; @@ -890,7 +904,7 @@ godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_po memnew_placement(&result, String(self->right(p_pos))); return result; -}; +} godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bool p_left, godot_bool p_right) { const String *self = (const String *)p_self; @@ -898,7 +912,7 @@ godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bo memnew_placement(&result, String(self->strip_edges(p_left, p_right))); return result; -}; +} godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -906,94 +920,96 @@ godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self) { memnew_placement(&result, String(self->strip_escapes())); return result; -}; +} void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars) { String *self = (String *)p_self; return self->erase(p_pos, p_chars); -}; +} -void GDAPI godot_string_ascii(godot_string *p_self, char *result) { - String *self = (String *)p_self; - Vector<char> return_value = self->ascii(); +godot_char_string GDAPI godot_string_ascii(const godot_string *p_self) { + const String *self = (const String *)p_self; + godot_char_string result; - for (int i = 0; i < return_value.size(); i++) { - result[i] = return_value[i]; - } + memnew_placement(&result, CharString(self->ascii())); + + return result; } -void GDAPI godot_string_ascii_extended(godot_string *p_self, char *result) { - String *self = (String *)p_self; - Vector<char> return_value = self->ascii(true); +godot_char_string GDAPI godot_string_ascii_extended(const godot_string *p_self) { + const String *self = (const String *)p_self; - for (int i = 0; i < return_value.size(); i++) { - result[i] = return_value[i]; - } + godot_char_string result; + + memnew_placement(&result, CharString(self->ascii(true))); + + return result; } -void GDAPI godot_string_utf8(godot_string *p_self, char *result) { - String *self = (String *)p_self; - Vector<char> return_value = self->utf8(); +godot_char_string GDAPI godot_string_utf8(const godot_string *p_self) { + const String *self = (const String *)p_self; - for (int i = 0; i < return_value.size(); i++) { - result[i] = return_value[i]; - } + godot_char_string result; + + memnew_placement(&result, CharString(self->utf8())); + + return result; } godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8) { String *self = (String *)p_self; return self->parse_utf8(p_utf8); -}; +} godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len) { String *self = (String *)p_self; return self->parse_utf8(p_utf8, p_len); -}; +} godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8) { godot_string result; memnew_placement(&result, String(String::utf8(p_utf8))); return result; -}; +} godot_string GDAPI godot_string_chars_to_utf8_with_len(const char *p_utf8, godot_int p_len) { godot_string result; memnew_placement(&result, String(String::utf8(p_utf8, p_len))); return result; -}; +} uint32_t GDAPI godot_string_hash(const godot_string *p_self) { const String *self = (const String *)p_self; return self->hash(); -}; +} uint64_t GDAPI godot_string_hash64(const godot_string *p_self) { const String *self = (const String *)p_self; return self->hash64(); -}; +} uint32_t GDAPI godot_string_hash_chars(const char *p_cstr) { return String::hash(p_cstr); -}; +} uint32_t GDAPI godot_string_hash_chars_with_len(const char *p_cstr, godot_int p_len) { return String::hash(p_cstr, p_len); -}; +} uint32_t GDAPI godot_string_hash_utf8_chars(const wchar_t *p_str) { return String::hash(p_str); -}; +} uint32_t GDAPI godot_string_hash_utf8_chars_with_len(const wchar_t *p_str, godot_int p_len) { return String::hash(p_str, p_len); -}; +} godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1010,7 +1026,7 @@ godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self) } return result; -}; +} godot_string GDAPI godot_string_md5_text(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1018,7 +1034,7 @@ godot_string GDAPI godot_string_md5_text(const godot_string *p_self) { memnew_placement(&result, String(self->md5_text())); return result; -}; +} godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1035,7 +1051,7 @@ godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_sel } return result; -}; +} godot_string GDAPI godot_string_sha256_text(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1043,13 +1059,13 @@ godot_string GDAPI godot_string_sha256_text(const godot_string *p_self) { memnew_placement(&result, String(self->sha256_text())); return result; -}; +} godot_bool godot_string_empty(const godot_string *p_self) { const String *self = (const String *)p_self; return self->empty(); -}; +} // path functions godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self) { @@ -1059,7 +1075,7 @@ godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self) { memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_get_file(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1068,7 +1084,7 @@ godot_string GDAPI godot_string_get_file(const godot_string *p_self) { memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_humanize_size(size_t p_size) { godot_string result; @@ -1076,25 +1092,25 @@ godot_string GDAPI godot_string_humanize_size(size_t p_size) { memnew_placement(&result, String(return_value)); return result; -}; +} godot_bool GDAPI godot_string_is_abs_path(const godot_string *p_self) { const String *self = (const String *)p_self; return self->is_abs_path(); -}; +} godot_bool GDAPI godot_string_is_rel_path(const godot_string *p_self) { const String *self = (const String *)p_self; return self->is_rel_path(); -}; +} godot_bool GDAPI godot_string_is_resource_file(const godot_string *p_self) { const String *self = (const String *)p_self; return self->is_resource_file(); -}; +} godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_string *p_path) { const String *self = (const String *)p_self; @@ -1104,7 +1120,7 @@ godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_ memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const godot_string *p_path) { const String *self = (const String *)p_self; @@ -1114,7 +1130,7 @@ godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const g memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_simplify_path(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1123,7 +1139,7 @@ godot_string GDAPI godot_string_simplify_path(const godot_string *p_self) { memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_c_escape(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1132,7 +1148,7 @@ godot_string GDAPI godot_string_c_escape(const godot_string *p_self) { memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1141,7 +1157,7 @@ godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self) { memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_c_unescape(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1150,7 +1166,7 @@ godot_string GDAPI godot_string_c_unescape(const godot_string *p_self) { memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_http_escape(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1159,7 +1175,7 @@ godot_string GDAPI godot_string_http_escape(const godot_string *p_self) { memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_http_unescape(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1168,7 +1184,7 @@ godot_string GDAPI godot_string_http_unescape(const godot_string *p_self) { memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_json_escape(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1177,7 +1193,7 @@ godot_string GDAPI godot_string_json_escape(const godot_string *p_self) { memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_word_wrap(const godot_string *p_self, godot_int p_chars_per_line) { const String *self = (const String *)p_self; @@ -1186,7 +1202,7 @@ godot_string GDAPI godot_string_word_wrap(const godot_string *p_self, godot_int memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_xml_escape(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1195,7 +1211,7 @@ godot_string GDAPI godot_string_xml_escape(const godot_string *p_self) { memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1204,7 +1220,7 @@ godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_sel memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1213,7 +1229,7 @@ godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self) { memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_percent_decode(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1222,7 +1238,7 @@ godot_string GDAPI godot_string_percent_decode(const godot_string *p_self) { memnew_placement(&result, String(return_value)); return result; -}; +} godot_string GDAPI godot_string_percent_encode(const godot_string *p_self) { const String *self = (const String *)p_self; @@ -1231,43 +1247,43 @@ godot_string GDAPI godot_string_percent_encode(const godot_string *p_self) { memnew_placement(&result, String(return_value)); return result; -}; +} godot_bool GDAPI godot_string_is_valid_float(const godot_string *p_self) { const String *self = (const String *)p_self; return self->is_valid_float(); -}; +} godot_bool GDAPI godot_string_is_valid_hex_number(const godot_string *p_self, godot_bool p_with_prefix) { const String *self = (const String *)p_self; return self->is_valid_hex_number(p_with_prefix); -}; +} godot_bool GDAPI godot_string_is_valid_html_color(const godot_string *p_self) { const String *self = (const String *)p_self; return self->is_valid_html_color(); -}; +} godot_bool GDAPI godot_string_is_valid_identifier(const godot_string *p_self) { const String *self = (const String *)p_self; return self->is_valid_identifier(); -}; +} godot_bool GDAPI godot_string_is_valid_integer(const godot_string *p_self) { const String *self = (const String *)p_self; return self->is_valid_integer(); -}; +} godot_bool GDAPI godot_string_is_valid_ip_address(const godot_string *p_self) { const String *self = (const String *)p_self; return self->is_valid_ip_address(); -}; +} #ifdef __cplusplus } diff --git a/modules/gdnative/gdnative/transform.cpp b/modules/gdnative/gdnative/transform.cpp index 9bd8c99612..715f2e3c08 100644 --- a/modules/gdnative/gdnative/transform.cpp +++ b/modules/gdnative/gdnative/transform.cpp @@ -63,7 +63,7 @@ godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self) { return dest; } -void GDAPI godot_transform_set_basis(godot_transform *p_self, godot_basis *p_v) { +void GDAPI godot_transform_set_basis(godot_transform *p_self, const godot_basis *p_v) { Transform *self = (Transform *)p_self; const Basis *v = (const Basis *)p_v; self->basis = *v; @@ -76,7 +76,7 @@ godot_vector3 GDAPI godot_transform_get_origin(const godot_transform *p_self) { return dest; } -void GDAPI godot_transform_set_origin(godot_transform *p_self, godot_vector3 *p_v) { +void GDAPI godot_transform_set_origin(godot_transform *p_self, const godot_vector3 *p_v) { Transform *self = (Transform *)p_self; const Vector3 *v = (const Vector3 *)p_v; self->origin = *v; diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index 06c6e9f410..a8919f7130 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -5,6 +5,7 @@ "major": 1, "minor": 0 }, + "next": null, "api": [ { "name": "godot_color_new_rgba", @@ -2090,6 +2091,13 @@ ] }, { + "name": "godot_pool_byte_array_read_access_copy", + "return_type": "godot_pool_byte_array_read_access *", + "arguments": [ + ["const godot_pool_byte_array_read_access *", "p_read"] + ] + }, + { "name": "godot_pool_byte_array_read_access_ptr", "return_type": "const uint8_t *", "arguments": [ @@ -2112,6 +2120,13 @@ ] }, { + "name": "godot_pool_int_array_read_access_copy", + "return_type": "godot_pool_int_array_read_access *", + "arguments": [ + ["const godot_pool_int_array_read_access *", "p_read"] + ] + }, + { "name": "godot_pool_int_array_read_access_ptr", "return_type": "const godot_int *", "arguments": [ @@ -2134,6 +2149,13 @@ ] }, { + "name": "godot_pool_real_array_read_access_copy", + "return_type": "godot_pool_real_array_read_access *", + "arguments": [ + ["const godot_pool_real_array_read_access *", "p_read"] + ] + }, + { "name": "godot_pool_real_array_read_access_ptr", "return_type": "const godot_real *", "arguments": [ @@ -2156,6 +2178,13 @@ ] }, { + "name": "godot_pool_string_array_read_access_copy", + "return_type": "godot_pool_string_array_read_access *", + "arguments": [ + ["const godot_pool_string_array_read_access *", "p_read"] + ] + }, + { "name": "godot_pool_string_array_read_access_ptr", "return_type": "const godot_string *", "arguments": [ @@ -2178,6 +2207,13 @@ ] }, { + "name": "godot_pool_vector2_array_read_access_copy", + "return_type": "godot_pool_vector2_array_read_access *", + "arguments": [ + ["const godot_pool_vector2_array_read_access *", "p_read"] + ] + }, + { "name": "godot_pool_vector2_array_read_access_ptr", "return_type": "const godot_vector2 *", "arguments": [ @@ -2200,6 +2236,13 @@ ] }, { + "name": "godot_pool_vector3_array_read_access_copy", + "return_type": "godot_pool_vector3_array_read_access *", + "arguments": [ + ["const godot_pool_vector3_array_read_access *", "p_read"] + ] + }, + { "name": "godot_pool_vector3_array_read_access_ptr", "return_type": "const godot_vector3 *", "arguments": [ @@ -2222,6 +2265,13 @@ ] }, { + "name": "godot_pool_color_array_read_access_copy", + "return_type": "godot_pool_color_array_read_access *", + "arguments": [ + ["const godot_pool_color_array_read_access *", "p_read"] + ] + }, + { "name": "godot_pool_color_array_read_access_ptr", "return_type": "const godot_color *", "arguments": [ @@ -2244,6 +2294,13 @@ ] }, { + "name": "godot_pool_byte_array_write_access_copy", + "return_type": "godot_pool_byte_array_write_access *", + "arguments": [ + ["const godot_pool_byte_array_write_access *", "p_write"] + ] + }, + { "name": "godot_pool_byte_array_write_access_ptr", "return_type": "uint8_t *", "arguments": [ @@ -2266,6 +2323,13 @@ ] }, { + "name": "godot_pool_int_array_write_access_copy", + "return_type": "godot_pool_int_array_write_access *", + "arguments": [ + ["const godot_pool_int_array_write_access *", "p_write"] + ] + }, + { "name": "godot_pool_int_array_write_access_ptr", "return_type": "godot_int *", "arguments": [ @@ -2288,6 +2352,13 @@ ] }, { + "name": "godot_pool_real_array_write_access_copy", + "return_type": "godot_pool_real_array_write_access *", + "arguments": [ + ["const godot_pool_real_array_write_access *", "p_write"] + ] + }, + { "name": "godot_pool_real_array_write_access_ptr", "return_type": "godot_real *", "arguments": [ @@ -2310,6 +2381,13 @@ ] }, { + "name": "godot_pool_string_array_write_access_copy", + "return_type": "godot_pool_string_array_write_access *", + "arguments": [ + ["const godot_pool_string_array_write_access *", "p_write"] + ] + }, + { "name": "godot_pool_string_array_write_access_ptr", "return_type": "godot_string *", "arguments": [ @@ -2332,6 +2410,13 @@ ] }, { + "name": "godot_pool_vector2_array_write_access_copy", + "return_type": "godot_pool_vector2_array_write_access *", + "arguments": [ + ["const godot_pool_vector2_array_write_access *", "p_write"] + ] + }, + { "name": "godot_pool_vector2_array_write_access_ptr", "return_type": "godot_vector2 *", "arguments": [ @@ -2354,6 +2439,13 @@ ] }, { + "name": "godot_pool_vector3_array_write_access_copy", + "return_type": "godot_pool_vector3_array_write_access *", + "arguments": [ + ["const godot_pool_vector3_array_write_access *", "p_write"] + ] + }, + { "name": "godot_pool_vector3_array_write_access_ptr", "return_type": "godot_vector3 *", "arguments": [ @@ -2376,6 +2468,13 @@ ] }, { + "name": "godot_pool_color_array_write_access_copy", + "return_type": "godot_pool_color_array_write_access *", + "arguments": [ + ["const godot_pool_color_array_write_access *", "p_write"] + ] + }, + { "name": "godot_pool_color_array_write_access_ptr", "return_type": "godot_color *", "arguments": [ @@ -3516,7 +3615,7 @@ "return_type": "void", "arguments": [ ["godot_transform *", "p_self"], - ["godot_basis *", "p_v"] + ["const godot_basis *", "p_v"] ] }, { @@ -3531,7 +3630,7 @@ "return_type": "void", "arguments": [ ["godot_transform *", "p_self"], - ["godot_vector3 *", "p_v"] + ["const godot_vector3 *", "p_v"] ] }, { @@ -3865,7 +3964,7 @@ "name": "godot_variant_new_bool", "return_type": "void", "arguments": [ - ["godot_variant *", "p_v"], + ["godot_variant *", "r_dest"], ["const godot_bool", "p_b"] ] }, @@ -4324,45 +4423,48 @@ ] }, { - "name": "godot_string_new", - "return_type": "void", + "name": "godot_char_string_length", + "return_type": "godot_int", "arguments": [ - ["godot_string *", "r_dest"] + ["const godot_char_string *", "p_cs"] ] }, { - "name": "godot_string_new_copy", + "name": "godot_char_string_get_data", + "return_type": "const char *", + "arguments": [ + ["const godot_char_string *", "p_cs"] + ] + }, + { + "name": "godot_char_string_destroy", "return_type": "void", "arguments": [ - ["godot_string *", "r_dest"], - ["const godot_string *", "p_src"] + ["godot_char_string *", "p_cs"] ] }, { - "name": "godot_string_new_data", + "name": "godot_string_new", "return_type": "void", "arguments": [ - ["godot_string *", "r_dest"], - ["const char *", "p_contents"], - ["const int", "p_size"] + ["godot_string *", "r_dest"] ] }, { - "name": "godot_string_new_unicode_data", + "name": "godot_string_new_copy", "return_type": "void", "arguments": [ ["godot_string *", "r_dest"], - ["const wchar_t *", "p_contents"], - ["const int", "p_size"] + ["const godot_string *", "p_src"] ] }, { - "name": "godot_string_get_data", + "name": "godot_string_new_with_wide_string", "return_type": "void", "arguments": [ - ["const godot_string *", "p_self"], - ["char *", "p_dest"], - ["int *", "p_size"] + ["godot_string *", "r_dest"], + ["const wchar_t *", "p_contents"], + ["const int", "p_size"] ] }, { @@ -4382,7 +4484,7 @@ ] }, { - "name": "godot_string_unicode_str", + "name": "godot_string_wide_str", "return_type": "const wchar_t *", "arguments": [ ["const godot_string *", "p_self"] @@ -4420,6 +4522,30 @@ ] }, { + "name": "godot_string_casecmp_to", + "return_type": "signed char", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_str"] + ] + }, + { + "name": "godot_string_nocasecmp_to", + "return_type": "signed char", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_str"] + ] + }, + { + "name": "godot_string_naturalnocasecmp_to", + "return_type": "signed char", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_str"] + ] + }, + { "name": "godot_string_begins_with", "return_type": "godot_bool", "arguments": [ @@ -5125,26 +5251,23 @@ }, { "name": "godot_string_ascii", - "return_type": "void", + "return_type": "godot_char_string", "arguments": [ - ["godot_string *", "p_self"], - ["char *", "result"] + ["const godot_string *", "p_self"] ] }, { "name": "godot_string_ascii_extended", - "return_type": "void", + "return_type": "godot_char_string", "arguments": [ - ["godot_string *", "p_self"], - ["char *", "result"] + ["const godot_string *", "p_self"] ] }, { "name": "godot_string_utf8", - "return_type": "void", + "return_type": "godot_char_string", "arguments": [ - ["godot_string *", "p_self"], - ["char *", "result"] + ["const godot_string *", "p_self"] ] }, { @@ -5640,6 +5763,104 @@ "major": 1, "minor": 0 }, + "next": { + "type": "NATIVESCRIPT", + "version": { + "major": 1, + "minor": 1 + }, + "next": null, + "api": [ + { + "name": "godot_nativescript_set_method_argument_information", + "return_type": "void", + "arguments": [ + ["void *", "p_gdnative_handle"], + ["const char *", "p_name"], + ["const char *", "p_function_name"], + ["int", "p_num_args"], + ["const godot_method_arg *", "p_args"] + ] + }, + { + "name": "godot_nativescript_set_class_documentation", + "return_type": "void", + "arguments": [ + ["void *", "p_gdnative_handle"], + ["const char *", "p_name"], + ["godot_string", "p_documentation"] + ] + }, + { + "name": "godot_nativescript_set_method_documentation", + "return_type": "void", + "arguments": [ + ["void *", "p_gdnative_handle"], + ["const char *", "p_name"], + ["const char *", "p_function_name"], + ["godot_string", "p_documentation"] + ] + }, + { + "name": "godot_nativescript_set_property_documentation", + "return_type": "void", + "arguments": [ + ["void *", "p_gdnative_handle"], + ["const char *", "p_name"], + ["const char *", "p_path"], + ["godot_string", "p_documentation"] + ] + }, + { + "name": "godot_nativescript_set_signal_documentation", + "return_type": "void", + "arguments": [ + ["void *", "p_gdnative_handle"], + ["const char *", "p_name"], + ["const char *", "p_signal_name"], + ["godot_string", "p_documentation"] + ] + }, + { + "name": "godot_nativescript_set_type_tag", + "return_type": "void", + "arguments": [ + ["void *", "p_gdnative_handle"], + ["const char *", "p_name"], + ["const void *", "p_type_tag"] + ] + }, + { + "name": "godot_nativescript_get_type_tag", + "return_type": "const void *", + "arguments": [ + ["const godot_object *", "p_object"] + ] + }, + { + "name": "godot_nativescript_register_instance_binding_data_functions", + "return_type": "int", + "arguments": [ + ["godot_instance_binding_functions", "p_binding_functions"] + ] + }, + { + "name": "godot_nativescript_unregister_instance_binding_data_functions", + "return_type": "void", + "arguments": [ + ["int", "p_idx"] + ] + }, + { + "name": "godot_nativescript_get_instance_binding_data", + "return_type": "void *", + "arguments": [ + ["int", "p_idx"], + ["godot_object *", "p_object"] + ] + } + ] + }, "api": [ { "name": "godot_nativescript_register_class", @@ -5710,6 +5931,7 @@ "major": 1, "minor": 0 }, + "next": null, "api": [ { "name": "godot_pluginscript_register_language", @@ -5726,6 +5948,7 @@ "major": 1, "minor": 0 }, + "next": null, "api": [ { "name": "godot_arvr_register_interface", diff --git a/modules/gdnative/gdnative_library_editor_plugin.h b/modules/gdnative/gdnative_library_editor_plugin.h index 94bc2adc7d..04d2911d8b 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.h +++ b/modules/gdnative/gdnative_library_editor_plugin.h @@ -79,7 +79,7 @@ protected: void _on_library_selected(const String &file); void _on_dependencies_selected(const PoolStringArray &files); void _on_filter_selected(int id); - void _on_item_collapsed(Object *item); + void _on_item_collapsed(Object *p_item); void _on_item_activated(); void _on_create_new_entry(); void _set_target_value(const String §ion, const String &target, Variant file); diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h index 56d3779d34..4cf6e99b06 100644 --- a/modules/gdnative/include/gdnative/gdnative.h +++ b/modules/gdnative/include/gdnative/gdnative.h @@ -70,7 +70,7 @@ typedef enum { GODOT_OK, GODOT_FAILED, ///< Generic fail error GODOT_ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable - GODOT_ERR_UNCONFIGURED, ///< The object being used hasnt been properly set up yet + GODOT_ERR_UNCONFIGURED, ///< The object being used hasn't 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 diff --git a/modules/gdnative/include/gdnative/pool_arrays.h b/modules/gdnative/include/gdnative/pool_arrays.h index 69a93725a8..1210039e34 100644 --- a/modules/gdnative/include/gdnative/pool_arrays.h +++ b/modules/gdnative/include/gdnative/pool_arrays.h @@ -383,30 +383,37 @@ void GDAPI godot_pool_color_array_destroy(godot_pool_color_array *p_self); // read accessor functions // +godot_pool_byte_array_read_access GDAPI *godot_pool_byte_array_read_access_copy(const godot_pool_byte_array_read_access *p_other); const uint8_t GDAPI *godot_pool_byte_array_read_access_ptr(const godot_pool_byte_array_read_access *p_read); void GDAPI godot_pool_byte_array_read_access_operator_assign(godot_pool_byte_array_read_access *p_read, godot_pool_byte_array_read_access *p_other); void GDAPI godot_pool_byte_array_read_access_destroy(godot_pool_byte_array_read_access *p_read); +godot_pool_int_array_read_access GDAPI *godot_pool_int_array_read_access_copy(const godot_pool_int_array_read_access *p_other); const godot_int GDAPI *godot_pool_int_array_read_access_ptr(const godot_pool_int_array_read_access *p_read); void GDAPI godot_pool_int_array_read_access_operator_assign(godot_pool_int_array_read_access *p_read, godot_pool_int_array_read_access *p_other); void GDAPI godot_pool_int_array_read_access_destroy(godot_pool_int_array_read_access *p_read); +godot_pool_real_array_read_access GDAPI *godot_pool_real_array_read_access_copy(const godot_pool_real_array_read_access *p_other); const godot_real GDAPI *godot_pool_real_array_read_access_ptr(const godot_pool_real_array_read_access *p_read); void GDAPI godot_pool_real_array_read_access_operator_assign(godot_pool_real_array_read_access *p_read, godot_pool_real_array_read_access *p_other); void GDAPI godot_pool_real_array_read_access_destroy(godot_pool_real_array_read_access *p_read); +godot_pool_string_array_read_access GDAPI *godot_pool_string_array_read_access_copy(const godot_pool_string_array_read_access *p_other); const godot_string GDAPI *godot_pool_string_array_read_access_ptr(const godot_pool_string_array_read_access *p_read); void GDAPI godot_pool_string_array_read_access_operator_assign(godot_pool_string_array_read_access *p_read, godot_pool_string_array_read_access *p_other); void GDAPI godot_pool_string_array_read_access_destroy(godot_pool_string_array_read_access *p_read); +godot_pool_vector2_array_read_access GDAPI *godot_pool_vector2_array_read_access_copy(const godot_pool_vector2_array_read_access *p_other); const godot_vector2 GDAPI *godot_pool_vector2_array_read_access_ptr(const godot_pool_vector2_array_read_access *p_read); void GDAPI godot_pool_vector2_array_read_access_operator_assign(godot_pool_vector2_array_read_access *p_read, godot_pool_vector2_array_read_access *p_other); void GDAPI godot_pool_vector2_array_read_access_destroy(godot_pool_vector2_array_read_access *p_read); +godot_pool_vector3_array_read_access GDAPI *godot_pool_vector3_array_read_access_copy(const godot_pool_vector3_array_read_access *p_other); const godot_vector3 GDAPI *godot_pool_vector3_array_read_access_ptr(const godot_pool_vector3_array_read_access *p_read); void GDAPI godot_pool_vector3_array_read_access_operator_assign(godot_pool_vector3_array_read_access *p_read, godot_pool_vector3_array_read_access *p_other); void GDAPI godot_pool_vector3_array_read_access_destroy(godot_pool_vector3_array_read_access *p_read); +godot_pool_color_array_read_access GDAPI *godot_pool_color_array_read_access_copy(const godot_pool_color_array_read_access *p_other); const godot_color GDAPI *godot_pool_color_array_read_access_ptr(const godot_pool_color_array_read_access *p_read); void GDAPI godot_pool_color_array_read_access_operator_assign(godot_pool_color_array_read_access *p_read, godot_pool_color_array_read_access *p_other); void GDAPI godot_pool_color_array_read_access_destroy(godot_pool_color_array_read_access *p_read); @@ -415,30 +422,37 @@ void GDAPI godot_pool_color_array_read_access_destroy(godot_pool_color_array_rea // write accessor functions // +godot_pool_byte_array_write_access GDAPI *godot_pool_byte_array_write_access_copy(const godot_pool_byte_array_write_access *p_other); uint8_t GDAPI *godot_pool_byte_array_write_access_ptr(const godot_pool_byte_array_write_access *p_write); void GDAPI godot_pool_byte_array_write_access_operator_assign(godot_pool_byte_array_write_access *p_write, godot_pool_byte_array_write_access *p_other); void GDAPI godot_pool_byte_array_write_access_destroy(godot_pool_byte_array_write_access *p_write); +godot_pool_int_array_write_access GDAPI *godot_pool_int_array_write_access_copy(const godot_pool_int_array_write_access *p_other); godot_int GDAPI *godot_pool_int_array_write_access_ptr(const godot_pool_int_array_write_access *p_write); void GDAPI godot_pool_int_array_write_access_operator_assign(godot_pool_int_array_write_access *p_write, godot_pool_int_array_write_access *p_other); void GDAPI godot_pool_int_array_write_access_destroy(godot_pool_int_array_write_access *p_write); +godot_pool_real_array_write_access GDAPI *godot_pool_real_array_write_access_copy(const godot_pool_real_array_write_access *p_other); godot_real GDAPI *godot_pool_real_array_write_access_ptr(const godot_pool_real_array_write_access *p_write); void GDAPI godot_pool_real_array_write_access_operator_assign(godot_pool_real_array_write_access *p_write, godot_pool_real_array_write_access *p_other); void GDAPI godot_pool_real_array_write_access_destroy(godot_pool_real_array_write_access *p_write); +godot_pool_string_array_write_access GDAPI *godot_pool_string_array_write_access_copy(const godot_pool_string_array_write_access *p_other); godot_string GDAPI *godot_pool_string_array_write_access_ptr(const godot_pool_string_array_write_access *p_write); void GDAPI godot_pool_string_array_write_access_operator_assign(godot_pool_string_array_write_access *p_write, godot_pool_string_array_write_access *p_other); void GDAPI godot_pool_string_array_write_access_destroy(godot_pool_string_array_write_access *p_write); +godot_pool_vector2_array_write_access GDAPI *godot_pool_vector2_array_write_access_copy(const godot_pool_vector2_array_write_access *p_other); godot_vector2 GDAPI *godot_pool_vector2_array_write_access_ptr(const godot_pool_vector2_array_write_access *p_write); void GDAPI godot_pool_vector2_array_write_access_operator_assign(godot_pool_vector2_array_write_access *p_write, godot_pool_vector2_array_write_access *p_other); void GDAPI godot_pool_vector2_array_write_access_destroy(godot_pool_vector2_array_write_access *p_write); +godot_pool_vector3_array_write_access GDAPI *godot_pool_vector3_array_write_access_copy(const godot_pool_vector3_array_write_access *p_other); godot_vector3 GDAPI *godot_pool_vector3_array_write_access_ptr(const godot_pool_vector3_array_write_access *p_write); void GDAPI godot_pool_vector3_array_write_access_operator_assign(godot_pool_vector3_array_write_access *p_write, godot_pool_vector3_array_write_access *p_other); void GDAPI godot_pool_vector3_array_write_access_destroy(godot_pool_vector3_array_write_access *p_write); +godot_pool_color_array_write_access GDAPI *godot_pool_color_array_write_access_copy(const godot_pool_color_array_write_access *p_other); godot_color GDAPI *godot_pool_color_array_write_access_ptr(const godot_pool_color_array_write_access *p_write); void GDAPI godot_pool_color_array_write_access_operator_assign(godot_pool_color_array_write_access *p_write, godot_pool_color_array_write_access *p_other); void GDAPI godot_pool_color_array_write_access_destroy(godot_pool_color_array_write_access *p_write); diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h index 080c0aa171..73245160c1 100644 --- a/modules/gdnative/include/gdnative/string.h +++ b/modules/gdnative/include/gdnative/string.h @@ -38,13 +38,24 @@ extern "C" { #include <stdint.h> #include <wchar.h> +typedef wchar_t godot_char_type; + #define GODOT_STRING_SIZE sizeof(void *) +#define GODOT_CHAR_STRING_SIZE sizeof(void *) #ifndef GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED #define GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED typedef struct { uint8_t _dont_touch_that[GODOT_STRING_SIZE]; } godot_string; + +#endif + +#ifndef GODOT_CORE_API_GODOT_CHAR_STRING_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_CHAR_STRING_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_CHAR_STRING_SIZE]; +} godot_char_string; #endif // reduce extern "C" nesting for VS2013 @@ -60,16 +71,17 @@ typedef struct { extern "C" { #endif +godot_int GDAPI godot_char_string_length(const godot_char_string *p_cs); +const char GDAPI *godot_char_string_get_data(const godot_char_string *p_cs); +void GDAPI godot_char_string_destroy(godot_char_string *p_cs); + void GDAPI godot_string_new(godot_string *r_dest); void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src); -void GDAPI godot_string_new_data(godot_string *r_dest, const char *p_contents, const int p_size); -void GDAPI godot_string_new_unicode_data(godot_string *r_dest, const wchar_t *p_contents, const int p_size); - -void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *p_size); +void GDAPI godot_string_new_with_wide_string(godot_string *r_dest, const wchar_t *p_contents, const int p_size); wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx); wchar_t GDAPI godot_string_operator_index_const(const godot_string *p_self, const godot_int p_idx); -const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_self); +const wchar_t GDAPI *godot_string_wide_str(const godot_string *p_self); godot_bool GDAPI godot_string_operator_equal(const godot_string *p_self, const godot_string *p_b); godot_bool GDAPI godot_string_operator_less(const godot_string *p_self, const godot_string *p_b); @@ -81,6 +93,10 @@ godot_int GDAPI godot_string_length(const godot_string *p_self); /* Helpers */ +signed char GDAPI godot_string_casecmp_to(const godot_string *p_self, const godot_string *p_str); +signed char GDAPI godot_string_nocasecmp_to(const godot_string *p_self, const godot_string *p_str); +signed char GDAPI godot_string_naturalnocasecmp_to(const godot_string *p_self, const godot_string *p_str); + godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string); godot_bool GDAPI godot_string_begins_with_char_array(const godot_string *p_self, const char *p_char_array); godot_array GDAPI godot_string_bigrams(const godot_string *p_self); @@ -177,9 +193,9 @@ godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self); void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars); -void GDAPI godot_string_ascii(godot_string *p_self, char *result); -void GDAPI godot_string_ascii_extended(godot_string *p_self, char *result); -void GDAPI godot_string_utf8(godot_string *p_self, char *result); +godot_char_string GDAPI godot_string_ascii(const godot_string *p_self); +godot_char_string GDAPI godot_string_ascii_extended(const godot_string *p_self); +godot_char_string GDAPI godot_string_utf8(const godot_string *p_self); godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8); godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len); godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8); diff --git a/modules/gdnative/include/gdnative/transform.h b/modules/gdnative/include/gdnative/transform.h index 10a242b205..a646da146a 100644 --- a/modules/gdnative/include/gdnative/transform.h +++ b/modules/gdnative/include/gdnative/transform.h @@ -64,10 +64,10 @@ void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const g void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin); godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self); -void GDAPI godot_transform_set_basis(godot_transform *p_self, godot_basis *p_v); +void GDAPI godot_transform_set_basis(godot_transform *p_self, const godot_basis *p_v); godot_vector3 GDAPI godot_transform_get_origin(const godot_transform *p_self); -void GDAPI godot_transform_set_origin(godot_transform *p_self, godot_vector3 *p_v); +void GDAPI godot_transform_set_origin(godot_transform *p_self, const godot_vector3 *p_v); godot_string GDAPI godot_transform_as_string(const godot_transform *p_self); diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h index d2e8246bfb..6779dc4092 100644 --- a/modules/gdnative/include/gdnative/variant.h +++ b/modules/gdnative/include/gdnative/variant.h @@ -135,7 +135,7 @@ void GDAPI godot_variant_new_copy(godot_variant *r_dest, const godot_variant *p_ void GDAPI godot_variant_new_nil(godot_variant *r_dest); -void GDAPI godot_variant_new_bool(godot_variant *p_v, const godot_bool p_b); +void GDAPI godot_variant_new_bool(godot_variant *r_dest, const godot_bool p_b); void GDAPI godot_variant_new_uint(godot_variant *r_dest, const uint64_t p_i); void GDAPI godot_variant_new_int(godot_variant *r_dest, const int64_t p_i); void GDAPI godot_variant_new_real(godot_variant *r_dest, const double p_r); diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h index fdd2a65bb2..747328bc41 100644 --- a/modules/gdnative/include/nativescript/godot_nativescript.h +++ b/modules/gdnative/include/nativescript/godot_nativescript.h @@ -50,7 +50,7 @@ typedef enum { GODOT_PROPERTY_HINT_RANGE, ///< hint_text = "min,max,step,slider; //slider is optional" GODOT_PROPERTY_HINT_EXP_RANGE, ///< hint_text = "min,max,step", exponential edit GODOT_PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc" - GODOT_PROPERTY_HINT_EXP_EASING, /// exponential easing funciton (Math::ease) + GODOT_PROPERTY_HINT_EXP_EASING, /// exponential easing function (Math::ease) GODOT_PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer) GODOT_PROPERTY_HINT_SPRITE_FRAME, GODOT_PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer) @@ -185,6 +185,52 @@ void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const cha void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance); +/* + * + * + * NativeScript 1.1 + * + * + */ + +// method registering with argument names + +typedef struct { + godot_string name; + + godot_variant_type type; + godot_property_hint hint; + godot_string hint_string; +} godot_method_arg; + +void GDAPI godot_nativescript_set_method_argument_information(void *p_gdnative_handle, const char *p_name, const char *p_function_name, int p_num_args, const godot_method_arg *p_args); + +// documentation + +void GDAPI godot_nativescript_set_class_documentation(void *p_gdnative_handle, const char *p_name, godot_string p_documentation); +void GDAPI godot_nativescript_set_method_documentation(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_string p_documentation); +void GDAPI godot_nativescript_set_property_documentation(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_string p_documentation); +void GDAPI godot_nativescript_set_signal_documentation(void *p_gdnative_handle, const char *p_name, const char *p_signal_name, godot_string p_documentation); + +// type tag API + +void GDAPI godot_nativescript_set_type_tag(void *p_gdnative_handle, const char *p_name, const void *p_type_tag); +const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object); + +// instance binding API + +typedef struct { + void *(*alloc_instance_binding_data)(void *, godot_object *); + void (*free_instance_binding_data)(void *, void *); + void *data; + void (*free_func)(void *); +} godot_instance_binding_functions; + +int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_instance_binding_functions p_binding_functions); +void GDAPI godot_nativescript_unregister_instance_binding_data_functions(int p_idx); + +void GDAPI *godot_nativescript_get_instance_binding_data(int p_idx, godot_object *p_object); + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp index b4f7e1555e..aea595d0f0 100644 --- a/modules/gdnative/nativescript/godot_nativescript.cpp +++ b/modules/gdnative/nativescript/godot_nativescript.cpp @@ -106,7 +106,7 @@ void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const cha Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); if (!E) { - ERR_EXPLAIN("Attempt to register method on non-existant class!"); + ERR_EXPLAIN("Attempted to register method on non-existent class!"); ERR_FAIL(); } @@ -125,7 +125,7 @@ void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const c Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); if (!E) { - ERR_EXPLAIN("Attempt to register method on non-existant class!"); + ERR_EXPLAIN("Attempted to register method on non-existent class!"); ERR_FAIL(); } @@ -150,7 +150,7 @@ void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const cha Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); if (!E) { - ERR_EXPLAIN("Attempt to register method on non-existant class!"); + ERR_EXPLAIN("Attempted to register method on non-existent class!"); ERR_FAIL(); } @@ -201,6 +201,164 @@ void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance) { return NULL; } +/* + * + * + * NativeScript 1.1 + * + * + */ + +void GDAPI godot_nativescript_set_method_argument_information(void *p_gdnative_handle, const char *p_name, const char *p_function_name, int p_num_args, const godot_method_arg *p_args) { + String *s = (String *)p_gdnative_handle; + + Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); + + if (!E) { + ERR_EXPLAIN("Attempted to add argument information for a method on a non-existent class!"); + ERR_FAIL(); + } + + Map<StringName, NativeScriptDesc::Method>::Element *method = E->get().methods.find(p_function_name); + if (!method) { + ERR_EXPLAIN("Attempted to add argument information to non-existent method!"); + ERR_FAIL(); + } + + MethodInfo *method_information = &method->get().info; + + List<PropertyInfo> args; + + for (int i = 0; i < p_num_args; i++) { + godot_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 godot_nativescript_set_class_documentation(void *p_gdnative_handle, const char *p_name, godot_string p_documentation) { + String *s = (String *)p_gdnative_handle; + + Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); + + if (!E) { + ERR_EXPLAIN("Attempted to add documentation to a non-existent class!"); + ERR_FAIL(); + } + + E->get().documentation = *(String *)&p_documentation; +} + +void GDAPI godot_nativescript_set_method_documentation(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_string p_documentation) { + String *s = (String *)p_gdnative_handle; + + Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); + + if (!E) { + ERR_EXPLAIN("Attempted to add documentation to a method on a non-existent class!"); + ERR_FAIL(); + } + + Map<StringName, NativeScriptDesc::Method>::Element *method = E->get().methods.find(p_function_name); + if (!method) { + ERR_EXPLAIN("Attempted to add documentatino to non-existent method!"); + ERR_FAIL(); + } + + method->get().documentation = *(String *)&p_documentation; +} + +void GDAPI godot_nativescript_set_property_documentation(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_string p_documentation) { + String *s = (String *)p_gdnative_handle; + + Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); + + if (!E) { + ERR_EXPLAIN("Attempted to add documentation to a property on a non-existent class!"); + ERR_FAIL(); + } + + OrderedHashMap<StringName, NativeScriptDesc::Property>::Element property = E->get().properties.find(p_path); + if (!property) { + ERR_EXPLAIN("Attempted to add documentation to non-existent property!"); + ERR_FAIL(); + } + + property.get().documentation = *(String *)&p_documentation; +} + +void GDAPI godot_nativescript_set_signal_documentation(void *p_gdnative_handle, const char *p_name, const char *p_signal_name, godot_string p_documentation) { + String *s = (String *)p_gdnative_handle; + + Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); + + if (!E) { + ERR_EXPLAIN("Attempted to add documentation to a signal on a non-existent class!"); + ERR_FAIL(); + } + + Map<StringName, NativeScriptDesc::Signal>::Element *signal = E->get().signals_.find(p_signal_name); + if (!signal) { + ERR_EXPLAIN("Attempted to add documentation to non-existent signal!"); + ERR_FAIL(); + } + + signal->get().documentation = *(String *)&p_documentation; +} + +void GDAPI godot_nativescript_set_type_tag(void *p_gdnative_handle, const char *p_name, const void *p_type_tag) { + String *s = (String *)p_gdnative_handle; + + Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); + + if (!E) { + ERR_EXPLAIN("Attempted to set type tag on a non-existent class!"); + ERR_FAIL(); + } + + E->get().type_tag = p_type_tag; +} + +const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object) { + + const Object *o = (Object *)p_object; + + if (!o->get_script_instance()) { + ERR_EXPLAIN("Attempted to get type tag on an object without a script!"); + ERR_FAIL_V(NULL); + } else { + NativeScript *script = Object::cast_to<NativeScript>(o->get_script_instance()->get_script().ptr()); + if (!script) { + ERR_EXPLAIN("Attempted to get type tag on an object without a nativescript attached"); + ERR_FAIL_V(NULL); + } + + if (script->get_script_desc()) + return script->get_script_desc()->type_tag; + } + + return NULL; +} + #ifdef __cplusplus } #endif + +int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_instance_binding_functions p_binding_functions) { + return NativeScriptLanguage::get_singleton()->register_binding_functions(p_binding_functions); +} + +void GDAPI godot_nativescript_unregister_instance_binding_data_functions(int p_idx) { + NativeScriptLanguage::get_singleton()->unregister_binding_functions(p_idx); +} + +void GDAPI *godot_nativescript_get_instance_binding_data(int p_idx, godot_object *p_object) { + return NativeScriptLanguage::get_singleton()->get_instance_binding_data(p_idx, (Object *)p_object); +} diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index e9e3180835..f2e9bef467 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -68,6 +68,11 @@ void NativeScript::_bind_methods() { ClassDB::bind_method(D_METHOD("set_library", "library"), &NativeScript::set_library); ClassDB::bind_method(D_METHOD("get_library"), &NativeScript::get_library); + ClassDB::bind_method(D_METHOD("get_class_documentation"), &NativeScript::get_class_documentation); + ClassDB::bind_method(D_METHOD("get_method_documentation", "method"), &NativeScript::get_method_documentation); + ClassDB::bind_method(D_METHOD("get_signal_documentation", "signal_name"), &NativeScript::get_signal_documentation); + ClassDB::bind_method(D_METHOD("get_property_documentation", "path"), &NativeScript::get_property_documentation); + ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "class_name"), "set_class_name", "get_class_name"); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library"); @@ -373,6 +378,86 @@ void NativeScript::get_script_property_list(List<PropertyInfo> *p_list) const { } } +String NativeScript::get_class_documentation() const { + NativeScriptDesc *script_data = get_script_desc(); + + if (!script_data) { + ERR_EXPLAIN("Attempt to get class documentation on invalid NativeScript"); + ERR_FAIL_V(""); + } + + return script_data->documentation; +} + +String NativeScript::get_method_documentation(const StringName &p_method) const { + NativeScriptDesc *script_data = get_script_desc(); + + if (!script_data) { + ERR_EXPLAIN("Attempt to get method documentation on invalid NativeScript"); + ERR_FAIL_V(""); + } + + while (script_data) { + + Map<StringName, NativeScriptDesc::Method>::Element *method = script_data->methods.find(p_method); + + if (method) { + return method->get().documentation; + } + + script_data = script_data->base_data; + } + + ERR_EXPLAIN("Attempt to get method documentation for non-existent method"); + ERR_FAIL_V(""); +} + +String NativeScript::get_signal_documentation(const StringName &p_signal_name) const { + NativeScriptDesc *script_data = get_script_desc(); + + if (!script_data) { + ERR_EXPLAIN("Attempt to get signal documentation on invalid NativeScript"); + ERR_FAIL_V(""); + } + + while (script_data) { + + Map<StringName, NativeScriptDesc::Signal>::Element *signal = script_data->signals_.find(p_signal_name); + + if (signal) { + return signal->get().documentation; + } + + script_data = script_data->base_data; + } + + ERR_EXPLAIN("Attempt to get signal documentation for non-existent signal"); + ERR_FAIL_V(""); +} + +String NativeScript::get_property_documentation(const StringName &p_path) const { + NativeScriptDesc *script_data = get_script_desc(); + + if (!script_data) { + ERR_EXPLAIN("Attempt to get property documentation on invalid NativeScript"); + ERR_FAIL_V(""); + } + + while (script_data) { + + OrderedHashMap<StringName, NativeScriptDesc::Property>::Element property = script_data->properties.find(p_path); + + if (property) { + return property.get().documentation; + } + + script_data = script_data->base_data; + } + + ERR_EXPLAIN("Attempt to get property documentation for non-existent signal"); + ERR_FAIL_V(""); +} + Variant NativeScript::_new(const Variant **p_args, int p_argcount, Variant::CallError &r_error) { if (lib_path.empty() || class_name.empty() || library.is_null()) { @@ -398,6 +483,11 @@ Variant NativeScript::_new(const Variant **p_args, int p_argcount, Variant::Call owner = memnew(Reference); } + if (!owner) { + r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL; + return Variant(); + } + Reference *r = Object::cast_to<Reference>(owner); if (r) { ref = REF(r); @@ -605,7 +695,7 @@ Variant::Type NativeScriptInstance::get_property_type(const StringName &p_name, } void NativeScriptInstance::get_method_list(List<MethodInfo> *p_list) const { - script->get_method_list(p_list); + script->get_script_method_list(p_list); } bool NativeScriptInstance::has_method(const StringName &p_method) const { @@ -793,11 +883,52 @@ NativeScriptLanguage *NativeScriptLanguage::singleton; void NativeScriptLanguage::_unload_stuff(bool p_reload) { for (Map<String, Map<StringName, NativeScriptDesc> >::Element *L = library_classes.front(); L; L = L->next()) { - if (p_reload && !library_gdnatives[L->key()]->get_library()->is_reloadable()) { - continue; + String lib_path = L->key(); + Map<StringName, NativeScriptDesc> classes = L->get(); + + if (p_reload) { + + Map<String, Ref<GDNative> >::Element *E = library_gdnatives.find(lib_path); + Ref<GDNative> gdn; + + if (E) { + gdn = E->get(); + } + + bool should_reload = false; + + if (gdn.is_valid()) { + Ref<GDNativeLibrary> lib = gdn->get_library(); + if (lib.is_valid()) { + should_reload = lib->is_reloadable(); + } + } + + if (!should_reload) { + continue; + } } - for (Map<StringName, NativeScriptDesc>::Element *C = L->get().front(); C; C = C->next()) { + Map<String, Ref<GDNative> >::Element *E = library_gdnatives.find(lib_path); + Ref<GDNative> gdn; + + if (E) { + gdn = E->get(); + } + + if (gdn.is_valid() && gdn->get_library().is_valid()) { + Ref<GDNativeLibrary> lib = gdn->get_library(); + void *terminate_fn; + Error err = gdn->get_symbol(lib->get_symbol_prefix() + _terminate_call_name, terminate_fn, true); + + if (err == OK) { + void (*terminate)(void *) = (void (*)(void *))terminate_fn; + + terminate((void *)&lib_path); + } + } + + for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) { // free property stuff first for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) { @@ -835,12 +966,14 @@ NativeScriptLanguage::~NativeScriptLanguage() { for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { - L->get()->terminate(); - NSL->library_classes.clear(); - NSL->library_gdnatives.clear(); - NSL->library_script_users.clear(); + if (L->get().is_valid()) + L->get()->terminate(); } + NSL->library_classes.clear(); + NSL->library_gdnatives.clear(); + NSL->library_script_users.clear(); + #ifndef NO_THREADS memdelete(mutex); #endif @@ -902,7 +1035,7 @@ Ref<Script> NativeScriptLanguage::get_template(const String &p_class_name, const return Ref<NativeScript>(s); } bool NativeScriptLanguage::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; + return true; } Script *NativeScriptLanguage::create_script() const { @@ -982,6 +1115,116 @@ int NativeScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, in return 0; } +int NativeScriptLanguage::register_binding_functions(godot_instance_binding_functions p_binding_functions) { + + // find index + + int idx = -1; + + for (int i = 0; i < binding_functions.size(); i++) { + if (!binding_functions[i].first) { + // free, we'll take it + idx = i; + break; + } + } + + if (idx == -1) { + idx = binding_functions.size(); + binding_functions.resize(idx + 1); + } + + // set the functions + binding_functions[idx].first = true; + binding_functions[idx].second = p_binding_functions; + + return idx; +} + +void NativeScriptLanguage::unregister_binding_functions(int p_idx) { + ERR_FAIL_INDEX(p_idx, binding_functions.size()); + + for (Set<Vector<void *> *>::Element *E = binding_instances.front(); E; E = E->next()) { + Vector<void *> &binding_data = *E->get(); + + if (binding_data[p_idx] && binding_functions[p_idx].second.free_instance_binding_data) + binding_functions[p_idx].second.free_instance_binding_data(binding_functions[p_idx].second.data, binding_data[p_idx]); + } + + binding_functions[p_idx].first = false; + + if (binding_functions[p_idx].second.free_func) + binding_functions[p_idx].second.free_func(binding_functions[p_idx].second.data); +} + +void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_object) { + ERR_FAIL_INDEX_V(p_idx, binding_functions.size(), NULL); + + if (!binding_functions[p_idx].first) { + ERR_EXPLAIN("Tried to get binding data for a nativescript binding that does not exist"); + ERR_FAIL_V(NULL); + } + + Vector<void *> *binding_data = (Vector<void *> *)p_object->get_script_instance_binding(lang_idx); + + if (!binding_data) + return NULL; // should never happen. + + if (binding_data->size() <= p_idx) { + // okay, add new elements here. + int old_size = binding_data->size(); + + binding_data->resize(p_idx + 1); + + for (int i = old_size; i <= p_idx; i++) { + (*binding_data)[i] = NULL; + } + } + + if (!(*binding_data)[p_idx]) { + // no binding data yet, soooooo alloc new one \o/ + (*binding_data)[p_idx] = binding_functions[p_idx].second.alloc_instance_binding_data(binding_functions[p_idx].second.data, (godot_object *)p_object); + } + + return (*binding_data)[p_idx]; +} + +void *NativeScriptLanguage::alloc_instance_binding_data(Object *p_object) { + + Vector<void *> *binding_data = new Vector<void *>; + + binding_data->resize(binding_functions.size()); + + for (int i = 0; i < binding_functions.size(); i++) { + (*binding_data)[i] = NULL; + } + + binding_instances.insert(binding_data); + + return (void *)binding_data; +} + +void NativeScriptLanguage::free_instance_binding_data(void *p_data) { + + if (!p_data) + return; + + Vector<void *> &binding_data = *(Vector<void *> *)p_data; + + for (int i = 0; i < binding_data.size(); i++) { + if (!binding_data[i]) + continue; + + if (binding_functions[i].first && binding_functions[i].second.free_instance_binding_data) { + binding_functions[i].second.free_instance_binding_data(binding_functions[i].second.data, binding_data[i]); + } + } + + binding_instances.erase(&binding_data); + + delete &binding_data; +} + #ifndef NO_THREADS void NativeScriptLanguage::defer_init_library(Ref<GDNativeLibrary> lib, NativeScript *script) { MutexLock lock(mutex); @@ -1056,6 +1299,11 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) { void NativeScriptLanguage::call_libraries_cb(const StringName &name) { // library_gdnatives is modified only from the main thread, so it's safe not to use mutex here for (Map<String, Ref<GDNative> >::Element *L = library_gdnatives.front(); L; L = L->next()) { + + if (L->get().is_null()) { + continue; + } + if (L->get()->is_initialized()) { void *proc_ptr; @@ -1118,6 +1366,10 @@ void NativeReloadNode::_notification(int p_what) { Ref<GDNative> gdn = L->get(); + if (gdn.is_null()) { + continue; + } + if (!gdn->get_library()->is_reloadable()) { continue; } @@ -1142,6 +1394,10 @@ void NativeReloadNode::_notification(int p_what) { Ref<GDNative> gdn = L->get(); + if (gdn.is_null()) { + continue; + } + if (!gdn->get_library()->is_reloadable()) { continue; } diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h index ac94c84bc4..17b6ddc747 100644 --- a/modules/gdnative/nativescript/nativescript.h +++ b/modules/gdnative/nativescript/nativescript.h @@ -53,6 +53,7 @@ struct NativeScriptDesc { godot_instance_method method; MethodInfo info; int rpc_mode; + String documentation; }; struct Property { godot_property_set_func setter; @@ -60,12 +61,16 @@ struct NativeScriptDesc { PropertyInfo info; Variant default_value; int rset_mode; + String documentation; }; struct Signal { MethodInfo signal; + String documentation; }; + String documentation; + Map<StringName, Method> methods; OrderedHashMap<StringName, Property> properties; Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals @@ -75,6 +80,8 @@ struct NativeScriptDesc { godot_instance_create_func create_func; godot_instance_destroy_func destroy_func; + const void *type_tag; + bool is_tool; inline NativeScriptDesc() : @@ -82,7 +89,9 @@ struct NativeScriptDesc { properties(), signals_(), base(), - base_native_type() { + base_native_type(), + documentation(), + type_tag(NULL) { zeromem(&create_func, sizeof(godot_instance_create_func)); zeromem(&destroy_func, sizeof(godot_instance_destroy_func)); } @@ -154,6 +163,11 @@ public: virtual void get_script_method_list(List<MethodInfo> *p_list) const; virtual void get_script_property_list(List<PropertyInfo> *p_list) const; + String get_class_documentation() const; + String get_method_documentation(const StringName &p_method) const; + String get_signal_documentation(const StringName &p_signal_name) const; + String get_property_documentation(const StringName &p_path) const; + Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error); NativeScript(); @@ -204,6 +218,7 @@ class NativeScriptLanguage : public ScriptLanguage { private: static NativeScriptLanguage *singleton; + int lang_idx; void _unload_stuff(bool p_reload = false); @@ -222,6 +237,9 @@ private: void call_libraries_cb(const StringName &name); + Vector<Pair<bool, godot_instance_binding_functions> > binding_functions; + Set<Vector<void *> *> binding_instances; + public: // These two maps must only be touched on the main thread Map<String, Map<StringName, NativeScriptDesc> > library_classes; @@ -232,6 +250,8 @@ public: const StringName _init_call_type = "nativescript_init"; const StringName _init_call_name = "nativescript_init"; + const StringName _terminate_call_name = "nativescript_terminate"; + const StringName _noarg_call_type = "nativescript_no_arg"; const StringName _frame_call_name = "nativescript_frame"; @@ -250,6 +270,8 @@ public: void _hacky_api_anchor(); + _FORCE_INLINE_ void set_language_index(int p_idx) { lang_idx = p_idx; } + #ifndef NO_THREADS virtual void thread_enter(); virtual void thread_exit(); @@ -293,6 +315,14 @@ public: virtual void profiling_stop(); virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max); virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max); + + int register_binding_functions(godot_instance_binding_functions p_binding_functions); + void unregister_binding_functions(int p_idx); + + void *get_instance_binding_data(int p_idx, Object *p_object); + + virtual void *alloc_instance_binding_data(Object *p_object); + virtual void free_instance_binding_data(void *p_data); }; inline NativeScriptDesc *NativeScript::get_script_desc() const { diff --git a/modules/gdnative/nativescript/register_types.cpp b/modules/gdnative/nativescript/register_types.cpp index cb55a13b3e..9a0e764391 100644 --- a/modules/gdnative/nativescript/register_types.cpp +++ b/modules/gdnative/nativescript/register_types.cpp @@ -47,6 +47,7 @@ void register_nativescript_types() { ClassDB::register_class<NativeScript>(); + native_script_language->set_language_index(ScriptServer::get_language_count()); ScriptServer::register_language(native_script_language); resource_saver_gdns = memnew(ResourceFormatSaverNativeScript); diff --git a/modules/gdnative/pluginscript/pluginscript_instance.cpp b/modules/gdnative/pluginscript/pluginscript_instance.cpp index 52d112bc93..931ab0bfe4 100644 --- a/modules/gdnative/pluginscript/pluginscript_instance.cpp +++ b/modules/gdnative/pluginscript/pluginscript_instance.cpp @@ -84,8 +84,9 @@ Variant PluginScriptInstance::call(const StringName &p_method, const Variant **p godot_variant ret = _desc->call_method( _data, (godot_string_name *)&p_method, (const godot_variant **)p_args, p_argcount, (godot_variant_call_error *)&r_error); - Variant *var_ret = (Variant *)&ret; - return *var_ret; + Variant var_ret = *(Variant *)&ret; + godot_variant_destroy(&ret); + return var_ret; } #if 0 // TODO: Don't rely on default implementations provided by ScriptInstance ? diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp index 2405afc677..8018178bd5 100644 --- a/modules/gdnative/pluginscript/pluginscript_language.cpp +++ b/modules/gdnative/pluginscript/pluginscript_language.cpp @@ -45,7 +45,11 @@ void PluginScriptLanguage::init() { } String PluginScriptLanguage::get_type() const { - return String(_desc.type); + // We should use _desc.type here, however the returned type is used to + // query ClassDB which would complain given the type is not registered + // from his point of view... + // To solve this we just use a more generic (but present in ClassDB) type. + return String("PluginScript"); } String PluginScriptLanguage::get_extension() const { @@ -99,6 +103,7 @@ Ref<Script> PluginScriptLanguage::get_template(const String &p_class_name, const if (_desc.get_template_source_code) { godot_string src = _desc.get_template_source_code(_data, (godot_string *)&p_class_name, (godot_string *)&p_base_class_name); script->set_source_code(*(String *)&src); + godot_string_destroy(&src); } return script; } @@ -168,7 +173,7 @@ Error PluginScriptLanguage::complete_code(const String &p_code, const String &p_ for (int i = 0; i < options.size(); i++) { r_options->push_back(String(options[i])); } - Error err = *(Error *)tmp; + Error err = *(Error *)&tmp; return err; } return ERR_UNAVAILABLE; diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp index b4525ff8aa..5ae7926f1b 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ b/modules/gdnative/pluginscript/pluginscript_script.cpp @@ -131,13 +131,10 @@ ScriptInstance *PluginScript::instance_create(Object *p_this) { #endif } - PluginScript *top = this; - // TODO: can be optimized by storing a PluginScript::_base_parent direct pointer - while (top->_ref_base_parent.is_valid()) - top = top->_ref_base_parent.ptr(); - if (top->_native_parent) { - if (!ClassDB::is_parent_class(p_this->get_class_name(), top->_native_parent)) { - String msg = "Script inherits from native type '" + String(top->_native_parent) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'"; + StringName base_type = get_instance_base_type(); + if (base_type) { + if (!ClassDB::is_parent_class(p_this->get_class_name(), base_type)) { + String msg = "Script inherits from native type '" + String(base_type) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'"; // TODO: implement PluginscriptLanguage::debug_break_parse // if (ScriptDebugger::get_singleton()) { // _language->debug_break_parse(get_path(), 0, msg); @@ -210,29 +207,31 @@ Error PluginScript::reload(bool p_keep_state) { // TODO: GDscript uses `ScriptDebugger` here to jump into the parsing error return err; } + + // Script's parent is passed as base_name which can make reference to a + // ClassDB name (i.e. `Node2D`) or a resource path (i.e. `res://foo/bar.gd`) + StringName *base_name = (StringName *)&manifest.base; + if (*base_name) { + + if (ClassDB::class_exists(*base_name)) { + _native_parent = *base_name; + } else { + Ref<Script> res = ResourceLoader::load(*base_name); + if (res.is_valid()) { + _ref_base_parent = res; + } else { + String name = *(StringName *)&manifest.name; + ERR_EXPLAIN(_path + ": Script '" + name + "' has an invalid parent '" + *base_name + "'."); + ERR_FAIL_V(ERR_PARSE_ERROR); + } + } + } + _valid = true; // Use the manifest to configure this script object _data = manifest.data; _name = *(StringName *)&manifest.name; _tool = manifest.is_tool; - // Base name is either another PluginScript or a regular class accessible - // through ClassDB - StringName *base_name = (StringName *)&manifest.base; - for (SelfList<PluginScript> *e = _language->_script_list.first(); e != NULL; e = e->next()) { - if (e->self()->_name == *base_name) { - // Found you, base is a PluginScript ! - _ref_base_parent = Ref<PluginScript>(e->self()); - break; - } - } - if (!_ref_base_parent.is_valid()) { - // Base is a native ClassDB - if (!ClassDB::class_exists(*base_name)) { - ERR_EXPLAIN("Unknown script '" + String(_name) + "' parent '" + String(*base_name) + "'."); - ERR_FAIL_V(ERR_PARSE_ERROR); - } - _native_parent = *base_name; - } Dictionary *members = (Dictionary *)&manifest.member_lines; for (const Variant *key = members->next(); key != NULL; key = members->next(key)) { diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h index 6b343ad844..1be9e907c2 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.h +++ b/modules/gdnative/pluginscript/pluginscript_script.h @@ -53,7 +53,7 @@ private: bool _tool; bool _valid; - Ref<PluginScript> _ref_base_parent; + Ref<Script> _ref_base_parent; StringName _native_parent; SelfList<PluginScript> _script_list; @@ -112,7 +112,7 @@ public: virtual void update_exports(); virtual void get_script_method_list(List<MethodInfo> *r_methods) const; - virtual void get_script_property_list(List<PropertyInfo> *r_propertieslist) const; + virtual void get_script_property_list(List<PropertyInfo> *r_properties) const; virtual int get_member_line(const StringName &p_member) const; |