From f7f4873ed08d6b465c8108f7ce0c1cb76f9caf2f Mon Sep 17 00:00:00 2001 From: kobewi Date: Mon, 8 Aug 2022 00:52:20 +0200 Subject: [PATCH] Replace Array return types with TypedArray 3 --- core/string/translation.cpp | 8 +-- core/string/translation.h | 2 +- doc/classes/RenderingServer.xml | 8 +-- doc/classes/TextServer.xml | 6 +- doc/classes/TextServerExtension.xml | 2 +- doc/classes/TextServerManager.xml | 2 +- doc/classes/TranslationServer.xml | 2 +- doc/classes/TreeItem.xml | 2 +- doc/classes/XRServer.xml | 2 +- modules/enet/doc_classes/ENetConnection.xml | 2 +- modules/enet/enet_connection.cpp | 5 +- modules/enet/enet_connection.h | 5 +- .../gdscript/gdscript_utility_functions.cpp | 5 +- modules/gdscript/gdscript_utility_functions.h | 3 + modules/gltf/doc_classes/GLTFSkeleton.xml | 4 +- modules/gltf/doc_classes/GLTFSkin.xml | 4 +- modules/gltf/doc_classes/GLTFState.xml | 60 ++++++++-------- modules/gltf/gltf_state.cpp | 68 +++++++++---------- modules/gltf/gltf_state.h | 64 ++++++++--------- modules/gltf/gltf_template_convert.h | 6 +- modules/gltf/structures/gltf_skeleton.cpp | 4 +- modules/gltf/structures/gltf_skeleton.h | 4 +- modules/gltf/structures/gltf_skin.cpp | 5 +- modules/gltf/structures/gltf_skin.h | 7 +- scene/gui/tree.cpp | 4 +- scene/gui/tree.h | 2 +- servers/rendering_server.cpp | 22 +++--- servers/rendering_server.h | 8 +-- servers/text/text_server_extension.cpp | 6 +- servers/text/text_server_extension.h | 4 +- servers/text_server.cpp | 14 ++-- servers/text_server.h | 8 +-- servers/xr_server.cpp | 2 +- servers/xr_server.h | 2 +- 34 files changed, 182 insertions(+), 170 deletions(-) diff --git a/core/string/translation.cpp b/core/string/translation.cpp index b83b7c786f8..4748f1a0cbd 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -70,7 +70,7 @@ void Translation::_set_messages(const Dictionary &p_messages) { void Translation::set_locale(const String &p_locale) { locale = TranslationServer::get_singleton()->standardize_locale(p_locale); - if (OS::get_singleton()->get_main_loop() && TranslationServer::get_singleton()->get_loaded_locales().has(this)) { + if (OS::get_singleton()->get_main_loop() && TranslationServer::get_singleton()->get_loaded_locales().has(get_locale())) { OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_TRANSLATION_CHANGED); } } @@ -505,11 +505,11 @@ String TranslationServer::get_locale() const { return locale; } -Array TranslationServer::get_loaded_locales() const { - Array locales; +PackedStringArray TranslationServer::get_loaded_locales() const { + PackedStringArray locales; for (const Ref &E : translations) { const Ref &t = E; - ERR_FAIL_COND_V(t.is_null(), Array()); + ERR_FAIL_COND_V(t.is_null(), PackedStringArray()); String l = t->get_locale(); locales.push_back(l); diff --git a/core/string/translation.h b/core/string/translation.h index 20c6ebd5a53..3f97a8d4fcd 100644 --- a/core/string/translation.h +++ b/core/string/translation.h @@ -145,7 +145,7 @@ public: String get_locale_name(const String &p_locale) const; - Array get_loaded_locales() const; + PackedStringArray get_loaded_locales() const; void add_translation(const Ref &p_translation); void remove_translation(const Ref &p_translation); diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml index 15d7fa4d4bd..a12bd714540 100644 --- a/doc/classes/RenderingServer.xml +++ b/doc/classes/RenderingServer.xml @@ -1406,7 +1406,7 @@ - + @@ -1581,7 +1581,7 @@ - + @@ -1590,7 +1590,7 @@ - + @@ -1599,7 +1599,7 @@ - + diff --git a/doc/classes/TextServer.xml b/doc/classes/TextServer.xml index 7b0fd4b17b5..9c4f7857c7c 100644 --- a/doc/classes/TextServer.xml +++ b/doc/classes/TextServer.xml @@ -1162,7 +1162,7 @@ - + Returns array of the glyphs in the ellipsis. @@ -1183,7 +1183,7 @@ - + Returns an array of glyphs in the visual order. @@ -1463,7 +1463,7 @@ - + Returns text glyphs in the logical order. diff --git a/doc/classes/TextServerExtension.xml b/doc/classes/TextServerExtension.xml index 17df7e841c5..9eb71888462 100644 --- a/doc/classes/TextServerExtension.xml +++ b/doc/classes/TextServerExtension.xml @@ -979,7 +979,7 @@ - + diff --git a/doc/classes/TextServerManager.xml b/doc/classes/TextServerManager.xml index 19b0e9e6f2f..9477e5ec543 100644 --- a/doc/classes/TextServerManager.xml +++ b/doc/classes/TextServerManager.xml @@ -38,7 +38,7 @@ - + Returns a list of available interfaces the index and name of each interface. diff --git a/doc/classes/TranslationServer.xml b/doc/classes/TranslationServer.xml index 3da90965552..7b18d8ddb65 100644 --- a/doc/classes/TranslationServer.xml +++ b/doc/classes/TranslationServer.xml @@ -65,7 +65,7 @@ - + Returns an array of all loaded locales of the project. diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml index 62074774412..6d4408cf613 100644 --- a/doc/classes/TreeItem.xml +++ b/doc/classes/TreeItem.xml @@ -126,7 +126,7 @@ - + Returns an array of references to the item's children. diff --git a/doc/classes/XRServer.xml b/doc/classes/XRServer.xml index 7e96b33eddf..48b00323d3e 100644 --- a/doc/classes/XRServer.xml +++ b/doc/classes/XRServer.xml @@ -64,7 +64,7 @@ - + Returns a list of available interfaces the ID and name of each interface. diff --git a/modules/enet/doc_classes/ENetConnection.xml b/modules/enet/doc_classes/ENetConnection.xml index c9bf1c65e17..8c84fe87d79 100644 --- a/modules/enet/doc_classes/ENetConnection.xml +++ b/modules/enet/doc_classes/ENetConnection.xml @@ -118,7 +118,7 @@ - + Returns the list of peers associated with this host. [b]Note:[/b] This list might include some peers that are not fully connected or are still being disconnected. diff --git a/modules/enet/enet_connection.cpp b/modules/enet/enet_connection.cpp index 629974d7c75..6a4bbecf6a8 100644 --- a/modules/enet/enet_connection.cpp +++ b/modules/enet/enet_connection.cpp @@ -34,6 +34,7 @@ #include "core/io/compression.h" #include "core/io/ip.h" +#include "core/variant/typed_array.h" void ENetConnection::broadcast(enet_uint8 p_channel, ENetPacket *p_packet) { ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); @@ -263,9 +264,9 @@ void ENetConnection::get_peers(List> &r_peers) { } } -Array ENetConnection::_get_peers() { +TypedArray ENetConnection::_get_peers() { ERR_FAIL_COND_V_MSG(!host, Array(), "The ENetConnection instance isn't currently active."); - Array out; + TypedArray out; for (const Ref &I : peers) { out.push_back(I); } diff --git a/modules/enet/enet_connection.h b/modules/enet/enet_connection.h index 0c873b6c55f..5cd8f6be9a3 100644 --- a/modules/enet/enet_connection.h +++ b/modules/enet/enet_connection.h @@ -38,6 +38,9 @@ #include +template +class TypedArray; + class ENetConnection : public RefCounted { GDCLASS(ENetConnection, RefCounted); @@ -83,7 +86,7 @@ private: Error _create(ENetAddress *p_address, int p_max_peers, int p_max_channels, int p_in_bandwidth, int p_out_bandwidth); Array _service(int p_timeout = 0); void _broadcast(int p_channel, PackedByteArray p_packet, int p_flags); - Array _get_peers(); + TypedArray _get_peers(); class Compressor { private: diff --git a/modules/gdscript/gdscript_utility_functions.cpp b/modules/gdscript/gdscript_utility_functions.cpp index 4b97486cb33..38893a422d0 100644 --- a/modules/gdscript/gdscript_utility_functions.cpp +++ b/modules/gdscript/gdscript_utility_functions.cpp @@ -36,6 +36,7 @@ #include "core/object/object.h" #include "core/templates/oa_hash_map.h" #include "core/templates/vector.h" +#include "core/variant/typed_array.h" #include "gdscript.h" #ifdef DEBUG_ENABLED @@ -468,12 +469,12 @@ struct GDScriptUtilityFunctionsDefinitions { static inline void get_stack(Variant *r_ret, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { VALIDATE_ARG_COUNT(0); if (Thread::get_caller_id() != Thread::get_main_id()) { - *r_ret = Array(); + *r_ret = TypedArray(); return; } ScriptLanguage *script = GDScriptLanguage::get_singleton(); - Array ret; + TypedArray ret; for (int i = 0; i < script->debug_get_stack_level_count(); i++) { Dictionary frame; frame["source"] = script->debug_get_stack_level_source(i); diff --git a/modules/gdscript/gdscript_utility_functions.h b/modules/gdscript/gdscript_utility_functions.h index 9ca7cf33d82..0f07db857f0 100644 --- a/modules/gdscript/gdscript_utility_functions.h +++ b/modules/gdscript/gdscript_utility_functions.h @@ -34,6 +34,9 @@ #include "core/string/string_name.h" #include "core/variant/variant.h" +template +class TypedArray; + class GDScriptUtilityFunctions { public: typedef void (*FunctionPtr)(Variant *r_ret, const Variant **p_args, int p_arg_count, Callable::CallError &r_error); diff --git a/modules/gltf/doc_classes/GLTFSkeleton.xml b/modules/gltf/doc_classes/GLTFSkeleton.xml index e1276d0e21c..d6ec09f113d 100644 --- a/modules/gltf/doc_classes/GLTFSkeleton.xml +++ b/modules/gltf/doc_classes/GLTFSkeleton.xml @@ -29,7 +29,7 @@ - + @@ -41,7 +41,7 @@ - + diff --git a/modules/gltf/doc_classes/GLTFSkin.xml b/modules/gltf/doc_classes/GLTFSkin.xml index 5abdf33360f..4de32857b5f 100644 --- a/modules/gltf/doc_classes/GLTFSkin.xml +++ b/modules/gltf/doc_classes/GLTFSkin.xml @@ -8,7 +8,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/modules/gltf/doc_classes/GLTFState.xml b/modules/gltf/doc_classes/GLTFState.xml index adf51ab59ea..1dbd89aed88 100644 --- a/modules/gltf/doc_classes/GLTFState.xml +++ b/modules/gltf/doc_classes/GLTFState.xml @@ -8,7 +8,7 @@ - + @@ -25,42 +25,42 @@ - + - + - + - + - + - + - + - + @@ -76,81 +76,81 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -162,31 +162,31 @@ - + - + - + - + - + @@ -194,7 +194,7 @@ - + @@ -206,7 +206,7 @@ - + diff --git a/modules/gltf/gltf_state.cpp b/modules/gltf/gltf_state.cpp index 8212e4c22fa..85bac446ccc 100644 --- a/modules/gltf/gltf_state.cpp +++ b/modules/gltf/gltf_state.cpp @@ -152,51 +152,51 @@ void GLTFState::set_use_named_skin_binds(bool p_use_named_skin_binds) { use_named_skin_binds = p_use_named_skin_binds; } -Array GLTFState::get_nodes() { +TypedArray GLTFState::get_nodes() { return GLTFTemplateConvert::to_array(nodes); } -void GLTFState::set_nodes(Array p_nodes) { +void GLTFState::set_nodes(TypedArray p_nodes) { GLTFTemplateConvert::set_from_array(nodes, p_nodes); } -Array GLTFState::get_buffers() { +TypedArray GLTFState::get_buffers() { return GLTFTemplateConvert::to_array(buffers); } -void GLTFState::set_buffers(Array p_buffers) { +void GLTFState::set_buffers(TypedArray p_buffers) { GLTFTemplateConvert::set_from_array(buffers, p_buffers); } -Array GLTFState::get_buffer_views() { +TypedArray GLTFState::get_buffer_views() { return GLTFTemplateConvert::to_array(buffer_views); } -void GLTFState::set_buffer_views(Array p_buffer_views) { +void GLTFState::set_buffer_views(TypedArray p_buffer_views) { GLTFTemplateConvert::set_from_array(buffer_views, p_buffer_views); } -Array GLTFState::get_accessors() { +TypedArray GLTFState::get_accessors() { return GLTFTemplateConvert::to_array(accessors); } -void GLTFState::set_accessors(Array p_accessors) { +void GLTFState::set_accessors(TypedArray p_accessors) { GLTFTemplateConvert::set_from_array(accessors, p_accessors); } -Array GLTFState::get_meshes() { +TypedArray GLTFState::get_meshes() { return GLTFTemplateConvert::to_array(meshes); } -void GLTFState::set_meshes(Array p_meshes) { +void GLTFState::set_meshes(TypedArray p_meshes) { GLTFTemplateConvert::set_from_array(meshes, p_meshes); } -Array GLTFState::get_materials() { +TypedArray GLTFState::get_materials() { return GLTFTemplateConvert::to_array(materials); } -void GLTFState::set_materials(Array p_materials) { +void GLTFState::set_materials(TypedArray p_materials) { GLTFTemplateConvert::set_from_array(materials, p_materials); } @@ -208,75 +208,75 @@ void GLTFState::set_scene_name(String p_scene_name) { scene_name = p_scene_name; } -Array GLTFState::get_root_nodes() { - return GLTFTemplateConvert::to_array(root_nodes); +PackedInt32Array GLTFState::get_root_nodes() { + return root_nodes; } -void GLTFState::set_root_nodes(Array p_root_nodes) { - GLTFTemplateConvert::set_from_array(root_nodes, p_root_nodes); +void GLTFState::set_root_nodes(PackedInt32Array p_root_nodes) { + root_nodes = p_root_nodes; } -Array GLTFState::get_textures() { +TypedArray GLTFState::get_textures() { return GLTFTemplateConvert::to_array(textures); } -void GLTFState::set_textures(Array p_textures) { +void GLTFState::set_textures(TypedArray p_textures) { GLTFTemplateConvert::set_from_array(textures, p_textures); } -Array GLTFState::get_images() { +TypedArray GLTFState::get_images() { return GLTFTemplateConvert::to_array(images); } -void GLTFState::set_images(Array p_images) { +void GLTFState::set_images(TypedArray p_images) { GLTFTemplateConvert::set_from_array(images, p_images); } -Array GLTFState::get_skins() { +TypedArray GLTFState::get_skins() { return GLTFTemplateConvert::to_array(skins); } -void GLTFState::set_skins(Array p_skins) { +void GLTFState::set_skins(TypedArray p_skins) { GLTFTemplateConvert::set_from_array(skins, p_skins); } -Array GLTFState::get_cameras() { +TypedArray GLTFState::get_cameras() { return GLTFTemplateConvert::to_array(cameras); } -void GLTFState::set_cameras(Array p_cameras) { +void GLTFState::set_cameras(TypedArray p_cameras) { GLTFTemplateConvert::set_from_array(cameras, p_cameras); } -Array GLTFState::get_lights() { +TypedArray GLTFState::get_lights() { return GLTFTemplateConvert::to_array(lights); } -void GLTFState::set_lights(Array p_lights) { +void GLTFState::set_lights(TypedArray p_lights) { GLTFTemplateConvert::set_from_array(lights, p_lights); } -Array GLTFState::get_unique_names() { +TypedArray GLTFState::get_unique_names() { return GLTFTemplateConvert::to_array(unique_names); } -void GLTFState::set_unique_names(Array p_unique_names) { +void GLTFState::set_unique_names(TypedArray p_unique_names) { GLTFTemplateConvert::set_from_array(unique_names, p_unique_names); } -Array GLTFState::get_unique_animation_names() { +TypedArray GLTFState::get_unique_animation_names() { return GLTFTemplateConvert::to_array(unique_animation_names); } -void GLTFState::set_unique_animation_names(Array p_unique_animation_names) { +void GLTFState::set_unique_animation_names(TypedArray p_unique_animation_names) { GLTFTemplateConvert::set_from_array(unique_animation_names, p_unique_animation_names); } -Array GLTFState::get_skeletons() { +TypedArray GLTFState::get_skeletons() { return GLTFTemplateConvert::to_array(skeletons); } -void GLTFState::set_skeletons(Array p_skeletons) { +void GLTFState::set_skeletons(TypedArray p_skeletons) { GLTFTemplateConvert::set_from_array(skeletons, p_skeletons); } @@ -296,11 +296,11 @@ void GLTFState::set_create_animations(bool p_create_animations) { create_animations = p_create_animations; } -Array GLTFState::get_animations() { +TypedArray GLTFState::get_animations() { return GLTFTemplateConvert::to_array(animations); } -void GLTFState::set_animations(Array p_animations) { +void GLTFState::set_animations(TypedArray p_animations) { GLTFTemplateConvert::set_from_array(animations, p_animations); } diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h index c08132f874a..6b2d1ca228b 100644 --- a/modules/gltf/gltf_state.h +++ b/modules/gltf/gltf_state.h @@ -115,23 +115,23 @@ public: bool get_discard_meshes_and_materials(); void set_discard_meshes_and_materials(bool p_discard_meshes_and_materials); - Array get_nodes(); - void set_nodes(Array p_nodes); + TypedArray get_nodes(); + void set_nodes(TypedArray p_nodes); - Array get_buffers(); - void set_buffers(Array p_buffers); + TypedArray get_buffers(); + void set_buffers(TypedArray p_buffers); - Array get_buffer_views(); - void set_buffer_views(Array p_buffer_views); + TypedArray get_buffer_views(); + void set_buffer_views(TypedArray p_buffer_views); - Array get_accessors(); - void set_accessors(Array p_accessors); + TypedArray get_accessors(); + void set_accessors(TypedArray p_accessors); - Array get_meshes(); - void set_meshes(Array p_meshes); + TypedArray get_meshes(); + void set_meshes(TypedArray p_meshes); - Array get_materials(); - void set_materials(Array p_materials); + TypedArray get_materials(); + void set_materials(TypedArray p_materials); String get_scene_name(); void set_scene_name(String p_scene_name); @@ -139,32 +139,32 @@ public: String get_base_path(); void set_base_path(String p_base_path); - Array get_root_nodes(); - void set_root_nodes(Array p_root_nodes); + PackedInt32Array get_root_nodes(); + void set_root_nodes(PackedInt32Array p_root_nodes); - Array get_textures(); - void set_textures(Array p_textures); + TypedArray get_textures(); + void set_textures(TypedArray p_textures); - Array get_images(); - void set_images(Array p_images); + TypedArray get_images(); + void set_images(TypedArray p_images); - Array get_skins(); - void set_skins(Array p_skins); + TypedArray get_skins(); + void set_skins(TypedArray p_skins); - Array get_cameras(); - void set_cameras(Array p_cameras); + TypedArray get_cameras(); + void set_cameras(TypedArray p_cameras); - Array get_lights(); - void set_lights(Array p_lights); + TypedArray get_lights(); + void set_lights(TypedArray p_lights); - Array get_unique_names(); - void set_unique_names(Array p_unique_names); + TypedArray get_unique_names(); + void set_unique_names(TypedArray p_unique_names); - Array get_unique_animation_names(); - void set_unique_animation_names(Array p_unique_names); + TypedArray get_unique_animation_names(); + void set_unique_animation_names(TypedArray p_unique_names); - Array get_skeletons(); - void set_skeletons(Array p_skeletons); + TypedArray get_skeletons(); + void set_skeletons(TypedArray p_skeletons); Dictionary get_skeleton_to_node(); void set_skeleton_to_node(Dictionary p_skeleton_to_node); @@ -172,8 +172,8 @@ public: bool get_create_animations(); void set_create_animations(bool p_create_animations); - Array get_animations(); - void set_animations(Array p_animations); + TypedArray get_animations(); + void set_animations(TypedArray p_animations); Node *get_scene_node(GLTFNodeIndex idx); diff --git a/modules/gltf/gltf_template_convert.h b/modules/gltf/gltf_template_convert.h index c915d3deb0b..8a4b595c9fd 100644 --- a/modules/gltf/gltf_template_convert.h +++ b/modules/gltf/gltf_template_convert.h @@ -46,8 +46,8 @@ static Array to_array(const Vector &p_inp) { } template -static Array to_array(const HashSet &p_inp) { - Array ret; +static TypedArray to_array(const HashSet &p_inp) { + TypedArray ret; typename HashSet::Iterator elem = p_inp.begin(); while (elem) { ret.push_back(*elem); @@ -65,7 +65,7 @@ static void set_from_array(Vector &r_out, const Array &p_inp) { } template -static void set_from_array(HashSet &r_out, const Array &p_inp) { +static void set_from_array(HashSet &r_out, const TypedArray &p_inp) { r_out.clear(); for (int i = 0; i < p_inp.size(); i++) { r_out.insert(p_inp[i]); diff --git a/modules/gltf/structures/gltf_skeleton.cpp b/modules/gltf/structures/gltf_skeleton.cpp index 90a6b0f50f5..0073357edad 100644 --- a/modules/gltf/structures/gltf_skeleton.cpp +++ b/modules/gltf/structures/gltf_skeleton.cpp @@ -72,11 +72,11 @@ Skeleton3D *GLTFSkeleton::get_godot_skeleton() { return godot_skeleton; } -Array GLTFSkeleton::get_unique_names() { +TypedArray GLTFSkeleton::get_unique_names() { return GLTFTemplateConvert::to_array(unique_names); } -void GLTFSkeleton::set_unique_names(Array p_unique_names) { +void GLTFSkeleton::set_unique_names(TypedArray p_unique_names) { GLTFTemplateConvert::set_from_array(unique_names, p_unique_names); } diff --git a/modules/gltf/structures/gltf_skeleton.h b/modules/gltf/structures/gltf_skeleton.h index db886232131..0f20b493b65 100644 --- a/modules/gltf/structures/gltf_skeleton.h +++ b/modules/gltf/structures/gltf_skeleton.h @@ -75,8 +75,8 @@ public: // this->godot_skeleton = p_godot_skeleton; // } - Array get_unique_names(); - void set_unique_names(Array p_unique_names); + TypedArray get_unique_names(); + void set_unique_names(TypedArray p_unique_names); //RBMap get_godot_bone_node() { // return this->godot_bone_node; diff --git a/modules/gltf/structures/gltf_skin.cpp b/modules/gltf/structures/gltf_skin.cpp index 2e46ee3be27..9717a660486 100644 --- a/modules/gltf/structures/gltf_skin.cpp +++ b/modules/gltf/structures/gltf_skin.cpp @@ -31,6 +31,7 @@ #include "gltf_skin.h" #include "../gltf_template_convert.h" +#include "core/variant/typed_array.h" #include "scene/resources/skin.h" void GLTFSkin::_bind_methods() { @@ -83,11 +84,11 @@ void GLTFSkin::set_joints_original(Vector p_joints_original) { joints_original = p_joints_original; } -Array GLTFSkin::get_inverse_binds() { +TypedArray GLTFSkin::get_inverse_binds() { return GLTFTemplateConvert::to_array(inverse_binds); } -void GLTFSkin::set_inverse_binds(Array p_inverse_binds) { +void GLTFSkin::set_inverse_binds(TypedArray p_inverse_binds) { GLTFTemplateConvert::set_from_array(inverse_binds, p_inverse_binds); } diff --git a/modules/gltf/structures/gltf_skin.h b/modules/gltf/structures/gltf_skin.h index 59b6a300ac2..1a4d54b3808 100644 --- a/modules/gltf/structures/gltf_skin.h +++ b/modules/gltf/structures/gltf_skin.h @@ -34,6 +34,9 @@ #include "../gltf_defines.h" #include "core/io/resource.h" +template +class TypedArray; + class GLTFSkin : public Resource { GDCLASS(GLTFSkin, Resource); friend class GLTFDocument; @@ -82,8 +85,8 @@ public: Vector get_joints_original(); void set_joints_original(Vector p_joints_original); - Array get_inverse_binds(); - void set_inverse_binds(Array p_inverse_binds); + TypedArray get_inverse_binds(); + void set_inverse_binds(TypedArray p_inverse_binds); Vector get_joints(); void set_joints(Vector p_joints); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index ede7bfb0bfb..52b45054a75 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -748,10 +748,10 @@ int TreeItem::get_child_count() { return children_cache.size(); } -Array TreeItem::get_children() { +TypedArray TreeItem::get_children() { // Don't need to explicitly create children cache, because get_child_count creates it. int size = get_child_count(); - Array arr; + TypedArray arr; arr.resize(size); for (int i = 0; i < size; i++) { arr[i] = children_cache[i]; diff --git a/scene/gui/tree.h b/scene/gui/tree.h index bcc2419b80a..7f9c00b1b92 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -339,7 +339,7 @@ public: TreeItem *get_child(int p_idx); int get_visible_child_count(); int get_child_count(); - Array get_children(); + TypedArray get_children(); int get_index(); #ifdef DEV_ENABLED diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 347a04159c3..a410cf0ed89 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -70,44 +70,44 @@ Array RenderingServer::_texture_debug_usage_bind() { return arr; } -static Array to_array(const Vector &ids) { - Array a; +static PackedInt64Array to_int_array(const Vector &ids) { + PackedInt64Array a; a.resize(ids.size()); for (int i = 0; i < ids.size(); ++i) { - a[i] = ids[i]; + a.write[i] = ids[i]; } return a; } -Array RenderingServer::_instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario) const { +PackedInt64Array RenderingServer::_instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario) const { if (RSG::threaded) { WARN_PRINT_ONCE("Using this function with a threaded renderer hurts performance, as it causes a server stall."); } Vector ids = instances_cull_aabb(p_aabb, p_scenario); - return to_array(ids); + return to_int_array(ids); } -Array RenderingServer::_instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const { +PackedInt64Array RenderingServer::_instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const { if (RSG::threaded) { WARN_PRINT_ONCE("Using this function with a threaded renderer hurts performance, as it causes a server stall."); } Vector ids = instances_cull_ray(p_from, p_to, p_scenario); - return to_array(ids); + return to_int_array(ids); } -Array RenderingServer::_instances_cull_convex_bind(const Array &p_convex, RID p_scenario) const { +PackedInt64Array RenderingServer::_instances_cull_convex_bind(const Array &p_convex, RID p_scenario) const { if (RSG::threaded) { WARN_PRINT_ONCE("Using this function with a threaded renderer hurts performance, as it causes a server stall."); } Vector planes; for (int i = 0; i < p_convex.size(); ++i) { Variant v = p_convex[i]; - ERR_FAIL_COND_V(v.get_type() != Variant::PLANE, Array()); + ERR_FAIL_COND_V(v.get_type() != Variant::PLANE, PackedInt64Array()); planes.push_back(v); } Vector ids = instances_cull_convex(planes, p_scenario); - return to_array(ids); + return to_int_array(ids); } RID RenderingServer::get_test_texture() { @@ -1626,7 +1626,7 @@ Dictionary RenderingServer::_mesh_get_surface(RID p_mesh, int p_idx) { return d; } -Array RenderingServer::_instance_geometry_get_shader_uniform_list(RID p_instance) const { +TypedArray RenderingServer::_instance_geometry_get_shader_uniform_list(RID p_instance) const { List params; instance_geometry_get_shader_uniform_list(p_instance, ¶ms); return convert_property_list(¶ms); diff --git a/servers/rendering_server.h b/servers/rendering_server.h index 9e98f528d2e..59887d7d37d 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -1216,9 +1216,9 @@ public: virtual Vector instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const = 0; virtual Vector instances_cull_convex(const Vector &p_convex, RID p_scenario = RID()) const = 0; - Array _instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario = RID()) const; - Array _instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const; - Array _instances_cull_convex_bind(const Array &p_convex, RID p_scenario = RID()) const; + PackedInt64Array _instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario = RID()) const; + PackedInt64Array _instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const; + PackedInt64Array _instances_cull_convex_bind(const Array &p_convex, RID p_scenario = RID()) const; enum InstanceFlags { INSTANCE_FLAG_USE_BAKED_LIGHT, @@ -1581,7 +1581,7 @@ private: RID _mesh_create_from_surfaces(const TypedArray &p_surfaces, int p_blend_shape_count); void _mesh_add_surface(RID p_mesh, const Dictionary &p_surface); Dictionary _mesh_get_surface(RID p_mesh, int p_idx); - Array _instance_geometry_get_shader_uniform_list(RID p_instance) const; + TypedArray _instance_geometry_get_shader_uniform_list(RID p_instance) const; TypedArray _bake_render_uv2(RID p_base, const TypedArray &p_material_overrides, const Size2i &p_image_size); void _particles_set_trail_bind_poses(RID p_particles, const TypedArray &p_bind_poses); }; diff --git a/servers/text/text_server_extension.cpp b/servers/text/text_server_extension.cpp index c53560523d2..855267e4283 100644 --- a/servers/text/text_server_extension.cpp +++ b/servers/text/text_server_extension.cpp @@ -1534,12 +1534,12 @@ String TextServerExtension::string_to_lower(const String &p_string, const String return p_string; } -Array TextServerExtension::parse_structured_text(StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const { - Array ret; +TypedArray TextServerExtension::parse_structured_text(StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const { + TypedArray ret; if (GDVIRTUAL_CALL(parse_structured_text, p_parser_type, p_args, p_text, ret)) { return ret; } - return Array(); + return TypedArray(); } PackedInt32Array TextServerExtension::string_get_word_breaks(const String &p_string, const String &p_language) const { diff --git a/servers/text/text_server_extension.h b/servers/text/text_server_extension.h index 15cffdf152c..7e1ed22390e 100644 --- a/servers/text/text_server_extension.h +++ b/servers/text/text_server_extension.h @@ -505,8 +505,8 @@ public: GDVIRTUAL2RC(String, string_to_upper, const String &, const String &); GDVIRTUAL2RC(String, string_to_lower, const String &, const String &); - Array parse_structured_text(StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const; - GDVIRTUAL3RC(Array, parse_structured_text, StructuredTextParser, const Array &, const String &); + TypedArray parse_structured_text(StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const; + GDVIRTUAL3RC(TypedArray, parse_structured_text, StructuredTextParser, const Array &, const String &); virtual int is_confusable(const String &p_string, const PackedStringArray &p_dict) const override; virtual bool spoof_check(const String &p_string) const override; diff --git a/servers/text_server.cpp b/servers/text_server.cpp index 75712d0c5ad..852672d81b8 100644 --- a/servers/text_server.cpp +++ b/servers/text_server.cpp @@ -104,8 +104,8 @@ Ref TextServerManager::find_interface(const String &p_name) const { return interfaces[idx]; } -Array TextServerManager::get_interfaces() const { - Array ret; +TypedArray TextServerManager::get_interfaces() const { + TypedArray ret; for (int i = 0; i < interfaces.size(); i++) { Dictionary iface_info; @@ -1663,8 +1663,8 @@ TypedArray TextServer::parse_structured_text(StructuredTextParser p_pa return ret; } -Array TextServer::_shaped_text_get_glyphs_wrapper(const RID &p_shaped) const { - Array ret; +TypedArray TextServer::_shaped_text_get_glyphs_wrapper(const RID &p_shaped) const { + TypedArray ret; const Glyph *glyphs = shaped_text_get_glyphs(p_shaped); int gl_size = shaped_text_get_glyph_count(p_shaped); @@ -1688,7 +1688,7 @@ Array TextServer::_shaped_text_get_glyphs_wrapper(const RID &p_shaped) const { return ret; } -Array TextServer::_shaped_text_sort_logical_wrapper(const RID &p_shaped) { +TypedArray TextServer::_shaped_text_sort_logical_wrapper(const RID &p_shaped) { Array ret; const Glyph *glyphs = shaped_text_sort_logical(p_shaped); @@ -1713,8 +1713,8 @@ Array TextServer::_shaped_text_sort_logical_wrapper(const RID &p_shaped) { return ret; } -Array TextServer::_shaped_text_get_ellipsis_glyphs_wrapper(const RID &p_shaped) const { - Array ret; +TypedArray TextServer::_shaped_text_get_ellipsis_glyphs_wrapper(const RID &p_shaped) const { + TypedArray ret; const Glyph *glyphs = shaped_text_get_ellipsis_glyphs(p_shaped); int gl_size = shaped_text_get_ellipsis_glyph_count(p_shaped); diff --git a/servers/text_server.h b/servers/text_server.h index 6360cc17264..9ffc2984d18 100644 --- a/servers/text_server.h +++ b/servers/text_server.h @@ -414,9 +414,9 @@ public: virtual bool shaped_text_is_ready(const RID &p_shaped) const = 0; virtual const Glyph *shaped_text_get_glyphs(const RID &p_shaped) const = 0; - Array _shaped_text_get_glyphs_wrapper(const RID &p_shaped) const; + TypedArray _shaped_text_get_glyphs_wrapper(const RID &p_shaped) const; virtual const Glyph *shaped_text_sort_logical(const RID &p_shaped) = 0; - Array _shaped_text_sort_logical_wrapper(const RID &p_shaped); + TypedArray _shaped_text_sort_logical_wrapper(const RID &p_shaped); virtual int64_t shaped_text_get_glyph_count(const RID &p_shaped) const = 0; virtual Vector2i shaped_text_get_range(const RID &p_shaped) const = 0; @@ -428,7 +428,7 @@ public: virtual int64_t shaped_text_get_trim_pos(const RID &p_shaped) const = 0; virtual int64_t shaped_text_get_ellipsis_pos(const RID &p_shaped) const = 0; virtual const Glyph *shaped_text_get_ellipsis_glyphs(const RID &p_shaped) const = 0; - Array _shaped_text_get_ellipsis_glyphs_wrapper(const RID &p_shaped) const; + TypedArray _shaped_text_get_ellipsis_glyphs_wrapper(const RID &p_shaped) const; virtual int64_t shaped_text_get_ellipsis_glyph_count(const RID &p_shaped) const = 0; virtual void shaped_text_overrun_trim_to_width(const RID &p_shaped, double p_width, BitField p_trim_flags) = 0; @@ -541,7 +541,7 @@ public: int get_interface_count() const; Ref get_interface(int p_index) const; Ref find_interface(const String &p_name) const; - Array get_interfaces() const; + TypedArray get_interfaces() const; _FORCE_INLINE_ Ref get_primary_interface() const { return primary_interface; diff --git a/servers/xr_server.cpp b/servers/xr_server.cpp index 990281d96d0..e26212ada16 100644 --- a/servers/xr_server.cpp +++ b/servers/xr_server.cpp @@ -226,7 +226,7 @@ Ref XRServer::find_interface(const String &p_name) const { return interfaces[idx]; }; -Array XRServer::get_interfaces() const { +TypedArray XRServer::get_interfaces() const { Array ret; for (int i = 0; i < interfaces.size(); i++) { diff --git a/servers/xr_server.h b/servers/xr_server.h index 74128bfb54f..57e42deccbf 100644 --- a/servers/xr_server.h +++ b/servers/xr_server.h @@ -157,7 +157,7 @@ public: int get_interface_count() const; Ref get_interface(int p_index) const; Ref find_interface(const String &p_name) const; - Array get_interfaces() const; + TypedArray get_interfaces() const; /* note, more then one interface can technically be active, especially on mobile, but only one interface is used for