Make Vector<T>::duplicate() const
I tried to duplicate a const PackedStringArray and I noticed that it was impossible, but it should be possible.
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
@godotengine/gdextension Does this technically break compat for extensions?
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 https://github.com/godotengine/godot/pull/76577).
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?
What is the correct way to add compatibility methods? Is there an example I can follow?
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.
Since there still isn't a way to register compatibility methods, I updated this PR to instead keep the bindings equivalent to the same method as before, while the version internal to the C++ code is now const. There are #ifndef DISABLE_DEPRECATED checks to ensure that the compat method is removed when building with deprecated disabled.
Since there still isn't a way to register compatibility methods, I updated this PR to instead keep the bindings equivalent to the same method as before, while the version internal to the C++ code is now
const.
So, essentially, this makes it const within Godot, but still non-const as exposed to GDExtension?
I just posted PR https://github.com/godotengine/godot/pull/112290 which finally adds a system for builtin method compatibility.
In order to test in, I've included (in the 2nd commit) the same core change as this PR (and listed @aaronfranke as a co-author)
Implemented via #112290