From 6f9dd799d0f13efbf2a60975d01a1b9c5e091579 Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 25 May 2023 21:29:02 +0200 Subject: [PATCH] More cleanups. --- gdnative.cpp | 6 +- gdnative.h | 8 +- gdnative/aabb.cpp | 4 +- gdnative/basis.cpp | 6 +- gdnative/gdnative.cpp | 2 +- gdnative/rid.cpp | 2 +- gdnative/string.cpp | 8 +- gdnative/transform2d.cpp | 2 +- gdnative/variant.cpp | 2 +- gdnative_api.json | 145 +------------------------ gdnative_library_editor_plugin.cpp | 40 ++++--- gdnative_library_editor_plugin.h | 6 +- gdnative_library_singleton_editor.cpp | 15 ++- gdnative_library_singleton_editor.h | 4 +- include/gdnative/string.h | 11 +- nativescript/api_generator.cpp | 6 +- nativescript/godot_nativescript.cpp | 28 ++--- nativescript/nativescript.cpp | 112 +++++++++---------- nativescript/nativescript.h | 38 +++---- net/multiplayer_peer_gdnative.h | 3 +- net/packet_peer_gdnative.h | 3 +- pluginscript/pluginscript_language.cpp | 2 +- pluginscript/pluginscript_language.h | 2 +- pluginscript/pluginscript_script.cpp | 20 ++-- pluginscript/pluginscript_script.h | 18 +-- register_types.cpp | 5 +- videodecoder/video_stream_gdnative.cpp | 2 +- videodecoder/video_stream_gdnative.h | 4 +- 28 files changed, 188 insertions(+), 316 deletions(-) diff --git a/gdnative.cpp b/gdnative.cpp index f71437b..f88250e 100644 --- a/gdnative.cpp +++ b/gdnative.cpp @@ -49,7 +49,7 @@ static const bool default_reloadable = true; // Defined in gdnative_api_struct.gen.cpp extern const godot_gdnative_core_api_struct api_struct; -Map>> GDNativeLibrary::loaded_libraries; +RBMap>> GDNativeLibrary::loaded_libraries; GDNativeLibrary::GDNativeLibrary() { config_file.instance(); @@ -473,7 +473,7 @@ Vector GDNativeCallRegistry::get_native_call_types() { call_types.resize(native_calls.size()); size_t idx = 0; - for (Map::Element *E = native_calls.front(); E; E = E->next(), idx++) { + for (RBMap::Element *E = native_calls.front(); E; E = E->next(), idx++) { call_types.write[idx] = E->key(); } @@ -481,7 +481,7 @@ Vector GDNativeCallRegistry::get_native_call_types() { } Variant GDNative::call_native(StringName p_native_call_type, StringName p_procedure_name, Array p_arguments) { - Map::Element *E = GDNativeCallRegistry::singleton->native_calls.find(p_native_call_type); + RBMap::Element *E = GDNativeCallRegistry::singleton->native_calls.find(p_native_call_type); if (!E) { ERR_PRINT((String("No handler for native call type \"" + p_native_call_type) + "\" found").utf8().get_data()); return Variant(); diff --git a/gdnative.h b/gdnative.h index 41fdf88..f272049 100644 --- a/gdnative.h +++ b/gdnative.h @@ -36,8 +36,8 @@ #include "core/os/thread_safe.h" #include "core/object/resource.h" -#include "gdnative/gdnative.h" -#include "gdnative_api_struct.gen.h" +#include "include/gdnative/gdnative.h" +#include "include/gdnative_api_struct.gen.h" #include "core/io/config_file.h" @@ -47,7 +47,7 @@ class GDNative; class GDNativeLibrary : public Resource { GDCLASS(GDNativeLibrary, Resource); - static Map>> loaded_libraries; + static RBMap>> loaded_libraries; friend class GDNativeLibraryResourceLoader; friend class GDNative; @@ -129,7 +129,7 @@ struct GDNativeCallRegistry { inline GDNativeCallRegistry() : native_calls() {} - Map native_calls; + RBMap native_calls; void register_native_call_type(StringName p_call_type, native_call_cb p_callback); diff --git a/gdnative/aabb.cpp b/gdnative/aabb.cpp index d2288cf..ace1ff4 100644 --- a/gdnative/aabb.cpp +++ b/gdnative/aabb.cpp @@ -83,12 +83,12 @@ godot_string GDAPI godot_aabb_as_string(const godot_aabb *p_self) { godot_real GDAPI godot_aabb_get_area(const godot_aabb *p_self) { const AABB *self = (const AABB *)p_self; - return self->get_area(); + return self->get_volume(); } godot_bool GDAPI godot_aabb_has_no_area(const godot_aabb *p_self) { const AABB *self = (const AABB *)p_self; - return self->has_no_area(); + return self->has_no_volume(); } godot_bool GDAPI godot_aabb_has_no_surface(const godot_aabb *p_self) { diff --git a/gdnative/basis.cpp b/gdnative/basis.cpp index 1fde515..1a4b473 100644 --- a/gdnative/basis.cpp +++ b/gdnative/basis.cpp @@ -210,9 +210,9 @@ void GDAPI godot_basis_new_with_euler_quaternion(godot_basis *r_dest, const godo void GDAPI godot_basis_get_elements(const godot_basis *p_self, godot_vector3 *p_elements) { const Basis *self = (const Basis *)p_self; Vector3 *elements = (Vector3 *)p_elements; - elements[0] = self->elements[0]; - elements[1] = self->elements[1]; - elements[2] = self->elements[2]; + elements[0] = self->rows[0]; + elements[1] = self->rows[1]; + elements[2] = self->rows[2]; } godot_vector3 GDAPI godot_basis_get_axis(const godot_basis *p_self, const godot_int p_axis) { diff --git a/gdnative/gdnative.cpp b/gdnative/gdnative.cpp index ae91b98..dcf9705 100644 --- a/gdnative/gdnative.cpp +++ b/gdnative/gdnative.cpp @@ -37,7 +37,7 @@ #include "core/os/os.h" #include "core/variant/variant.h" -#include "../gdnative/gdnative.h" +#include "../gdnative.h" #ifdef __cplusplus extern "C" { diff --git a/gdnative/rid.cpp b/gdnative/rid.cpp index 411292a..c17f7c4 100644 --- a/gdnative/rid.cpp +++ b/gdnative/rid.cpp @@ -31,7 +31,7 @@ #include "gdnative/rid.h" #include "core/object/resource.h" -#include "core/object/rid.h" +#include "core/containers/rid.h" #include "core/variant/variant.h" #ifdef __cplusplus diff --git a/gdnative/string.cpp b/gdnative/string.cpp index 267ec77..a031073 100644 --- a/gdnative/string.cpp +++ b/gdnative/string.cpp @@ -78,19 +78,19 @@ void GDAPI godot_string_new_with_wide_string(godot_string *r_dest, const wchar_t memnew_placement(dest, String(p_contents, p_size)); } -const wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx) { +const char32_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)); } -wchar_t GDAPI godot_string_operator_index_const(const godot_string *p_self, const godot_int p_idx) { +char32_t GDAPI godot_string_operator_index_const(const godot_string *p_self, const godot_int p_idx) { const String *self = (const String *)p_self; return self->operator[](p_idx); } -const wchar_t GDAPI *godot_string_wide_str(const godot_string *p_self) { +const char32_t GDAPI *godot_string_wide_str(const godot_string *p_self) { const String *self = (const String *)p_self; - return self->c_str(); + return self->get_data(); } godot_bool GDAPI godot_string_operator_equal(const godot_string *p_self, const godot_string *p_b) { diff --git a/gdnative/transform2d.cpp b/gdnative/transform2d.cpp index 938d4b2..af94149 100644 --- a/gdnative/transform2d.cpp +++ b/gdnative/transform2d.cpp @@ -95,7 +95,7 @@ godot_vector2 GDAPI godot_transform2d_get_scale(const godot_transform2d *p_self) godot_real GDAPI godot_transform2d_determinant(const godot_transform2d *p_self) { const Transform2D *self = (const Transform2D *)p_self; - return self->determinant(); + return self->basis_determinant(); } godot_transform2d GDAPI godot_transform2d_orthonormalized(const godot_transform2d *p_self) { diff --git a/gdnative/variant.cpp b/gdnative/variant.cpp index 3b29ba9..f703f0f 100644 --- a/gdnative/variant.cpp +++ b/gdnative/variant.cpp @@ -30,7 +30,7 @@ #include "gdnative/variant.h" -#include "core/reference.h" +#include "core/object/reference.h" #include "core/variant/variant.h" #ifdef __cplusplus diff --git a/gdnative_api.json b/gdnative_api.json index 288188f..0a49c76 100644 --- a/gdnative_api.json +++ b/gdnative_api.json @@ -6600,126 +6600,6 @@ } ] }, - { - "name": "arvr", - "type": "ARVR", - "version": { - "major": 1, - "minor": 1 - }, - "next": { - "name": "arvr", - "type": "ARVR", - "version": { - "major": 1, - "minor": 2 - }, - "next": null, - "api": [{ - "name": "godot_arvr_set_interface", - "return_type": "void", - "arguments": [ - ["godot_object *", "p_arvr_interface"], - ["const godot_arvr_interface_gdnative *", "p_gdn_interface"] - ] - }, - { - "name": "godot_arvr_get_depthid", - "return_type": "godot_int", - "arguments": [ - ["godot_rid *", "p_render_target"] - ] - } - ] - }, - "api": [{ - "name": "godot_arvr_register_interface", - "return_type": "void", - "arguments": [ - ["const godot_arvr_interface_gdnative *", "p_interface"] - ] - }, - { - "name": "godot_arvr_get_worldscale", - "return_type": "godot_real", - "arguments": [] - }, - { - "name": "godot_arvr_get_reference_frame", - "return_type": "godot_transform", - "arguments": [] - }, - { - "name": "godot_arvr_blit", - "return_type": "void", - "arguments": [ - ["int", "p_eye"], - ["godot_rid *", "p_render_target"], - ["godot_rect2 *", "p_screen_rect"] - ] - }, - { - "name": "godot_arvr_get_texid", - "return_type": "godot_int", - "arguments": [ - ["godot_rid *", "p_render_target"] - ] - }, - { - "name": "godot_arvr_add_controller", - "return_type": "godot_int", - "arguments": [ - ["char *", "p_device_name"], - ["godot_int", "p_hand"], - ["godot_bool", "p_tracks_orientation"], - ["godot_bool", "p_tracks_position"] - ] - }, - { - "name": "godot_arvr_remove_controller", - "return_type": "void", - "arguments": [ - ["godot_int", "p_controller_id"] - ] - }, - { - "name": "godot_arvr_set_controller_transform", - "return_type": "void", - "arguments": [ - ["godot_int", "p_controller_id"], - ["godot_transform *", "p_transform"], - ["godot_bool", "p_tracks_orientation"], - ["godot_bool", "p_tracks_position"] - ] - }, - { - "name": "godot_arvr_set_controller_button", - "return_type": "void", - "arguments": [ - ["godot_int", "p_controller_id"], - ["godot_int", "p_button"], - ["godot_bool", "p_is_pressed"] - ] - }, - { - "name": "godot_arvr_set_controller_axis", - "return_type": "void", - "arguments": [ - ["godot_int", "p_controller_id"], - ["godot_int", "p_exis"], - ["godot_real", "p_value"], - ["godot_bool", "p_can_be_negative"] - ] - }, - { - "name": "godot_arvr_get_controller_rumble", - "return_type": "godot_real", - "arguments": [ - ["godot_int", "p_controller_id"] - ] - } - ] - }, { "name": "videodecoder", "type": "VIDEODECODER", @@ -6769,30 +6649,7 @@ "minor": 2 }, "next": null, - "api": [{ - "name": "godot_net_set_webrtc_library", - "return_type": "godot_error", - "arguments": [ - ["const godot_net_webrtc_library *", "p_library"] - ] - }, - { - "name": "godot_net_bind_webrtc_peer_connection", - "return_type": "void", - "arguments": [ - ["godot_object *", "p_obj"], - ["const godot_net_webrtc_peer_connection *", "p_interface"] - ] - }, - { - "name": "godot_net_bind_webrtc_data_channel", - "return_type": "void", - "arguments": [ - ["godot_object *", "p_obj"], - ["const godot_net_webrtc_data_channel *", "p_interface"] - ] - } - ] + "api": [] }, "api": [{ "name": "godot_net_bind_stream_peer", diff --git a/gdnative_library_editor_plugin.cpp b/gdnative_library_editor_plugin.cpp index 77a9c28..9303fe1 100644 --- a/gdnative_library_editor_plugin.cpp +++ b/gdnative_library_editor_plugin.cpp @@ -34,11 +34,17 @@ #include "editor/editor_scale.h" +#include "editor/editor_file_dialog.h" +#include "scene/gui/line_edit.h" +#include "scene/gui/popup_menu.h" +#include "scene/gui/tree.h" +#include "scene/gui/label.h" + void GDNativeLibraryEditor::edit(Ref p_library) { library = p_library; Ref config = p_library->get_config_file(); - for (Map::Element *E = platforms.front(); E; E = E->next()) { + for (RBMap::Element *E = platforms.front(); E; E = E->next()) { for (List::Element *it = E->value().entries.front(); it; it = it->next()) { String target = E->key() + "." + it->get(); TargetConfig ecfg; @@ -71,7 +77,7 @@ void GDNativeLibraryEditor::_update_tree() { if (!filter_list->is_item_checked(i)) { continue; } - Map::Element *E = platforms.find(filter_list->get_item_metadata(i)); + RBMap::Element *E = platforms.find(filter_list->get_item_metadata(i)); if (!text.empty()) { text += ", "; } @@ -81,9 +87,9 @@ void GDNativeLibraryEditor::_update_tree() { platform->set_text(0, E->get().name); platform->set_metadata(0, E->get().library_extension); - platform->set_custom_bg_color(0, get_color("prop_category", "Editor")); - platform->set_custom_bg_color(1, get_color("prop_category", "Editor")); - platform->set_custom_bg_color(2, get_color("prop_category", "Editor")); + platform->set_custom_bg_color(0, get_theme_color("prop_category", "Editor")); + platform->set_custom_bg_color(1, get_theme_color("prop_category", "Editor")); + platform->set_custom_bg_color(2, get_theme_color("prop_category", "Editor")); platform->set_selectable(0, false); platform->set_expand_right(0, true); @@ -94,31 +100,31 @@ void GDNativeLibraryEditor::_update_tree() { bit->set_text(0, it->get()); bit->set_metadata(0, target); bit->set_selectable(0, false); - bit->set_custom_bg_color(0, get_color("prop_subsection", "Editor")); + bit->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor")); - bit->add_button(1, get_icon("Folder", "EditorIcons"), BUTTON_SELECT_LIBRARY, false, TTR("Select the dynamic library for this entry")); + bit->add_button(1, get_theme_icon("Folder", "EditorIcons"), BUTTON_SELECT_LIBRARY, false, TTR("Select the dynamic library for this entry")); String file = entry_configs[target].library; if (!file.empty()) { - bit->add_button(1, get_icon("Clear", "EditorIcons"), BUTTON_CLEAR_LIBRARY, false, TTR("Clear")); + bit->add_button(1, get_theme_icon("Clear", "EditorIcons"), BUTTON_CLEAR_LIBRARY, false, TTR("Clear")); } bit->set_text(1, file); - bit->add_button(2, get_icon("Folder", "EditorIcons"), BUTTON_SELECT_DEPENDENCES, false, TTR("Select dependencies of the library for this entry")); + bit->add_button(2, get_theme_icon("Folder", "EditorIcons"), BUTTON_SELECT_DEPENDENCES, false, TTR("Select dependencies of the library for this entry")); Array files = entry_configs[target].dependencies; if (files.size()) { - bit->add_button(2, get_icon("Clear", "EditorIcons"), BUTTON_CLEAR_DEPENDENCES, false, TTR("Clear")); + bit->add_button(2, get_theme_icon("Clear", "EditorIcons"), BUTTON_CLEAR_DEPENDENCES, false, TTR("Clear")); } bit->set_text(2, Variant(files)); - bit->add_button(3, get_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP, false, TTR("Move Up")); - bit->add_button(3, get_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN, false, TTR("Move Down")); - bit->add_button(3, get_icon("Remove", "EditorIcons"), BUTTON_ERASE_ENTRY, false, TTR("Remove current entry")); + bit->add_button(3, get_theme_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP, false, TTR("Move Up")); + bit->add_button(3, get_theme_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN, false, TTR("Move Down")); + bit->add_button(3, get_theme_icon("Remove", "EditorIcons"), BUTTON_ERASE_ENTRY, false, TTR("Remove current entry")); } TreeItem *new_arch = tree->create_item(platform); new_arch->set_text(0, TTR("Double click to create a new entry")); new_arch->set_text_align(0, TreeItem::ALIGN_CENTER); - new_arch->set_custom_color(0, get_color("accent_color", "Editor")); + new_arch->set_custom_color(0, get_theme_color("accent_color", "Editor")); new_arch->set_expand_right(0, true); new_arch->set_metadata(1, E->key()); @@ -187,7 +193,7 @@ void GDNativeLibraryEditor::_on_item_collapsed(Object *p_item) { if (item->is_collapsed()) { collapsed_items.insert(name); - } else if (Set::Element *e = collapsed_items.find(name)) { + } else if (RBSet::Element *e = collapsed_items.find(name)) { collapsed_items.erase(e); } } @@ -253,7 +259,7 @@ void GDNativeLibraryEditor::_translate_to_config_file() { config->erase_section("entry"); config->erase_section("dependencies"); - for (Map::Element *E = platforms.front(); E; E = E->next()) { + for (RBMap::Element *E = platforms.front(); E; E = E->next()) { for (List::Element *it = E->value().entries.front(); it; it = it->next()) { String target = E->key() + "." + it->get(); if (entry_configs[target].library.empty() && entry_configs[target].dependencies.empty()) { @@ -349,7 +355,7 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() { filter_list->set_hide_on_checkable_item_selection(false); int idx = 0; - for (Map::Element *E = platforms.front(); E; E = E->next()) { + for (RBMap::Element *E = platforms.front(); E; E = E->next()) { filter_list->add_check_item(E->get().name, idx); filter_list->set_item_metadata(idx, E->key()); filter_list->set_item_checked(idx, true); diff --git a/gdnative_library_editor_plugin.h b/gdnative_library_editor_plugin.h index e6e3116..6f10f84 100644 --- a/gdnative_library_editor_plugin.h +++ b/gdnative_library_editor_plugin.h @@ -64,12 +64,12 @@ class GDNativeLibraryEditor : public Control { EditorFileDialog *file_dialog; ConfirmationDialog *new_architecture_dialog; LineEdit *new_architecture_input; - Set collapsed_items; + RBSet collapsed_items; String showing_platform; Ref library; - Map platforms; - Map entry_configs; + RBMap platforms; + RBMap entry_configs; protected: static void _bind_methods(); diff --git a/gdnative_library_singleton_editor.cpp b/gdnative_library_singleton_editor.cpp index 8b257a7..b6df52c 100644 --- a/gdnative_library_singleton_editor.cpp +++ b/gdnative_library_singleton_editor.cpp @@ -34,8 +34,11 @@ #include "editor/editor_node.h" -Set GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFileSystemDirectory *p_dir) { - Set file_paths; +#include "core/config/project_settings.h" +#include "scene/gui/tree.h" + +RBSet GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFileSystemDirectory *p_dir) { + RBSet file_paths; // check children @@ -55,9 +58,9 @@ Set GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFil // check subdirectories for (int i = 0; i < p_dir->get_subdir_count(); i++) { - Set paths = _find_singletons_recursive(p_dir->get_subdir(i)); + RBSet paths = _find_singletons_recursive(p_dir->get_subdir(i)); - for (Set::Element *E = paths.front(); E; E = E->next()) { + for (RBSet::Element *E = paths.front(); E; E = E->next()) { file_paths.insert(E->get()); } } @@ -68,7 +71,7 @@ Set GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFil void GDNativeLibrarySingletonEditor::_discover_singletons() { EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->get_filesystem(); - Set file_paths = _find_singletons_recursive(dir); + RBSet file_paths = _find_singletons_recursive(dir); bool changed = false; Array current_files; @@ -76,7 +79,7 @@ void GDNativeLibrarySingletonEditor::_discover_singletons() { current_files = ProjectSettings::get_singleton()->get("gdnative/singletons"); } Array files; - for (Set::Element *E = file_paths.front(); E; E = E->next()) { + for (RBSet::Element *E = file_paths.front(); E; E = E->next()) { if (!current_files.has(E->get())) { changed = true; } diff --git a/gdnative_library_singleton_editor.h b/gdnative_library_singleton_editor.h index 1402f9e..7026aff 100644 --- a/gdnative_library_singleton_editor.h +++ b/gdnative_library_singleton_editor.h @@ -35,6 +35,8 @@ #include "editor/editor_file_system.h" #include "editor/project_settings_editor.h" +#include "scene/gui/box_container.h" + class GDNativeLibrarySingletonEditor : public VBoxContainer { GDCLASS(GDNativeLibrarySingletonEditor, VBoxContainer); @@ -44,7 +46,7 @@ private: bool updating; - static Set _find_singletons_recursive(EditorFileSystemDirectory *p_dir); + static RBSet _find_singletons_recursive(EditorFileSystemDirectory *p_dir); protected: void _notification(int p_what); diff --git a/include/gdnative/string.h b/include/gdnative/string.h index 2d96d17..db74b97 100644 --- a/include/gdnative/string.h +++ b/include/gdnative/string.h @@ -36,9 +36,10 @@ extern "C" { #endif #include -#include +//#include +#include -typedef wchar_t godot_char_type; +typedef char32_t godot_char_type; #define GODOT_STRING_SIZE sizeof(void *) #define GODOT_CHAR_STRING_SIZE sizeof(void *) @@ -79,9 +80,9 @@ 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_with_wide_string(godot_string *r_dest, const wchar_t *p_contents, const int p_size); -const 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_wide_str(const godot_string *p_self); +const char32_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx); +char32_t GDAPI godot_string_operator_index_const(const godot_string *p_self, const godot_int p_idx); +const char32_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); diff --git a/nativescript/api_generator.cpp b/nativescript/api_generator.cpp index df6f814..24126af 100644 --- a/nativescript/api_generator.cpp +++ b/nativescript/api_generator.cpp @@ -36,7 +36,7 @@ #include "core/config/engine.h" #include "core/global_constants.h" #include "core/os/file_access.h" -#include "core/pair.h" +#include "core/containers/pair.h" // helper stuff @@ -63,7 +63,7 @@ struct MethodAPI { List argument_types; List argument_names; - Map default_arguments; + RBMap default_arguments; int argument_count; bool has_varargs; @@ -92,7 +92,7 @@ struct SignalAPI { String name; List argument_types; List argument_names; - Map default_arguments; + RBMap default_arguments; }; struct EnumAPI { diff --git a/nativescript/godot_nativescript.cpp b/nativescript/godot_nativescript.cpp index a999457..7bc4cd2 100644 --- a/nativescript/godot_nativescript.cpp +++ b/nativescript/godot_nativescript.cpp @@ -53,7 +53,7 @@ extern "C" void _native_script_hook() { void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) { String *s = (String *)p_gdnative_handle; - Map *classes = &NSL->library_classes[*s]; + RBMap *classes = &NSL->library_classes[*s]; NativeScriptDesc desc; @@ -77,7 +77,7 @@ void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) { String *s = (String *)p_gdnative_handle; - Map *classes = &NSL->library_classes[*s]; + RBMap *classes = &NSL->library_classes[*s]; NativeScriptDesc desc; @@ -100,7 +100,7 @@ void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method) { String *s = (String *)p_gdnative_handle; - Map::Element *E = NSL->library_classes[*s].find(p_name); + RBMap::Element *E = NSL->library_classes[*s].find(p_name); ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class."); NativeScriptDesc::Method method; @@ -114,7 +114,7 @@ void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const cha void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_property_attributes *p_attr, godot_property_set_func p_set_func, godot_property_get_func p_get_func) { String *s = (String *)p_gdnative_handle; - Map::Element *E = NSL->library_classes[*s].find(p_name); + RBMap::Element *E = NSL->library_classes[*s].find(p_name); ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class."); NativeScriptDesc::Property property; @@ -134,7 +134,7 @@ void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const c void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_signal *p_signal) { String *s = (String *)p_gdnative_handle; - Map::Element *E = NSL->library_classes[*s].find(p_name); + RBMap::Element *E = NSL->library_classes[*s].find(p_name); ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class."); List args; @@ -196,10 +196,10 @@ void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance) { 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::Element *E = NSL->library_classes[*s].find(p_name); + RBMap::Element *E = NSL->library_classes[*s].find(p_name); ERR_FAIL_COND_MSG(!E, "Attempted to add argument information for a method on a non-existent class."); - Map::Element *method = E->get().methods.find(p_function_name); + RBMap::Element *method = E->get().methods.find(p_function_name); ERR_FAIL_COND_MSG(!method, "Attempted to add argument information to non-existent method."); MethodInfo *method_information = &method->get().info; @@ -223,7 +223,7 @@ void GDAPI godot_nativescript_set_method_argument_information(void *p_gdnative_h 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::Element *E = NSL->library_classes[*s].find(p_name); + RBMap::Element *E = NSL->library_classes[*s].find(p_name); ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a non-existent class."); E->get().documentation = *(String *)&p_documentation; @@ -232,10 +232,10 @@ void GDAPI godot_nativescript_set_class_documentation(void *p_gdnative_handle, c 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::Element *E = NSL->library_classes[*s].find(p_name); + RBMap::Element *E = NSL->library_classes[*s].find(p_name); ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a method on a non-existent class."); - Map::Element *method = E->get().methods.find(p_function_name); + RBMap::Element *method = E->get().methods.find(p_function_name); ERR_FAIL_COND_MSG(!method, "Attempted to add documentation to non-existent method."); method->get().documentation = *(String *)&p_documentation; @@ -244,7 +244,7 @@ void GDAPI godot_nativescript_set_method_documentation(void *p_gdnative_handle, 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::Element *E = NSL->library_classes[*s].find(p_name); + RBMap::Element *E = NSL->library_classes[*s].find(p_name); ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a property on a non-existent class."); OrderedHashMap::Element property = E->get().properties.find(p_path); @@ -256,10 +256,10 @@ void GDAPI godot_nativescript_set_property_documentation(void *p_gdnative_handle 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::Element *E = NSL->library_classes[*s].find(p_name); + RBMap::Element *E = NSL->library_classes[*s].find(p_name); ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a signal on a non-existent class."); - Map::Element *signal = E->get().signals_.find(p_signal_name); + RBMap::Element *signal = E->get().signals_.find(p_signal_name); ERR_FAIL_COND_MSG(!signal, "Attempted to add documentation to non-existent signal."); signal->get().documentation = *(String *)&p_documentation; @@ -276,7 +276,7 @@ const void GDAPI *godot_nativescript_get_global_type_tag(int p_idx, const char * 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::Element *E = NSL->library_classes[*s].find(p_name); + RBMap::Element *E = NSL->library_classes[*s].find(p_name); ERR_FAIL_COND_MSG(!E, "Attempted to set type tag on a non-existent class."); E->get().type_tag = p_type_tag; diff --git a/nativescript/nativescript.cpp b/nativescript/nativescript.cpp index 0800b52..e63b5e5 100644 --- a/nativescript/nativescript.cpp +++ b/nativescript/nativescript.cpp @@ -32,12 +32,12 @@ #include "gdnative/gdnative.h" +#include "core/config/project_settings.h" #include "core/core_string_names.h" #include "core/global_constants.h" #include "core/io/file_access_encrypted.h" #include "core/os/file_access.h" #include "core/os/os.h" -#include "core/config/project_settings.h" #include "main/main.h" @@ -95,7 +95,7 @@ void NativeScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) List info; get_script_property_list(&info); - Map values; + RBMap values; for (List::Element *E = info.front(); E; E = E->next()) { Variant value; get_property_default_value(E->get().name, value); @@ -305,7 +305,7 @@ MethodInfo NativeScript::get_method_info(const StringName &p_method) const { } while (script_data) { - Map::Element *M = script_data->methods.find(p_method); + RBMap::Element *M = script_data->methods.find(p_method); if (M) { return M->get().info; @@ -353,17 +353,17 @@ void NativeScript::get_script_signal_list(List *r_signals) const { return; } - Set signals_; + RBSet signals_; while (script_data) { - for (Map::Element *S = script_data->signals_.front(); S; S = S->next()) { + for (RBMap::Element *S = script_data->signals_.front(); S; S = S->next()) { signals_.insert(S->get().signal); } script_data = script_data->base_data; } - for (Set::Element *E = signals_.front(); E; E = E->next()) { + for (RBSet::Element *E = signals_.front(); E; E = E->next()) { r_signals->push_back(E->get()); } } @@ -394,17 +394,17 @@ void NativeScript::get_script_method_list(List *p_list) const { return; } - Set methods; + RBSet methods; while (script_data) { - for (Map::Element *E = script_data->methods.front(); E; E = E->next()) { + for (RBMap::Element *E = script_data->methods.front(); E; E = E->next()) { methods.insert(E->get().info); } script_data = script_data->base_data; } - for (Set::Element *E = methods.front(); E; E = E->next()) { + for (RBSet::Element *E = methods.front(); E; E = E->next()) { p_list->push_back(E->get()); } } @@ -412,7 +412,7 @@ void NativeScript::get_script_method_list(List *p_list) const { void NativeScript::get_script_property_list(List *p_list) const { NativeScriptDesc *script_data = get_script_desc(); - Set existing_properties; + RBSet existing_properties; List::Element *original_back = p_list->back(); while (script_data) { List::Element *insert_position = original_back; @@ -441,7 +441,7 @@ String NativeScript::get_method_documentation(const StringName &p_method) const ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get method documentation on invalid NativeScript."); while (script_data) { - Map::Element *method = script_data->methods.find(p_method); + RBMap::Element *method = script_data->methods.find(p_method); if (method) { return method->get().documentation; @@ -459,7 +459,7 @@ String NativeScript::get_signal_documentation(const StringName &p_signal_name) c ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get signal documentation on invalid NativeScript."); while (script_data) { - Map::Element *signal = script_data->signals_.find(p_signal_name); + RBMap::Element *signal = script_data->signals_.find(p_signal_name); if (signal) { return signal->get().documentation; @@ -558,7 +558,7 @@ void NativeScriptInstance::_ml_call_reversed(NativeScriptDesc *script_data, cons _ml_call_reversed(script_data->base_data, p_method, p_args, p_argcount); } - Map::Element *E = script_data->methods.find(p_method); + RBMap::Element *E = script_data->methods.find(p_method); if (E) { godot_variant res = E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, p_argcount, (godot_variant **)p_args); godot_variant_destroy(&res); @@ -578,7 +578,7 @@ bool NativeScriptInstance::set(const StringName &p_name, const Variant &p_value) return true; } - Map::Element *E = script_data->methods.find("_set"); + RBMap::Element *E = script_data->methods.find("_set"); if (E) { Variant name = p_name; const Variant *args[2] = { &name, &p_value }; @@ -615,7 +615,7 @@ bool NativeScriptInstance::get(const StringName &p_name, Variant &r_ret) const { return true; } - Map::Element *E = script_data->methods.find("_get"); + RBMap::Element *E = script_data->methods.find("_get"); if (E) { Variant name = p_name; const Variant *args[1] = { &name }; @@ -644,7 +644,7 @@ void NativeScriptInstance::get_property_list(List *p_properties) c NativeScriptDesc *script_data = GET_SCRIPT_DESC(); while (script_data) { - Map::Element *E = script_data->methods.find("_get_property_list"); + RBMap::Element *E = script_data->methods.find("_get_property_list"); if (E) { godot_variant result; result = E->get().method.method((godot_object *)owner, @@ -720,7 +720,7 @@ Variant NativeScriptInstance::call(const StringName &p_method, const Variant **p NativeScriptDesc *script_data = GET_SCRIPT_DESC(); while (script_data) { - Map::Element *E = script_data->methods.find(p_method); + RBMap::Element *E = script_data->methods.find(p_method); if (E) { godot_variant result; @@ -819,7 +819,7 @@ MultiplayerAPI::RPCMode NativeScriptInstance::get_rpc_mode(const StringName &p_m NativeScriptDesc *script_data = GET_SCRIPT_DESC(); while (script_data) { - Map::Element *E = script_data->methods.find(p_method); + RBMap::Element *E = script_data->methods.find(p_method); if (E) { switch (E->get().rpc_mode) { case GODOT_METHOD_RPC_MODE_DISABLED: @@ -887,7 +887,7 @@ void NativeScriptInstance::call_multilevel(const StringName &p_method, const Var NativeScriptDesc *script_data = GET_SCRIPT_DESC(); while (script_data) { - Map::Element *E = script_data->methods.find(p_method); + RBMap::Element *E = script_data->methods.find(p_method); if (E) { godot_variant res = E->get().method.method((godot_object *)owner, E->get().method.method_data, @@ -927,14 +927,14 @@ NativeScriptInstance::~NativeScriptInstance() { NativeScriptLanguage *NativeScriptLanguage::singleton; void NativeScriptLanguage::_unload_stuff(bool p_reload) { - Map> erase_and_unload; + RBMap> erase_and_unload; - for (Map>::Element *L = library_classes.front(); L; L = L->next()) { + for (RBMap>::Element *L = library_classes.front(); L; L = L->next()) { String lib_path = L->key(); - Map classes = L->get(); + RBMap classes = L->get(); if (p_reload) { - Map>::Element *E = library_gdnatives.find(lib_path); + RBMap>::Element *E = library_gdnatives.find(lib_path); Ref gdn; if (E) { @@ -955,14 +955,14 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) { } } - Map>::Element *E = library_gdnatives.find(lib_path); + RBMap>::Element *E = library_gdnatives.find(lib_path); Ref gdn; if (E) { gdn = E->get(); } - for (Map::Element *C = classes.front(); C; C = C->next()) { + for (RBMap::Element *C = classes.front(); C; C = C->next()) { // free property stuff first for (OrderedHashMap::Element P = C->get().properties.front(); P; P = P.next()) { if (P.get().getter.free_func) { @@ -975,7 +975,7 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) { } // free method stuff - for (Map::Element *M = C->get().methods.front(); M; M = M->next()) { + for (RBMap::Element *M = C->get().methods.front(); M; M = M->next()) { if (M->get().method.free_func) { M->get().method.free_func(M->get().method.method_data); } @@ -994,7 +994,7 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) { erase_and_unload.insert(lib_path, gdn); } - for (Map>::Element *E = erase_and_unload.front(); E; E = E->next()) { + for (RBMap>::Element *E = erase_and_unload.front(); E; E = E->next()) { String lib_path = E->key(); Ref gdn = E->get(); @@ -1029,7 +1029,7 @@ NativeScriptLanguage::NativeScriptLanguage() { } NativeScriptLanguage::~NativeScriptLanguage() { - for (Map>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { + for (RBMap>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { Ref lib = L->get(); // only shut down valid libs, duh! if (lib.is_valid()) { @@ -1104,7 +1104,7 @@ Ref