197 Commits

Author SHA1 Message Date
045c1f9a4d Use const for const var 2023-12-22 20:48:42 +01:00
4a91d9dc7d Use build.run instead of build.exec 2023-12-22 20:38:25 +01:00
Hugo Machet
b9c6fcb8ca docs: Update to addCustomProtocol() in README 2023-09-25 23:32:38 +02:00
Isaac Freund
7f528883e0 ci: update to Zig 0.11.0 2023-08-12 16:05:39 +02:00
Isaac Freund
bdbf7b6b5c docs: Update example in README 2023-08-12 16:03:16 +02:00
Isaac Freund
8918e2659f build: allow custom wayland.xml/wayland-protocols paths 2023-08-12 15:51:00 +02:00
Isaac Freund
fc14d2efb7 build: refactor to eliminate Scanner.finish() 2023-08-11 19:16:39 +02:00
Isaac Freund
a956f4461d Update zig version in README 2023-08-09 15:42:57 +02:00
Isaac Freund
f41a61d655 Fix compile error in setHandler 2023-08-09 12:46:47 +02:00
Isaac Freund
6042311f2a Fix compilation error in setHandler() generation 2023-08-02 21:22:46 +02:00
Isaac Freund
d874998dea Track FileSource -> LazyPath changes 2023-08-02 20:29:46 +02:00
Isaac Freund
2a74c691eb Enforce alignment of Array.slice() at compile time 2023-07-20 23:25:47 +02:00
JimnwQ
c2ae31892e Track deprecating std.cstr namespace 2023-07-20 23:19:59 +02:00
JimnwQ
000bf6f9ed Track deprecating std.math.min / std.math.max 2023-07-20 23:19:59 +02:00
JimnwQ
95b0a4e2a1 Track removing destination type from cast builtins 2023-07-20 23:19:59 +02:00
JimnwQ
6f3a2f8781 Track xToY() renamed to yFromX() breaking changes 2023-07-20 23:19:59 +02:00
Isaac Freund
aaeb7e2545 Track @call() breaking change 2023-06-17 12:13:59 +02:00
Isaac Freund
8139379080 Remove wart of new build.zig API 2023-06-15 20:00:05 +02:00
Isaac Freund
8429629cb5 Update to Zig master 2023-06-15 19:24:52 +02:00
Isaac Freund
d507189f62 scanner: handle keywords in camelCase formatting 2023-03-16 10:31:22 +01:00
Isaac Freund
e9484c8148 Make prepend/appendList() leave other initialized 2023-02-27 17:56:29 +01:00
Isaac Freund
dd9ffa05cc Switch to enum literals for list.Head
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.
2023-02-27 17:27:37 +01:00
Isaac Freund
676ba262dd Fix list.FieldEnum when there are no fields 2023-02-27 13:26:23 +01:00
Isaac Freund
e88586a81a Add list.Head.prependList/appendList
The existing insertList never compiled.
2023-02-27 13:16:11 +01:00
Isaac Freund
45c11bb3ec Use an enum for the field name in list.Head
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
2023-02-27 13:16:02 +01:00
Isaac Freund
d8f8e4a1d6 Add more list.Link Functions
- Add Link.replaceWith()
- Add Link.swapWith()
- Rename Link.insertAfter() -> Link.insert() as the status quo reads
  very poorly in practice.
2023-02-26 12:06:48 +01:00
Isaac Freund
b3789919b7 Add list.Link.init()
This is useful on links as well to allow remove() to be called even if
not added to a list.
2023-02-24 15:05:24 +01:00
Isaac Freund
ace6aeebcf common: fix build on aarch64 and others
On aarch64 for example, function alignment is 4 so we need to
@alignCast() when casting ?*const anyopaque to function pointers.
2023-01-09 14:45:43 +01:00
Isaac Freund
71d21959b4 scanner: use destructor event annotations
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().
2022-12-31 23:11:50 +01:00
Ashlynn Anderson
d1d9714840 Correct error in EventLoop.addIdle()
`_wrapper` return type should be `void`, not `c_int`.
2022-12-18 18:36:33 +01:00
Isaac Freund
cf165f481e scanner: add missing version check on server side
Currently we generate all server side functions to send events
regardless of the max protocol version requested at build time.
2022-12-02 15:08:48 +01:00
Isaac Freund
10ca26f93e ci: update for zig 0.10.0 2022-11-27 17:46:47 +01:00
Isaac Freund
717d292d40 Update to zig 0.10.0 2022-11-27 17:42:25 +01:00
Isaac Freund
f64abbd016 common: make Array.slice() helper safer 2022-07-11 23:33:34 +02:00
Isaac Freund
c09f4d631b ci: fix xbps invocation 2022-06-02 20:29:30 +02:00
Isaac Freund
6052024f92 common: clean up wl.Array.slice() helper 2022-06-02 20:00:59 +02:00
Isaac Freund
ead050907d scanner: use buffered I/O in scanProtocol() 2022-05-21 20:04:43 +02:00
Isaac Freund
c677cf8348 scanner: improve error message on parse failure 2022-05-20 16:05:46 +02:00
Isaac Freund
86f6d102d9 scanner: handle references to interfaces in other protocols
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`.
2022-05-20 15:50:44 +02:00
Isaac Freund
ffc8fbe6c6 scanner: fix tests broken by previous commit 2022-05-20 14:43:27 +02:00
Isaac Freund
92c242cafc scanner: always generate wl_buffer, refactor
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.
2022-05-20 14:36:25 +02:00
Isaac Freund
0a0cca2f90 scanner: fix wl.Registry.bind() versioning safeguard
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.
2022-05-19 22:36:22 +02:00
Isaac Freund
1767128453 scanner: handle interfaces created by more than one message
For example, zwlr_screencopy_frame_v1 is created by both
zwlr_screencopy_manager_v1.capture_output and
zwlr_screencopy_manager_v1.capture_output_region.
2022-05-18 11:16:02 +02:00
Isaac Freund
6e298f878e client: limit version passed to wl.Registry.bind()
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().
2022-05-18 10:55:51 +02:00
Isaac Freund
c19ffc58a8 scanner: fix memory leak
We were leaking namespace strings when separate protocol files share the
same namespace. Luckily the std's general purpose allocator caught it :)
2022-05-11 17:59:07 +02:00
Isaac Freund
1b9628ba77 build: fix C source linkage
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.
2022-05-11 17:37:06 +02:00
Isaac Freund
5336fea583 scanner: improve error handling
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.
2022-05-11 17:22:05 +02:00
Isaac Freund
f8c1dcf05f scanner: cleanup memory leaks 2022-05-11 00:17:06 +02:00
Isaac Freund
57cfef1d4e scanner: error if requested global not found
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.
2022-05-10 23:59:07 +02:00
Isaac Freund
c9b8c0c424 scanner: require explicit target globals/versions
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.
2022-05-10 23:31:25 +02:00