floooh / sokol-zig

Zig bindings for the sokol headers (https://github.com/floooh/sokol)
zlib License
341 stars 46 forks source link

Use `zig fmt` to fix the casting changes in the latest zig version #39

Closed GeezerLMAO closed 1 year ago

GeezerLMAO commented 1 year ago

New change from the latest zig version uses @destFromSrc() instead of @srcToDest() for casting

floooh commented 1 year ago

Ah ok, tests are expected to fail because the CI pipeline doesn't use the Zig dev version.

I'll try to test the change manually before merging the PR, might take a couple of days though until I get around it.

GeezerLMAO commented 1 year ago

This Fixes #40 but zig fmt also formats the code, so a lot has change

nurpax commented 1 year ago

IMO it'd be great to always format the Zig sources in Sokol with zig fmt. Otherwise it's kind of hard to make PRs against these files. (I have zig fmt integrated into VSCode "save file" and I think many others have it like this too.)

GeezerLMAO commented 1 year ago

Tried to preserve the old formatting but I'm sure I'm missing a lot.

nurpax commented 1 year ago

Looks good to me at least. That's the style of Zig that I see everywhere.

I used to sweat over code formatting, like aligning tables & such, but the convenience of just hitting Save in VSCode and letting it run "zig fmt" to clean things up is so high.

floooh commented 1 year ago

Hmm, we should probably fix the code generation so that the output matches zig fmt (the Rust generator currently has the same problem (codegen doesn't match cargo fmt, and that's a bit of a hassle).

This can wait a bit though.

like aligning tables & such

This is my main complaint with formatting tools, anything that's not properly aligned seems to trigger my OCPD ;)

It's ok though, maybe zig fmt will one day get a bit more clever about column formatting.

nurpax commented 1 year ago

This is my main complaint with formatting tools, anything that's not properly aligned seems to trigger my OCPD ;)

Yup, that's been my biggest issue with auto-formatting tool. At some point I just gave up though since auto-formatting seem to be increasingly prevalent (esp. with golang where it's basically required for any real work) and none of these tools seem to care much for this type of alignment. I wouldn't go back to manual formatting anymore, "format on save" is just so convenient and you learn to rely on it a lot.

It's nice that at least line breaks can be controlled pretty well with added commas, as was used in this PR too.

Hmm, we should probably fix the code generation so that the output matches zig fmt (the Rust generator currently has the same problem (codegen doesn't match cargo fmt, and that's a bit of a hassle).

I can volunteer for looking into this. :) EDIT: here you go: https://github.com/floooh/sokol/pull/849

floooh commented 1 year ago

...going to merge this now, and then apply the new bindgen with @nurpax's formatting fixes.

floooh commented 1 year ago

ah... when doing this I also need to fix the samples for the last round of breaking changes (in the sokol headers) doh... (the 0.11.0 branch unfortunately wasn't updated yet... would have made sense to do this first, but too late now)

floooh commented 1 year ago

Ok, the zig-0.11.0 branch should now be in good shape again, and also updated with the latest headers and example fixes from master.