Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Vector<T>::duplicate() const #79140

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aaronfranke
Copy link
Member

I tried to duplicate a const PackedStringArray and I noticed that it was impossible, but it should be possible.

@aaronfranke aaronfranke requested review from a team as code owners July 7, 2023 04:12
@aaronfranke aaronfranke added this to the 4.x milestone Jul 7, 2023
@AThousandShips
Copy link
Member

AThousandShips commented Jul 7, 2023

Needs an update to the extension API validation

Also, do we need to add a 4.1 one as well now that we have released it, along with 4.0

@akien-mga
Copy link
Member

@godotengine/gdextension Does this technically break compat for extensions?

@raulsntos
Copy link
Member

If the method's hash changed, then I guess it breaks compat. Otherwise, a GDExtension that was built for 4.1 making use of ClassDB::get_method_with_compatibility passing the old hash will not be able to find the method in 4.2.

To avoid breaking compat, you would need to add a compat method (see #76577).

@dsnopek
Copy link
Contributor

dsnopek commented Jul 7, 2023

Does this technically break compat for extensions?

Yes, I think @raulsntos is correct.

I guess it's time to start testing out this compatibility system for real?

@aaronfranke
Copy link
Member Author

What is the correct way to add compatibility methods? Is there an example I can follow?

@dsnopek
Copy link
Contributor

dsnopek commented Sep 7, 2023

Hm, digging into this one deeper, I don't think we currently have a way to provide compatibility methods on Variant types.

gdextension_variant_get_ptr_builtin_method() in gdextension_interface.cpp looks up the method by the name, recalculates its hash, and simply compares that with the value provided. We'll need to add something to variant_call.cpp to store, register and call compatibility methods, similar to the mechanism we already have in ClassDB.

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: Hash changed for 'builtin_classes/PackedByteArray/methods/duplicate', from 32C526A8 to 0EC26674. This means that the function has changed and no compatibility function was provided.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Hash changed" errors shouldn't be silenced. You need to add compat methods for all these, otherwise this breaks binary compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, as I pointed out in my previous comment, there isn't presently a way to register compatibility methods on Variant types. Adding a way to do that is a pre-requisite to this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants