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

Fix const qualifier for parameters in GDExtension api functions #67751

Conversation

touilleMan
Copy link
Member

@touilleMan touilleMan commented Oct 22, 2022

see the related Godot-CPP PR: godotengine/godot-cpp#897

The GDExtension contains code like this:

typedef void *FooPtr;
void do_something(const FooPtr foo);

What we'd like to have is foo being typed as const void* (i.e. a pointer on a constant structure), however what it is actually typed is void *const (i.e. a constant pointer on a modifiable structure)

This PR fix this by introducing const types, e.g.:

typedef void *FooPtr;
typedef const void*ConstFooPtr;
void do_something(ConstFooPtr foo);

@touilleMan touilleMan requested review from a team as code owners October 22, 2022 13:11
@touilleMan touilleMan force-pushed the gdextension-fix-gdnative-types-const-qualifier branch 2 times, most recently from e9f646c to 38b5b9f Compare October 22, 2022 13:25
@touilleMan touilleMan requested a review from a team as a code owner October 22, 2022 13:39
@touilleMan touilleMan force-pushed the gdextension-fix-gdnative-types-const-qualifier branch from 8f29442 to f16b9c7 Compare October 22, 2022 16:13
@Chaosus Chaosus added this to the 4.0 milestone Oct 23, 2022
@touilleMan touilleMan force-pushed the gdextension-fix-gdnative-types-const-qualifier branch from f16b9c7 to 02f4b0c Compare October 23, 2022 07:32
@touilleMan touilleMan force-pushed the gdextension-fix-gdnative-types-const-qualifier branch from 02f4b0c to 001f521 Compare November 12, 2022 22:56
@touilleMan
Copy link
Member Author

rebased ;-)

@touilleMan touilleMan force-pushed the gdextension-fix-gdnative-types-const-qualifier branch from 001f521 to c6d7abd Compare November 12, 2022 23:27
@Calinou Calinou added bug and removed enhancement labels Nov 13, 2022
Copy link
Member

@groud groud left a comment

Choose a reason for hiding this comment

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

Approved in GDExtension PR review.

The modification in linux_builds.yml needs to be removed once the related PR in godot-cpp is merged.

@touilleMan touilleMan force-pushed the gdextension-fix-gdnative-types-const-qualifier branch 2 times, most recently from 28161ba to 61c900a Compare December 3, 2022 10:14
@akien-mga akien-mga merged commit 8cf1bea into godotengine:master Dec 3, 2022
@akien-mga
Copy link
Member

Thanks!

@touilleMan touilleMan deleted the gdextension-fix-gdnative-types-const-qualifier branch December 3, 2022 18:11
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