Skip to content

Simplify and optimize call arguments from generic parse_class_body() #107849

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

Closed

Conversation

Lazy-Rabbit-2001
Copy link
Contributor

The calls called in parse_class_body() requires a series of booleans, which would lead to problems, especially parse_variables() as it has a overloading version with 3 booleans, which has potential conflict with the one with 2 booleans.

In this pr, these calls receive only one int argument as flags. Not only do the arguments get reduced, but this solves the conflict mentioned above.

@Lazy-Rabbit-2001 Lazy-Rabbit-2001 requested a review from a team as a code owner June 22, 2025 14:15
@AThousandShips AThousandShips changed the title Simplified and optimized calls' arguments from generic parse_class_body() Simplify and optimize call arguments from generic parse_class_body() Jun 22, 2025
@@ -876,13 +876,13 @@ bool GDScriptParser::has_class(const GDScriptParser::ClassNode *p_class) const {
return false;
}

GDScriptParser::ClassNode *GDScriptParser::parse_class(bool p_is_abstract, bool p_is_static) {
GDScriptParser::ClassNode *GDScriptParser::parse_class(int p_flags) {
Copy link
Member

Choose a reason for hiding this comment

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

This (and other places where you want to pass these flags) should use BitField. Passing flags in a plain int doesn't provide enough static safety.

@vnen
Copy link
Member

vnen commented Jun 22, 2025

I'm against refactoring just for the sake of it. There's no reason to believe we'll be adding more flags in the future. The abstract one is already being removed in #107717.

@Lazy-Rabbit-2001
Copy link
Contributor Author

Lazy-Rabbit-2001 commented Jun 22, 2025

dunno why but when I used the BitField some tests returned incorrect results.
plus, I checked the @abstract being annotation and the boolean will be removed from the call parse_function() and parse_class(). Seems that there's only p_static left. If static becomes @static maybe we can finally call these calls without any extra modifier parameters.

Closed and removed the branch.

@Lazy-Rabbit-2001 Lazy-Rabbit-2001 deleted the gds_simplification branch June 22, 2025 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants