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

Core: Bind and document iterator API virtual methods #89649

Conversation

dalexeev
Copy link
Member

@dalexeev dalexeev commented Mar 18, 2024

This is documented here, but I think it's not enough. This is one of Godot's secret features. Binding and documentation facilitates better discoverability, autocompletion, and static checks. See also #89639, the bug still exists only because it is not obvious that the _iter_get() argument does not have Array wrapper, unlike _iter_init() and _iter_next().


// These are actually `Variant` methods, but that doesn't matter since scripts can't inherit built-in types.

BIND_OBJ_CORE_METHOD(MethodInfo(Variant::BOOL, "_iter_init", PropertyInfo(Variant::ARRAY, "iter")));
Copy link
Member Author

Choose a reason for hiding this comment

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

The name iter comes from here. I was thinking about binding this as state, but not sure.

bool iter_init(Variant &r_iter, bool &r_valid) const;
bool iter_next(Variant &r_iter, bool &r_valid) const;
Variant iter_get(const Variant &r_iter, bool &r_valid) const;

@dalexeev dalexeev force-pushed the core-bind-and-doc-iter-virtual-methods branch from 8bcb25d to 8aa0533 Compare March 19, 2024 07:57
Copy link
Member

@mhilbrunner mhilbrunner left a comment

Choose a reason for hiding this comment

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

Documentation looks good to me.

@dalexeev dalexeev force-pushed the core-bind-and-doc-iter-virtual-methods branch from 8aa0533 to be5068d Compare August 27, 2024 18:57
Copy link
Contributor

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

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

I hope @dalexeev knows the documentation part is fine by me, too.

@dalexeev dalexeev modified the milestones: 4.x, 4.4 Sep 4, 2024
@dalexeev
Copy link
Member Author

dalexeev commented Sep 4, 2024

Since in my opinion this is a simple, small, but useful addition and since there are two approvals, I moved milestone to 4.4.

@akien-mga akien-mga merged commit 58b3481 into godotengine:master Sep 6, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

@dalexeev dalexeev deleted the core-bind-and-doc-iter-virtual-methods branch September 6, 2024 09: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.

Remove function argument for custom iterators in GDScript
5 participants