Unfortunately FieldEnum is causing dependency loops in practice as
introspecting T with @typeInfo() requires T to be fully resolved.
Using an enum literal is far simpler and still avoids the memoization
problems of using slices.
This avoids issues with zig's comptime function memoization semantics
when pointer types such as slices are used.
References: https://github.com/ziglang/zig/issues/7948
Make use of destructor annotations on events to generate more robust
server code. It's now impossible to forget e.g. the required
wl.Callback.destroy() call after wl.Callback.sendDone() since now there
is no wl.Callback.sendDone(), only wl.Callback.destroySendDone().
For example, zwp_linux_dmabuf_v1 can create a wl_buffer but it's not in
the same file/namespace. To fix this the scanner must emit
`client.wl.buffer` instead of just `Buffer`.
Like wl_display, wl_registry, and wl_callback, wl_buffer is special
in that it can be created through multiple different interfaces and is
locked to version 1.
Currently we are only capping the version of the client side object
created, not the version we tell the server to create. Obviously, this
is a problem.
For example, zwlr_screencopy_frame_v1 is created by both
zwlr_screencopy_manager_v1.capture_output and
zwlr_screencopy_manager_v1.capture_output_region.
Passing the version advertised by the server directly to
wl_registry_bind() is a common bug in clients using libwayland (e.g.
chromium, some of my own programs, many others). Clients should instead
compare the server advertised version with the maximum version the
client supports to avoid forwards compatibility bugs.
To make such bugs impossible, leverage the compile time known max
supported interface versions we now have to limit the version passed to
wl.Registry.bind().
This was actually always broken as it didn't work properly unless called
after all protocols had already been added with addProtocolPath() and
addSystemProtocol(), breaking the declarative nature of the zig build
system.
This brokenness was made much worse by a recent cleanup commit however.
Invalid protocol xml will still give poor error messages, but that won't
be fixed until there exists a more featureful xml parser for zig which
can report token line/column numbers and whatnot. Until then using
wayland-scanner to validate protocol xml is recommended.
Now calling ScanProtocolsStep.generate() with a global interface name
not found in the protocol xml will result in an error, which should help
catch typos.
Now only wl_display, wl_registry, and wl_callback are generated by
default (these interfaces are locked to version 1 for eternity).
All other interfaces must be explicitly requested in the program's
build.zig using ScanProtocolsStep.generate(global_name, version).
This ensures forwards compatibility of programs written using
zig-wayland with newer protocol xml.