diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-08-24 16:05:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-24 16:05:59 +0200 |
commit | 4698dc67b575a93d83933147207b0e57e7a58672 (patch) | |
tree | e182c2313f758d5babf2ab9b8c159a93ac2e9b54 | |
parent | 5d14d0870269eb6c4eeb7bff6e8e66dfd0f4773e (diff) | |
parent | f7f4873ed08d6b465c8108f7ce0c1cb76f9caf2f (diff) |
Merge pull request #64082 from KoBeWi/array3k
34 files changed, 182 insertions, 170 deletions
diff --git a/core/string/translation.cpp b/core/string/translation.cpp index b83b7c786f..4748f1a0cb 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<Translation> &E : translations) { const Ref<Translation> &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 20c6ebd5a5..3f97a8d4fc 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<Translation> &p_translation); void remove_translation(const Ref<Translation> &p_translation); diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml index 15d7fa4d4b..a12bd71454 100644 --- a/doc/classes/RenderingServer.xml +++ b/doc/classes/RenderingServer.xml @@ -1406,7 +1406,7 @@ </description> </method> <method name="instance_geometry_get_shader_uniform_list" qualifiers="const"> - <return type="Array" /> + <return type="Dictionary[]" /> <param index="0" name="instance" type="RID" /> <description> </description> @@ -1581,7 +1581,7 @@ </description> </method> <method name="instances_cull_aabb" qualifiers="const"> - <return type="Array" /> + <return type="PackedInt64Array" /> <param index="0" name="aabb" type="AABB" /> <param index="1" name="scenario" type="RID" /> <description> @@ -1590,7 +1590,7 @@ </description> </method> <method name="instances_cull_convex" qualifiers="const"> - <return type="Array" /> + <return type="PackedInt64Array" /> <param index="0" name="convex" type="Array" /> <param index="1" name="scenario" type="RID" /> <description> @@ -1599,7 +1599,7 @@ </description> </method> <method name="instances_cull_ray" qualifiers="const"> - <return type="Array" /> + <return type="PackedInt64Array" /> <param index="0" name="from" type="Vector3" /> <param index="1" name="to" type="Vector3" /> <param index="2" name="scenario" type="RID" /> diff --git a/doc/classes/TextServer.xml b/doc/classes/TextServer.xml index 7b0fd4b17b..9c4f7857c7 100644 --- a/doc/classes/TextServer.xml +++ b/doc/classes/TextServer.xml @@ -1162,7 +1162,7 @@ </description> </method> <method name="shaped_text_get_ellipsis_glyphs" qualifiers="const"> - <return type="Array" /> + <return type="Dictionary[]" /> <param index="0" name="shaped" type="RID" /> <description> Returns array of the glyphs in the ellipsis. @@ -1183,7 +1183,7 @@ </description> </method> <method name="shaped_text_get_glyphs" qualifiers="const"> - <return type="Array" /> + <return type="Dictionary[]" /> <param index="0" name="shaped" type="RID" /> <description> Returns an array of glyphs in the visual order. @@ -1463,7 +1463,7 @@ </description> </method> <method name="shaped_text_sort_logical"> - <return type="Array" /> + <return type="Dictionary[]" /> <param index="0" name="shaped" type="RID" /> <description> Returns text glyphs in the logical order. diff --git a/doc/classes/TextServerExtension.xml b/doc/classes/TextServerExtension.xml index 17df7e841c..9eb7188846 100644 --- a/doc/classes/TextServerExtension.xml +++ b/doc/classes/TextServerExtension.xml @@ -979,7 +979,7 @@ </description> </method> <method name="parse_structured_text" qualifiers="virtual const"> - <return type="Array" /> + <return type="Vector2i[]" /> <param index="0" name="parser_type" type="int" enum="TextServer.StructuredTextParser" /> <param index="1" name="args" type="Array" /> <param index="2" name="text" type="String" /> diff --git a/doc/classes/TextServerManager.xml b/doc/classes/TextServerManager.xml index 19b0e9e6f2..9477e5ec54 100644 --- a/doc/classes/TextServerManager.xml +++ b/doc/classes/TextServerManager.xml @@ -38,7 +38,7 @@ </description> </method> <method name="get_interfaces" qualifiers="const"> - <return type="Array" /> + <return type="Dictionary[]" /> <description> Returns a list of available interfaces the index and name of each interface. </description> diff --git a/doc/classes/TranslationServer.xml b/doc/classes/TranslationServer.xml index 3da9096555..7b18d8ddb6 100644 --- a/doc/classes/TranslationServer.xml +++ b/doc/classes/TranslationServer.xml @@ -65,7 +65,7 @@ </description> </method> <method name="get_loaded_locales" qualifiers="const"> - <return type="Array" /> + <return type="PackedStringArray" /> <description> Returns an array of all loaded locales of the project. </description> diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml index 6207477441..6d4408cf61 100644 --- a/doc/classes/TreeItem.xml +++ b/doc/classes/TreeItem.xml @@ -126,7 +126,7 @@ </description> </method> <method name="get_children"> - <return type="Array" /> + <return type="TreeItem[]" /> <description> Returns an array of references to the item's children. </description> diff --git a/doc/classes/XRServer.xml b/doc/classes/XRServer.xml index 7e96b33edd..48b00323d3 100644 --- a/doc/classes/XRServer.xml +++ b/doc/classes/XRServer.xml @@ -64,7 +64,7 @@ </description> </method> <method name="get_interfaces" qualifiers="const"> - <return type="Array" /> + <return type="Dictionary[]" /> <description> Returns a list of available interfaces the ID and name of each interface. </description> diff --git a/modules/enet/doc_classes/ENetConnection.xml b/modules/enet/doc_classes/ENetConnection.xml index c9bf1c65e1..8c84fe87d7 100644 --- a/modules/enet/doc_classes/ENetConnection.xml +++ b/modules/enet/doc_classes/ENetConnection.xml @@ -118,7 +118,7 @@ </description> </method> <method name="get_peers"> - <return type="Array" /> + <return type="ENetPacketPeer[]" /> <description> 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 629974d7c7..6a4bbecf6a 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<Ref<ENetPacketPeer>> &r_peers) { } } -Array ENetConnection::_get_peers() { +TypedArray<ENetPacketPeer> ENetConnection::_get_peers() { ERR_FAIL_COND_V_MSG(!host, Array(), "The ENetConnection instance isn't currently active."); - Array out; + TypedArray<ENetPacketPeer> out; for (const Ref<ENetPacketPeer> &I : peers) { out.push_back(I); } diff --git a/modules/enet/enet_connection.h b/modules/enet/enet_connection.h index 0c873b6c55..5cd8f6be9a 100644 --- a/modules/enet/enet_connection.h +++ b/modules/enet/enet_connection.h @@ -38,6 +38,9 @@ #include <enet/enet.h> +template <typename T> +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<ENetPacketPeer> _get_peers(); class Compressor { private: diff --git a/modules/gdscript/gdscript_utility_functions.cpp b/modules/gdscript/gdscript_utility_functions.cpp index 4b97486cb3..38893a422d 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<Dictionary>(); return; } ScriptLanguage *script = GDScriptLanguage::get_singleton(); - Array ret; + TypedArray<Dictionary> 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 9ca7cf33d8..0f07db857f 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 <typename T> +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 e1276d0e21..d6ec09f113 100644 --- a/modules/gltf/doc_classes/GLTFSkeleton.xml +++ b/modules/gltf/doc_classes/GLTFSkeleton.xml @@ -29,7 +29,7 @@ </description> </method> <method name="get_unique_names"> - <return type="Array" /> + <return type="String[]" /> <description> </description> </method> @@ -41,7 +41,7 @@ </method> <method name="set_unique_names"> <return type="void" /> - <param index="0" name="unique_names" type="Array" /> + <param index="0" name="unique_names" type="String[]" /> <description> </description> </method> diff --git a/modules/gltf/doc_classes/GLTFSkin.xml b/modules/gltf/doc_classes/GLTFSkin.xml index 5abdf33360..4de32857b5 100644 --- a/modules/gltf/doc_classes/GLTFSkin.xml +++ b/modules/gltf/doc_classes/GLTFSkin.xml @@ -8,7 +8,7 @@ </tutorials> <methods> <method name="get_inverse_binds"> - <return type="Array" /> + <return type="Transform3D[]" /> <description> </description> </method> @@ -24,7 +24,7 @@ </method> <method name="set_inverse_binds"> <return type="void" /> - <param index="0" name="inverse_binds" type="Array" /> + <param index="0" name="inverse_binds" type="Transform3D[]" /> <description> </description> </method> diff --git a/modules/gltf/doc_classes/GLTFState.xml b/modules/gltf/doc_classes/GLTFState.xml index adf51ab59e..1dbd89aed8 100644 --- a/modules/gltf/doc_classes/GLTFState.xml +++ b/modules/gltf/doc_classes/GLTFState.xml @@ -8,7 +8,7 @@ </tutorials> <methods> <method name="get_accessors"> - <return type="Array" /> + <return type="GLTFAccessor[]" /> <description> </description> </method> @@ -25,42 +25,42 @@ </description> </method> <method name="get_animations"> - <return type="Array" /> + <return type="GLTFAnimation[]" /> <description> </description> </method> <method name="get_buffer_views"> - <return type="Array" /> + <return type="GLTFBufferView[]" /> <description> </description> </method> <method name="get_cameras"> - <return type="Array" /> + <return type="GLTFCamera[]" /> <description> </description> </method> <method name="get_images"> - <return type="Array" /> + <return type="Texture2D[]" /> <description> </description> </method> <method name="get_lights"> - <return type="Array" /> + <return type="GLTFLight[]" /> <description> </description> </method> <method name="get_materials"> - <return type="Array" /> + <return type="BaseMaterial3D[]" /> <description> </description> </method> <method name="get_meshes"> - <return type="Array" /> + <return type="GLTFMesh[]" /> <description> </description> </method> <method name="get_nodes"> - <return type="Array" /> + <return type="GLTFNode[]" /> <description> </description> </method> @@ -76,81 +76,81 @@ </description> </method> <method name="get_skeletons"> - <return type="Array" /> + <return type="GLTFSkeleton[]" /> <description> </description> </method> <method name="get_skins"> - <return type="Array" /> + <return type="GLTFSkin[]" /> <description> </description> </method> <method name="get_textures"> - <return type="Array" /> + <return type="GLTFTexture[]" /> <description> </description> </method> <method name="get_unique_animation_names"> - <return type="Array" /> + <return type="String[]" /> <description> </description> </method> <method name="get_unique_names"> - <return type="Array" /> + <return type="String[]" /> <description> </description> </method> <method name="set_accessors"> <return type="void" /> - <param index="0" name="accessors" type="Array" /> + <param index="0" name="accessors" type="GLTFAccessor[]" /> <description> </description> </method> <method name="set_animations"> <return type="void" /> - <param index="0" name="animations" type="Array" /> + <param index="0" name="animations" type="GLTFAnimation[]" /> <description> </description> </method> <method name="set_buffer_views"> <return type="void" /> - <param index="0" name="buffer_views" type="Array" /> + <param index="0" name="buffer_views" type="GLTFBufferView[]" /> <description> </description> </method> <method name="set_cameras"> <return type="void" /> - <param index="0" name="cameras" type="Array" /> + <param index="0" name="cameras" type="GLTFCamera[]" /> <description> </description> </method> <method name="set_images"> <return type="void" /> - <param index="0" name="images" type="Array" /> + <param index="0" name="images" type="Texture2D[]" /> <description> </description> </method> <method name="set_lights"> <return type="void" /> - <param index="0" name="lights" type="Array" /> + <param index="0" name="lights" type="GLTFLight[]" /> <description> </description> </method> <method name="set_materials"> <return type="void" /> - <param index="0" name="materials" type="Array" /> + <param index="0" name="materials" type="BaseMaterial3D[]" /> <description> </description> </method> <method name="set_meshes"> <return type="void" /> - <param index="0" name="meshes" type="Array" /> + <param index="0" name="meshes" type="GLTFMesh[]" /> <description> </description> </method> <method name="set_nodes"> <return type="void" /> - <param index="0" name="nodes" type="Array" /> + <param index="0" name="nodes" type="GLTFNode[]" /> <description> </description> </method> @@ -162,31 +162,31 @@ </method> <method name="set_skeletons"> <return type="void" /> - <param index="0" name="skeletons" type="Array" /> + <param index="0" name="skeletons" type="GLTFSkeleton[]" /> <description> </description> </method> <method name="set_skins"> <return type="void" /> - <param index="0" name="skins" type="Array" /> + <param index="0" name="skins" type="GLTFSkin[]" /> <description> </description> </method> <method name="set_textures"> <return type="void" /> - <param index="0" name="textures" type="Array" /> + <param index="0" name="textures" type="GLTFTexture[]" /> <description> </description> </method> <method name="set_unique_animation_names"> <return type="void" /> - <param index="0" name="unique_animation_names" type="Array" /> + <param index="0" name="unique_animation_names" type="String[]" /> <description> </description> </method> <method name="set_unique_names"> <return type="void" /> - <param index="0" name="unique_names" type="Array" /> + <param index="0" name="unique_names" type="String[]" /> <description> </description> </method> @@ -194,7 +194,7 @@ <members> <member name="base_path" type="String" setter="set_base_path" getter="get_base_path" default=""""> </member> - <member name="buffers" type="Array" setter="set_buffers" getter="get_buffers" default="[]"> + <member name="buffers" type="PackedByteArray[]" setter="set_buffers" getter="get_buffers" default="[]"> </member> <member name="create_animations" type="bool" setter="set_create_animations" getter="get_create_animations" default="true"> </member> @@ -206,7 +206,7 @@ </member> <member name="minor_version" type="int" setter="set_minor_version" getter="get_minor_version" default="0"> </member> - <member name="root_nodes" type="Array" setter="set_root_nodes" getter="get_root_nodes" default="[]"> + <member name="root_nodes" type="PackedInt32Array" setter="set_root_nodes" getter="get_root_nodes" default="PackedInt32Array()"> </member> <member name="scene_name" type="String" setter="set_scene_name" getter="get_scene_name" default=""""> </member> diff --git a/modules/gltf/gltf_state.cpp b/modules/gltf/gltf_state.cpp index 8212e4c22f..85bac446cc 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<GLTFNode> GLTFState::get_nodes() { return GLTFTemplateConvert::to_array(nodes); } -void GLTFState::set_nodes(Array p_nodes) { +void GLTFState::set_nodes(TypedArray<GLTFNode> p_nodes) { GLTFTemplateConvert::set_from_array(nodes, p_nodes); } -Array GLTFState::get_buffers() { +TypedArray<PackedByteArray> GLTFState::get_buffers() { return GLTFTemplateConvert::to_array(buffers); } -void GLTFState::set_buffers(Array p_buffers) { +void GLTFState::set_buffers(TypedArray<PackedByteArray> p_buffers) { GLTFTemplateConvert::set_from_array(buffers, p_buffers); } -Array GLTFState::get_buffer_views() { +TypedArray<GLTFBufferView> 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<GLTFBufferView> p_buffer_views) { GLTFTemplateConvert::set_from_array(buffer_views, p_buffer_views); } -Array GLTFState::get_accessors() { +TypedArray<GLTFAccessor> GLTFState::get_accessors() { return GLTFTemplateConvert::to_array(accessors); } -void GLTFState::set_accessors(Array p_accessors) { +void GLTFState::set_accessors(TypedArray<GLTFAccessor> p_accessors) { GLTFTemplateConvert::set_from_array(accessors, p_accessors); } -Array GLTFState::get_meshes() { +TypedArray<GLTFMesh> GLTFState::get_meshes() { return GLTFTemplateConvert::to_array(meshes); } -void GLTFState::set_meshes(Array p_meshes) { +void GLTFState::set_meshes(TypedArray<GLTFMesh> p_meshes) { GLTFTemplateConvert::set_from_array(meshes, p_meshes); } -Array GLTFState::get_materials() { +TypedArray<BaseMaterial3D> GLTFState::get_materials() { return GLTFTemplateConvert::to_array(materials); } -void GLTFState::set_materials(Array p_materials) { +void GLTFState::set_materials(TypedArray<BaseMaterial3D> 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<GLTFTexture> GLTFState::get_textures() { return GLTFTemplateConvert::to_array(textures); } -void GLTFState::set_textures(Array p_textures) { +void GLTFState::set_textures(TypedArray<GLTFTexture> p_textures) { GLTFTemplateConvert::set_from_array(textures, p_textures); } -Array GLTFState::get_images() { +TypedArray<Texture2D> GLTFState::get_images() { return GLTFTemplateConvert::to_array(images); } -void GLTFState::set_images(Array p_images) { +void GLTFState::set_images(TypedArray<Texture2D> p_images) { GLTFTemplateConvert::set_from_array(images, p_images); } -Array GLTFState::get_skins() { +TypedArray<GLTFSkin> GLTFState::get_skins() { return GLTFTemplateConvert::to_array(skins); } -void GLTFState::set_skins(Array p_skins) { +void GLTFState::set_skins(TypedArray<GLTFSkin> p_skins) { GLTFTemplateConvert::set_from_array(skins, p_skins); } -Array GLTFState::get_cameras() { +TypedArray<GLTFCamera> GLTFState::get_cameras() { return GLTFTemplateConvert::to_array(cameras); } -void GLTFState::set_cameras(Array p_cameras) { +void GLTFState::set_cameras(TypedArray<GLTFCamera> p_cameras) { GLTFTemplateConvert::set_from_array(cameras, p_cameras); } -Array GLTFState::get_lights() { +TypedArray<GLTFLight> GLTFState::get_lights() { return GLTFTemplateConvert::to_array(lights); } -void GLTFState::set_lights(Array p_lights) { +void GLTFState::set_lights(TypedArray<GLTFLight> p_lights) { GLTFTemplateConvert::set_from_array(lights, p_lights); } -Array GLTFState::get_unique_names() { +TypedArray<String> 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<String> p_unique_names) { GLTFTemplateConvert::set_from_array(unique_names, p_unique_names); } -Array GLTFState::get_unique_animation_names() { +TypedArray<String> 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<String> p_unique_animation_names) { GLTFTemplateConvert::set_from_array(unique_animation_names, p_unique_animation_names); } -Array GLTFState::get_skeletons() { +TypedArray<GLTFSkeleton> GLTFState::get_skeletons() { return GLTFTemplateConvert::to_array(skeletons); } -void GLTFState::set_skeletons(Array p_skeletons) { +void GLTFState::set_skeletons(TypedArray<GLTFSkeleton> 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<GLTFAnimation> GLTFState::get_animations() { return GLTFTemplateConvert::to_array(animations); } -void GLTFState::set_animations(Array p_animations) { +void GLTFState::set_animations(TypedArray<GLTFAnimation> p_animations) { GLTFTemplateConvert::set_from_array(animations, p_animations); } diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h index c08132f874..6b2d1ca228 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<GLTFNode> get_nodes(); + void set_nodes(TypedArray<GLTFNode> p_nodes); - Array get_buffers(); - void set_buffers(Array p_buffers); + TypedArray<PackedByteArray> get_buffers(); + void set_buffers(TypedArray<PackedByteArray> p_buffers); - Array get_buffer_views(); - void set_buffer_views(Array p_buffer_views); + TypedArray<GLTFBufferView> get_buffer_views(); + void set_buffer_views(TypedArray<GLTFBufferView> p_buffer_views); - Array get_accessors(); - void set_accessors(Array p_accessors); + TypedArray<GLTFAccessor> get_accessors(); + void set_accessors(TypedArray<GLTFAccessor> p_accessors); - Array get_meshes(); - void set_meshes(Array p_meshes); + TypedArray<GLTFMesh> get_meshes(); + void set_meshes(TypedArray<GLTFMesh> p_meshes); - Array get_materials(); - void set_materials(Array p_materials); + TypedArray<BaseMaterial3D> get_materials(); + void set_materials(TypedArray<BaseMaterial3D> 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<GLTFTexture> get_textures(); + void set_textures(TypedArray<GLTFTexture> p_textures); - Array get_images(); - void set_images(Array p_images); + TypedArray<Texture2D> get_images(); + void set_images(TypedArray<Texture2D> p_images); - Array get_skins(); - void set_skins(Array p_skins); + TypedArray<GLTFSkin> get_skins(); + void set_skins(TypedArray<GLTFSkin> p_skins); - Array get_cameras(); - void set_cameras(Array p_cameras); + TypedArray<GLTFCamera> get_cameras(); + void set_cameras(TypedArray<GLTFCamera> p_cameras); - Array get_lights(); - void set_lights(Array p_lights); + TypedArray<GLTFLight> get_lights(); + void set_lights(TypedArray<GLTFLight> p_lights); - Array get_unique_names(); - void set_unique_names(Array p_unique_names); + TypedArray<String> get_unique_names(); + void set_unique_names(TypedArray<String> p_unique_names); - Array get_unique_animation_names(); - void set_unique_animation_names(Array p_unique_names); + TypedArray<String> get_unique_animation_names(); + void set_unique_animation_names(TypedArray<String> p_unique_names); - Array get_skeletons(); - void set_skeletons(Array p_skeletons); + TypedArray<GLTFSkeleton> get_skeletons(); + void set_skeletons(TypedArray<GLTFSkeleton> 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<GLTFAnimation> get_animations(); + void set_animations(TypedArray<GLTFAnimation> 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 c915d3deb0..8a4b595c9f 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<T> &p_inp) { } template <class T> -static Array to_array(const HashSet<T> &p_inp) { - Array ret; +static TypedArray<T> to_array(const HashSet<T> &p_inp) { + TypedArray<T> ret; typename HashSet<T>::Iterator elem = p_inp.begin(); while (elem) { ret.push_back(*elem); @@ -65,7 +65,7 @@ static void set_from_array(Vector<T> &r_out, const Array &p_inp) { } template <class T> -static void set_from_array(HashSet<T> &r_out, const Array &p_inp) { +static void set_from_array(HashSet<T> &r_out, const TypedArray<T> &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 90a6b0f50f..0073357eda 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<String> 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<String> 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 db88623213..0f20b493b6 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<String> get_unique_names(); + void set_unique_names(TypedArray<String> p_unique_names); //RBMap<int32_t, GLTFNodeIndex> 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 2e46ee3be2..9717a66048 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<GLTFNodeIndex> p_joints_original) { joints_original = p_joints_original; } -Array GLTFSkin::get_inverse_binds() { +TypedArray<Transform3D> 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<Transform3D> 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 59b6a300ac..1a4d54b380 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 <typename T> +class TypedArray; + class GLTFSkin : public Resource { GDCLASS(GLTFSkin, Resource); friend class GLTFDocument; @@ -82,8 +85,8 @@ public: Vector<GLTFNodeIndex> get_joints_original(); void set_joints_original(Vector<GLTFNodeIndex> p_joints_original); - Array get_inverse_binds(); - void set_inverse_binds(Array p_inverse_binds); + TypedArray<Transform3D> get_inverse_binds(); + void set_inverse_binds(TypedArray<Transform3D> p_inverse_binds); Vector<GLTFNodeIndex> get_joints(); void set_joints(Vector<GLTFNodeIndex> p_joints); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index bd60799c53..4a3a35383e 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -802,10 +802,10 @@ int TreeItem::get_child_count() { return children_cache.size(); } -Array TreeItem::get_children() { +TypedArray<TreeItem> 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<TreeItem> 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 bcc2419b80..7f9c00b1b9 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<TreeItem> get_children(); int get_index(); #ifdef DEV_ENABLED diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 347a04159c..a410cf0ed8 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<ObjectID> &ids) { - Array a; +static PackedInt64Array to_int_array(const Vector<ObjectID> &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<ObjectID> 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<ObjectID> 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<Plane> 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<ObjectID> 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<Dictionary> RenderingServer::_instance_geometry_get_shader_uniform_list(RID p_instance) const { List<PropertyInfo> 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 9e98f528d2..59887d7d37 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -1216,9 +1216,9 @@ public: virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const = 0; virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &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<Dictionary> &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<Dictionary> _instance_geometry_get_shader_uniform_list(RID p_instance) const; TypedArray<Image> _bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size); void _particles_set_trail_bind_poses(RID p_particles, const TypedArray<Transform3D> &p_bind_poses); }; diff --git a/servers/text/text_server_extension.cpp b/servers/text/text_server_extension.cpp index c53560523d..855267e428 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<Vector2i> TextServerExtension::parse_structured_text(StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const { + TypedArray<Vector2i> ret; if (GDVIRTUAL_CALL(parse_structured_text, p_parser_type, p_args, p_text, ret)) { return ret; } - return Array(); + return TypedArray<Vector2i>(); } 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 15cffdf152..7e1ed22390 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<Vector2i> parse_structured_text(StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const; + GDVIRTUAL3RC(TypedArray<Vector2i>, 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 7570143b43..66b32dba84 100644 --- a/servers/text_server.cpp +++ b/servers/text_server.cpp @@ -104,8 +104,8 @@ Ref<TextServer> TextServerManager::find_interface(const String &p_name) const { return interfaces[idx]; } -Array TextServerManager::get_interfaces() const { - Array ret; +TypedArray<Dictionary> TextServerManager::get_interfaces() const { + TypedArray<Dictionary> ret; for (int i = 0; i < interfaces.size(); i++) { Dictionary iface_info; @@ -1663,8 +1663,8 @@ TypedArray<Vector2i> TextServer::parse_structured_text(StructuredTextParser p_pa return ret; } -Array TextServer::_shaped_text_get_glyphs_wrapper(const RID &p_shaped) const { - Array ret; +TypedArray<Dictionary> TextServer::_shaped_text_get_glyphs_wrapper(const RID &p_shaped) const { + TypedArray<Dictionary> 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<Dictionary> 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<Dictionary> TextServer::_shaped_text_get_ellipsis_glyphs_wrapper(const RID &p_shaped) const { + TypedArray<Dictionary> 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 6360cc1726..9ffc2984d1 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<Dictionary> _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<Dictionary> _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<Dictionary> _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<TextServer::TextOverrunFlag> p_trim_flags) = 0; @@ -541,7 +541,7 @@ public: int get_interface_count() const; Ref<TextServer> get_interface(int p_index) const; Ref<TextServer> find_interface(const String &p_name) const; - Array get_interfaces() const; + TypedArray<Dictionary> get_interfaces() const; _FORCE_INLINE_ Ref<TextServer> get_primary_interface() const { return primary_interface; diff --git a/servers/xr_server.cpp b/servers/xr_server.cpp index 990281d96d..e26212ada1 100644 --- a/servers/xr_server.cpp +++ b/servers/xr_server.cpp @@ -226,7 +226,7 @@ Ref<XRInterface> XRServer::find_interface(const String &p_name) const { return interfaces[idx]; }; -Array XRServer::get_interfaces() const { +TypedArray<Dictionary> 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 74128bfb54..57e42deccb 100644 --- a/servers/xr_server.h +++ b/servers/xr_server.h @@ -157,7 +157,7 @@ public: int get_interface_count() const; Ref<XRInterface> get_interface(int p_index) const; Ref<XRInterface> find_interface(const String &p_name) const; - Array get_interfaces() const; + TypedArray<Dictionary> get_interfaces() const; /* note, more then one interface can technically be active, especially on mobile, but only one interface is used for |