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

GDExtension: Convert validated_call() to ptrcall() (rather than call()) #82794

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

dsnopek
Copy link
Contributor

@dsnopek dsnopek commented Oct 4, 2023

Presently, if you do a validated_call() to a GDExtension method, and the GDExtension doesn't provide special support for validated calls (very unlikely), then it will convert that to a call(). This will be much slower than necessary, since we know all the argument types match - it would be better to do a ptrcall().

Right now, this isn't that important, because GDScript will do ptrcall()s directly (when possible), but PR #79893 would switch GDScript to doing validated_call().

So, this PR changes validated_call() to GDExtension methods to use ptrcall().

I've tested this PR, in combination with PR #79893, and it seems to be working fine (the automated godot-cpp tests pass).

It also fixes an issue in Object::get_opaque_pointer() that was missed in PR #77410. That PR made the same change to the const version of Object::get_opaque_pointer(), but missed it for the non-const version. We didn't notice, because we were only using it for function arguments (which are const), and in this PR we start using it for function return values as well (which are non-const).

Comment on lines 420 to +421
case Variant::OBJECT:
return v->_get_obj().obj;
return get_object(v);
Copy link
Contributor Author

@dsnopek dsnopek Oct 4, 2023

Choose a reason for hiding this comment

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

This change was made in the const version of get_opaque_pointer in PR #77410, but, unfortunately, the non-const version was missed (sorry, it was my PR, so it's my fault :-)).

@akien-mga akien-mga modified the milestones: 4.x, 4.2 Oct 6, 2023
@akien-mga akien-mga merged commit a6a2d0d into godotengine:master Oct 6, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@dsnopek dsnopek deleted the gdextension-validated-call branch July 22, 2024 15:28
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.

3 participants