Skip to content

Specifically handle each "meta" value, so new ones don't break code generation#1868

Merged
dsnopek merged 1 commit into
godotengine:masterfrom
dsnopek:meta-required
Oct 20, 2025
Merged

Specifically handle each "meta" value, so new ones don't break code generation#1868
dsnopek merged 1 commit into
godotengine:masterfrom
dsnopek:meta-required

Conversation

@dsnopek

@dsnopek dsnopek commented Oct 17, 2025

Copy link
Copy Markdown
Collaborator

Originally, this PR specifically ignored the "required" meta that is added in PR godotengine/godot#86079

However, I've decided to go a different way instead, and specifically address all the "meta" values we are aware of, so that things won't break in the future when new ones are added (including the "required" one)

This should make this safe to be merged even before that PR and cherry-pick it

Original Description

This fixes issues in our code generation when used with Godot PR godotengine/godot#86079

It basically just makes it ignore the "required" meta, which may be the right thing to do for godot-cpp, at least as far as handling APIs from Godot, although, this is something we should discuss.

But even if we do do that, we should still add RequiredParam<T> and RequiredValue<T> in godot-cpp for the purpose of marking APIs created in GDExtensions as having required parameters and values, but that can be a separate PR (since this one will need to be cherry-picked to Godot 4.5, but the further changes shouldn't be)

@dsnopek dsnopek added this to the 4.x milestone Oct 17, 2025
@dsnopek
dsnopek requested a review from a team as a code owner October 17, 2025 20:17
@dsnopek dsnopek added enhancement This is an enhancement on the current functionality cherrypick:4.5 labels Oct 17, 2025
@dsnopek
dsnopek marked this pull request as draft October 17, 2025 20:17
@dsnopek dsnopek changed the title [DRAFT] Handle "required" meta in extension_api.json for arguments and return values Specifically handle each "meta" value, so new ones don't break code generation Oct 18, 2025
@dsnopek
dsnopek marked this pull request as ready for review October 18, 2025 19:03
@dsnopek

dsnopek commented Oct 18, 2025

Copy link
Copy Markdown
Collaborator Author

I've decided to go a different way instead, and specifically address all the "meta" values we are aware of, so that things won't break in the future when new ones are added (including the "required" one)

This should make this safe to be merged even before PR godotengine/godot#86079 and cherry-pick it

Comment thread binding_generator.py
@@ -2745,12 +2745,12 @@ def correct_typed_dictionary(type_name):
def correct_type(type_name, meta=None, use_alias=True):
type_conversion = {"float": "double", "int": "int64_t", "Nil": "Variant"}
if meta is not None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What if meta is not None, but we don't handle it here (unexpected value)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It will ignore it. That's actually the whole point of this PR: if there's an unexpected value in "meta", then we'll ignore it and not potentially generate invalid code.

PR godotengine/godot#86079 adds "required" as a potential value for "meta", and without this PR, it'll generate invalid code (attempting to use "required" as a type name).

@Ivorforce Ivorforce left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense to me.

@dsnopek
dsnopek merged commit b14df6e into godotengine:master Oct 20, 2025
16 checks passed
@dsnopek

dsnopek commented Oct 20, 2025

Copy link
Copy Markdown
Collaborator Author

Cherry-picked for 4.5 in PR #1870

@dsnopek

dsnopek commented Oct 20, 2025

Copy link
Copy Markdown
Collaborator Author

Cherry-picked for 4.4 in PR #1871

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

Labels

enhancement This is an enhancement on the current functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants