From 344e5f5745bba8bf6657b9da48099bd2fc683755 Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Sun, 8 Sep 2024 17:21:33 -0500 Subject: [PATCH] Core: Migrate typed container logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Dedicated typed container files entirely removed • Typed container classes now defined in their base headers; methods declared in `variant.h` • Consolidate to a single template for both typed containers, thanks to `constexpr` • Nest private containers in their base classes --- core/config/engine.cpp | 1 - core/config/engine.h | 3 - core/config/project_settings.cpp | 1 - core/config/project_settings.h | 3 - core/core_bind.cpp | 1 - core/core_bind.h | 2 - core/input/input.h | 1 - core/input/input_map.cpp | 1 - core/input/input_map.h | 3 - core/io/ip.cpp | 1 - core/io/ip.h | 3 - core/math/a_star_grid_2d.compat.inc | 2 - core/math/a_star_grid_2d.cpp | 2 - core/object/object.cpp | 1 - core/object/object.h | 3 - core/object/script_language.h | 3 - core/object/script_language_extension.h | 1 - core/typedefs.h | 5 + core/variant/array.cpp | 3 +- core/variant/array.h | 11 +- core/variant/dictionary.cpp | 2 +- core/variant/dictionary.h | 15 +- core/variant/method_ptrcall.h | 46 +++ core/variant/type_info.h | 75 +++- core/variant/typed_array.h | 255 ------------- core/variant/typed_dictionary.h | 342 ------------------ core/variant/variant.h | 150 ++++++++ core/variant/variant_internal.h | 12 + editor/editor_translation_parser.h | 1 - editor/editor_vcs_interface.h | 1 - editor/import/editor_import_plugin.h | 1 - main/performance.cpp | 1 - main/performance.h | 3 - modules/enet/enet_connection.cpp | 1 - modules/enet/enet_connection.h | 3 - .../gdscript/gdscript_utility_functions.cpp | 1 - modules/gdscript/gdscript_utility_functions.h | 3 - modules/gltf/gltf_template_convert.h | 1 - .../structures/gltf_object_model_property.h | 1 - modules/gltf/structures/gltf_skin.cpp | 1 - modules/gltf/structures/gltf_skin.h | 3 - modules/multiplayer/multiplayer_spawner.h | 1 - .../multiplayer/scene_replication_config.h | 1 - modules/noise/noise.h | 1 - modules/ogg/ogg_packet_sequence.cpp | 2 - modules/ogg/ogg_packet_sequence.h | 1 - .../openxr_extension_wrapper_extension.h | 1 - modules/regex/regex.h | 1 - modules/vorbis/audio_stream_ogg_vorbis.cpp | 1 - platform/android/api/java_class_wrapper.h | 1 - platform/android/java_godot_io_wrapper.h | 1 - platform/macos/godot_open_save_delegate.h | 1 - scene/main/node.h | 1 - scene/resources/animation_library.h | 1 - scene/resources/bit_map.cpp | 1 - scene/resources/bit_map.h | 3 - servers/audio/audio_stream.h | 1 - servers/camera_server.cpp | 1 - servers/camera_server.h | 2 - .../extensions/physics_server_2d_extension.h | 1 - .../extensions/physics_server_3d_extension.h | 1 - .../navigation_path_query_result_3d.h | 1 - servers/navigation/navigation_utilities.h | 3 +- servers/physics_server_2d.cpp | 1 - servers/physics_server_2d.h | 2 - servers/physics_server_3d.cpp | 1 - servers/physics_server_3d.h | 2 - servers/rendering/rendering_device.h | 1 - servers/rendering_server.cpp | 1 - servers/rendering_server.h | 4 - servers/text/text_server_extension.h | 1 - servers/text_server.cpp | 1 - servers/text_server.h | 3 - tests/core/variant/test_dictionary.h | 1 - 74 files changed, 311 insertions(+), 704 deletions(-) delete mode 100644 core/variant/typed_array.h delete mode 100644 core/variant/typed_dictionary.h diff --git a/core/config/engine.cpp b/core/config/engine.cpp index aac048e93f7e..ed47abc898ba 100644 --- a/core/config/engine.cpp +++ b/core/config/engine.cpp @@ -34,7 +34,6 @@ #include "core/config/project_settings.h" #include "core/donors.gen.h" #include "core/license.gen.h" -#include "core/variant/typed_array.h" #include "core/version.h" #include "servers/rendering/rendering_device.h" diff --git a/core/config/engine.h b/core/config/engine.h index b38412308ae7..ff5366e7b3a2 100644 --- a/core/config/engine.h +++ b/core/config/engine.h @@ -36,9 +36,6 @@ #include "core/templates/list.h" #include "core/templates/vector.h" -template -class TypedArray; - class Engine { public: struct Singleton { diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 6c28b00f4870..5f7dc7e8eb5d 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -41,7 +41,6 @@ #include "core/object/script_language.h" #include "core/os/keyboard.h" #include "core/templates/rb_set.h" -#include "core/variant/typed_array.h" #include "core/variant/variant_parser.h" #include "core/version.h" diff --git a/core/config/project_settings.h b/core/config/project_settings.h index 922c88c15132..c98e1baa5c6b 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -33,9 +33,6 @@ #include "core/object/class_db.h" -template -class TypedArray; - class ProjectSettings : public Object { GDCLASS(ProjectSettings, Object); _THREAD_SAFE_CLASS_ diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 925551d933fe..bd14ef24301d 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -42,7 +42,6 @@ #include "core/math/geometry_3d.h" #include "core/os/keyboard.h" #include "core/os/thread_safe.h" -#include "core/variant/typed_array.h" namespace core_bind { diff --git a/core/core_bind.h b/core/core_bind.h index d013e348bd87..3ce1533b61ba 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -41,8 +41,6 @@ #include "core/templates/safe_refcount.h" class MainLoop; -template -class TypedArray; namespace core_bind { diff --git a/core/input/input.h b/core/input/input.h index a189ae7d9ada..7a218e162965 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -36,7 +36,6 @@ #include "core/os/keyboard.h" #include "core/os/thread_safe.h" #include "core/templates/rb_set.h" -#include "core/variant/typed_array.h" class Input : public Object { GDCLASS(Input, Object); diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index abd2c80ce1ce..abcc03237e3b 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -35,7 +35,6 @@ #include "core/input/input.h" #include "core/os/keyboard.h" #include "core/os/os.h" -#include "core/variant/typed_array.h" InputMap *InputMap::singleton = nullptr; diff --git a/core/input/input_map.h b/core/input/input_map.h index 0479d45c57b5..5e1824f2aee9 100644 --- a/core/input/input_map.h +++ b/core/input/input_map.h @@ -36,9 +36,6 @@ #include "core/object/object.h" #include "core/templates/hash_map.h" -template -class TypedArray; - class InputMap : public Object { GDCLASS(InputMap, Object); diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 3c67a8f89429..3559eaa83806 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -33,7 +33,6 @@ #include "core/os/semaphore.h" #include "core/os/thread.h" #include "core/templates/hash_map.h" -#include "core/variant/typed_array.h" /************* RESOLVER ******************/ diff --git a/core/io/ip.h b/core/io/ip.h index 4816d59ac2df..937f501862db 100644 --- a/core/io/ip.h +++ b/core/io/ip.h @@ -34,9 +34,6 @@ #include "core/io/ip_address.h" #include "core/os/os.h" -template -class TypedArray; - struct _IP_ResolverPrivate; class IP : public Object { diff --git a/core/math/a_star_grid_2d.compat.inc b/core/math/a_star_grid_2d.compat.inc index e7124c2477b5..6761148b7eb9 100644 --- a/core/math/a_star_grid_2d.compat.inc +++ b/core/math/a_star_grid_2d.compat.inc @@ -30,8 +30,6 @@ #ifndef DISABLE_DEPRECATED -#include "core/variant/typed_array.h" - TypedArray AStarGrid2D::_get_id_path_bind_compat_88047(const Vector2i &p_from_id, const Vector2i &p_to_id) { return get_id_path(p_from_id, p_to_id, false); } diff --git a/core/math/a_star_grid_2d.cpp b/core/math/a_star_grid_2d.cpp index 7e0e982c6244..2bd8c451b5d7 100644 --- a/core/math/a_star_grid_2d.cpp +++ b/core/math/a_star_grid_2d.cpp @@ -31,8 +31,6 @@ #include "a_star_grid_2d.h" #include "a_star_grid_2d.compat.inc" -#include "core/variant/typed_array.h" - static real_t heuristic_euclidean(const Vector2i &p_from, const Vector2i &p_to) { real_t dx = (real_t)ABS(p_to.x - p_from.x); real_t dy = (real_t)ABS(p_to.y - p_from.y); diff --git a/core/object/object.cpp b/core/object/object.cpp index ef1ca8132cbd..da4188522283 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -39,7 +39,6 @@ #include "core/string/print_string.h" #include "core/string/translation_server.h" #include "core/templates/local_vector.h" -#include "core/variant/typed_array.h" #ifdef DEBUG_ENABLED diff --git a/core/object/object.h b/core/object/object.h index 11b94a7fbf0a..91f6c1a3f422 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -44,9 +44,6 @@ #include "core/variant/callable_bind.h" #include "core/variant/variant.h" -template -class TypedArray; - enum PropertyHint { PROPERTY_HINT_NONE, ///< no hint provided. PROPERTY_HINT_RANGE, ///< hint_text = "min,max[,step][,or_greater][,or_less][,hide_slider][,radians_as_degrees][,degrees][,exp][,suffix:] range. diff --git a/core/object/script_language.h b/core/object/script_language.h index 31d6638e58e8..fe3337733d1c 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -37,11 +37,8 @@ #include "core/templates/pair.h" #include "core/templates/rb_map.h" #include "core/templates/safe_refcount.h" -#include "core/variant/typed_array.h" class ScriptLanguage; -template -class TypedArray; typedef void (*ScriptEditRequestFunction)(const String &p_path); diff --git a/core/object/script_language_extension.h b/core/object/script_language_extension.h index d2dce34d4fed..545d79b706a6 100644 --- a/core/object/script_language_extension.h +++ b/core/object/script_language_extension.h @@ -35,7 +35,6 @@ #include "core/object/gdvirtual.gen.inc" #include "core/object/script_language.h" #include "core/variant/native_ptr.h" -#include "core/variant/typed_array.h" class ScriptExtension : public Script { GDCLASS(ScriptExtension, Script) diff --git a/core/typedefs.h b/core/typedefs.h index 35c4668581ba..b5aff0e4d268 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -54,6 +54,11 @@ static_assert(__cplusplus >= 201703L); #define _MKSTR(m_x) _STR(m_x) #endif +// Allow comma separators within macros. +#ifndef _COMMA +#define _COMMA , +#endif + // Should always inline no matter what. #ifndef _ALWAYS_INLINE_ #if defined(__GNUC__) diff --git a/core/variant/array.cpp b/core/variant/array.cpp index f7a86b8fa386..0f0374967d32 100644 --- a/core/variant/array.cpp +++ b/core/variant/array.cpp @@ -41,8 +41,7 @@ #include "core/variant/dictionary.h" #include "core/variant/variant.h" -class ArrayPrivate { -public: +struct Array::ArrayPrivate { SafeRefCount refcount; Vector array; Variant *read_only = nullptr; // If enabled, a pointer is used to a temporary value that is used to return read-only values. diff --git a/core/variant/array.h b/core/variant/array.h index 6c3bae6ccb35..c610c028b6c0 100644 --- a/core/variant/array.h +++ b/core/variant/array.h @@ -36,12 +36,12 @@ #include class Variant; -class ArrayPrivate; class Object; class StringName; class Callable; class Array { + struct ArrayPrivate; mutable ArrayPrivate *_p; void _unref() const; @@ -203,4 +203,13 @@ class Array { ~Array(); }; +template +class TypedArray : public Array { +public: + _FORCE_INLINE_ void operator=(const Array &p_array); + _FORCE_INLINE_ TypedArray(const Variant &p_variant); + _FORCE_INLINE_ TypedArray(const Array &p_array); + _FORCE_INLINE_ TypedArray(); +}; + #endif // ARRAY_H diff --git a/core/variant/dictionary.cpp b/core/variant/dictionary.cpp index 501ca6920558..93936dd43596 100644 --- a/core/variant/dictionary.cpp +++ b/core/variant/dictionary.cpp @@ -40,7 +40,7 @@ #include "core/variant/type_info.h" #include "core/variant/variant_internal.h" -struct DictionaryPrivate { +struct Dictionary::DictionaryPrivate { SafeRefCount refcount; Variant *read_only = nullptr; // If enabled, a pointer is used to a temporary value that is used to return read-only values. HashMap variant_map; diff --git a/core/variant/dictionary.h b/core/variant/dictionary.h index bbfb5b30837d..ca96cad5a1b6 100644 --- a/core/variant/dictionary.h +++ b/core/variant/dictionary.h @@ -31,15 +31,11 @@ #ifndef DICTIONARY_H #define DICTIONARY_H -#include "core/string/ustring.h" #include "core/templates/list.h" #include "core/variant/array.h" -class Variant; - -struct DictionaryPrivate; - class Dictionary { + struct DictionaryPrivate; mutable DictionaryPrivate *_p; void _ref(const Dictionary &p_from) const; @@ -116,4 +112,13 @@ class Dictionary { ~Dictionary(); }; +template +class TypedDictionary : public Dictionary { +public: + _FORCE_INLINE_ void operator=(const Dictionary &p_dictionary); + _FORCE_INLINE_ TypedDictionary(const Variant &p_variant); + _FORCE_INLINE_ TypedDictionary(const Dictionary &p_dictionary); + _FORCE_INLINE_ TypedDictionary(); +}; + #endif // DICTIONARY_H diff --git a/core/variant/method_ptrcall.h b/core/variant/method_ptrcall.h index 1e10709b12bd..a3bfb7aea351 100644 --- a/core/variant/method_ptrcall.h +++ b/core/variant/method_ptrcall.h @@ -192,6 +192,52 @@ struct PtrToArg { } }; +// This is for typed containers. + +template +struct PtrToArg> { + _FORCE_INLINE_ static TypedArray convert(const void *p_ptr) { + return TypedArray(*reinterpret_cast(p_ptr)); + } + typedef Array EncodeT; + _FORCE_INLINE_ static void encode(TypedArray p_val, void *p_ptr) { + *(Array *)p_ptr = p_val; + } +}; + +template +struct PtrToArg &> { + _FORCE_INLINE_ static TypedArray convert(const void *p_ptr) { + return TypedArray(*reinterpret_cast(p_ptr)); + } + typedef Array EncodeT; + _FORCE_INLINE_ static void encode(TypedArray p_val, void *p_ptr) { + *(Array *)p_ptr = p_val; + } +}; + +template +struct PtrToArg> { + _FORCE_INLINE_ static TypedDictionary convert(const void *p_ptr) { + return TypedDictionary(*reinterpret_cast(p_ptr)); + } + typedef Dictionary EncodeT; + _FORCE_INLINE_ static void encode(TypedDictionary p_val, void *p_ptr) { + *(Dictionary *)p_ptr = p_val; + } +}; + +template +struct PtrToArg &> { + _FORCE_INLINE_ static TypedDictionary convert(const void *p_ptr) { + return TypedDictionary(*reinterpret_cast(p_ptr)); + } + typedef Dictionary EncodeT; + _FORCE_INLINE_ static void encode(TypedDictionary p_val, void *p_ptr) { + *(Dictionary *)p_ptr = p_val; + } +}; + // This is for the special cases used by Variant. // No EncodeT because direct pointer conversion not possible. diff --git a/core/variant/type_info.h b/core/variant/type_info.h index 6bb703f2dd6e..5e35adada542 100644 --- a/core/variant/type_info.h +++ b/core/variant/type_info.h @@ -31,7 +31,7 @@ #ifndef TYPE_INFO_H #define TYPE_INFO_H -#include "core/typedefs.h" +#include "core/object/object.h" #include @@ -148,6 +148,79 @@ MAKE_TYPE_INFO(PackedVector4Array, Variant::PACKED_VECTOR4_ARRAY) MAKE_TYPE_INFO(IPAddress, Variant::STRING) +// Typed containers. +template +struct GetTypeInfo> { + static const Variant::Type VARIANT_TYPE = Variant::ARRAY; + static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; + static inline PropertyInfo get_class_info() { + String hint_string; + if constexpr (GTI::variant_type_v == Variant::OBJECT) { + hint_string = T::get_class_static(); + } else { + hint_string = Variant::get_type_name(GTI::variant_type_v); + } + return PropertyInfo(VARIANT_TYPE, String(), PROPERTY_HINT_ARRAY_TYPE, hint_string); + } +}; + +template +struct GetTypeInfo &> { + static const Variant::Type VARIANT_TYPE = Variant::ARRAY; + static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; + static inline PropertyInfo get_class_info() { + String hint_string; + if constexpr (GTI::variant_type_v == Variant::OBJECT) { + hint_string = T::get_class_static(); + } else { + hint_string = Variant::get_type_name(GTI::variant_type_v); + } + return PropertyInfo(VARIANT_TYPE, String(), PROPERTY_HINT_ARRAY_TYPE, hint_string); + } +}; + +template +struct GetTypeInfo> { + static const Variant::Type VARIANT_TYPE = Variant::DICTIONARY; + static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; + static inline PropertyInfo get_class_info() { + String hint_key; + if constexpr (GTI::variant_type_v == Variant::OBJECT) { + hint_key = K::get_class_static(); + } else { + hint_key = GTI::variant_type_v == Variant::NIL ? "Variant" : Variant::get_type_name(GTI::variant_type_v); + } + String hint_value; + if constexpr (GTI::variant_type_v == Variant::OBJECT) { + hint_value = V::get_class_static(); + } else { + hint_value = GTI::variant_type_v == Variant::NIL ? "Variant" : Variant::get_type_name(GTI::variant_type_v); + } + return PropertyInfo(VARIANT_TYPE, String(), PROPERTY_HINT_DICTIONARY_TYPE, vformat("%s;%s", hint_key, hint_value)); + } +}; + +template +struct GetTypeInfo &> { + static const Variant::Type VARIANT_TYPE = Variant::DICTIONARY; + static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; + static inline PropertyInfo get_class_info() { + String hint_key; + if constexpr (GTI::variant_type_v == Variant::OBJECT) { + hint_key = K::get_class_static(); + } else { + hint_key = GTI::variant_type_v == Variant::NIL ? "Variant" : Variant::get_type_name(GTI::variant_type_v); + } + String hint_value; + if constexpr (GTI::variant_type_v == Variant::OBJECT) { + hint_value = V::get_class_static(); + } else { + hint_value = GTI::variant_type_v == Variant::NIL ? "Variant" : Variant::get_type_name(GTI::variant_type_v); + } + return PropertyInfo(VARIANT_TYPE, String(), PROPERTY_HINT_DICTIONARY_TYPE, vformat("%s;%s", hint_key, hint_value)); + } +}; + //objectID template <> struct GetTypeInfo { diff --git a/core/variant/typed_array.h b/core/variant/typed_array.h deleted file mode 100644 index 07bf8afa7b7b..000000000000 --- a/core/variant/typed_array.h +++ /dev/null @@ -1,255 +0,0 @@ -/**************************************************************************/ -/* typed_array.h */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -#ifndef TYPED_ARRAY_H -#define TYPED_ARRAY_H - -#include "core/object/object.h" -#include "core/variant/array.h" -#include "core/variant/binder_common.h" -#include "core/variant/method_ptrcall.h" -#include "core/variant/type_info.h" -#include "core/variant/variant.h" - -template -class TypedArray : public Array { -public: - _FORCE_INLINE_ void operator=(const Array &p_array) { - ERR_FAIL_COND_MSG(!is_same_typed(p_array), "Cannot assign an array with a different element type."); - _ref(p_array); - } - _FORCE_INLINE_ TypedArray(const Variant &p_variant) : - TypedArray(Array(p_variant)) { - } - _FORCE_INLINE_ TypedArray(const Array &p_array) { - set_typed(Variant::OBJECT, T::get_class_static(), Variant()); - if (is_same_typed(p_array)) { - _ref(p_array); - } else { - assign(p_array); - } - } - _FORCE_INLINE_ TypedArray() { - set_typed(Variant::OBJECT, T::get_class_static(), Variant()); - } -}; - -template -struct VariantInternalAccessor> { - static _FORCE_INLINE_ TypedArray get(const Variant *v) { return *VariantInternal::get_array(v); } - static _FORCE_INLINE_ void set(Variant *v, const TypedArray &p_array) { *VariantInternal::get_array(v) = p_array; } -}; -template -struct VariantInternalAccessor &> { - static _FORCE_INLINE_ TypedArray get(const Variant *v) { return *VariantInternal::get_array(v); } - static _FORCE_INLINE_ void set(Variant *v, const TypedArray &p_array) { *VariantInternal::get_array(v) = p_array; } -}; - -//specialization for the rest of variant types - -#define MAKE_TYPED_ARRAY(m_type, m_variant_type) \ - template <> \ - class TypedArray : public Array { \ - public: \ - _FORCE_INLINE_ void operator=(const Array &p_array) { \ - ERR_FAIL_COND_MSG(!is_same_typed(p_array), "Cannot assign an array with a different element type."); \ - _ref(p_array); \ - } \ - _FORCE_INLINE_ TypedArray(const Variant &p_variant) : \ - TypedArray(Array(p_variant)) { \ - } \ - _FORCE_INLINE_ TypedArray(const Array &p_array) { \ - set_typed(m_variant_type, StringName(), Variant()); \ - if (is_same_typed(p_array)) { \ - _ref(p_array); \ - } else { \ - assign(p_array); \ - } \ - } \ - _FORCE_INLINE_ TypedArray() { \ - set_typed(m_variant_type, StringName(), Variant()); \ - } \ - }; - -// All Variant::OBJECT types are intentionally omitted from this list because they are handled by -// the unspecialized TypedArray definition. -MAKE_TYPED_ARRAY(bool, Variant::BOOL) -MAKE_TYPED_ARRAY(uint8_t, Variant::INT) -MAKE_TYPED_ARRAY(int8_t, Variant::INT) -MAKE_TYPED_ARRAY(uint16_t, Variant::INT) -MAKE_TYPED_ARRAY(int16_t, Variant::INT) -MAKE_TYPED_ARRAY(uint32_t, Variant::INT) -MAKE_TYPED_ARRAY(int32_t, Variant::INT) -MAKE_TYPED_ARRAY(uint64_t, Variant::INT) -MAKE_TYPED_ARRAY(int64_t, Variant::INT) -MAKE_TYPED_ARRAY(float, Variant::FLOAT) -MAKE_TYPED_ARRAY(double, Variant::FLOAT) -MAKE_TYPED_ARRAY(String, Variant::STRING) -MAKE_TYPED_ARRAY(Vector2, Variant::VECTOR2) -MAKE_TYPED_ARRAY(Vector2i, Variant::VECTOR2I) -MAKE_TYPED_ARRAY(Rect2, Variant::RECT2) -MAKE_TYPED_ARRAY(Rect2i, Variant::RECT2I) -MAKE_TYPED_ARRAY(Vector3, Variant::VECTOR3) -MAKE_TYPED_ARRAY(Vector3i, Variant::VECTOR3I) -MAKE_TYPED_ARRAY(Transform2D, Variant::TRANSFORM2D) -MAKE_TYPED_ARRAY(Vector4, Variant::VECTOR4) -MAKE_TYPED_ARRAY(Vector4i, Variant::VECTOR4I) -MAKE_TYPED_ARRAY(Plane, Variant::PLANE) -MAKE_TYPED_ARRAY(Quaternion, Variant::QUATERNION) -MAKE_TYPED_ARRAY(AABB, Variant::AABB) -MAKE_TYPED_ARRAY(Basis, Variant::BASIS) -MAKE_TYPED_ARRAY(Transform3D, Variant::TRANSFORM3D) -MAKE_TYPED_ARRAY(Projection, Variant::PROJECTION) -MAKE_TYPED_ARRAY(Color, Variant::COLOR) -MAKE_TYPED_ARRAY(StringName, Variant::STRING_NAME) -MAKE_TYPED_ARRAY(NodePath, Variant::NODE_PATH) -MAKE_TYPED_ARRAY(RID, Variant::RID) -MAKE_TYPED_ARRAY(Callable, Variant::CALLABLE) -MAKE_TYPED_ARRAY(Signal, Variant::SIGNAL) -MAKE_TYPED_ARRAY(Dictionary, Variant::DICTIONARY) -MAKE_TYPED_ARRAY(Array, Variant::ARRAY) -MAKE_TYPED_ARRAY(PackedByteArray, Variant::PACKED_BYTE_ARRAY) -MAKE_TYPED_ARRAY(PackedInt32Array, Variant::PACKED_INT32_ARRAY) -MAKE_TYPED_ARRAY(PackedInt64Array, Variant::PACKED_INT64_ARRAY) -MAKE_TYPED_ARRAY(PackedFloat32Array, Variant::PACKED_FLOAT32_ARRAY) -MAKE_TYPED_ARRAY(PackedFloat64Array, Variant::PACKED_FLOAT64_ARRAY) -MAKE_TYPED_ARRAY(PackedStringArray, Variant::PACKED_STRING_ARRAY) -MAKE_TYPED_ARRAY(PackedVector2Array, Variant::PACKED_VECTOR2_ARRAY) -MAKE_TYPED_ARRAY(PackedVector3Array, Variant::PACKED_VECTOR3_ARRAY) -MAKE_TYPED_ARRAY(PackedColorArray, Variant::PACKED_COLOR_ARRAY) -MAKE_TYPED_ARRAY(PackedVector4Array, Variant::PACKED_VECTOR4_ARRAY) -MAKE_TYPED_ARRAY(IPAddress, Variant::STRING) - -template -struct PtrToArg> { - _FORCE_INLINE_ static TypedArray convert(const void *p_ptr) { - return TypedArray(*reinterpret_cast(p_ptr)); - } - typedef Array EncodeT; - _FORCE_INLINE_ static void encode(TypedArray p_val, void *p_ptr) { - *(Array *)p_ptr = p_val; - } -}; - -template -struct PtrToArg &> { - typedef Array EncodeT; - _FORCE_INLINE_ static TypedArray convert(const void *p_ptr) { - return TypedArray(*reinterpret_cast(p_ptr)); - } -}; - -template -struct GetTypeInfo> { - static const Variant::Type VARIANT_TYPE = Variant::ARRAY; - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; - static inline PropertyInfo get_class_info() { - return PropertyInfo(Variant::ARRAY, String(), PROPERTY_HINT_ARRAY_TYPE, T::get_class_static()); - } -}; - -template -struct GetTypeInfo &> { - static const Variant::Type VARIANT_TYPE = Variant::ARRAY; - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; - static inline PropertyInfo get_class_info() { - return PropertyInfo(Variant::ARRAY, String(), PROPERTY_HINT_ARRAY_TYPE, T::get_class_static()); - } -}; - -#define MAKE_TYPED_ARRAY_INFO(m_type, m_variant_type) \ - template <> \ - struct GetTypeInfo> { \ - static const Variant::Type VARIANT_TYPE = Variant::ARRAY; \ - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo(Variant::ARRAY, String(), PROPERTY_HINT_ARRAY_TYPE, Variant::get_type_name(m_variant_type)); \ - } \ - }; \ - template <> \ - struct GetTypeInfo &> { \ - static const Variant::Type VARIANT_TYPE = Variant::ARRAY; \ - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo(Variant::ARRAY, String(), PROPERTY_HINT_ARRAY_TYPE, Variant::get_type_name(m_variant_type)); \ - } \ - }; - -MAKE_TYPED_ARRAY_INFO(bool, Variant::BOOL) -MAKE_TYPED_ARRAY_INFO(uint8_t, Variant::INT) -MAKE_TYPED_ARRAY_INFO(int8_t, Variant::INT) -MAKE_TYPED_ARRAY_INFO(uint16_t, Variant::INT) -MAKE_TYPED_ARRAY_INFO(int16_t, Variant::INT) -MAKE_TYPED_ARRAY_INFO(uint32_t, Variant::INT) -MAKE_TYPED_ARRAY_INFO(int32_t, Variant::INT) -MAKE_TYPED_ARRAY_INFO(uint64_t, Variant::INT) -MAKE_TYPED_ARRAY_INFO(int64_t, Variant::INT) -MAKE_TYPED_ARRAY_INFO(float, Variant::FLOAT) -MAKE_TYPED_ARRAY_INFO(double, Variant::FLOAT) -MAKE_TYPED_ARRAY_INFO(String, Variant::STRING) -MAKE_TYPED_ARRAY_INFO(Vector2, Variant::VECTOR2) -MAKE_TYPED_ARRAY_INFO(Vector2i, Variant::VECTOR2I) -MAKE_TYPED_ARRAY_INFO(Rect2, Variant::RECT2) -MAKE_TYPED_ARRAY_INFO(Rect2i, Variant::RECT2I) -MAKE_TYPED_ARRAY_INFO(Vector3, Variant::VECTOR3) -MAKE_TYPED_ARRAY_INFO(Vector3i, Variant::VECTOR3I) -MAKE_TYPED_ARRAY_INFO(Transform2D, Variant::TRANSFORM2D) -MAKE_TYPED_ARRAY_INFO(Vector4, Variant::VECTOR4) -MAKE_TYPED_ARRAY_INFO(Vector4i, Variant::VECTOR4I) -MAKE_TYPED_ARRAY_INFO(Plane, Variant::PLANE) -MAKE_TYPED_ARRAY_INFO(Quaternion, Variant::QUATERNION) -MAKE_TYPED_ARRAY_INFO(AABB, Variant::AABB) -MAKE_TYPED_ARRAY_INFO(Basis, Variant::BASIS) -MAKE_TYPED_ARRAY_INFO(Transform3D, Variant::TRANSFORM3D) -MAKE_TYPED_ARRAY_INFO(Projection, Variant::PROJECTION) -MAKE_TYPED_ARRAY_INFO(Color, Variant::COLOR) -MAKE_TYPED_ARRAY_INFO(StringName, Variant::STRING_NAME) -MAKE_TYPED_ARRAY_INFO(NodePath, Variant::NODE_PATH) -MAKE_TYPED_ARRAY_INFO(RID, Variant::RID) -MAKE_TYPED_ARRAY_INFO(Callable, Variant::CALLABLE) -MAKE_TYPED_ARRAY_INFO(Signal, Variant::SIGNAL) -MAKE_TYPED_ARRAY_INFO(Dictionary, Variant::DICTIONARY) -MAKE_TYPED_ARRAY_INFO(Array, Variant::ARRAY) -MAKE_TYPED_ARRAY_INFO(PackedByteArray, Variant::PACKED_BYTE_ARRAY) -MAKE_TYPED_ARRAY_INFO(PackedInt32Array, Variant::PACKED_INT32_ARRAY) -MAKE_TYPED_ARRAY_INFO(PackedInt64Array, Variant::PACKED_INT64_ARRAY) -MAKE_TYPED_ARRAY_INFO(PackedFloat32Array, Variant::PACKED_FLOAT32_ARRAY) -MAKE_TYPED_ARRAY_INFO(PackedFloat64Array, Variant::PACKED_FLOAT64_ARRAY) -MAKE_TYPED_ARRAY_INFO(PackedStringArray, Variant::PACKED_STRING_ARRAY) -MAKE_TYPED_ARRAY_INFO(PackedVector2Array, Variant::PACKED_VECTOR2_ARRAY) -MAKE_TYPED_ARRAY_INFO(PackedVector3Array, Variant::PACKED_VECTOR3_ARRAY) -MAKE_TYPED_ARRAY_INFO(PackedColorArray, Variant::PACKED_COLOR_ARRAY) -MAKE_TYPED_ARRAY_INFO(PackedVector4Array, Variant::PACKED_VECTOR4_ARRAY) -MAKE_TYPED_ARRAY_INFO(IPAddress, Variant::STRING) - -#undef MAKE_TYPED_ARRAY -#undef MAKE_TYPED_ARRAY_INFO - -#endif // TYPED_ARRAY_H diff --git a/core/variant/typed_dictionary.h b/core/variant/typed_dictionary.h deleted file mode 100644 index 67fc33b4fc73..000000000000 --- a/core/variant/typed_dictionary.h +++ /dev/null @@ -1,342 +0,0 @@ -/**************************************************************************/ -/* typed_dictionary.h */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -#ifndef TYPED_DICTIONARY_H -#define TYPED_DICTIONARY_H - -#include "core/object/object.h" -#include "core/variant/binder_common.h" -#include "core/variant/dictionary.h" -#include "core/variant/method_ptrcall.h" -#include "core/variant/type_info.h" -#include "core/variant/variant.h" - -template -class TypedDictionary : public Dictionary { -public: - _FORCE_INLINE_ void operator=(const Dictionary &p_dictionary) { - ERR_FAIL_COND_MSG(!is_same_typed(p_dictionary), "Cannot assign a dictionary with a different element type."); - Dictionary::operator=(p_dictionary); - } - _FORCE_INLINE_ TypedDictionary(const Variant &p_variant) : - TypedDictionary(Dictionary(p_variant)) { - } - _FORCE_INLINE_ TypedDictionary(const Dictionary &p_dictionary) { - set_typed(Variant::OBJECT, K::get_class_static(), Variant(), Variant::OBJECT, V::get_class_static(), Variant()); - if (is_same_typed(p_dictionary)) { - Dictionary::operator=(p_dictionary); - } else { - assign(p_dictionary); - } - } - _FORCE_INLINE_ TypedDictionary() { - set_typed(Variant::OBJECT, K::get_class_static(), Variant(), Variant::OBJECT, V::get_class_static(), Variant()); - } -}; - -template -struct VariantInternalAccessor> { - static _FORCE_INLINE_ TypedDictionary get(const Variant *v) { return *VariantInternal::get_dictionary(v); } - static _FORCE_INLINE_ void set(Variant *v, const TypedDictionary &p_dictionary) { *VariantInternal::get_dictionary(v) = p_dictionary; } -}; - -template -struct VariantInternalAccessor &> { - static _FORCE_INLINE_ TypedDictionary get(const Variant *v) { return *VariantInternal::get_dictionary(v); } - static _FORCE_INLINE_ void set(Variant *v, const TypedDictionary &p_dictionary) { *VariantInternal::get_dictionary(v) = p_dictionary; } -}; - -template -struct PtrToArg> { - _FORCE_INLINE_ static TypedDictionary convert(const void *p_ptr) { - return TypedDictionary(*reinterpret_cast(p_ptr)); - } - typedef Dictionary EncodeT; - _FORCE_INLINE_ static void encode(TypedDictionary p_val, void *p_ptr) { - *(Dictionary *)p_ptr = p_val; - } -}; - -template -struct PtrToArg &> { - typedef Dictionary EncodeT; - _FORCE_INLINE_ static TypedDictionary - convert(const void *p_ptr) { - return TypedDictionary(*reinterpret_cast(p_ptr)); - } -}; - -template -struct GetTypeInfo> { - static const Variant::Type VARIANT_TYPE = Variant::DICTIONARY; - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; - static inline PropertyInfo get_class_info() { - return PropertyInfo(Variant::DICTIONARY, String(), PROPERTY_HINT_DICTIONARY_TYPE, vformat("%s;%s", K::get_class_static(), V::get_class_static())); - } -}; - -template -struct GetTypeInfo &> { - static const Variant::Type VARIANT_TYPE = Variant::DICTIONARY; - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; - static inline PropertyInfo get_class_info() { - return PropertyInfo(Variant::DICTIONARY, String(), PROPERTY_HINT_DICTIONARY_TYPE, vformat("%s;%s", K::get_class_static(), V::get_class_static())); - } -}; - -// Specialization for the rest of the Variant types. - -#define MAKE_TYPED_DICTIONARY_WITH_OBJECT(m_type, m_variant_type) \ - template \ - class TypedDictionary : public Dictionary { \ - public: \ - _FORCE_INLINE_ void operator=(const Dictionary &p_dictionary) { \ - ERR_FAIL_COND_MSG(!is_same_typed(p_dictionary), "Cannot assign an dictionary with a different element type."); \ - Dictionary::operator=(p_dictionary); \ - } \ - _FORCE_INLINE_ TypedDictionary(const Variant &p_variant) : \ - TypedDictionary(Dictionary(p_variant)) { \ - } \ - _FORCE_INLINE_ TypedDictionary(const Dictionary &p_dictionary) { \ - set_typed(Variant::OBJECT, T::get_class_static(), Variant(), m_variant_type, StringName(), Variant()); \ - if (is_same_typed(p_dictionary)) { \ - Dictionary::operator=(p_dictionary); \ - } else { \ - assign(p_dictionary); \ - } \ - } \ - _FORCE_INLINE_ TypedDictionary() { \ - set_typed(Variant::OBJECT, T::get_class_static(), Variant(), m_variant_type, StringName(), Variant()); \ - } \ - }; \ - template \ - struct GetTypeInfo> { \ - static const Variant::Type VARIANT_TYPE = Variant::DICTIONARY; \ - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo(Variant::DICTIONARY, String(), PROPERTY_HINT_DICTIONARY_TYPE, \ - vformat("%s;%s", T::get_class_static(), m_variant_type == Variant::NIL ? "Variant" : Variant::get_type_name(m_variant_type))); \ - } \ - }; \ - template \ - struct GetTypeInfo &> { \ - static const Variant::Type VARIANT_TYPE = Variant::DICTIONARY; \ - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo(Variant::DICTIONARY, String(), PROPERTY_HINT_DICTIONARY_TYPE, \ - vformat("%s;%s", T::get_class_static(), m_variant_type == Variant::NIL ? "Variant" : Variant::get_type_name(m_variant_type))); \ - } \ - }; \ - template \ - class TypedDictionary : public Dictionary { \ - public: \ - _FORCE_INLINE_ void operator=(const Dictionary &p_dictionary) { \ - ERR_FAIL_COND_MSG(!is_same_typed(p_dictionary), "Cannot assign an dictionary with a different element type."); \ - Dictionary::operator=(p_dictionary); \ - } \ - _FORCE_INLINE_ TypedDictionary(const Variant &p_variant) : \ - TypedDictionary(Dictionary(p_variant)) { \ - } \ - _FORCE_INLINE_ TypedDictionary(const Dictionary &p_dictionary) { \ - set_typed(m_variant_type, StringName(), Variant(), Variant::OBJECT, T::get_class_static(), Variant()); \ - if (is_same_typed(p_dictionary)) { \ - Dictionary::operator=(p_dictionary); \ - } else { \ - assign(p_dictionary); \ - } \ - } \ - _FORCE_INLINE_ TypedDictionary() { \ - set_typed(m_variant_type, StringName(), Variant(), Variant::OBJECT, T::get_class_static(), Variant()); \ - } \ - }; \ - template \ - struct GetTypeInfo> { \ - static const Variant::Type VARIANT_TYPE = Variant::DICTIONARY; \ - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo(Variant::DICTIONARY, String(), PROPERTY_HINT_DICTIONARY_TYPE, \ - vformat("%s;%s", m_variant_type == Variant::NIL ? "Variant" : Variant::get_type_name(m_variant_type), T::get_class_static())); \ - } \ - }; \ - template \ - struct GetTypeInfo &> { \ - static const Variant::Type VARIANT_TYPE = Variant::DICTIONARY; \ - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo(Variant::DICTIONARY, String(), PROPERTY_HINT_DICTIONARY_TYPE, \ - vformat("%s;%s", m_variant_type == Variant::NIL ? "Variant" : Variant::get_type_name(m_variant_type), T::get_class_static())); \ - } \ - }; - -#define MAKE_TYPED_DICTIONARY_EXPANDED(m_type_key, m_variant_type_key, m_type_value, m_variant_type_value) \ - template <> \ - class TypedDictionary : public Dictionary { \ - public: \ - _FORCE_INLINE_ void operator=(const Dictionary &p_dictionary) { \ - ERR_FAIL_COND_MSG(!is_same_typed(p_dictionary), "Cannot assign an dictionary with a different element type."); \ - Dictionary::operator=(p_dictionary); \ - } \ - _FORCE_INLINE_ TypedDictionary(const Variant &p_variant) : \ - TypedDictionary(Dictionary(p_variant)) { \ - } \ - _FORCE_INLINE_ TypedDictionary(const Dictionary &p_dictionary) { \ - set_typed(m_variant_type_key, StringName(), Variant(), m_variant_type_value, StringName(), Variant()); \ - if (is_same_typed(p_dictionary)) { \ - Dictionary::operator=(p_dictionary); \ - } else { \ - assign(p_dictionary); \ - } \ - } \ - _FORCE_INLINE_ TypedDictionary() { \ - set_typed(m_variant_type_key, StringName(), Variant(), m_variant_type_value, StringName(), Variant()); \ - } \ - }; \ - template <> \ - struct GetTypeInfo> { \ - static const Variant::Type VARIANT_TYPE = Variant::DICTIONARY; \ - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo(Variant::DICTIONARY, String(), PROPERTY_HINT_DICTIONARY_TYPE, \ - vformat("%s;%s", m_variant_type_key == Variant::NIL ? "Variant" : Variant::get_type_name(m_variant_type_key), \ - m_variant_type_value == Variant::NIL ? "Variant" : Variant::get_type_name(m_variant_type_value))); \ - } \ - }; \ - template <> \ - struct GetTypeInfo &> { \ - static const Variant::Type VARIANT_TYPE = Variant::DICTIONARY; \ - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo(Variant::DICTIONARY, String(), PROPERTY_HINT_DICTIONARY_TYPE, \ - vformat("%s;%s", m_variant_type_key == Variant::NIL ? "Variant" : Variant::get_type_name(m_variant_type_key), \ - m_variant_type_value == Variant::NIL ? "Variant" : Variant::get_type_name(m_variant_type_value))); \ - } \ - }; - -#define MAKE_TYPED_DICTIONARY_NIL(m_type, m_variant_type) \ - MAKE_TYPED_DICTIONARY_WITH_OBJECT(m_type, m_variant_type) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, bool, Variant::BOOL) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, uint8_t, Variant::INT) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, int8_t, Variant::INT) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, uint16_t, Variant::INT) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, int16_t, Variant::INT) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, uint32_t, Variant::INT) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, int32_t, Variant::INT) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, uint64_t, Variant::INT) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, int64_t, Variant::INT) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, float, Variant::FLOAT) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, double, Variant::FLOAT) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, String, Variant::STRING) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Vector2, Variant::VECTOR2) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Vector2i, Variant::VECTOR2I) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Rect2, Variant::RECT2) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Rect2i, Variant::RECT2I) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Vector3, Variant::VECTOR3) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Vector3i, Variant::VECTOR3I) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Transform2D, Variant::TRANSFORM2D) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Plane, Variant::PLANE) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Quaternion, Variant::QUATERNION) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, AABB, Variant::AABB) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Basis, Variant::BASIS) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Transform3D, Variant::TRANSFORM3D) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Color, Variant::COLOR) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, StringName, Variant::STRING_NAME) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, NodePath, Variant::NODE_PATH) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, RID, Variant::RID) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Callable, Variant::CALLABLE) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Signal, Variant::SIGNAL) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Dictionary, Variant::DICTIONARY) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Array, Variant::ARRAY) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, PackedByteArray, Variant::PACKED_BYTE_ARRAY) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, PackedInt32Array, Variant::PACKED_INT32_ARRAY) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, PackedInt64Array, Variant::PACKED_INT64_ARRAY) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, PackedFloat32Array, Variant::PACKED_FLOAT32_ARRAY) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, PackedFloat64Array, Variant::PACKED_FLOAT64_ARRAY) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, PackedStringArray, Variant::PACKED_STRING_ARRAY) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, PackedVector2Array, Variant::PACKED_VECTOR2_ARRAY) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, PackedVector3Array, Variant::PACKED_VECTOR3_ARRAY) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, PackedColorArray, Variant::PACKED_COLOR_ARRAY) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, PackedVector4Array, Variant::PACKED_VECTOR4_ARRAY) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, IPAddress, Variant::STRING) - -#define MAKE_TYPED_DICTIONARY(m_type, m_variant_type) \ - MAKE_TYPED_DICTIONARY_EXPANDED(m_type, m_variant_type, Variant, Variant::NIL) \ - MAKE_TYPED_DICTIONARY_NIL(m_type, m_variant_type) - -MAKE_TYPED_DICTIONARY_NIL(Variant, Variant::NIL) -MAKE_TYPED_DICTIONARY(bool, Variant::BOOL) -MAKE_TYPED_DICTIONARY(uint8_t, Variant::INT) -MAKE_TYPED_DICTIONARY(int8_t, Variant::INT) -MAKE_TYPED_DICTIONARY(uint16_t, Variant::INT) -MAKE_TYPED_DICTIONARY(int16_t, Variant::INT) -MAKE_TYPED_DICTIONARY(uint32_t, Variant::INT) -MAKE_TYPED_DICTIONARY(int32_t, Variant::INT) -MAKE_TYPED_DICTIONARY(uint64_t, Variant::INT) -MAKE_TYPED_DICTIONARY(int64_t, Variant::INT) -MAKE_TYPED_DICTIONARY(float, Variant::FLOAT) -MAKE_TYPED_DICTIONARY(double, Variant::FLOAT) -MAKE_TYPED_DICTIONARY(String, Variant::STRING) -MAKE_TYPED_DICTIONARY(Vector2, Variant::VECTOR2) -MAKE_TYPED_DICTIONARY(Vector2i, Variant::VECTOR2I) -MAKE_TYPED_DICTIONARY(Rect2, Variant::RECT2) -MAKE_TYPED_DICTIONARY(Rect2i, Variant::RECT2I) -MAKE_TYPED_DICTIONARY(Vector3, Variant::VECTOR3) -MAKE_TYPED_DICTIONARY(Vector3i, Variant::VECTOR3I) -MAKE_TYPED_DICTIONARY(Transform2D, Variant::TRANSFORM2D) -MAKE_TYPED_DICTIONARY(Plane, Variant::PLANE) -MAKE_TYPED_DICTIONARY(Quaternion, Variant::QUATERNION) -MAKE_TYPED_DICTIONARY(AABB, Variant::AABB) -MAKE_TYPED_DICTIONARY(Basis, Variant::BASIS) -MAKE_TYPED_DICTIONARY(Transform3D, Variant::TRANSFORM3D) -MAKE_TYPED_DICTIONARY(Color, Variant::COLOR) -MAKE_TYPED_DICTIONARY(StringName, Variant::STRING_NAME) -MAKE_TYPED_DICTIONARY(NodePath, Variant::NODE_PATH) -MAKE_TYPED_DICTIONARY(RID, Variant::RID) -MAKE_TYPED_DICTIONARY(Callable, Variant::CALLABLE) -MAKE_TYPED_DICTIONARY(Signal, Variant::SIGNAL) -MAKE_TYPED_DICTIONARY(Dictionary, Variant::DICTIONARY) -MAKE_TYPED_DICTIONARY(Array, Variant::ARRAY) -MAKE_TYPED_DICTIONARY(PackedByteArray, Variant::PACKED_BYTE_ARRAY) -MAKE_TYPED_DICTIONARY(PackedInt32Array, Variant::PACKED_INT32_ARRAY) -MAKE_TYPED_DICTIONARY(PackedInt64Array, Variant::PACKED_INT64_ARRAY) -MAKE_TYPED_DICTIONARY(PackedFloat32Array, Variant::PACKED_FLOAT32_ARRAY) -MAKE_TYPED_DICTIONARY(PackedFloat64Array, Variant::PACKED_FLOAT64_ARRAY) -MAKE_TYPED_DICTIONARY(PackedStringArray, Variant::PACKED_STRING_ARRAY) -MAKE_TYPED_DICTIONARY(PackedVector2Array, Variant::PACKED_VECTOR2_ARRAY) -MAKE_TYPED_DICTIONARY(PackedVector3Array, Variant::PACKED_VECTOR3_ARRAY) -MAKE_TYPED_DICTIONARY(PackedColorArray, Variant::PACKED_COLOR_ARRAY) -MAKE_TYPED_DICTIONARY(PackedVector4Array, Variant::PACKED_VECTOR4_ARRAY) -MAKE_TYPED_DICTIONARY(IPAddress, Variant::STRING) - -#undef MAKE_TYPED_DICTIONARY -#undef MAKE_TYPED_DICTIONARY_NIL -#undef MAKE_TYPED_DICTIONARY_EXPANDED -#undef MAKE_TYPED_DICTIONARY_WITH_OBJECT - -#endif // TYPED_DICTIONARY_H diff --git a/core/variant/variant.h b/core/variant/variant.h index babd2cf08474..b85c558e4f83 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -57,6 +57,7 @@ #include "core/string/ustring.h" #include "core/templates/paged_allocator.h" #include "core/templates/rid.h" +#include "core/templates/simple_type.h" #include "core/variant/array.h" #include "core/variant/callable.h" #include "core/variant/dictionary.h" @@ -968,4 +969,153 @@ Array::ConstIterator &Array::ConstIterator::operator--() { return *this; } +namespace GodotTypeInfo { + +// This dual-format of `_SomeInfo` and `some_info_v` is with the intent of the former +// accepting specializations while the latter is what's called publicly. This is +// because the latter automatically converts to a simple type (removes cvref) BEFORE +// calling to the former, removing the need for duplicate templates. + +template +struct _VariantType { + static constexpr Variant::Type value() { + if constexpr (std::is_base_of_v>) { + return Variant::OBJECT; + } else if constexpr (std::is_enum_v) { + return Variant::INT; + } else { + return Variant::VARIANT_MAX; + } + } +}; +template +inline constexpr Variant::Type variant_type_v = _VariantType>::value(); + +} //namespace GodotTypeInfo + +#define GTI GodotTypeInfo + +#define GTI_TMPL_VARIANT_TYPE(m_template, m_type, m_var_type) \ + template \ + struct GodotTypeInfo::_VariantType { \ + static constexpr Variant::Type value() { return m_var_type; } \ + }; +#define GTI_VARIANT_TYPE(m_type, m_var_type) GTI_TMPL_VARIANT_TYPE(, m_type, m_var_type) + +GTI_VARIANT_TYPE(Variant, Variant::NIL) +GTI_VARIANT_TYPE(bool, Variant::BOOL) +GTI_VARIANT_TYPE(uint8_t, Variant::INT) +GTI_VARIANT_TYPE(int8_t, Variant::INT) +GTI_VARIANT_TYPE(uint16_t, Variant::INT) +GTI_VARIANT_TYPE(int16_t, Variant::INT) +GTI_VARIANT_TYPE(uint32_t, Variant::INT) +GTI_VARIANT_TYPE(int32_t, Variant::INT) +GTI_VARIANT_TYPE(uint64_t, Variant::INT) +GTI_VARIANT_TYPE(int64_t, Variant::INT) +GTI_VARIANT_TYPE(float, Variant::FLOAT) +GTI_VARIANT_TYPE(double, Variant::FLOAT) +GTI_VARIANT_TYPE(String, Variant::STRING) +GTI_VARIANT_TYPE(Vector2, Variant::VECTOR2) +GTI_VARIANT_TYPE(Rect2, Variant::RECT2) +GTI_VARIANT_TYPE(Vector3, Variant::VECTOR3) +GTI_VARIANT_TYPE(Vector2i, Variant::VECTOR2I) +GTI_VARIANT_TYPE(Rect2i, Variant::RECT2I) +GTI_VARIANT_TYPE(Vector3i, Variant::VECTOR3I) +GTI_VARIANT_TYPE(Vector4, Variant::VECTOR4) +GTI_VARIANT_TYPE(Vector4i, Variant::VECTOR4I) +GTI_VARIANT_TYPE(Transform2D, Variant::TRANSFORM2D) +GTI_VARIANT_TYPE(Plane, Variant::PLANE) +GTI_VARIANT_TYPE(Quaternion, Variant::QUATERNION) +GTI_VARIANT_TYPE(AABB, Variant::AABB) +GTI_VARIANT_TYPE(Basis, Variant::BASIS) +GTI_VARIANT_TYPE(Transform3D, Variant::TRANSFORM3D) +GTI_VARIANT_TYPE(Projection, Variant::PROJECTION) +GTI_VARIANT_TYPE(Color, Variant::COLOR) +GTI_VARIANT_TYPE(StringName, Variant::STRING_NAME) +GTI_VARIANT_TYPE(NodePath, Variant::NODE_PATH) +GTI_VARIANT_TYPE(RID, Variant::RID) +GTI_VARIANT_TYPE(Callable, Variant::CALLABLE) +GTI_VARIANT_TYPE(Signal, Variant::SIGNAL) +GTI_VARIANT_TYPE(Dictionary, Variant::DICTIONARY) +GTI_TMPL_VARIANT_TYPE(typename K _COMMA typename V, TypedDictionary, Variant::DICTIONARY) +GTI_VARIANT_TYPE(Array, Variant::ARRAY) +GTI_TMPL_VARIANT_TYPE(typename T, TypedArray, Variant::ARRAY) +GTI_VARIANT_TYPE(PackedByteArray, Variant::PACKED_BYTE_ARRAY) +GTI_VARIANT_TYPE(PackedInt32Array, Variant::PACKED_INT32_ARRAY) +GTI_VARIANT_TYPE(PackedInt64Array, Variant::PACKED_INT64_ARRAY) +GTI_VARIANT_TYPE(PackedFloat32Array, Variant::PACKED_FLOAT32_ARRAY) +GTI_VARIANT_TYPE(PackedFloat64Array, Variant::PACKED_FLOAT64_ARRAY) +GTI_VARIANT_TYPE(PackedStringArray, Variant::PACKED_STRING_ARRAY) +GTI_VARIANT_TYPE(PackedVector2Array, Variant::PACKED_VECTOR2_ARRAY) +GTI_VARIANT_TYPE(PackedVector3Array, Variant::PACKED_VECTOR3_ARRAY) +GTI_VARIANT_TYPE(PackedColorArray, Variant::PACKED_COLOR_ARRAY) +GTI_VARIANT_TYPE(PackedVector4Array, Variant::PACKED_VECTOR4_ARRAY) +GTI_VARIANT_TYPE(IPAddress, Variant::STRING) + +template +void TypedArray::operator=(const Array &p_array) { + ERR_FAIL_COND_MSG(!is_same_typed(p_array), "Cannot assign an array with a different element type."); + _ref(p_array); +} + +template +TypedArray::TypedArray(const Variant &p_variant) : + TypedArray(Array(p_variant)) {} + +template +TypedArray::TypedArray(const Array &p_array) : + TypedArray() { + if (is_same_typed(p_array)) { + _ref(p_array); + } else { + assign(p_array); + } +} + +template +TypedArray::TypedArray() { + static_assert(GTI::variant_type_v != Variant::VARIANT_MAX, "Type is not a Variant type, or is not yet bound."); + static_assert(GTI::variant_type_v != Variant::NIL, "`TypedArray` is undefined."); + String class_name; + if constexpr (GTI::variant_type_v == Variant::OBJECT) { + class_name = T::get_class_static(); + } + set_typed(GTI::variant_type_v, class_name, Variant()); +} + +template +void TypedDictionary::operator=(const Dictionary &p_dictionary) { + ERR_FAIL_COND_MSG(!is_same_typed(p_dictionary), "Cannot assign a dictionary with a different element type."); + Dictionary::operator=(p_dictionary); +} + +template +TypedDictionary::TypedDictionary(const Variant &p_variant) : + TypedDictionary(Dictionary(p_variant)) {} + +template +TypedDictionary::TypedDictionary(const Dictionary &p_dictionary) : + TypedDictionary() { + if (is_same_typed(p_dictionary)) { + Dictionary::operator=(p_dictionary); + } else { + assign(p_dictionary); + } +} + +template +TypedDictionary::TypedDictionary() { + static_assert(GTI::variant_type_v != Variant::VARIANT_MAX && GTI::variant_type_v != Variant::VARIANT_MAX, "Type is not a Variant type, or is not yet bound."); + static_assert(GTI::variant_type_v != Variant::NIL || GTI::variant_type_v != Variant::NIL, "`TypedDictionary` is undefined."); + String key_name; + if constexpr (GTI::variant_type_v == Variant::OBJECT) { + key_name = K::get_class_static(); + } + String value_name; + if constexpr (GTI::variant_type_v == Variant::OBJECT) { + value_name = V::get_class_static(); + } + set_typed(GTI::variant_type_v, key_name, Variant(), GTI::variant_type_v, value_name, Variant()); +} + #endif // VARIANT_H diff --git a/core/variant/variant_internal.h b/core/variant/variant_internal.h index 58652d26e0c2..c9ab448c630a 100644 --- a/core/variant/variant_internal.h +++ b/core/variant/variant_internal.h @@ -1021,12 +1021,24 @@ struct VariantInternalAccessor { static _FORCE_INLINE_ void set(Variant *v, const Dictionary &p_value) { *VariantInternal::get_dictionary(v) = p_value; } }; +template +struct VariantInternalAccessor> { + static _FORCE_INLINE_ TypedDictionary get(const Variant *v) { return *VariantInternal::get_dictionary(v); } + static _FORCE_INLINE_ void set(Variant *v, const TypedDictionary &p_dictionary) { *VariantInternal::get_dictionary(v) = p_dictionary; } +}; + template <> struct VariantInternalAccessor { static _FORCE_INLINE_ const Array &get(const Variant *v) { return *VariantInternal::get_array(v); } static _FORCE_INLINE_ void set(Variant *v, const Array &p_value) { *VariantInternal::get_array(v) = p_value; } }; +template +struct VariantInternalAccessor> { + static _FORCE_INLINE_ TypedArray get(const Variant *v) { return *VariantInternal::get_array(v); } + static _FORCE_INLINE_ void set(Variant *v, const TypedArray &p_array) { *VariantInternal::get_array(v) = p_array; } +}; + template <> struct VariantInternalAccessor { static _FORCE_INLINE_ const PackedByteArray &get(const Variant *v) { return *VariantInternal::get_byte_array(v); } diff --git a/editor/editor_translation_parser.h b/editor/editor_translation_parser.h index 20c8ed79391b..8b08f0f80abc 100644 --- a/editor/editor_translation_parser.h +++ b/editor/editor_translation_parser.h @@ -34,7 +34,6 @@ #include "core/error/error_list.h" #include "core/object/gdvirtual.gen.inc" #include "core/object/ref_counted.h" -#include "core/variant/typed_array.h" class EditorTranslationParserPlugin : public RefCounted { GDCLASS(EditorTranslationParserPlugin, RefCounted); diff --git a/editor/editor_vcs_interface.h b/editor/editor_vcs_interface.h index a425682bed27..829e3da4aaa2 100644 --- a/editor/editor_vcs_interface.h +++ b/editor/editor_vcs_interface.h @@ -35,7 +35,6 @@ #include "core/object/gdvirtual.gen.inc" #include "core/string/ustring.h" #include "core/variant/type_info.h" -#include "core/variant/typed_array.h" class EditorVCSInterface : public Object { GDCLASS(EditorVCSInterface, Object) diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h index df472b416b2b..f1207ba59f28 100644 --- a/editor/import/editor_import_plugin.h +++ b/editor/import/editor_import_plugin.h @@ -32,7 +32,6 @@ #define EDITOR_IMPORT_PLUGIN_H #include "core/io/resource_importer.h" -#include "core/variant/typed_array.h" class EditorImportPlugin : public ResourceImporter { GDCLASS(EditorImportPlugin, ResourceImporter); diff --git a/main/performance.cpp b/main/performance.cpp index 398511995b01..0d4ed2bf0022 100644 --- a/main/performance.cpp +++ b/main/performance.cpp @@ -31,7 +31,6 @@ #include "performance.h" #include "core/os/os.h" -#include "core/variant/typed_array.h" #include "scene/main/node.h" #include "scene/main/scene_tree.h" #include "servers/audio_server.h" diff --git a/main/performance.h b/main/performance.h index e88bdcb337bd..d9992b606b8d 100644 --- a/main/performance.h +++ b/main/performance.h @@ -37,9 +37,6 @@ #define PERF_WARN_OFFLINE_FUNCTION #define PERF_WARN_PROCESS_SYNC -template -class TypedArray; - class Performance : public Object { GDCLASS(Performance, Object); diff --git a/modules/enet/enet_connection.cpp b/modules/enet/enet_connection.cpp index 9c9302a51cb3..39c0cf57dbd7 100644 --- a/modules/enet/enet_connection.cpp +++ b/modules/enet/enet_connection.cpp @@ -34,7 +34,6 @@ #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_NULL_MSG(host, "The ENetConnection instance isn't currently active."); diff --git a/modules/enet/enet_connection.h b/modules/enet/enet_connection.h index 616402be2037..d225dde1a8fb 100644 --- a/modules/enet/enet_connection.h +++ b/modules/enet/enet_connection.h @@ -38,9 +38,6 @@ #include -template -class TypedArray; - class ENetConnection : public RefCounted { GDCLASS(ENetConnection, RefCounted); diff --git a/modules/gdscript/gdscript_utility_functions.cpp b/modules/gdscript/gdscript_utility_functions.cpp index 82460696964d..5293f09fb5c6 100644 --- a/modules/gdscript/gdscript_utility_functions.cpp +++ b/modules/gdscript/gdscript_utility_functions.cpp @@ -37,7 +37,6 @@ #include "core/object/object.h" #include "core/templates/oa_hash_map.h" #include "core/templates/vector.h" -#include "core/variant/typed_array.h" #ifdef DEBUG_ENABLED diff --git a/modules/gdscript/gdscript_utility_functions.h b/modules/gdscript/gdscript_utility_functions.h index 1c4e4452c88a..d1a69462651a 100644 --- a/modules/gdscript/gdscript_utility_functions.h +++ b/modules/gdscript/gdscript_utility_functions.h @@ -34,9 +34,6 @@ #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/gltf_template_convert.h b/modules/gltf/gltf_template_convert.h index 46f185867ae7..afb05629d78f 100644 --- a/modules/gltf/gltf_template_convert.h +++ b/modules/gltf/gltf_template_convert.h @@ -34,7 +34,6 @@ #include "core/templates/hash_set.h" #include "core/variant/array.h" #include "core/variant/dictionary.h" -#include "core/variant/typed_array.h" namespace GLTFTemplateConvert { template diff --git a/modules/gltf/structures/gltf_object_model_property.h b/modules/gltf/structures/gltf_object_model_property.h index d8a4ed420a36..86dd15d14d8b 100644 --- a/modules/gltf/structures/gltf_object_model_property.h +++ b/modules/gltf/structures/gltf_object_model_property.h @@ -32,7 +32,6 @@ #define GLTF_OBJECT_MODEL_PROPERTY_H #include "core/math/expression.h" -#include "core/variant/typed_array.h" #include "gltf_accessor.h" // Object model: https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/ObjectModel.adoc diff --git a/modules/gltf/structures/gltf_skin.cpp b/modules/gltf/structures/gltf_skin.cpp index 18aa90a628cc..0d15d0f08e0c 100644 --- a/modules/gltf/structures/gltf_skin.cpp +++ b/modules/gltf/structures/gltf_skin.cpp @@ -32,7 +32,6 @@ #include "../gltf_template_convert.h" -#include "core/variant/typed_array.h" #include "scene/resources/3d/skin.h" void GLTFSkin::_bind_methods() { diff --git a/modules/gltf/structures/gltf_skin.h b/modules/gltf/structures/gltf_skin.h index 4649a918e3f6..bec53cde54f8 100644 --- a/modules/gltf/structures/gltf_skin.h +++ b/modules/gltf/structures/gltf_skin.h @@ -36,9 +36,6 @@ #include "core/io/resource.h" #include "scene/resources/3d/skin.h" -template -class TypedArray; - class GLTFSkin : public Resource { GDCLASS(GLTFSkin, Resource); friend class GLTFDocument; diff --git a/modules/multiplayer/multiplayer_spawner.h b/modules/multiplayer/multiplayer_spawner.h index 868efb9e0b2f..f4b25e33ec68 100644 --- a/modules/multiplayer/multiplayer_spawner.h +++ b/modules/multiplayer/multiplayer_spawner.h @@ -34,7 +34,6 @@ #include "scene_replication_config.h" #include "core/templates/local_vector.h" -#include "core/variant/typed_array.h" #include "scene/main/node.h" #include "scene/resources/packed_scene.h" diff --git a/modules/multiplayer/scene_replication_config.h b/modules/multiplayer/scene_replication_config.h index 969a23d788fb..2e7bd46ceb50 100644 --- a/modules/multiplayer/scene_replication_config.h +++ b/modules/multiplayer/scene_replication_config.h @@ -32,7 +32,6 @@ #define SCENE_REPLICATION_CONFIG_H #include "core/io/resource.h" -#include "core/variant/typed_array.h" class SceneReplicationConfig : public Resource { GDCLASS(SceneReplicationConfig, Resource); diff --git a/modules/noise/noise.h b/modules/noise/noise.h index 6c49c12bc227..ec7e1b152526 100644 --- a/modules/noise/noise.h +++ b/modules/noise/noise.h @@ -32,7 +32,6 @@ #define NOISE_H #include "core/io/image.h" -#include "core/variant/typed_array.h" class Noise : public Resource { GDCLASS(Noise, Resource); diff --git a/modules/ogg/ogg_packet_sequence.cpp b/modules/ogg/ogg_packet_sequence.cpp index 1e6a9bbb6a37..5694b7793c07 100644 --- a/modules/ogg/ogg_packet_sequence.cpp +++ b/modules/ogg/ogg_packet_sequence.cpp @@ -30,8 +30,6 @@ #include "ogg_packet_sequence.h" -#include "core/variant/typed_array.h" - void OggPacketSequence::push_page(int64_t p_granule_pos, const Vector &p_data) { Vector data_stored; for (int i = 0; i < p_data.size(); i++) { diff --git a/modules/ogg/ogg_packet_sequence.h b/modules/ogg/ogg_packet_sequence.h index 922a16560ca2..ab25c8d56d31 100644 --- a/modules/ogg/ogg_packet_sequence.h +++ b/modules/ogg/ogg_packet_sequence.h @@ -32,7 +32,6 @@ #define OGG_PACKET_SEQUENCE_H #include "core/io/resource.h" -#include "core/variant/typed_array.h" #include "core/variant/variant.h" #include diff --git a/modules/openxr/extensions/openxr_extension_wrapper_extension.h b/modules/openxr/extensions/openxr_extension_wrapper_extension.h index 8fc6511277ba..55ca66eeda70 100644 --- a/modules/openxr/extensions/openxr_extension_wrapper_extension.h +++ b/modules/openxr/extensions/openxr_extension_wrapper_extension.h @@ -38,7 +38,6 @@ #include "core/os/os.h" #include "core/os/thread_safe.h" #include "core/variant/native_ptr.h" -#include "core/variant/typed_array.h" class OpenXRExtensionWrapperExtension : public Object, public OpenXRExtensionWrapper, public OpenXRCompositionLayerProvider { GDCLASS(OpenXRExtensionWrapperExtension, Object); diff --git a/modules/regex/regex.h b/modules/regex/regex.h index cb8b0459ade8..c7f5655ca64d 100644 --- a/modules/regex/regex.h +++ b/modules/regex/regex.h @@ -37,7 +37,6 @@ #include "core/templates/vector.h" #include "core/variant/array.h" #include "core/variant/dictionary.h" -#include "core/variant/typed_array.h" class RegExMatch : public RefCounted { GDCLASS(RegExMatch, RefCounted); diff --git a/modules/vorbis/audio_stream_ogg_vorbis.cpp b/modules/vorbis/audio_stream_ogg_vorbis.cpp index c89534a60c4c..c2c4cecca207 100644 --- a/modules/vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/vorbis/audio_stream_ogg_vorbis.cpp @@ -31,7 +31,6 @@ #include "audio_stream_ogg_vorbis.h" #include "core/io/file_access.h" -#include "core/variant/typed_array.h" #include "modules/vorbis/resource_importer_ogg_vorbis.h" #include diff --git a/platform/android/api/java_class_wrapper.h b/platform/android/api/java_class_wrapper.h index c74cef8dd0b3..dc741a72516f 100644 --- a/platform/android/api/java_class_wrapper.h +++ b/platform/android/api/java_class_wrapper.h @@ -32,7 +32,6 @@ #define JAVA_CLASS_WRAPPER_H #include "core/object/ref_counted.h" -#include "core/variant/typed_array.h" #ifdef ANDROID_ENABLED #include diff --git a/platform/android/java_godot_io_wrapper.h b/platform/android/java_godot_io_wrapper.h index 0a372641cbb9..38d7d9b51865 100644 --- a/platform/android/java_godot_io_wrapper.h +++ b/platform/android/java_godot_io_wrapper.h @@ -34,7 +34,6 @@ #include "string_android.h" #include "core/math/rect2i.h" -#include "core/variant/typed_array.h" #include #include diff --git a/platform/macos/godot_open_save_delegate.h b/platform/macos/godot_open_save_delegate.h index 8857ef1fa95b..f0b9eb6b3af3 100644 --- a/platform/macos/godot_open_save_delegate.h +++ b/platform/macos/godot_open_save_delegate.h @@ -35,7 +35,6 @@ #import #include "core/templates/hash_map.h" -#include "core/variant/typed_array.h" #include "core/variant/variant.h" @interface GodotOpenSaveDelegate : NSObject { diff --git a/scene/main/node.h b/scene/main/node.h index e2f3ce9b7801..aa7eee1a4d2f 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -33,7 +33,6 @@ #include "core/string/node_path.h" #include "core/templates/rb_map.h" -#include "core/variant/typed_array.h" #include "scene/main/scene_tree.h" #include "scene/scene_string_names.h" diff --git a/scene/resources/animation_library.h b/scene/resources/animation_library.h index 00baf9d302b3..0b05c1f72b39 100644 --- a/scene/resources/animation_library.h +++ b/scene/resources/animation_library.h @@ -31,7 +31,6 @@ #ifndef ANIMATION_LIBRARY_H #define ANIMATION_LIBRARY_H -#include "core/variant/typed_array.h" #include "scene/resources/animation.h" class AnimationLibrary : public Resource { diff --git a/scene/resources/bit_map.cpp b/scene/resources/bit_map.cpp index 53f97fefc9f5..7f592b994a85 100644 --- a/scene/resources/bit_map.cpp +++ b/scene/resources/bit_map.cpp @@ -31,7 +31,6 @@ #include "bit_map.h" #include "core/io/image_loader.h" -#include "core/variant/typed_array.h" void BitMap::create(const Size2i &p_size) { ERR_FAIL_COND(p_size.width < 1); diff --git a/scene/resources/bit_map.h b/scene/resources/bit_map.h index 8912e3992e24..b93c29a33395 100644 --- a/scene/resources/bit_map.h +++ b/scene/resources/bit_map.h @@ -35,9 +35,6 @@ #include "core/io/resource.h" #include "core/io/resource_loader.h" -template -class TypedArray; - class BitMap : public Resource { GDCLASS(BitMap, Resource); OBJ_SAVE_TYPE(BitMap); diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h index 65efccdc28e7..a807c70b64b1 100644 --- a/servers/audio/audio_stream.h +++ b/servers/audio/audio_stream.h @@ -39,7 +39,6 @@ #include "core/object/gdvirtual.gen.inc" #include "core/variant/native_ptr.h" -#include "core/variant/typed_array.h" class AudioStream; diff --git a/servers/camera_server.cpp b/servers/camera_server.cpp index b78a0c44e756..3b8406b4767a 100644 --- a/servers/camera_server.cpp +++ b/servers/camera_server.cpp @@ -29,7 +29,6 @@ /**************************************************************************/ #include "camera_server.h" -#include "core/variant/typed_array.h" #include "rendering_server.h" #include "servers/camera/camera_feed.h" diff --git a/servers/camera_server.h b/servers/camera_server.h index 6a79b62fbd16..d5492e5debda 100644 --- a/servers/camera_server.h +++ b/servers/camera_server.h @@ -43,8 +43,6 @@ **/ class CameraFeed; -template -class TypedArray; class CameraServer : public Object { GDCLASS(CameraServer, Object); diff --git a/servers/extensions/physics_server_2d_extension.h b/servers/extensions/physics_server_2d_extension.h index 7bbd84ddf4ff..8ea59a3418be 100644 --- a/servers/extensions/physics_server_2d_extension.h +++ b/servers/extensions/physics_server_2d_extension.h @@ -35,7 +35,6 @@ #include "core/object/gdvirtual.gen.inc" #include "core/variant/native_ptr.h" #include "core/variant/type_info.h" -#include "core/variant/typed_array.h" #include "servers/physics_server_2d.h" class PhysicsDirectBodyState2DExtension : public PhysicsDirectBodyState2D { diff --git a/servers/extensions/physics_server_3d_extension.h b/servers/extensions/physics_server_3d_extension.h index b808b80b938b..b9703409fd00 100644 --- a/servers/extensions/physics_server_3d_extension.h +++ b/servers/extensions/physics_server_3d_extension.h @@ -35,7 +35,6 @@ #include "core/object/script_language.h" #include "core/variant/native_ptr.h" #include "core/variant/type_info.h" -#include "core/variant/typed_array.h" #include "servers/physics_server_3d.h" class PhysicsDirectBodyState3DExtension : public PhysicsDirectBodyState3D { diff --git a/servers/navigation/navigation_path_query_result_3d.h b/servers/navigation/navigation_path_query_result_3d.h index fd8545a0c933..e0d5c068fbee 100644 --- a/servers/navigation/navigation_path_query_result_3d.h +++ b/servers/navigation/navigation_path_query_result_3d.h @@ -32,7 +32,6 @@ #define NAVIGATION_PATH_QUERY_RESULT_3D_H #include "core/object/ref_counted.h" -#include "core/variant/typed_array.h" #include "servers/navigation/navigation_utilities.h" class NavigationPathQueryResult3D : public RefCounted { diff --git a/servers/navigation/navigation_utilities.h b/servers/navigation/navigation_utilities.h index 7ae22b1d3a28..98b4f7133c01 100644 --- a/servers/navigation/navigation_utilities.h +++ b/servers/navigation/navigation_utilities.h @@ -32,7 +32,8 @@ #define NAVIGATION_UTILITIES_H #include "core/math/vector3.h" -#include "core/variant/typed_array.h" +#include "core/variant/type_info.h" +#include "core/variant/variant.h" namespace NavigationUtilities { diff --git a/servers/physics_server_2d.cpp b/servers/physics_server_2d.cpp index f4f9a2e8b759..9a29b31653bb 100644 --- a/servers/physics_server_2d.cpp +++ b/servers/physics_server_2d.cpp @@ -32,7 +32,6 @@ #include "core/config/project_settings.h" #include "core/string/print_string.h" -#include "core/variant/typed_array.h" PhysicsServer2D *PhysicsServer2D::singleton = nullptr; diff --git a/servers/physics_server_2d.h b/servers/physics_server_2d.h index 67fc0ed899d5..3b9b939686c4 100644 --- a/servers/physics_server_2d.h +++ b/servers/physics_server_2d.h @@ -36,8 +36,6 @@ #include "core/object/ref_counted.h" class PhysicsDirectSpaceState2D; -template -class TypedArray; class PhysicsDirectBodyState2D : public Object { GDCLASS(PhysicsDirectBodyState2D, Object); diff --git a/servers/physics_server_3d.cpp b/servers/physics_server_3d.cpp index 312b67ada955..b1b090b385c5 100644 --- a/servers/physics_server_3d.cpp +++ b/servers/physics_server_3d.cpp @@ -34,7 +34,6 @@ #include "core/config/project_settings.h" #include "core/string/print_string.h" -#include "core/variant/typed_array.h" void PhysicsServer3DRenderingServerHandler::set_vertex(int p_vertex_id, const Vector3 &p_vertex) { GDVIRTUAL_CALL(_set_vertex, p_vertex_id, p_vertex); diff --git a/servers/physics_server_3d.h b/servers/physics_server_3d.h index 33def7cf8d44..fc9c10093e9d 100644 --- a/servers/physics_server_3d.h +++ b/servers/physics_server_3d.h @@ -39,8 +39,6 @@ #include "core/variant/native_ptr.h" class PhysicsDirectSpaceState3D; -template -class TypedArray; class PhysicsDirectBodyState3D : public Object { GDCLASS(PhysicsDirectBodyState3D, Object); diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h index ccfe51043b4d..baf9270759ee 100644 --- a/servers/rendering/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -38,7 +38,6 @@ #include "core/templates/local_vector.h" #include "core/templates/oa_hash_map.h" #include "core/templates/rid_owner.h" -#include "core/variant/typed_array.h" #include "servers/display_server.h" #include "servers/rendering/rendering_device_commons.h" #include "servers/rendering/rendering_device_driver.h" diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 2051d0caac0e..4c331c97f697 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -33,7 +33,6 @@ #include "core/config/project_settings.h" #include "core/object/worker_thread_pool.h" -#include "core/variant/typed_array.h" #include "servers/rendering/rendering_server_globals.h" #include "servers/rendering/shader_language.h" #include "servers/rendering/shader_warnings.h" diff --git a/servers/rendering_server.h b/servers/rendering_server.h index 0917af73c6a6..aa07fa5d0818 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -36,7 +36,6 @@ #include "core/math/transform_2d.h" #include "core/object/class_db.h" #include "core/templates/rid.h" -#include "core/variant/typed_array.h" #include "core/variant/variant.h" #include "servers/display_server.h" #include "servers/rendering/rendering_device.h" @@ -57,9 +56,6 @@ #define ERR_NOT_ON_RENDER_THREAD_V(m_ret) #endif -template -class TypedArray; - class RenderingServer : public Object { GDCLASS(RenderingServer, Object); diff --git a/servers/text/text_server_extension.h b/servers/text/text_server_extension.h index bd803be8aad0..b8a079b7814b 100644 --- a/servers/text/text_server_extension.h +++ b/servers/text/text_server_extension.h @@ -34,7 +34,6 @@ #include "core/object/gdvirtual.gen.inc" #include "core/os/thread_safe.h" #include "core/variant/native_ptr.h" -#include "core/variant/typed_array.h" #include "servers/text_server.h" class TextServerExtension : public TextServer { diff --git a/servers/text_server.cpp b/servers/text_server.cpp index d2cf4674ae02..5d9ae22c74b2 100644 --- a/servers/text_server.cpp +++ b/servers/text_server.cpp @@ -31,7 +31,6 @@ #include "servers/text_server.h" #include "text_server.compat.inc" -#include "core/variant/typed_array.h" #include "servers/rendering_server.h" TextServerManager *TextServerManager::singleton = nullptr; diff --git a/servers/text_server.h b/servers/text_server.h index f448d62cb226..e743ce3f9480 100644 --- a/servers/text_server.h +++ b/servers/text_server.h @@ -38,9 +38,6 @@ #include "core/variant/native_ptr.h" #include "core/variant/variant.h" -template -class TypedArray; - struct Glyph; struct CaretInfo; diff --git a/tests/core/variant/test_dictionary.h b/tests/core/variant/test_dictionary.h index 48a48f6ca62b..8e48db28e581 100644 --- a/tests/core/variant/test_dictionary.h +++ b/tests/core/variant/test_dictionary.h @@ -31,7 +31,6 @@ #ifndef TEST_DICTIONARY_H #define TEST_DICTIONARY_H -#include "core/variant/typed_dictionary.h" #include "tests/test_macros.h" namespace TestDictionary {