More cleanups.

This commit is contained in:
Relintai 2023-05-25 21:29:02 +02:00
parent 92bbcd20c2
commit 6f9dd799d0
28 changed files with 188 additions and 316 deletions

View File

@ -49,7 +49,7 @@ static const bool default_reloadable = true;
// Defined in gdnative_api_struct.gen.cpp // Defined in gdnative_api_struct.gen.cpp
extern const godot_gdnative_core_api_struct api_struct; extern const godot_gdnative_core_api_struct api_struct;
Map<String, Vector<Ref<GDNative>>> GDNativeLibrary::loaded_libraries; RBMap<String, Vector<Ref<GDNative>>> GDNativeLibrary::loaded_libraries;
GDNativeLibrary::GDNativeLibrary() { GDNativeLibrary::GDNativeLibrary() {
config_file.instance(); config_file.instance();
@ -473,7 +473,7 @@ Vector<StringName> GDNativeCallRegistry::get_native_call_types() {
call_types.resize(native_calls.size()); call_types.resize(native_calls.size());
size_t idx = 0; size_t idx = 0;
for (Map<StringName, native_call_cb>::Element *E = native_calls.front(); E; E = E->next(), idx++) { for (RBMap<StringName, native_call_cb>::Element *E = native_calls.front(); E; E = E->next(), idx++) {
call_types.write[idx] = E->key(); call_types.write[idx] = E->key();
} }
@ -481,7 +481,7 @@ Vector<StringName> GDNativeCallRegistry::get_native_call_types() {
} }
Variant GDNative::call_native(StringName p_native_call_type, StringName p_procedure_name, Array p_arguments) { Variant GDNative::call_native(StringName p_native_call_type, StringName p_procedure_name, Array p_arguments) {
Map<StringName, native_call_cb>::Element *E = GDNativeCallRegistry::singleton->native_calls.find(p_native_call_type); RBMap<StringName, native_call_cb>::Element *E = GDNativeCallRegistry::singleton->native_calls.find(p_native_call_type);
if (!E) { if (!E) {
ERR_PRINT((String("No handler for native call type \"" + p_native_call_type) + "\" found").utf8().get_data()); ERR_PRINT((String("No handler for native call type \"" + p_native_call_type) + "\" found").utf8().get_data());
return Variant(); return Variant();

View File

@ -36,8 +36,8 @@
#include "core/os/thread_safe.h" #include "core/os/thread_safe.h"
#include "core/object/resource.h" #include "core/object/resource.h"
#include "gdnative/gdnative.h" #include "include/gdnative/gdnative.h"
#include "gdnative_api_struct.gen.h" #include "include/gdnative_api_struct.gen.h"
#include "core/io/config_file.h" #include "core/io/config_file.h"
@ -47,7 +47,7 @@ class GDNative;
class GDNativeLibrary : public Resource { class GDNativeLibrary : public Resource {
GDCLASS(GDNativeLibrary, Resource); GDCLASS(GDNativeLibrary, Resource);
static Map<String, Vector<Ref<GDNative>>> loaded_libraries; static RBMap<String, Vector<Ref<GDNative>>> loaded_libraries;
friend class GDNativeLibraryResourceLoader; friend class GDNativeLibraryResourceLoader;
friend class GDNative; friend class GDNative;
@ -129,7 +129,7 @@ struct GDNativeCallRegistry {
inline GDNativeCallRegistry() : inline GDNativeCallRegistry() :
native_calls() {} native_calls() {}
Map<StringName, native_call_cb> native_calls; RBMap<StringName, native_call_cb> native_calls;
void register_native_call_type(StringName p_call_type, native_call_cb p_callback); void register_native_call_type(StringName p_call_type, native_call_cb p_callback);

View File

@ -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) { godot_real GDAPI godot_aabb_get_area(const godot_aabb *p_self) {
const AABB *self = (const 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) { godot_bool GDAPI godot_aabb_has_no_area(const godot_aabb *p_self) {
const AABB *self = (const 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) { godot_bool GDAPI godot_aabb_has_no_surface(const godot_aabb *p_self) {

View File

@ -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) { void GDAPI godot_basis_get_elements(const godot_basis *p_self, godot_vector3 *p_elements) {
const Basis *self = (const Basis *)p_self; const Basis *self = (const Basis *)p_self;
Vector3 *elements = (Vector3 *)p_elements; Vector3 *elements = (Vector3 *)p_elements;
elements[0] = self->elements[0]; elements[0] = self->rows[0];
elements[1] = self->elements[1]; elements[1] = self->rows[1];
elements[2] = self->elements[2]; elements[2] = self->rows[2];
} }
godot_vector3 GDAPI godot_basis_get_axis(const godot_basis *p_self, const godot_int p_axis) { godot_vector3 GDAPI godot_basis_get_axis(const godot_basis *p_self, const godot_int p_axis) {

View File

@ -37,7 +37,7 @@
#include "core/os/os.h" #include "core/os/os.h"
#include "core/variant/variant.h" #include "core/variant/variant.h"
#include "../gdnative/gdnative.h" #include "../gdnative.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -31,7 +31,7 @@
#include "gdnative/rid.h" #include "gdnative/rid.h"
#include "core/object/resource.h" #include "core/object/resource.h"
#include "core/object/rid.h" #include "core/containers/rid.h"
#include "core/variant/variant.h" #include "core/variant/variant.h"
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -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)); 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; String *self = (String *)p_self;
return &(self->operator[](p_idx)); 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; const String *self = (const String *)p_self;
return self->operator[](p_idx); 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; 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) { godot_bool GDAPI godot_string_operator_equal(const godot_string *p_self, const godot_string *p_b) {

View File

@ -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) { godot_real GDAPI godot_transform2d_determinant(const godot_transform2d *p_self) {
const Transform2D *self = (const 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) { godot_transform2d GDAPI godot_transform2d_orthonormalized(const godot_transform2d *p_self) {

View File

@ -30,7 +30,7 @@
#include "gdnative/variant.h" #include "gdnative/variant.h"
#include "core/reference.h" #include "core/object/reference.h"
#include "core/variant/variant.h" #include "core/variant/variant.h"
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -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", "name": "videodecoder",
"type": "VIDEODECODER", "type": "VIDEODECODER",
@ -6769,30 +6649,7 @@
"minor": 2 "minor": 2
}, },
"next": null, "next": null,
"api": [{ "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", "name": "godot_net_bind_stream_peer",

View File

@ -34,11 +34,17 @@
#include "editor/editor_scale.h" #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<GDNativeLibrary> p_library) { void GDNativeLibraryEditor::edit(Ref<GDNativeLibrary> p_library) {
library = p_library; library = p_library;
Ref<ConfigFile> config = p_library->get_config_file(); Ref<ConfigFile> config = p_library->get_config_file();
for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) { for (RBMap<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) {
for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) { for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) {
String target = E->key() + "." + it->get(); String target = E->key() + "." + it->get();
TargetConfig ecfg; TargetConfig ecfg;
@ -71,7 +77,7 @@ void GDNativeLibraryEditor::_update_tree() {
if (!filter_list->is_item_checked(i)) { if (!filter_list->is_item_checked(i)) {
continue; continue;
} }
Map<String, NativePlatformConfig>::Element *E = platforms.find(filter_list->get_item_metadata(i)); RBMap<String, NativePlatformConfig>::Element *E = platforms.find(filter_list->get_item_metadata(i));
if (!text.empty()) { if (!text.empty()) {
text += ", "; text += ", ";
} }
@ -81,9 +87,9 @@ void GDNativeLibraryEditor::_update_tree() {
platform->set_text(0, E->get().name); platform->set_text(0, E->get().name);
platform->set_metadata(0, E->get().library_extension); platform->set_metadata(0, E->get().library_extension);
platform->set_custom_bg_color(0, get_color("prop_category", "Editor")); platform->set_custom_bg_color(0, get_theme_color("prop_category", "Editor"));
platform->set_custom_bg_color(1, get_color("prop_category", "Editor")); platform->set_custom_bg_color(1, get_theme_color("prop_category", "Editor"));
platform->set_custom_bg_color(2, get_color("prop_category", "Editor")); platform->set_custom_bg_color(2, get_theme_color("prop_category", "Editor"));
platform->set_selectable(0, false); platform->set_selectable(0, false);
platform->set_expand_right(0, true); platform->set_expand_right(0, true);
@ -94,31 +100,31 @@ void GDNativeLibraryEditor::_update_tree() {
bit->set_text(0, it->get()); bit->set_text(0, it->get());
bit->set_metadata(0, target); bit->set_metadata(0, target);
bit->set_selectable(0, false); 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; String file = entry_configs[target].library;
if (!file.empty()) { 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->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; Array files = entry_configs[target].dependencies;
if (files.size()) { 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->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_theme_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_theme_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("Remove", "EditorIcons"), BUTTON_ERASE_ENTRY, false, TTR("Remove current entry"));
} }
TreeItem *new_arch = tree->create_item(platform); TreeItem *new_arch = tree->create_item(platform);
new_arch->set_text(0, TTR("Double click to create a new entry")); 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_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_expand_right(0, true);
new_arch->set_metadata(1, E->key()); new_arch->set_metadata(1, E->key());
@ -187,7 +193,7 @@ void GDNativeLibraryEditor::_on_item_collapsed(Object *p_item) {
if (item->is_collapsed()) { if (item->is_collapsed()) {
collapsed_items.insert(name); collapsed_items.insert(name);
} else if (Set<String>::Element *e = collapsed_items.find(name)) { } else if (RBSet<String>::Element *e = collapsed_items.find(name)) {
collapsed_items.erase(e); collapsed_items.erase(e);
} }
} }
@ -253,7 +259,7 @@ void GDNativeLibraryEditor::_translate_to_config_file() {
config->erase_section("entry"); config->erase_section("entry");
config->erase_section("dependencies"); config->erase_section("dependencies");
for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) { for (RBMap<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) {
for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) { for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) {
String target = E->key() + "." + it->get(); String target = E->key() + "." + it->get();
if (entry_configs[target].library.empty() && entry_configs[target].dependencies.empty()) { 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); filter_list->set_hide_on_checkable_item_selection(false);
int idx = 0; int idx = 0;
for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) { for (RBMap<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) {
filter_list->add_check_item(E->get().name, idx); filter_list->add_check_item(E->get().name, idx);
filter_list->set_item_metadata(idx, E->key()); filter_list->set_item_metadata(idx, E->key());
filter_list->set_item_checked(idx, true); filter_list->set_item_checked(idx, true);

View File

@ -64,12 +64,12 @@ class GDNativeLibraryEditor : public Control {
EditorFileDialog *file_dialog; EditorFileDialog *file_dialog;
ConfirmationDialog *new_architecture_dialog; ConfirmationDialog *new_architecture_dialog;
LineEdit *new_architecture_input; LineEdit *new_architecture_input;
Set<String> collapsed_items; RBSet<String> collapsed_items;
String showing_platform; String showing_platform;
Ref<GDNativeLibrary> library; Ref<GDNativeLibrary> library;
Map<String, NativePlatformConfig> platforms; RBMap<String, NativePlatformConfig> platforms;
Map<String, TargetConfig> entry_configs; RBMap<String, TargetConfig> entry_configs;
protected: protected:
static void _bind_methods(); static void _bind_methods();

View File

@ -34,8 +34,11 @@
#include "editor/editor_node.h" #include "editor/editor_node.h"
Set<String> GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFileSystemDirectory *p_dir) { #include "core/config/project_settings.h"
Set<String> file_paths; #include "scene/gui/tree.h"
RBSet<String> GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFileSystemDirectory *p_dir) {
RBSet<String> file_paths;
// check children // check children
@ -55,9 +58,9 @@ Set<String> GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFil
// check subdirectories // check subdirectories
for (int i = 0; i < p_dir->get_subdir_count(); i++) { for (int i = 0; i < p_dir->get_subdir_count(); i++) {
Set<String> paths = _find_singletons_recursive(p_dir->get_subdir(i)); RBSet<String> paths = _find_singletons_recursive(p_dir->get_subdir(i));
for (Set<String>::Element *E = paths.front(); E; E = E->next()) { for (RBSet<String>::Element *E = paths.front(); E; E = E->next()) {
file_paths.insert(E->get()); file_paths.insert(E->get());
} }
} }
@ -68,7 +71,7 @@ Set<String> GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFil
void GDNativeLibrarySingletonEditor::_discover_singletons() { void GDNativeLibrarySingletonEditor::_discover_singletons() {
EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->get_filesystem(); EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->get_filesystem();
Set<String> file_paths = _find_singletons_recursive(dir); RBSet<String> file_paths = _find_singletons_recursive(dir);
bool changed = false; bool changed = false;
Array current_files; Array current_files;
@ -76,7 +79,7 @@ void GDNativeLibrarySingletonEditor::_discover_singletons() {
current_files = ProjectSettings::get_singleton()->get("gdnative/singletons"); current_files = ProjectSettings::get_singleton()->get("gdnative/singletons");
} }
Array files; Array files;
for (Set<String>::Element *E = file_paths.front(); E; E = E->next()) { for (RBSet<String>::Element *E = file_paths.front(); E; E = E->next()) {
if (!current_files.has(E->get())) { if (!current_files.has(E->get())) {
changed = true; changed = true;
} }

View File

@ -35,6 +35,8 @@
#include "editor/editor_file_system.h" #include "editor/editor_file_system.h"
#include "editor/project_settings_editor.h" #include "editor/project_settings_editor.h"
#include "scene/gui/box_container.h"
class GDNativeLibrarySingletonEditor : public VBoxContainer { class GDNativeLibrarySingletonEditor : public VBoxContainer {
GDCLASS(GDNativeLibrarySingletonEditor, VBoxContainer); GDCLASS(GDNativeLibrarySingletonEditor, VBoxContainer);
@ -44,7 +46,7 @@ private:
bool updating; bool updating;
static Set<String> _find_singletons_recursive(EditorFileSystemDirectory *p_dir); static RBSet<String> _find_singletons_recursive(EditorFileSystemDirectory *p_dir);
protected: protected:
void _notification(int p_what); void _notification(int p_what);

View File

@ -36,9 +36,10 @@ extern "C" {
#endif #endif
#include <stdint.h> #include <stdint.h>
#include <wchar.h> //#include <wchar.h>
#include <uchar.h>
typedef wchar_t godot_char_type; typedef char32_t godot_char_type;
#define GODOT_STRING_SIZE sizeof(void *) #define GODOT_STRING_SIZE sizeof(void *)
#define GODOT_CHAR_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_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); 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); const char32_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); char32_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_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_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); godot_bool GDAPI godot_string_operator_less(const godot_string *p_self, const godot_string *p_b);

View File

@ -36,7 +36,7 @@
#include "core/config/engine.h" #include "core/config/engine.h"
#include "core/global_constants.h" #include "core/global_constants.h"
#include "core/os/file_access.h" #include "core/os/file_access.h"
#include "core/pair.h" #include "core/containers/pair.h"
// helper stuff // helper stuff
@ -63,7 +63,7 @@ struct MethodAPI {
List<String> argument_types; List<String> argument_types;
List<String> argument_names; List<String> argument_names;
Map<int, Variant> default_arguments; RBMap<int, Variant> default_arguments;
int argument_count; int argument_count;
bool has_varargs; bool has_varargs;
@ -92,7 +92,7 @@ struct SignalAPI {
String name; String name;
List<String> argument_types; List<String> argument_types;
List<String> argument_names; List<String> argument_names;
Map<int, Variant> default_arguments; RBMap<int, Variant> default_arguments;
}; };
struct EnumAPI { struct EnumAPI {

View File

@ -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) { 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; String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc> *classes = &NSL->library_classes[*s]; RBMap<StringName, NativeScriptDesc> *classes = &NSL->library_classes[*s];
NativeScriptDesc desc; 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) { 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; String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc> *classes = &NSL->library_classes[*s]; RBMap<StringName, NativeScriptDesc> *classes = &NSL->library_classes[*s];
NativeScriptDesc desc; 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) { 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; String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); RBMap<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class."); ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class.");
NativeScriptDesc::Method method; 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) { 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; String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); RBMap<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class."); ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class.");
NativeScriptDesc::Property property; 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) { 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; String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); RBMap<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class."); ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class.");
List<PropertyInfo> args; List<PropertyInfo> 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) { 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; String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); RBMap<StringName, NativeScriptDesc>::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."); ERR_FAIL_COND_MSG(!E, "Attempted to add argument information for a method on a non-existent class.");
Map<StringName, NativeScriptDesc::Method>::Element *method = E->get().methods.find(p_function_name); RBMap<StringName, NativeScriptDesc::Method>::Element *method = E->get().methods.find(p_function_name);
ERR_FAIL_COND_MSG(!method, "Attempted to add argument information to non-existent method."); ERR_FAIL_COND_MSG(!method, "Attempted to add argument information to non-existent method.");
MethodInfo *method_information = &method->get().info; 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) { 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; String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); RBMap<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a non-existent class."); ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a non-existent class.");
E->get().documentation = *(String *)&p_documentation; 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) { 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; String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); RBMap<StringName, NativeScriptDesc>::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."); ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a method on a non-existent class.");
Map<StringName, NativeScriptDesc::Method>::Element *method = E->get().methods.find(p_function_name); RBMap<StringName, NativeScriptDesc::Method>::Element *method = E->get().methods.find(p_function_name);
ERR_FAIL_COND_MSG(!method, "Attempted to add documentation to non-existent method."); ERR_FAIL_COND_MSG(!method, "Attempted to add documentation to non-existent method.");
method->get().documentation = *(String *)&p_documentation; 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) { 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; String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); RBMap<StringName, NativeScriptDesc>::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."); ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a property on a non-existent class.");
OrderedHashMap<StringName, NativeScriptDesc::Property>::Element property = E->get().properties.find(p_path); OrderedHashMap<StringName, NativeScriptDesc::Property>::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) { 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; String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); RBMap<StringName, NativeScriptDesc>::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."); ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a signal on a non-existent class.");
Map<StringName, NativeScriptDesc::Signal>::Element *signal = E->get().signals_.find(p_signal_name); RBMap<StringName, NativeScriptDesc::Signal>::Element *signal = E->get().signals_.find(p_signal_name);
ERR_FAIL_COND_MSG(!signal, "Attempted to add documentation to non-existent signal."); ERR_FAIL_COND_MSG(!signal, "Attempted to add documentation to non-existent signal.");
signal->get().documentation = *(String *)&p_documentation; 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) { 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; String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name); RBMap<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
ERR_FAIL_COND_MSG(!E, "Attempted to set type tag on a non-existent class."); ERR_FAIL_COND_MSG(!E, "Attempted to set type tag on a non-existent class.");
E->get().type_tag = p_type_tag; E->get().type_tag = p_type_tag;

View File

@ -32,12 +32,12 @@
#include "gdnative/gdnative.h" #include "gdnative/gdnative.h"
#include "core/config/project_settings.h"
#include "core/core_string_names.h" #include "core/core_string_names.h"
#include "core/global_constants.h" #include "core/global_constants.h"
#include "core/io/file_access_encrypted.h" #include "core/io/file_access_encrypted.h"
#include "core/os/file_access.h" #include "core/os/file_access.h"
#include "core/os/os.h" #include "core/os/os.h"
#include "core/config/project_settings.h"
#include "main/main.h" #include "main/main.h"
@ -95,7 +95,7 @@ void NativeScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder)
List<PropertyInfo> info; List<PropertyInfo> info;
get_script_property_list(&info); get_script_property_list(&info);
Map<StringName, Variant> values; RBMap<StringName, Variant> values;
for (List<PropertyInfo>::Element *E = info.front(); E; E = E->next()) { for (List<PropertyInfo>::Element *E = info.front(); E; E = E->next()) {
Variant value; Variant value;
get_property_default_value(E->get().name, 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) { while (script_data) {
Map<StringName, NativeScriptDesc::Method>::Element *M = script_data->methods.find(p_method); RBMap<StringName, NativeScriptDesc::Method>::Element *M = script_data->methods.find(p_method);
if (M) { if (M) {
return M->get().info; return M->get().info;
@ -353,17 +353,17 @@ void NativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
return; return;
} }
Set<MethodInfo> signals_; RBSet<MethodInfo> signals_;
while (script_data) { while (script_data) {
for (Map<StringName, NativeScriptDesc::Signal>::Element *S = script_data->signals_.front(); S; S = S->next()) { for (RBMap<StringName, NativeScriptDesc::Signal>::Element *S = script_data->signals_.front(); S; S = S->next()) {
signals_.insert(S->get().signal); signals_.insert(S->get().signal);
} }
script_data = script_data->base_data; script_data = script_data->base_data;
} }
for (Set<MethodInfo>::Element *E = signals_.front(); E; E = E->next()) { for (RBSet<MethodInfo>::Element *E = signals_.front(); E; E = E->next()) {
r_signals->push_back(E->get()); r_signals->push_back(E->get());
} }
} }
@ -394,17 +394,17 @@ void NativeScript::get_script_method_list(List<MethodInfo> *p_list) const {
return; return;
} }
Set<MethodInfo> methods; RBSet<MethodInfo> methods;
while (script_data) { while (script_data) {
for (Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.front(); E; E = E->next()) { for (RBMap<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.front(); E; E = E->next()) {
methods.insert(E->get().info); methods.insert(E->get().info);
} }
script_data = script_data->base_data; script_data = script_data->base_data;
} }
for (Set<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { for (RBSet<MethodInfo>::Element *E = methods.front(); E; E = E->next()) {
p_list->push_back(E->get()); p_list->push_back(E->get());
} }
} }
@ -412,7 +412,7 @@ void NativeScript::get_script_method_list(List<MethodInfo> *p_list) const {
void NativeScript::get_script_property_list(List<PropertyInfo> *p_list) const { void NativeScript::get_script_property_list(List<PropertyInfo> *p_list) const {
NativeScriptDesc *script_data = get_script_desc(); NativeScriptDesc *script_data = get_script_desc();
Set<StringName> existing_properties; RBSet<StringName> existing_properties;
List<PropertyInfo>::Element *original_back = p_list->back(); List<PropertyInfo>::Element *original_back = p_list->back();
while (script_data) { while (script_data) {
List<PropertyInfo>::Element *insert_position = original_back; List<PropertyInfo>::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."); ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get method documentation on invalid NativeScript.");
while (script_data) { while (script_data) {
Map<StringName, NativeScriptDesc::Method>::Element *method = script_data->methods.find(p_method); RBMap<StringName, NativeScriptDesc::Method>::Element *method = script_data->methods.find(p_method);
if (method) { if (method) {
return method->get().documentation; 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."); ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get signal documentation on invalid NativeScript.");
while (script_data) { while (script_data) {
Map<StringName, NativeScriptDesc::Signal>::Element *signal = script_data->signals_.find(p_signal_name); RBMap<StringName, NativeScriptDesc::Signal>::Element *signal = script_data->signals_.find(p_signal_name);
if (signal) { if (signal) {
return signal->get().documentation; 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); _ml_call_reversed(script_data->base_data, p_method, p_args, p_argcount);
} }
Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method); RBMap<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
if (E) { 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 res = E->get().method.method((godot_object *)owner, E->get().method.method_data, userdata, p_argcount, (godot_variant **)p_args);
godot_variant_destroy(&res); godot_variant_destroy(&res);
@ -578,7 +578,7 @@ bool NativeScriptInstance::set(const StringName &p_name, const Variant &p_value)
return true; return true;
} }
Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find("_set"); RBMap<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find("_set");
if (E) { if (E) {
Variant name = p_name; Variant name = p_name;
const Variant *args[2] = { &name, &p_value }; const Variant *args[2] = { &name, &p_value };
@ -615,7 +615,7 @@ bool NativeScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
return true; return true;
} }
Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find("_get"); RBMap<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find("_get");
if (E) { if (E) {
Variant name = p_name; Variant name = p_name;
const Variant *args[1] = { &name }; const Variant *args[1] = { &name };
@ -644,7 +644,7 @@ void NativeScriptInstance::get_property_list(List<PropertyInfo> *p_properties) c
NativeScriptDesc *script_data = GET_SCRIPT_DESC(); NativeScriptDesc *script_data = GET_SCRIPT_DESC();
while (script_data) { while (script_data) {
Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find("_get_property_list"); RBMap<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find("_get_property_list");
if (E) { if (E) {
godot_variant result; godot_variant result;
result = E->get().method.method((godot_object *)owner, 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(); NativeScriptDesc *script_data = GET_SCRIPT_DESC();
while (script_data) { while (script_data) {
Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method); RBMap<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
if (E) { if (E) {
godot_variant result; godot_variant result;
@ -819,7 +819,7 @@ MultiplayerAPI::RPCMode NativeScriptInstance::get_rpc_mode(const StringName &p_m
NativeScriptDesc *script_data = GET_SCRIPT_DESC(); NativeScriptDesc *script_data = GET_SCRIPT_DESC();
while (script_data) { while (script_data) {
Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method); RBMap<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
if (E) { if (E) {
switch (E->get().rpc_mode) { switch (E->get().rpc_mode) {
case GODOT_METHOD_RPC_MODE_DISABLED: 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(); NativeScriptDesc *script_data = GET_SCRIPT_DESC();
while (script_data) { while (script_data) {
Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method); RBMap<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
if (E) { if (E) {
godot_variant res = E->get().method.method((godot_object *)owner, godot_variant res = E->get().method.method((godot_object *)owner,
E->get().method.method_data, E->get().method.method_data,
@ -927,14 +927,14 @@ NativeScriptInstance::~NativeScriptInstance() {
NativeScriptLanguage *NativeScriptLanguage::singleton; NativeScriptLanguage *NativeScriptLanguage::singleton;
void NativeScriptLanguage::_unload_stuff(bool p_reload) { void NativeScriptLanguage::_unload_stuff(bool p_reload) {
Map<String, Ref<GDNative>> erase_and_unload; RBMap<String, Ref<GDNative>> erase_and_unload;
for (Map<String, Map<StringName, NativeScriptDesc>>::Element *L = library_classes.front(); L; L = L->next()) { for (RBMap<String, RBMap<StringName, NativeScriptDesc>>::Element *L = library_classes.front(); L; L = L->next()) {
String lib_path = L->key(); String lib_path = L->key();
Map<StringName, NativeScriptDesc> classes = L->get(); RBMap<StringName, NativeScriptDesc> classes = L->get();
if (p_reload) { if (p_reload) {
Map<String, Ref<GDNative>>::Element *E = library_gdnatives.find(lib_path); RBMap<String, Ref<GDNative>>::Element *E = library_gdnatives.find(lib_path);
Ref<GDNative> gdn; Ref<GDNative> gdn;
if (E) { if (E) {
@ -955,14 +955,14 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) {
} }
} }
Map<String, Ref<GDNative>>::Element *E = library_gdnatives.find(lib_path); RBMap<String, Ref<GDNative>>::Element *E = library_gdnatives.find(lib_path);
Ref<GDNative> gdn; Ref<GDNative> gdn;
if (E) { if (E) {
gdn = E->get(); gdn = E->get();
} }
for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) { for (RBMap<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) {
// free property stuff first // free property stuff first
for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) { for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) {
if (P.get().getter.free_func) { if (P.get().getter.free_func) {
@ -975,7 +975,7 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) {
} }
// free method stuff // free method stuff
for (Map<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) { for (RBMap<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) {
if (M->get().method.free_func) { if (M->get().method.free_func) {
M->get().method.free_func(M->get().method.method_data); 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); erase_and_unload.insert(lib_path, gdn);
} }
for (Map<String, Ref<GDNative>>::Element *E = erase_and_unload.front(); E; E = E->next()) { for (RBMap<String, Ref<GDNative>>::Element *E = erase_and_unload.front(); E; E = E->next()) {
String lib_path = E->key(); String lib_path = E->key();
Ref<GDNative> gdn = E->get(); Ref<GDNative> gdn = E->get();
@ -1029,7 +1029,7 @@ NativeScriptLanguage::NativeScriptLanguage() {
} }
NativeScriptLanguage::~NativeScriptLanguage() { NativeScriptLanguage::~NativeScriptLanguage() {
for (Map<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { for (RBMap<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
Ref<GDNative> lib = L->get(); Ref<GDNative> lib = L->get();
// only shut down valid libs, duh! // only shut down valid libs, duh!
if (lib.is_valid()) { if (lib.is_valid()) {
@ -1104,7 +1104,7 @@ Ref<Script> NativeScriptLanguage::get_template(const String &p_class_name, const
s->set_class_name(p_class_name); s->set_class_name(p_class_name);
return Ref<NativeScript>(s); 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, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const { 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, List<ScriptLanguage::Warning> *r_warnings, RBSet<int> *r_safe_lines) const {
return true; return true;
} }
@ -1196,7 +1196,7 @@ int NativeScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_a
#endif #endif
int current = 0; int current = 0;
for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) { for (RBMap<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) {
if (current >= p_info_max) { if (current >= p_info_max) {
break; break;
} }
@ -1221,7 +1221,7 @@ int NativeScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, in
#endif #endif
int current = 0; int current = 0;
for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) { for (RBMap<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) {
if (current >= p_info_max) { if (current >= p_info_max) {
break; break;
} }
@ -1247,7 +1247,7 @@ void NativeScriptLanguage::profiling_add_data(StringName p_signature, uint64_t p
MutexLock lock(mutex); MutexLock lock(mutex);
#endif #endif
Map<StringName, ProfileData>::Element *d = profile_data.find(p_signature); RBMap<StringName, ProfileData>::Element *d = profile_data.find(p_signature);
if (d) { if (d) {
d->get().call_count += 1; d->get().call_count += 1;
d->get().total_time += p_time; d->get().total_time += p_time;
@ -1300,7 +1300,7 @@ int NativeScriptLanguage::register_binding_functions(godot_instance_binding_func
void NativeScriptLanguage::unregister_binding_functions(int p_idx) { void NativeScriptLanguage::unregister_binding_functions(int p_idx) {
ERR_FAIL_INDEX(p_idx, binding_functions.size()); ERR_FAIL_INDEX(p_idx, binding_functions.size());
for (Set<Vector<void *> *>::Element *E = binding_instances.front(); E; E = E->next()) { for (RBSet<Vector<void *> *>::Element *E = binding_instances.front(); E; E = E->next()) {
Vector<void *> &binding_data = *E->get(); Vector<void *> &binding_data = *E->get();
if (p_idx < binding_data.size() && binding_data[p_idx] && binding_functions[p_idx].second.free_instance_binding_data) { if (p_idx < binding_data.size() && binding_data[p_idx] && binding_functions[p_idx].second.free_instance_binding_data) {
@ -1477,7 +1477,7 @@ void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) {
// See if this library was "registered" already. // See if this library was "registered" already.
const String &lib_path = lib->get_current_library_path(); const String &lib_path = lib->get_current_library_path();
ERR_FAIL_COND_MSG(lib_path.length() == 0, lib->get_name() + " does not have a library for the current platform."); ERR_FAIL_COND_MSG(lib_path.length() == 0, lib->get_name() + " does not have a library for the current platform.");
Map<String, Ref<GDNative>>::Element *E = library_gdnatives.find(lib_path); RBMap<String, Ref<GDNative>>::Element *E = library_gdnatives.find(lib_path);
if (!E) { if (!E) {
Ref<GDNative> gdn; Ref<GDNative> gdn;
@ -1489,10 +1489,10 @@ void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) {
library_gdnatives.insert(lib_path, gdn); library_gdnatives.insert(lib_path, gdn);
library_classes.insert(lib_path, Map<StringName, NativeScriptDesc>()); library_classes.insert(lib_path, RBMap<StringName, NativeScriptDesc>());
if (!library_script_users.has(lib_path)) { if (!library_script_users.has(lib_path)) {
library_script_users.insert(lib_path, Set<NativeScript *>()); library_script_users.insert(lib_path, RBSet<NativeScript *>());
} }
void *proc_ptr; void *proc_ptr;
@ -1520,22 +1520,22 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) {
#ifndef NO_THREADS #ifndef NO_THREADS
MutexLock lock(mutex); MutexLock lock(mutex);
#endif #endif
Map<String, Set<NativeScript *>>::Element *S = library_script_users.find(script->lib_path); RBMap<String, RBSet<NativeScript *>>::Element *S = library_script_users.find(script->lib_path);
if (S) { if (S) {
S->get().erase(script); S->get().erase(script);
if (S->get().size() == 0) { if (S->get().size() == 0) {
library_script_users.erase(S); library_script_users.erase(S);
Map<String, Ref<GDNative>>::Element *G = library_gdnatives.find(script->lib_path); RBMap<String, Ref<GDNative>>::Element *G = library_gdnatives.find(script->lib_path);
if (G && G->get()->get_library()->is_reloadable()) { if (G && G->get()->get_library()->is_reloadable()) {
// ONLY if the library is marked as reloadable, and no more instances of its scripts exist do we unload the library // ONLY if the library is marked as reloadable, and no more instances of its scripts exist do we unload the library
// First remove meta data related to the library // First remove meta data related to the library
Map<String, Map<StringName, NativeScriptDesc>>::Element *L = library_classes.find(script->lib_path); RBMap<String, RBMap<StringName, NativeScriptDesc>>::Element *L = library_classes.find(script->lib_path);
if (L) { if (L) {
Map<StringName, NativeScriptDesc> classes = L->get(); RBMap<StringName, NativeScriptDesc> classes = L->get();
for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) { for (RBMap<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) {
// free property stuff first // free property stuff first
for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) { for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) {
if (P.get().getter.free_func) { if (P.get().getter.free_func) {
@ -1548,7 +1548,7 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) {
} }
// free method stuff // free method stuff
for (Map<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) { for (RBMap<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) {
if (M->get().method.free_func) { if (M->get().method.free_func) {
M->get().method.free_func(M->get().method.method_data); M->get().method.free_func(M->get().method.method_data);
} }
@ -1580,7 +1580,7 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) {
void NativeScriptLanguage::call_libraries_cb(const StringName &name) { 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 // 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()) { for (RBMap<String, Ref<GDNative>>::Element *L = library_gdnatives.front(); L; L = L->next()) {
if (L->get().is_null()) { if (L->get().is_null()) {
continue; continue;
} }
@ -1600,11 +1600,11 @@ void NativeScriptLanguage::frame() {
#ifndef NO_THREADS #ifndef NO_THREADS
if (has_objects_to_register.is_set()) { if (has_objects_to_register.is_set()) {
MutexLock lock(mutex); MutexLock lock(mutex);
for (Set<Ref<GDNativeLibrary>>::Element *L = libs_to_init.front(); L; L = L->next()) { for (RBSet<Ref<GDNativeLibrary>>::Element *L = libs_to_init.front(); L; L = L->next()) {
init_library(L->get()); init_library(L->get());
} }
libs_to_init.clear(); libs_to_init.clear();
for (Set<NativeScript *>::Element *S = scripts_to_register.front(); S; S = S->next()) { for (RBSet<NativeScript *>::Element *S = scripts_to_register.front(); S; S = S->next()) {
register_script(S->get()); register_script(S->get());
} }
scripts_to_register.clear(); scripts_to_register.clear();
@ -1618,7 +1618,7 @@ void NativeScriptLanguage::frame() {
MutexLock lock(mutex); MutexLock lock(mutex);
#endif #endif
for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) { for (RBMap<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) {
d->get().last_frame_call_count = d->get().frame_call_count; d->get().last_frame_call_count = d->get().frame_call_count;
d->get().last_frame_self_time = d->get().frame_self_time; d->get().last_frame_self_time = d->get().frame_self_time;
d->get().last_frame_total_time = d->get().frame_total_time; d->get().last_frame_total_time = d->get().frame_total_time;
@ -1687,7 +1687,7 @@ void NativeReloadNode::_notification(int p_what) {
#endif #endif
NSL->_unload_stuff(true); NSL->_unload_stuff(true);
for (Map<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { for (RBMap<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
Ref<GDNative> gdn = L->get(); Ref<GDNative> gdn = L->get();
if (gdn.is_null()) { if (gdn.is_null()) {
@ -1721,8 +1721,8 @@ void NativeReloadNode::_notification(int p_what) {
#ifndef NO_THREADS #ifndef NO_THREADS
MutexLock lock(NSL->mutex); MutexLock lock(NSL->mutex);
#endif #endif
Set<StringName> libs_to_remove; RBSet<StringName> libs_to_remove;
for (Map<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { for (RBMap<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
Ref<GDNative> gdn = L->get(); Ref<GDNative> gdn = L->get();
if (gdn.is_null()) { if (gdn.is_null()) {
@ -1744,7 +1744,7 @@ void NativeReloadNode::_notification(int p_what) {
continue; continue;
} }
NSL->library_classes.insert(L->key(), Map<StringName, NativeScriptDesc>()); NSL->library_classes.insert(L->key(), RBMap<StringName, NativeScriptDesc>());
// here the library registers all the classes and stuff. // here the library registers all the classes and stuff.
@ -1756,7 +1756,7 @@ void NativeReloadNode::_notification(int p_what) {
((void (*)(void *))proc_ptr)((void *)&L->key()); ((void (*)(void *))proc_ptr)((void *)&L->key());
} }
for (Map<String, Set<NativeScript *>>::Element *U = NSL->library_script_users.front(); U; U = U->next()) { for (RBMap<String, RBSet<NativeScript *>>::Element *U = NSL->library_script_users.front(); U; U = U->next()) {
// Multiple GDNative libraries may be reloaded. The library and script // Multiple GDNative libraries may be reloaded. The library and script
// path should match to prevent failing `NSL->library_classes` lookup // path should match to prevent failing `NSL->library_classes` lookup
// from `get_script_desc()` in `script->_update_placeholder` below. // from `get_script_desc()` in `script->_update_placeholder` below.
@ -1766,14 +1766,14 @@ void NativeReloadNode::_notification(int p_what) {
continue; continue;
} }
for (Set<NativeScript *>::Element *S = U->get().front(); S; S = S->next()) { for (RBSet<NativeScript *>::Element *S = U->get().front(); S; S = S->next()) {
NativeScript *script = S->get(); NativeScript *script = S->get();
if (script->placeholders.size() == 0) { if (script->placeholders.size() == 0) {
continue; continue;
} }
for (Set<PlaceHolderScriptInstance *>::Element *P = script->placeholders.front(); P; P = P->next()) { for (RBSet<PlaceHolderScriptInstance *>::Element *P = script->placeholders.front(); P; P = P->next()) {
script->_update_placeholder(P->get()); script->_update_placeholder(P->get());
} }
} }
@ -1782,7 +1782,7 @@ void NativeReloadNode::_notification(int p_what) {
unloaded = false; unloaded = false;
for (Set<StringName>::Element *R = libs_to_remove.front(); R; R = R->next()) { for (RBSet<StringName>::Element *R = libs_to_remove.front(); R; R = R->next()) {
NSL->library_gdnatives.erase(R->get()); NSL->library_gdnatives.erase(R->get());
} }
@ -1793,8 +1793,8 @@ void NativeReloadNode::_notification(int p_what) {
#endif #endif
} }
RES ResourceFormatLoaderNativeScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_no_subresource_cache) { RES ResourceFormatLoaderNativeScript::load(const String &p_path, const String &p_original_path, Error *r_error) {
return ResourceFormatLoaderText::singleton->load(p_path, p_original_path, r_error, p_no_subresource_cache); return ResourceFormatLoaderText::singleton->load(p_path, p_original_path, r_error);
} }
void ResourceFormatLoaderNativeScript::get_recognized_extensions(List<String> *p_extensions) const { void ResourceFormatLoaderNativeScript::get_recognized_extensions(List<String> *p_extensions) const {

View File

@ -33,16 +33,16 @@
#include "core/io/resource_loader.h" #include "core/io/resource_loader.h"
#include "core/io/resource_saver.h" #include "core/io/resource_saver.h"
#include "core/oa_hash_map.h" #include "core/containers/oa_hash_map.h"
#include "core/ordered_hash_map.h" #include "core/containers/ordered_hash_map.h"
#include "core/os/thread_safe.h" #include "core/os/thread_safe.h"
#include "core/object/resource.h" #include "core/object/resource.h"
#include "core/safe_refcount.h" #include "core/os/safe_refcount.h"
#include "core/object/script_language.h" #include "core/object/script_language.h"
#include "core/containers/self_list.h" #include "core/containers/self_list.h"
#include "scene/main/node.h" #include "scene/main/node.h"
#include "modules/gdnative/gdnative.h" #include "../gdnative.h"
#include <nativescript/godot_nativescript.h> #include <nativescript/godot_nativescript.h>
#ifndef NO_THREADS #ifndef NO_THREADS
@ -70,9 +70,9 @@ struct NativeScriptDesc {
String documentation; String documentation;
}; };
Map<StringName, Method> methods; RBMap<StringName, Method> methods;
OrderedHashMap<StringName, Property> properties; OrderedHashMap<StringName, Property> properties;
Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals RBMap<StringName, Signal> signals_; // QtCreator doesn't like the name signals
StringName base; StringName base;
StringName base_native_type; StringName base_native_type;
NativeScriptDesc *base_data; NativeScriptDesc *base_data;
@ -102,7 +102,7 @@ class NativeScript : public Script {
GDCLASS(NativeScript, Script); GDCLASS(NativeScript, Script);
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
Set<PlaceHolderScriptInstance *> placeholders; RBSet<PlaceHolderScriptInstance *> placeholders;
void _update_placeholder(PlaceHolderScriptInstance *p_placeholder); void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder); virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder);
#endif #endif
@ -122,7 +122,7 @@ class NativeScript : public Script {
String script_class_icon_path; String script_class_icon_path;
Mutex owners_lock; Mutex owners_lock;
Set<Object *> instance_owners; RBSet<Object *> instance_owners;
protected: protected:
static void _bind_methods(); static void _bind_methods();
@ -238,8 +238,8 @@ private:
#ifndef NO_THREADS #ifndef NO_THREADS
Mutex mutex; Mutex mutex;
Set<Ref<GDNativeLibrary>> libs_to_init; RBSet<Ref<GDNativeLibrary>> libs_to_init;
Set<NativeScript *> scripts_to_register; RBSet<NativeScript *> scripts_to_register;
SafeFlag has_objects_to_register; // so that we don't lock mutex every frame - it's rarely needed SafeFlag has_objects_to_register; // so that we don't lock mutex every frame - it's rarely needed
void defer_init_library(Ref<GDNativeLibrary> lib, NativeScript *script); void defer_init_library(Ref<GDNativeLibrary> lib, NativeScript *script);
#endif #endif
@ -251,9 +251,9 @@ private:
void call_libraries_cb(const StringName &name); void call_libraries_cb(const StringName &name);
Vector<Pair<bool, godot_instance_binding_functions>> binding_functions; Vector<Pair<bool, godot_instance_binding_functions>> binding_functions;
Set<Vector<void *> *> binding_instances; RBSet<Vector<void *> *> binding_instances;
Map<int, HashMap<StringName, const void *>> global_type_tags; RBMap<int, HashMap<StringName, const void *>> global_type_tags;
struct ProfileData { struct ProfileData {
StringName signature; StringName signature;
@ -268,14 +268,14 @@ private:
uint64_t last_frame_total_time; uint64_t last_frame_total_time;
}; };
Map<StringName, ProfileData> profile_data; RBMap<StringName, ProfileData> profile_data;
public: public:
// These two maps must only be touched on the main thread // These two maps must only be touched on the main thread
Map<String, Map<StringName, NativeScriptDesc>> library_classes; RBMap<String, RBMap<StringName, NativeScriptDesc>> library_classes;
Map<String, Ref<GDNative>> library_gdnatives; RBMap<String, Ref<GDNative>> library_gdnatives;
Map<String, Set<NativeScript *>> library_script_users; RBMap<String, RBSet<NativeScript *>> library_script_users;
StringName _init_call_type; StringName _init_call_type;
StringName _init_call_name; StringName _init_call_name;
@ -314,7 +314,7 @@ public:
virtual void get_comment_delimiters(List<String> *p_delimiters) const; virtual void get_comment_delimiters(List<String> *p_delimiters) const;
virtual void get_string_delimiters(List<String> *p_delimiters) const; virtual void get_string_delimiters(List<String> *p_delimiters) const;
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const; virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
virtual bool 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, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const; virtual bool 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, List<ScriptLanguage::Warning> *r_warnings = nullptr, RBSet<int> *r_safe_lines = nullptr) const;
virtual Script *create_script() const; virtual Script *create_script() const;
virtual bool has_named_classes() const; virtual bool has_named_classes() const;
virtual bool supports_builtin_mode() const; virtual bool supports_builtin_mode() const;
@ -361,7 +361,7 @@ public:
}; };
inline NativeScriptDesc *NativeScript::get_script_desc() const { inline NativeScriptDesc *NativeScript::get_script_desc() const {
Map<StringName, NativeScriptDesc>::Element *E = NativeScriptLanguage::singleton->library_classes[lib_path].find(class_name); RBMap<StringName, NativeScriptDesc>::Element *E = NativeScriptLanguage::singleton->library_classes[lib_path].find(class_name);
return E ? &E->get() : nullptr; return E ? &E->get() : nullptr;
} }
@ -379,7 +379,7 @@ public:
class ResourceFormatLoaderNativeScript : public ResourceFormatLoader { class ResourceFormatLoaderNativeScript : public ResourceFormatLoader {
public: public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_no_subresource_cache = false); virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr);
virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const; virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const; virtual String get_resource_type(const String &p_path) const;

View File

@ -32,7 +32,8 @@
#define MULTIPLAYER_PEER_GDNATIVE_H #define MULTIPLAYER_PEER_GDNATIVE_H
#include "core/io/networked_multiplayer_peer.h" #include "core/io/networked_multiplayer_peer.h"
#include "../gdnative.h"
#include "../include/gdnative/gdnative.h"
#include "../include/net/godot_net.h" #include "../include/net/godot_net.h"
class MultiplayerPeerGDNative : public NetworkedMultiplayerPeer { class MultiplayerPeerGDNative : public NetworkedMultiplayerPeer {

View File

@ -32,7 +32,8 @@
#define PACKET_PEER_GDNATIVE_H #define PACKET_PEER_GDNATIVE_H
#include "core/io/packet_peer.h" #include "core/io/packet_peer.h"
#include "../gdnative.h"
#include "../include/gdnative/gdnative.h"
#include "../include/net/godot_net.h" #include "../include/net/godot_net.h"
class PacketPeerGDNative : public PacketPeer { class PacketPeerGDNative : public PacketPeer {

View File

@ -112,7 +112,7 @@ Ref<Script> PluginScriptLanguage::get_template(const String &p_class_name, const
return script; return script;
} }
bool PluginScriptLanguage::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, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const { bool PluginScriptLanguage::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, List<ScriptLanguage::Warning> *r_warnings, RBSet<int> *r_safe_lines) const {
PoolStringArray functions; PoolStringArray functions;
if (_desc.validate) { if (_desc.validate) {
bool ret = _desc.validate( bool ret = _desc.validate(

View File

@ -75,7 +75,7 @@ public:
virtual void get_comment_delimiters(List<String> *p_delimiters) const; virtual void get_comment_delimiters(List<String> *p_delimiters) const;
virtual void get_string_delimiters(List<String> *p_delimiters) const; virtual void get_string_delimiters(List<String> *p_delimiters) const;
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const; virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
virtual bool 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 = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const; virtual bool 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 = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, RBSet<int> *r_safe_lines = nullptr) const;
virtual Script *create_script() const; virtual Script *create_script() const;
virtual bool has_named_classes() const; virtual bool has_named_classes() const;
virtual bool supports_builtin_mode() const; virtual bool supports_builtin_mode() const;

View File

@ -177,11 +177,11 @@ void PluginScript::update_exports() {
ASSERT_SCRIPT_VALID(); ASSERT_SCRIPT_VALID();
if (placeholders.size()) { if (placeholders.size()) {
//update placeholders if any //update placeholders if any
Map<StringName, Variant> propdefvalues; RBMap<StringName, Variant> propdefvalues;
List<PropertyInfo> propinfos; List<PropertyInfo> propinfos;
get_script_property_list(&propinfos); get_script_property_list(&propinfos);
for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) { for (RBSet<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) {
E->get()->update(propinfos, _properties_default_values); E->get()->update(propinfos, _properties_default_values);
} }
} }
@ -359,14 +359,14 @@ Error PluginScript::reload(bool p_keep_state) {
void PluginScript::get_script_method_list(List<MethodInfo> *r_methods) const { void PluginScript::get_script_method_list(List<MethodInfo> *r_methods) const {
ASSERT_SCRIPT_VALID(); ASSERT_SCRIPT_VALID();
for (Map<StringName, MethodInfo>::Element *e = _methods_info.front(); e != nullptr; e = e->next()) { for (RBMap<StringName, MethodInfo>::Element *e = _methods_info.front(); e != nullptr; e = e->next()) {
r_methods->push_back(e->get()); r_methods->push_back(e->get());
} }
} }
void PluginScript::get_script_property_list(List<PropertyInfo> *r_properties) const { void PluginScript::get_script_property_list(List<PropertyInfo> *r_properties) const {
ASSERT_SCRIPT_VALID(); ASSERT_SCRIPT_VALID();
for (Map<StringName, PropertyInfo>::Element *e = _properties_info.front(); e != nullptr; e = e->next()) { for (RBMap<StringName, PropertyInfo>::Element *e = _properties_info.front(); e != nullptr; e = e->next()) {
r_properties->push_back(e->get()); r_properties->push_back(e->get());
} }
} }
@ -378,7 +378,7 @@ bool PluginScript::has_method(const StringName &p_method) const {
MethodInfo PluginScript::get_method_info(const StringName &p_method) const { MethodInfo PluginScript::get_method_info(const StringName &p_method) const {
ASSERT_SCRIPT_VALID_V(MethodInfo()); ASSERT_SCRIPT_VALID_V(MethodInfo());
const Map<StringName, MethodInfo>::Element *e = _methods_info.find(p_method); const RBMap<StringName, MethodInfo>::Element *e = _methods_info.find(p_method);
if (e != nullptr) { if (e != nullptr) {
return e->get(); return e->get();
} else { } else {
@ -393,7 +393,7 @@ bool PluginScript::has_property(const StringName &p_method) const {
PropertyInfo PluginScript::get_property_info(const StringName &p_property) const { PropertyInfo PluginScript::get_property_info(const StringName &p_property) const {
ASSERT_SCRIPT_VALID_V(PropertyInfo()); ASSERT_SCRIPT_VALID_V(PropertyInfo());
const Map<StringName, PropertyInfo>::Element *e = _properties_info.find(p_property); const RBMap<StringName, PropertyInfo>::Element *e = _properties_info.find(p_property);
if (e != nullptr) { if (e != nullptr) {
return e->get(); return e->get();
} else { } else {
@ -404,7 +404,7 @@ PropertyInfo PluginScript::get_property_info(const StringName &p_property) const
bool PluginScript::get_property_default_value(const StringName &p_property, Variant &r_value) const { bool PluginScript::get_property_default_value(const StringName &p_property, Variant &r_value) const {
ASSERT_SCRIPT_VALID_V(false); ASSERT_SCRIPT_VALID_V(false);
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
const Map<StringName, Variant>::Element *e = _properties_default_values.find(p_property); const RBMap<StringName, Variant>::Element *e = _properties_default_values.find(p_property);
if (e != nullptr) { if (e != nullptr) {
r_value = e->get(); r_value = e->get();
return true; return true;
@ -451,7 +451,7 @@ bool PluginScript::has_script_signal(const StringName &p_signal) const {
void PluginScript::get_script_signal_list(List<MethodInfo> *r_signals) const { void PluginScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
ASSERT_SCRIPT_VALID(); ASSERT_SCRIPT_VALID();
for (Map<StringName, MethodInfo>::Element *e = _signals_info.front(); e != nullptr; e = e->next()) { for (RBMap<StringName, MethodInfo>::Element *e = _signals_info.front(); e != nullptr; e = e->next()) {
r_signals->push_back(e->get()); r_signals->push_back(e->get());
} }
} }
@ -467,7 +467,7 @@ int PluginScript::get_member_line(const StringName &p_member) const {
MultiplayerAPI::RPCMode PluginScript::get_rpc_mode(const StringName &p_method) const { MultiplayerAPI::RPCMode PluginScript::get_rpc_mode(const StringName &p_method) const {
ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED); ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED);
const Map<StringName, MultiplayerAPI::RPCMode>::Element *e = _methods_rpc_mode.find(p_method); const RBMap<StringName, MultiplayerAPI::RPCMode>::Element *e = _methods_rpc_mode.find(p_method);
if (e != nullptr) { if (e != nullptr) {
return e->get(); return e->get();
} else { } else {
@ -477,7 +477,7 @@ MultiplayerAPI::RPCMode PluginScript::get_rpc_mode(const StringName &p_method) c
MultiplayerAPI::RPCMode PluginScript::get_rset_mode(const StringName &p_variable) const { MultiplayerAPI::RPCMode PluginScript::get_rset_mode(const StringName &p_variable) const {
ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED); ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED);
const Map<StringName, MultiplayerAPI::RPCMode>::Element *e = _variables_rset_mode.find(p_variable); const RBMap<StringName, MultiplayerAPI::RPCMode>::Element *e = _variables_rset_mode.find(p_variable);
if (e != nullptr) { if (e != nullptr) {
return e->get(); return e->get();
} else { } else {

View File

@ -54,15 +54,15 @@ private:
StringName _native_parent; StringName _native_parent;
SelfList<PluginScript> _script_list; SelfList<PluginScript> _script_list;
Map<StringName, int> _member_lines; RBMap<StringName, int> _member_lines;
Map<StringName, Variant> _properties_default_values; RBMap<StringName, Variant> _properties_default_values;
Map<StringName, PropertyInfo> _properties_info; RBMap<StringName, PropertyInfo> _properties_info;
Map<StringName, MethodInfo> _signals_info; RBMap<StringName, MethodInfo> _signals_info;
Map<StringName, MethodInfo> _methods_info; RBMap<StringName, MethodInfo> _methods_info;
Map<StringName, MultiplayerAPI::RPCMode> _variables_rset_mode; RBMap<StringName, MultiplayerAPI::RPCMode> _variables_rset_mode;
Map<StringName, MultiplayerAPI::RPCMode> _methods_rpc_mode; RBMap<StringName, MultiplayerAPI::RPCMode> _methods_rpc_mode;
Set<Object *> _instances; RBSet<Object *> _instances;
//exported members //exported members
String _source; String _source;
String _path; String _path;
@ -77,7 +77,7 @@ protected:
Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error); Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
Set<PlaceHolderScriptInstance *> placeholders; RBSet<PlaceHolderScriptInstance *> placeholders;
//void _update_placeholder(PlaceHolderScriptInstance *p_placeholder); //void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder); virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder);
#endif #endif

View File

@ -48,10 +48,11 @@
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "gdnative_library_editor_plugin.h" #include "gdnative_library_editor_plugin.h"
#include "gdnative_library_singleton_editor.h" #include "gdnative_library_singleton_editor.h"
#include "scene/gui/tab_container.h"
class GDNativeExportPlugin : public EditorExportPlugin { class GDNativeExportPlugin : public EditorExportPlugin {
protected: protected:
virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features); virtual void _export_file(const String &p_path, const String &p_type, const RBSet<String> &p_features);
}; };
struct LibrarySymbol { struct LibrarySymbol {
@ -59,7 +60,7 @@ struct LibrarySymbol {
bool is_required; bool is_required;
}; };
void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) { void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_type, const RBSet<String> &p_features) {
if (p_type != "GDNativeLibrary") { if (p_type != "GDNativeLibrary") {
return; return;
} }

View File

@ -380,7 +380,7 @@ RES ResourceFormatLoaderVideoStreamGDNative::load(const String &p_path, const St
} }
void ResourceFormatLoaderVideoStreamGDNative::get_recognized_extensions(List<String> *p_extensions) const { void ResourceFormatLoaderVideoStreamGDNative::get_recognized_extensions(List<String> *p_extensions) const {
Map<String, int>::Element *el = VideoDecoderServer::get_instance()->get_extensions().front(); RBMap<String, int>::Element *el = VideoDecoderServer::get_instance()->get_extensions().front();
while (el) { while (el) {
p_extensions->push_back(el->key()); p_extensions->push_back(el->key());
el = el->next(); el = el->next();

View File

@ -65,7 +65,7 @@ private:
class VideoDecoderServer { class VideoDecoderServer {
private: private:
Vector<VideoDecoderGDNative *> decoders; Vector<VideoDecoderGDNative *> decoders;
Map<String, int> extensions; RBMap<String, int> extensions;
static VideoDecoderServer *instance; static VideoDecoderServer *instance;
@ -74,7 +74,7 @@ public:
return instance; return instance;
} }
const Map<String, int> &get_extensions() { const RBMap<String, int> &get_extensions() {
return extensions; return extensions;
} }