197 Commits

Author SHA1 Message Date
Isaac Freund
e5eeb6827b Use void instead of struct {} 2020-11-25 20:00:30 +01:00
Isaac Freund
7848a30142 @ptrCast() T to ?*c_void not itself 2020-11-25 10:48:42 +01:00
Isaac Freund
1bb7c5d0f0 Fix assorted minor errors
Getting close to building river!
2020-11-24 21:28:01 +01:00
Isaac Freund
b74348e448 Fix missing prefix of generated file names 2020-11-24 20:47:56 +01:00
Isaac Freund
a355fe89ef Use proper types for fds to ensure ABI compat 2020-11-23 23:07:09 +01:00
Isaac Freund
3a644d2671 Add @ptrCasts/return errors from EventLoop functions 2020-11-23 23:05:04 +01:00
Isaac Freund
9502db8826 Expose postNoMemory() on server objects 2020-11-23 22:06:26 +01:00
Isaac Freund
2a42d7a27b Emit normal C ABI enums as well for bitfields
These are needed in some cases when interacting with C code.
2020-11-23 20:24:50 +01:00
Isaac Freund
65c342ce62 Prefix namespace of unstable protocols with 'z'
wlr_layer_shell_unstable_v1 becomes zwlr.LayerShellV1
2020-11-21 14:03:20 +01:00
Isaac Freund
f7e3dd462b Put all protocols without prefix in wl namespace
The "drm" protocol also has no prefix and belongs in wl.
2020-11-21 11:48:04 +01:00
Isaac Freund
61e3a8d54e Add recursive ref all decls test, fix errors
Breaking change: Object.interface() renamed to Object.getInterface() for
consistency and to avoid shadowing.

Note: this test doesn't function properly with zig 0.7.0, this issue has
been fixed in https://github.com/ziglang/zig/pull/7178
2020-11-20 20:28:43 +01:00
Isaac Freund
181f9344b2 Migrate missed functions to new list impl 2020-11-18 18:32:54 +01:00
Isaac Freund
f77821b1aa Improve type safe list API
- Add support for lists of wl.Resource/wl.Client
- Greatly simplify code
2020-11-18 18:25:22 +01:00
Isaac Freund
ba49b2b6f9 Make wl_list bindings type-safe 2020-11-18 14:55:05 +01:00
Isaac Freund
0c0f5ccf33 Properly generate server objects without requests 2020-11-09 00:41:07 +01:00
Isaac Freund
683511ef00 Fix duplicate generated function 2020-11-07 11:03:18 +01:00
Isaac Freund
c1b300afab Expose more Resource functions on wrapper objects 2020-11-06 19:14:03 +01:00
Isaac Freund
9a3a603f50 Add type safety for server object destroy handlers 2020-11-06 18:37:25 +01:00
Isaac Freund
a336fec68d Generate create() and destroy() for server objects 2020-11-06 18:00:44 +01:00
Isaac Freund
6c7dc1e562 Make packed struct bitfields have alignment of u32
This allows safely including them as fields of extern structs where a
u32 is expected.
2020-11-03 23:12:17 +01:00
Isaac Freund
931b6f767b Use std.ascii.spaces 2020-11-03 00:35:56 +01:00
Marten Ringwelski
5fd4f6aa1c code: Use std.mem.trim instead of deprecated std.fmt.trim 2020-11-02 17:44:55 +01:00
Isaac Freund
d0fcd31b54 Use process.getCwdAlloc() instead of $PWD
This should be more reliable
2020-11-02 13:56:01 +01:00
Isaac Freund
c7f2b5e6d0 Convert relative to absolute paths if needed 2020-11-02 12:38:14 +01:00
Isaac Freund
590773b617 Rethink handling of client vs server linkage
The simplest and most flexible way to handle things is to stop linking
wayland-client/wayland-server for the user and let them handle it,
always generating bindings for both. This greatly simplifies integration
with projects using both client and server bindings in different
LibExeObjSteps.
2020-11-01 14:42:53 +01:00
Isaac Freund
f335337bca Add README 2020-11-01 13:53:47 +01:00
Isaac Freund
b6cbd99882 Integrate scanner with the zig build system 2020-11-01 13:23:08 +01:00
Isaac Freund
62c3dbdc9a Drop expat for pure zig xml parser 2020-10-31 19:16:07 +01:00
Tadeo Kondrak
f1b4bbac4c Add a native Zig XML parser 2020-10-31 18:46:54 +01:00
Reiner Gerecke
dad6bea7ce Add example for seats, showing bitfield support 2020-10-24 10:11:21 +02:00
Reiner Gerecke
a643ab20a1 Use enum attributes in request arguments 2020-10-24 10:11:21 +02:00
Isaac Freund
b4d4428fe8 Implement addSocketAuto() that skips wayland-0 2020-10-19 19:45:59 +02:00
Reiner Gerecke
9bdc09e66a Fix wrong namespace references for unstable interfaces
A protocol as defined in "wlr-screencopy-unstable-v1.xml", named
"wlr_screencopy_unstable_v1" will emit something like this in
commons.zig

    pub const wlr = struct {pub usingnamespace @import("wlr_screencopy_unstable_v1_common.zig");};

under the name "wlr". That is the prefix derived from the protocol name.

Definitions in client/server however use the interface's name to get the
namespace, which for an interface such as "zwlr_screencopy_manager_v1"
would result in references to commons.zig like this:

    pub const Error = common.zwlr.layer_shell_v1.Error;

Those references break. This change passes the namespace from the
protocol down to the interface emitters.
2020-10-19 11:35:11 +02:00
Reiner Gerecke
1849d4e513 Properly cast Fixed in Dispatcher
Fixes the following error:

    ./zig-wayland/common.zig:75:44: error: cannot cast a value of type '.wayland.common.Fixed'
                          4 => @bitCast(f.field_type, args[i].u),
                                         ^
    ./zig-wayland/common.zig:75:44: note: use @intToEnum for type coercion
                          4 => @bitCast(f.field_type, args[i].u),
                                         ^
    ./zig-wayland/common.zig:75:64: note: referenced here
                                4 => @bitCast(f.field_type, args[i].u),
2020-10-18 21:41:59 +02:00
Reiner Gerecke
f4d11e4ed2 Complete implementation of Fixed conversions 2020-10-18 21:41:59 +02:00
Reiner Gerecke
a9825f44ed Run tests defined in scanner.zig and common_core.zig 2020-10-18 21:41:59 +02:00
Reiner Gerecke
fbb211dff4 Emit functions accepting optional object pointers
The previous code would always generate this:

  .{ o = @ptrCast(*common.Object, argument) },

That fails if `argument` is optional, with this change, it generates
this instead:

  .{ o = if (argument) |o| @ptrCast(*common.Object, o) else null },
2020-10-18 11:51:10 +02:00
Reiner Gerecke
1c52af0b46 Fix handling allow-null attributes when scanning
The current code compares "allow_null" (with underscore) against
"allow-null" (with hyphen) from the XML. That always fails and
allow_null is left to the default value.
2020-10-18 11:51:10 +02:00
Isaac Freund
c3bf235498 Fix failing test after refactor 2020-10-18 11:44:21 +02:00
Isaac Freund
fda4c78e79 Allow void Signal/Listeners, add example 2020-10-17 23:06:05 +02:00
Isaac Freund
b21e255e02 Make List.next/List.prev nullable
libwayland sets these to null on removal
2020-10-17 21:51:37 +02:00
Isaac Freund
73b5763460 Remove outdated test data 2020-10-17 11:49:18 +02:00
Isaac Freund
16c0fc24e8 Remove wayland.common from public API
All of the necessary pieces are re-exported in wayland.server.wl and
wayland.client.wl, which makes the package nicer to use as only one
import is needed.
2020-10-15 19:11:17 +02:00
Isaac Freund
38e12ad2fe Use non-exhaustive enums for forward compatibility 2020-10-15 19:11:17 +02:00
Isaac Freund
64a20bf4cb Make all enums extern
This is required to use the zig-wayland with C APIs such as wlroots.
2020-10-13 22:50:25 +02:00
Isaac Freund
82da74d346 Make Signal/Listener more type safe 2020-10-12 21:10:48 +02:00
Isaac Freund
f0d4b6306c Use a stronger cast on pointer args
We need to cast alignment and constness in some cases. Don't worry, this
is totally safe
2020-10-12 01:28:45 +02:00
Isaac Freund
dd00dcf3bb Fill in some wl_display client error handling 2020-10-12 01:23:24 +02:00
Isaac Freund
caae5189b4 Generate missing @ptrCast 2020-10-11 22:37:22 +02:00
Isaac Freund
f8f4636abf Emit full namespace for argument types
This is needed if a local object has the same basename as an object in
another namespace (e.g. xdg_surface and wl_surface)
2020-10-11 22:28:32 +02:00