Skip to content

Conversation

@MightyJosip
Copy link
Member

A lot of code used for different rect attributes is repeated. So this PR moves it to macro, and for each attribute only defines unique parts

@MightyJosip MightyJosip requested a review from a team as a code owner June 9, 2025 12:42
Copy link
Member

@zoldalma999 zoldalma999 left a comment

Choose a reason for hiding this comment

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

There's a conflict now, because relcenter was added. Also added a nitpicky comment/question.

Comment on lines +2455 to +2460
RECT_ATTRIBUTE(topright,
TupleFromTwoPrimitives(self->r.x + self->r.w, self->r.y),
PrimitiveType val1;
PrimitiveType val2, twoPrimitivesFromObj(value, &val1, &val2),
self->r.x = val1 - self->r.w;
self->r.y = val2;)
Copy link
Member

Choose a reason for hiding this comment

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

Not sure how much the formatter allows it, but it was not clear to me that val1 and val2 are in the same argument, or what each argument does. Maybe adding comments might help?

@Starbuck5
Copy link
Member

Making functions inside macros is definitely tempting, especially for repetition like this. However it does make it harder to jump around the code with editor tools and sometimes to read at all. (Although rect is already pretty bad in this regard).

So my idea here would be to leave the function definitions hardcoded, but use macros to take over repetitive parts / the whole of the bodies of the functions.

Anyways marking as draft pending merge conflict resolution.

@Starbuck5 Starbuck5 marked this pull request as draft November 2, 2025 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants