Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/extension/extension_api_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,17 @@ Dictionary GDExtensionAPIDump::generate_extension_api(bool p_include_docs) {
d2["is_static"] = Variant::is_builtin_method_static(type, method_name);
d2["hash"] = Variant::get_builtin_method_hash(type, method_name);

Vector<uint32_t> compat_hashes = Variant::get_builtin_method_compatibility_hashes(type, method_name);
Array compatibility;
if (compat_hashes.size()) {
for (int j = 0; j < compat_hashes.size(); j++) {
compatibility.push_back(compat_hashes[j]);
}
}
if (compatibility.size() > 0) {
d2["hash_compatibility"] = compatibility;
}

Vector<Variant> default_args = Variant::get_builtin_method_default_arguments(type, method_name);

Array arguments;
Expand Down
10 changes: 4 additions & 6 deletions core/extension/gdextension_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,13 +817,11 @@ static GDExtensionPtrOperatorEvaluator gdextension_variant_get_ptr_operator_eval
}
static GDExtensionPtrBuiltInMethod gdextension_variant_get_ptr_builtin_method(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, GDExtensionInt p_hash) {
const StringName method = *reinterpret_cast<const StringName *>(p_method);
uint32_t hash = Variant::get_builtin_method_hash(Variant::Type(p_type), method);
if (hash != p_hash) {
ERR_PRINT_ONCE("Error getting method " + method + ", hash mismatch.");
return nullptr;
GDExtensionPtrBuiltInMethod ptr = (GDExtensionPtrBuiltInMethod)Variant::get_ptr_builtin_method_with_compatibility(Variant::Type(p_type), method, p_hash);
if (!ptr) {
ERR_PRINT("Error getting method " + method + ", missing or hash mismatch.");
}

return (GDExtensionPtrBuiltInMethod)Variant::get_ptr_builtin_method(Variant::Type(p_type), method);
return ptr;
}
static GDExtensionPtrConstructor gdextension_variant_get_ptr_constructor(GDExtensionVariantType p_type, int32_t p_constructor) {
return (GDExtensionPtrConstructor)Variant::get_ptr_constructor(Variant::Type(p_type), p_constructor);
Expand Down
8 changes: 7 additions & 1 deletion core/templates/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,16 @@ class Vector {
return span().bisect(p_value, p_before, Comparator{ args... });
}

Vector<T> duplicate() {
Vector<T> duplicate() const {
return *this;
}

#ifndef DISABLE_DEPRECATED
Vector<T> _duplicate_bind_compat_112290() {
return *this;
}
#endif // DISABLE_DEPRECATED

void ordered_insert(const T &p_val) {
Size i;
for (i = 0; i < _cowdata.size(); i++) {
Expand Down
2 changes: 2 additions & 0 deletions core/variant/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ class Variant {

static ValidatedBuiltInMethod get_validated_builtin_method(Variant::Type p_type, const StringName &p_method);
static PTRBuiltInMethod get_ptr_builtin_method(Variant::Type p_type, const StringName &p_method);
static PTRBuiltInMethod get_ptr_builtin_method_with_compatibility(Variant::Type p_type, const StringName &p_method, uint32_t p_hash);

static MethodInfo get_builtin_method_info(Variant::Type p_type, const StringName &p_method);
static int get_builtin_method_argument_count(Variant::Type p_type, const StringName &p_method);
Expand All @@ -659,6 +660,7 @@ class Variant {
static void get_builtin_method_list(Variant::Type p_type, List<StringName> *p_list);
static int get_builtin_method_count(Variant::Type p_type);
static uint32_t get_builtin_method_hash(Variant::Type p_type, const StringName &p_method);
static Vector<uint32_t> get_builtin_method_compatibility_hashes(Variant::Type p_type, const StringName &p_method);

void callp(const StringName &p_method, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error);

Expand Down
317 changes: 260 additions & 57 deletions core/variant/variant_call.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/classes/PackedByteArray.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
[b]Note:[/b] Decompression is not guaranteed to work with data not compressed by Godot, for example if data compressed with the deflate compression mode lacks a checksum or header.
</description>
</method>
<method name="duplicate">
<method name="duplicate" qualifiers="const">
<return type="PackedByteArray" />
<description>
Creates a copy of the array, and returns it.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/PackedColorArray.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
Returns the number of times an element is in the array.
</description>
</method>
<method name="duplicate">
<method name="duplicate" qualifiers="const">
<return type="PackedColorArray" />
<description>
Creates a copy of the array, and returns it.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/PackedFloat32Array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
[b]Note:[/b] [constant @GDScript.NAN] doesn't behave the same as other numbers. Therefore, the results from this method may not be accurate if NaNs are included.
</description>
</method>
<method name="duplicate">
<method name="duplicate" qualifiers="const">
<return type="PackedFloat32Array" />
<description>
Creates a copy of the array, and returns it.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/PackedFloat64Array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
[b]Note:[/b] [constant @GDScript.NAN] doesn't behave the same as other numbers. Therefore, the results from this method may not be accurate if NaNs are included.
</description>
</method>
<method name="duplicate">
<method name="duplicate" qualifiers="const">
<return type="PackedFloat64Array" />
<description>
Creates a copy of the array, and returns it.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/PackedInt32Array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
Returns the number of times an element is in the array.
</description>
</method>
<method name="duplicate">
<method name="duplicate" qualifiers="const">
<return type="PackedInt32Array" />
<description>
Creates a copy of the array, and returns it.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/PackedInt64Array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
Returns the number of times an element is in the array.
</description>
</method>
<method name="duplicate">
<method name="duplicate" qualifiers="const">
<return type="PackedInt64Array" />
<description>
Creates a copy of the array, and returns it.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/PackedStringArray.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
Returns the number of times an element is in the array.
</description>
</method>
<method name="duplicate">
<method name="duplicate" qualifiers="const">
<return type="PackedStringArray" />
<description>
Creates a copy of the array, and returns it.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/PackedVector2Array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
[b]Note:[/b] Vectors with [constant @GDScript.NAN] elements don't behave the same as other vectors. Therefore, the results from this method may not be accurate if NaNs are included.
</description>
</method>
<method name="duplicate">
<method name="duplicate" qualifiers="const">
<return type="PackedVector2Array" />
<description>
Creates a copy of the array, and returns it.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/PackedVector3Array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
[b]Note:[/b] Vectors with [constant @GDScript.NAN] elements don't behave the same as other vectors. Therefore, the results from this method may not be accurate if NaNs are included.
</description>
</method>
<method name="duplicate">
<method name="duplicate" qualifiers="const">
<return type="PackedVector3Array" />
<description>
Creates a copy of the array, and returns it.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/PackedVector4Array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
[b]Note:[/b] Vectors with [constant @GDScript.NAN] elements don't behave the same as other vectors. Therefore, the results from this method may not be accurate if NaNs are included.
</description>
</method>
<method name="duplicate">
<method name="duplicate" qualifiers="const">
<return type="PackedVector4Array" />
<description>
Creates a copy of the array, and returns it.
Expand Down
17 changes: 17 additions & 0 deletions misc/extension_api_validation/4.5-stable.expected
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,20 @@ GH-110433
Validate extension JSON: Error: Field 'classes/Performance/methods/add_custom_monitor/arguments': size changed value in new API, from 3 to 4.

Optional argument added. Compatibility method registered.


GH-112290
---------

Validate extension JSON: Error: Field 'builtin_classes/PackedByteArray/methods/duplicate': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'builtin_classes/PackedColorArray/methods/duplicate': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'builtin_classes/PackedFloat32Array/methods/duplicate': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'builtin_classes/PackedFloat64Array/methods/duplicate': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'builtin_classes/PackedInt32Array/methods/duplicate': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'builtin_classes/PackedInt64Array/methods/duplicate': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'builtin_classes/PackedStringArray/methods/duplicate': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'builtin_classes/PackedVector2Array/methods/duplicate': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'builtin_classes/PackedVector3Array/methods/duplicate': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'builtin_classes/PackedVector4Array/methods/duplicate': is_const changed value in new API, from false to true.

Duplicate method made const. Compatibility methods registered.