diff options
-rw-r--r-- | binding_generator.py | 1 | ||||
-rw-r--r-- | gdextension/extension_api.json | 393 | ||||
-rw-r--r-- | gdextension/gdextension_interface.h | 1 | ||||
-rw-r--r-- | include/godot_cpp/variant/typed_array.hpp | 42 | ||||
-rw-r--r-- | src/variant/packed_arrays.cpp | 4 |
5 files changed, 217 insertions, 224 deletions
diff --git a/binding_generator.py b/binding_generator.py index 2e6c1fc..d3c7261 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -696,6 +696,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl result.append("\tconst Variant &operator[](int p_index) const;") result.append("\tVariant &operator[](int p_index);") result.append("\tvoid set_typed(uint32_t p_type, const StringName &p_class_name, const Variant &p_script);") + result.append("\tvoid _ref(const Array &p_from) const;") if class_name == "Dictionary": result.append("\tconst Variant &operator[](const Variant &p_key) const;") diff --git a/gdextension/extension_api.json b/gdextension/extension_api.json index b44f143..87b8855 100644 --- a/gdextension/extension_api.json +++ b/gdextension/extension_api.json @@ -18913,6 +18913,19 @@ "hash": 3173160232 }, { + "name": "assign", + "is_vararg": false, + "is_const": false, + "is_static": false, + "hash": 2307260970, + "arguments": [ + { + "name": "array", + "type": "Array" + } + ] + }, + { "name": "push_back", "is_vararg": false, "is_const": false, @@ -19367,26 +19380,26 @@ "hash": 1460142086 }, { - "name": "typed_assign", + "name": "is_typed", "return_type": "bool", "is_vararg": false, - "is_const": false, + "is_const": true, "is_static": false, - "hash": 1485459766, - "arguments": [ - { - "name": "array", - "type": "Array" - } - ] + "hash": 3918633141 }, { - "name": "is_typed", + "name": "is_same_typed", "return_type": "bool", "is_vararg": false, "is_const": true, "is_static": false, - "hash": 3918633141 + "hash": 2988181878, + "arguments": [ + { + "name": "array", + "type": "Array" + } + ] }, { "name": "get_typed_builtin", @@ -30738,80 +30751,92 @@ ] }, { - "name": "set_xfade_time", + "name": "set_input_reset", "is_const": false, "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 373806689, + "hash": 300928843, "arguments": [ { - "name": "time", - "type": "float", - "meta": "double" + "name": "input", + "type": "int", + "meta": "int32" + }, + { + "name": "enable", + "type": "bool" } ] }, { - "name": "get_xfade_time", + "name": "is_input_reset", "is_const": true, "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 1740695150, + "hash": 1116898809, "return_value": { - "type": "float", - "meta": "double" - } + "type": "bool" + }, + "arguments": [ + { + "name": "input", + "type": "int", + "meta": "int32" + } + ] }, { - "name": "set_xfade_curve", + "name": "set_xfade_time", "is_const": false, "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 270443179, + "hash": 373806689, "arguments": [ { - "name": "curve", - "type": "Curve" + "name": "time", + "type": "float", + "meta": "double" } ] }, { - "name": "get_xfade_curve", + "name": "get_xfade_time", "is_const": true, "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 2460114913, + "hash": 1740695150, "return_value": { - "type": "Curve" + "type": "float", + "meta": "double" } }, { - "name": "set_reset", + "name": "set_xfade_curve", "is_const": false, "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 2586408642, + "hash": 270443179, "arguments": [ { - "name": "reset", - "type": "bool" + "name": "curve", + "type": "Curve" } ] }, { - "name": "is_reset", + "name": "get_xfade_curve", "is_const": true, "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 36873697, + "hash": 2460114913, "return_value": { - "type": "bool" + "type": "Curve" } } ], @@ -30829,12 +30854,6 @@ "getter": "get_xfade_curve" }, { - "type": "bool", - "name": "reset", - "setter": "set_reset", - "getter": "is_reset" - }, - { "type": "int", "name": "input_count", "setter": "set_input_count", @@ -70751,23 +70770,14 @@ "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 3871247334, + "hash": 1262296096, "return_value": { "type": "enum::Error" }, "arguments": [ { - "name": "key", - "type": "CryptoKey" - }, - { - "name": "certificate", - "type": "X509Certificate" - }, - { - "name": "chain", - "type": "X509Certificate", - "default_value": "null" + "name": "server_options", + "type": "TLSOptions" } ] }, @@ -75968,18 +75978,14 @@ "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 3447544237, + "hash": 1262296096, "return_value": { "type": "enum::Error" }, "arguments": [ { - "name": "key", - "type": "CryptoKey" - }, - { - "name": "certificate", - "type": "X509Certificate" + "name": "server_options", + "type": "TLSOptions" } ] }, @@ -75989,23 +75995,19 @@ "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 2959136280, + "hash": 3097527179, "return_value": { "type": "enum::Error" }, "arguments": [ { - "name": "certificate", - "type": "X509Certificate" - }, - { "name": "hostname", "type": "String" }, { - "name": "verify", - "type": "bool", - "default_value": "true" + "name": "client_options", + "type": "TLSOptions", + "default_value": "null" } ] }, @@ -106783,7 +106785,7 @@ "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 2602796911, + "hash": 1970282951, "return_value": { "type": "enum::Error" }, @@ -106799,14 +106801,9 @@ "default_value": "-1" }, { - "name": "use_tls", - "type": "bool", - "default_value": "false" - }, - { - "name": "verify_host", - "type": "bool", - "default_value": "true" + "name": "tls_options", + "type": "TLSOptions", + "default_value": "null" } ] }, @@ -107209,7 +107206,7 @@ "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 1899023990, + "hash": 2720304520, "return_value": { "type": "enum::Error" }, @@ -107224,11 +107221,6 @@ "default_value": "PackedStringArray()" }, { - "name": "tls_validate_domain", - "type": "bool", - "default_value": "true" - }, - { "name": "method", "type": "enum::HTTPClient.Method", "default_value": "0" @@ -107246,7 +107238,7 @@ "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 3236422912, + "hash": 4282724657, "return_value": { "type": "enum::Error" }, @@ -107261,11 +107253,6 @@ "default_value": "PackedStringArray()" }, { - "name": "tls_validate_domain", - "type": "bool", - "default_value": "true" - }, - { "name": "method", "type": "enum::HTTPClient.Method", "default_value": "0" @@ -107286,6 +107273,20 @@ "hash": 3218959716 }, { + "name": "set_tls_options", + "is_const": false, + "is_vararg": false, + "is_static": false, + "is_virtual": false, + "hash": 2210231844, + "arguments": [ + { + "name": "client_options", + "type": "TLSOptions" + } + ] + }, + { "name": "get_http_client_status", "is_const": true, "is_vararg": false, @@ -109060,7 +109061,7 @@ "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 3422491167, + "hash": 4094210332, "return_value": { "type": "enum::Error" }, @@ -109075,12 +109076,6 @@ "default_value": "0" }, { - "name": "lossy_quality", - "type": "float", - "meta": "float", - "default_value": "0.7" - }, - { "name": "astc_format", "type": "enum::Image.ASTCFormat", "default_value": "0" @@ -109093,7 +109088,7 @@ "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 180597543, + "hash": 279105990, "return_value": { "type": "enum::Error" }, @@ -109107,12 +109102,6 @@ "type": "enum::Image.UsedChannels" }, { - "name": "lossy_quality", - "type": "float", - "meta": "float", - "default_value": "0.7" - }, - { "name": "astc_format", "type": "enum::Image.ASTCFormat", "default_value": "0" @@ -110130,7 +110119,7 @@ { "name": "blend_shapes", "type": "typedarray::Array", - "default_value": "[]" + "default_value": "Array[Array]([])" }, { "name": "lods", @@ -142942,7 +142931,7 @@ "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 293566484, + "hash": 1801538152, "return_value": { "type": "enum::Error" }, @@ -142952,18 +142941,12 @@ "type": "PacketPeerUDP" }, { - "name": "validate_certs", - "type": "bool", - "default_value": "true" - }, - { - "name": "for_hostname", - "type": "String", - "default_value": "\"\"" + "name": "hostname", + "type": "String" }, { - "name": "valid_certificate", - "type": "X509Certificate", + "name": "client_options", + "type": "TLSOptions", "default_value": "null" } ] @@ -152015,7 +151998,7 @@ { "name": "exclude", "type": "typedarray::RID", - "default_value": "[]" + "default_value": "Array[RID]([])" } ] }, @@ -152277,7 +152260,7 @@ { "name": "exclude", "type": "typedarray::RID", - "default_value": "[]" + "default_value": "Array[RID]([])" } ] }, @@ -179773,7 +179756,7 @@ { "name": "specialization_constants", "type": "typedarray::RDPipelineSpecializationConstant", - "default_value": "[]" + "default_value": "Array[RDPipelineSpecializationConstant]([])" } ] }, @@ -179812,7 +179795,7 @@ { "name": "specialization_constants", "type": "typedarray::RDPipelineSpecializationConstant", - "default_value": "[]" + "default_value": "Array[RDPipelineSpecializationConstant]([])" } ] }, @@ -179967,7 +179950,7 @@ { "name": "storage_textures", "type": "Array", - "default_value": "[]" + "default_value": "Array[RID]([])" } ] }, @@ -180032,7 +180015,7 @@ { "name": "storage_textures", "type": "typedarray::RID", - "default_value": "[]" + "default_value": "Array[RID]([])" } ] }, @@ -212668,7 +212651,7 @@ "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 2359858912, + "hash": 4292689651, "return_value": { "type": "enum::Error" }, @@ -212678,17 +212661,8 @@ "type": "StreamPeer" }, { - "name": "private_key", - "type": "CryptoKey" - }, - { - "name": "certificate", - "type": "X509Certificate" - }, - { - "name": "chain", - "type": "X509Certificate", - "default_value": "null" + "name": "server_options", + "type": "TLSOptions" } ] }, @@ -212698,7 +212672,7 @@ "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 127827767, + "hash": 1325480781, "return_value": { "type": "enum::Error" }, @@ -212708,18 +212682,12 @@ "type": "StreamPeer" }, { - "name": "validate_certs", - "type": "bool", - "default_value": "false" - }, - { - "name": "for_hostname", - "type": "String", - "default_value": "\"\"" + "name": "common_name", + "type": "String" }, { - "name": "valid_certificate", - "type": "X509Certificate", + "name": "client_options", + "type": "TLSOptions", "default_value": "null" } ] @@ -212753,39 +212721,6 @@ "is_static": false, "is_virtual": false, "hash": 3218959716 - }, - { - "name": "set_blocking_handshake_enabled", - "is_const": false, - "is_vararg": false, - "is_static": false, - "is_virtual": false, - "hash": 2586408642, - "arguments": [ - { - "name": "enabled", - "type": "bool" - } - ] - }, - { - "name": "is_blocking_handshake_enabled", - "is_const": true, - "is_vararg": false, - "is_static": false, - "is_virtual": false, - "hash": 36873697, - "return_value": { - "type": "bool" - } - } - ], - "properties": [ - { - "type": "bool", - "name": "blocking_handshake", - "setter": "set_blocking_handshake_enabled", - "getter": "is_blocking_handshake_enabled" } ] }, @@ -215652,6 +215587,77 @@ ] }, { + "name": "TLSOptions", + "is_refcounted": true, + "is_instantiable": false, + "inherits": "RefCounted", + "api_type": "core", + "methods": [ + { + "name": "client", + "is_const": false, + "is_vararg": false, + "is_static": true, + "is_virtual": false, + "hash": 3565000357, + "return_value": { + "type": "TLSOptions" + }, + "arguments": [ + { + "name": "trusted_chain", + "type": "X509Certificate", + "default_value": "null" + }, + { + "name": "common_name_override", + "type": "String", + "default_value": "\"\"" + } + ] + }, + { + "name": "client_unsafe", + "is_const": false, + "is_vararg": false, + "is_static": true, + "is_virtual": false, + "hash": 2090251749, + "return_value": { + "type": "TLSOptions" + }, + "arguments": [ + { + "name": "trusted_chain", + "type": "X509Certificate", + "default_value": "null" + } + ] + }, + { + "name": "server", + "is_const": false, + "is_vararg": false, + "is_static": true, + "is_virtual": false, + "hash": 36969539, + "return_value": { + "type": "TLSOptions" + }, + "arguments": [ + { + "name": "key", + "type": "CryptoKey" + }, + { + "name": "certificate", + "type": "X509Certificate" + } + ] + } + ] + }, + { "name": "TabBar", "is_refcounted": false, "is_instantiable": true, @@ -258837,7 +258843,7 @@ "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 3369256093, + "hash": 3097527179, "return_value": { "type": "enum::Error" }, @@ -258847,13 +258853,8 @@ "type": "String" }, { - "name": "verify_tls", - "type": "bool", - "default_value": "true" - }, - { - "name": "tls_certificate", - "type": "X509Certificate", + "name": "tls_client_options", + "type": "TLSOptions", "default_value": "null" } ] @@ -258864,7 +258865,7 @@ "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 2363339283, + "hash": 337374795, "return_value": { "type": "enum::Error" }, @@ -258880,13 +258881,8 @@ "default_value": "\"*\"" }, { - "name": "tls_key", - "type": "CryptoKey", - "default_value": "null" - }, - { - "name": "tls_certificate", - "type": "X509Certificate", + "name": "tls_server_options", + "type": "TLSOptions", "default_value": "null" } ] @@ -259195,7 +259191,7 @@ "is_vararg": false, "is_static": false, "is_virtual": false, - "hash": 3369256093, + "hash": 3097527179, "return_value": { "type": "enum::Error" }, @@ -259205,13 +259201,8 @@ "type": "String" }, { - "name": "verify_tls", - "type": "bool", - "default_value": "true" - }, - { - "name": "trusted_tls_certificate", - "type": "X509Certificate", + "name": "tls_client_options", + "type": "TLSOptions", "default_value": "null" } ] diff --git a/gdextension/gdextension_interface.h b/gdextension/gdextension_interface.h index 7f8f737..876a09b 100644 --- a/gdextension/gdextension_interface.h +++ b/gdextension/gdextension_interface.h @@ -551,6 +551,7 @@ typedef struct { GDExtensionVariantPtr (*array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be an Array ptr GDExtensionVariantPtr (*array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be an Array ptr + void (*array_ref)(GDExtensionTypePtr p_self, GDExtensionConstTypePtr p_from); // p_self should be an Array ptr void (*array_set_typed)(GDExtensionTypePtr p_self, uint32_t p_type, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstVariantPtr p_script); // p_self should be an Array ptr /* Dictionary functions */ diff --git a/include/godot_cpp/variant/typed_array.hpp b/include/godot_cpp/variant/typed_array.hpp index 2d71c0f..5e7084e 100644 --- a/include/godot_cpp/variant/typed_array.hpp +++ b/include/godot_cpp/variant/typed_array.hpp @@ -39,14 +39,9 @@ namespace godot { template <class T> class TypedArray : public Array { public: - template <class U> - _FORCE_INLINE_ void operator=(const TypedArray<U> &p_array) { - static_assert(__is_base_of(T, U)); - typed_assign(p_array); - } - _FORCE_INLINE_ void operator=(const Array &p_array) { - typed_assign(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) : Array(p_variant.operator Array(), Variant::OBJECT, T::get_class_static(), Variant()) { @@ -61,22 +56,23 @@ public: // specialization for the rest of variant types -#define MAKE_TYPED_ARRAY(m_type, m_variant_type) \ - template <> \ - class TypedArray<m_type> : public Array { \ - public: \ - _FORCE_INLINE_ void operator=(const Array &p_array) { \ - typed_assign(p_array); \ - } \ - _FORCE_INLINE_ TypedArray(const Variant &p_variant) : \ - Array(p_variant.operator Array(), m_variant_type, StringName(), Variant()) { \ - } \ - _FORCE_INLINE_ TypedArray(const Array &p_array) : \ - Array(p_array, m_variant_type, StringName(), Variant()) { \ - } \ - _FORCE_INLINE_ TypedArray() { \ - set_typed(m_variant_type, StringName(), Variant()); \ - } \ +#define MAKE_TYPED_ARRAY(m_type, m_variant_type) \ + template <> \ + class TypedArray<m_type> : 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) : \ + Array(p_variant.operator Array(), m_variant_type, StringName(), Variant()) { \ + } \ + _FORCE_INLINE_ TypedArray(const Array &p_array) : \ + Array(p_array, m_variant_type, StringName(), Variant()) { \ + } \ + _FORCE_INLINE_ TypedArray() { \ + set_typed(m_variant_type, StringName(), Variant()); \ + } \ }; MAKE_TYPED_ARRAY(bool, Variant::BOOL) diff --git a/src/variant/packed_arrays.cpp b/src/variant/packed_arrays.cpp index 5f35abd..e565888 100644 --- a/src/variant/packed_arrays.cpp +++ b/src/variant/packed_arrays.cpp @@ -212,6 +212,10 @@ void Array::set_typed(uint32_t p_type, const StringName &p_class_name, const Var internal::gde_interface->array_set_typed((GDExtensionTypePtr *)this, p_type, (GDExtensionConstStringNamePtr)&p_class_name, (GDExtensionConstVariantPtr)&p_script); } +void Array::_ref(const Array &p_from) const { + internal::gde_interface->array_ref((GDExtensionTypePtr *)this, (GDExtensionConstTypePtr *)&p_from); +} + const Variant &Dictionary::operator[](const Variant &p_key) const { const Variant *var = (const Variant *)internal::gde_interface->dictionary_operator_index_const((GDExtensionTypePtr *)this, (GDExtensionVariantPtr)&p_key); return *var; |