[DRAFT] GDExtension: Add compatibility system for virtual methods #100674
+540
−195
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the start of a compatibility system that will allow us to change the signature of virtual methods, and not crash existing GDExtensions that implemented the old version of the virtual methods.
It allows registering compatibility virtual methods, like:
Then when we're calling the virtual method, we can do something like this:
This also changes the
extension_api.json
file to include a hash for the signature of each virtual method, and updates the GDExtension interface to include a hash argument when Godot is asking the GDExtension for a particular virtual method.The idea is: the bindings will hang on to the hashes for all the virtual methods they support, and when Godot asks for a particular virtual method, if the hash doesn't match what the GDExtension has, then return
nullptr
as if the GDExtension didn't implement the virtual method at all. So, if a GDExtension was compiled with an older hash, then the firstGDVIRTUAL_CALL()
will returnfalse
(indicating that the virtual method isn't implemented), but then the second one will succeed because the hash will match what the GDExtension has.PR godotengine/godot-cpp#1676 are the companion changes for godot-cpp
Marking as DRAFT because there's still a couple things to do:
Make a godot-cpp PR that implements thisNOTE: This presently includes the changes from PR #100447 so that I'd have a change to test, since there is a virtual method signature that we want to change there.