SiegeLord / DAllegro5

D binding to the Allegro5 game development library
Other
42 stars 15 forks source link

Fix #53: in X* -> const(X)* for DMD 2.104.0 #54

Closed SimonN closed 1 year ago

SimonN commented 1 year ago

This fixes the warnings from DMD 2.104.0 as in #53.

I've agreed with SiegeLord that in X* in C bindings should become const(X)*. It's not a perfect match (C's const is not transitive), but it comes closest in semantics.

I haven't looked at D1 semantics for in. It's theoretically possible that this breaks D1 projects.

Because this change touches so many files, I've trimmed all trailing whitespace throughout the project in a separate commit first. Let me know if you don't want that trimming; I'll manually reapply the second commit then to the untrimmed codebase.

SimonN commented 1 year ago

You can verify that the first commit really touches only whitespace by observing empty output of git diff -w:

git diff origin/master..dmd-in-warnings^ -w

Lix (my game) has run without problems for over a week using both commits in DAllegro5. Lix loads and plays music, sound, draws text, images, reads mouse and keyboard, ...


I've reviewed the entire second commit myself. The code semantics were fine.

Nonetheless, I changed the second commit in two places. Last week's second commit was this now-unlinked commit. The new second commit (99b3229) corrects a bogus automatic replacement in a comment:

Bad: ALLEGRO_DISPLAY* display; /* the window the key was pressed const()*/ Now: ALLEGRO_DISPLAY* display; /* the window the key was pressed in */

Also, it fixes a double whitespace * s that my autoreplacement introduced:

Bad: ALLEGRO_USTR* al_ustr_new_from_utf16(const(ushort)* s); Now: ALLEGRO_USTR* al_ustr_new_from_utf16(const(ushort)* s);

Except for these two changes, this PR is identical to how it was last week.

SiegeLord commented 1 year ago

Thanks!