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

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

Merged
merged 3 commits into from
Jul 1, 2023

Conversation

GeezerLMAO
Copy link
Contributor

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

@floooh
Copy link
Owner

floooh commented Jun 26, 2023

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
Copy link
Contributor Author

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

@GeezerLMAO GeezerLMAO changed the title change @srcToDest to @destFromSrc Use zig fmt to fix the casting changes in the latest zig version Jun 29, 2023
@nurpax
Copy link

nurpax commented Jun 29, 2023

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.)

pip_desc = .{
.shader = sg.makeShader(shd.quadShaderDesc(sg.queryBackend())),
.primitive_type = .TRIANGLE_STRIP,
.blend_color = .{ .r=1.0, .g=0.0, .b=0.0, .a=1.0 }
Copy link

Choose a reason for hiding this comment

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

With a trailing comma for the last argument, zig fmt will preserve multiple lines for pip_desc initialization. In other words, add a comma , after the closing brace } of .blend_color = ....

.blend_color = .{ .r=1.0, .g=0.0, .b=0.0, .a=1.0 },

const t: vec3 = .{
.x = (@intToFloat(f32, dst) - shift) * 3.0,
.y = (@intToFloat(f32, src) - shift) * 2.2,
.z = 0.0
Copy link

Choose a reason for hiding this comment

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

Again, trailing comma would preserve the multiple lines here.

@GeezerLMAO
Copy link
Contributor Author

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

@nurpax
Copy link

nurpax commented Jun 29, 2023

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
Copy link
Owner

floooh commented Jun 30, 2023

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
Copy link

nurpax commented Jun 30, 2023

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: floooh/sokol#849

@floooh
Copy link
Owner

floooh commented Jul 1, 2023

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

@floooh floooh merged commit 0c30d0a into floooh:zig-0.11.0 Jul 1, 2023
0 of 3 checks passed
@floooh
Copy link
Owner

floooh commented Jul 1, 2023

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
Copy link
Owner

floooh commented Jul 1, 2023

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.

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.

4 participants