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

Fixes for latest Zig master #72

Closed
wants to merge 3 commits into from

Conversation

sin-ack
Copy link
Contributor

@sin-ack sin-ack commented Sep 15, 2024

This PR updates the project for the latest changes in Zig master. The project is now buildable and runnable under Zig 0.14.0-dev.1573+4d81e8ee9. The extension code has also been updated.

I am able to run zig build codegen -Dgir-profile=gnome46 inside the Flatpak environment successfully with these changes.

Zig no longer allows field and declaration names within the same decl
scope to be the same. This mostly affects bit-fields, where the decls
for individual values are now prefixed with "flag_", and classes/records
where fields are prefixed with "field_".
@ianprime0509
Copy link
Owner

Thanks for the PR! Sorry I haven't been keeping this project as up to date as it should be; I got sidetracked rewriting my XML parser, and now that that's mostly done, I'm hoping to come back to make more progress here.

Currently, I'm trying to primarily target Zig 0.13.0 until a new release is tagged, to make things a bit easier/more stable for users who might want to take advantage of other dependencies also following the latest tagged release (e.g. https://github.com/allyourcodebase as one recent example) and ecosystem tools such as the Zig SDK extension for Flatpaks. However, I would definitely like the generated bindings to support Zig master as well, which I think should be possible on top of your current changes by replacing direct usage of @typeInfo with a wrapper function that adapts the older naming conventions to match the new ones (and which could be removed when Zig 0.14.0 is out).

The Zig version targeted by the bindings generator itself is a little more flexible, since it's not going to be used by other projects. I'm inclined to go with using Zig master for it, given there are no other constraints.

In order to effectively support both 0.13.0 and master for the bindings, the test sub-project will need to be updated as well to support running under both versions; there's a bunch of "ABI tests" being generated as part of the translation process which were helpful earlier in development for spotting issues (though more ad-hoc than something like ziglang/zig#20654) which can probably be made to work on both versions in a similar way to the bindings.

I'd also like to double-check the field names being changed and make sure none of them break any of the translated virtual method helpers (which reference fields in their implementations).

I know that's a lot; when I get a chance later this week I'm planning to come back to this and take another look, and build on top of this PR to address the points mentioned above (though you're certainly welcome to try making any of those changes yourself, if you'd like). Thanks again for getting this started!

@sin-ack
Copy link
Contributor Author

sin-ack commented Sep 16, 2024

Thanks for the detailed explanation! My changes were "just enough" to make a basic GTK application work with Zig master (as part of the Browser Jam), and I definitely didn't check things exhaustively. Please feel free to base your changes off of mine. Best of luck!

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.

2 participants