mirror of
https://github.com/zoriya/zig-wayland.git
synced 2026-06-09 21:09:25 +00:00
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 },
This commit is contained in:
committed by
Isaac Freund
parent
1c52af0b46
commit
fbb211dff4
+9
-3
@@ -309,9 +309,15 @@ const Message = struct {
|
||||
},
|
||||
.object, .new_id => |new_iface| {
|
||||
if (arg.kind == .object or target == .server) {
|
||||
try writer.writeAll(".{ .o = @ptrCast(*common.Object, ");
|
||||
try printIdentifier(writer, arg.name);
|
||||
try writer.writeAll(") },");
|
||||
if (arg.allow_null) {
|
||||
try writer.writeAll(".{ .o = if (");
|
||||
try printIdentifier(writer, arg.name);
|
||||
try writer.writeAll(") |o| @ptrCast(*common.Object, o) else null },");
|
||||
} else {
|
||||
try writer.writeAll(".{ .o = @ptrCast(*common.Object, ");
|
||||
try printIdentifier(writer, arg.name);
|
||||
try writer.writeAll(") },");
|
||||
}
|
||||
} else {
|
||||
if (new_iface == null) {
|
||||
try writer.writeAll(
|
||||
|
||||
Reference in New Issue
Block a user