Skip to content

Commit

Permalink
Don't convert enum/flags to ptrs in signal callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
frmdstryr committed Jan 13, 2024
1 parent 7816bb0 commit 712f693
Show file tree
Hide file tree
Showing 139 changed files with 942 additions and 939 deletions.
5 changes: 4 additions & 1 deletion gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,11 @@ def func_arg_type(func, arg, imports: set[str]) -> Optional[str]:
it = f"*{it}" # Arg is modification?
if it.startswith("*") and arg.may_be_null():
return f"?{it}"
# Hack??
# Hack, why does is_pointer not work ??
if not it.startswith("*") and str(func).startswith("gi.SignalInfo"):
i = str(atype.get_interface())
if i.startswith("gi.EnumInfo") or i.startswith("gi.FlagInfo"):
return it
return f"*{it}"
return it
if t == "array" and (at := array_type_to_string(atype, imports)):
Expand Down
4 changes: 2 additions & 2 deletions src/gdk/drag.zig
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub const Drag = extern struct {
pub inline fn connectCancel(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, reason: *gdk.DragCancelReason, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, reason: gdk.DragCancelReason, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -143,7 +143,7 @@ pub const Drag = extern struct {
pub inline fn connectCancelSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, reason: *gdk.DragCancelReason) callconv(.C) void,
callback: *const fn (data: *T, reason: gdk.DragCancelReason) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down
4 changes: 2 additions & 2 deletions src/gio/dtls_connection.zig
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub const DtlsConnection = extern struct {
pub inline fn connectAcceptCertificate(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, peer_cert: *gio.TlsCertificate, errors: *gio.TlsCertificateFlags, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, peer_cert: *gio.TlsCertificate, errors: gio.TlsCertificateFlags, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -109,7 +109,7 @@ pub const DtlsConnection = extern struct {
pub inline fn connectAcceptCertificateSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, peer_cert: *gio.TlsCertificate, errors: *gio.TlsCertificateFlags) callconv(.C) void,
callback: *const fn (data: *T, peer_cert: *gio.TlsCertificate, errors: gio.TlsCertificateFlags) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down
4 changes: 2 additions & 2 deletions src/gio/file_monitor.zig
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub const FileMonitor = extern struct {
pub inline fn connectChanged(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, file: *gio.File, other_file: *gio.File, event_type: *gio.FileMonitorEvent, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, file: *gio.File, other_file: *gio.File, event_type: gio.FileMonitorEvent, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -124,7 +124,7 @@ pub const FileMonitor = extern struct {
pub inline fn connectChangedSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, file: *gio.File, other_file: *gio.File, event_type: *gio.FileMonitorEvent) callconv(.C) void,
callback: *const fn (data: *T, file: *gio.File, other_file: *gio.File, event_type: gio.FileMonitorEvent) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down
4 changes: 2 additions & 2 deletions src/gio/memory_monitor.zig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub const MemoryMonitor = extern struct {
pub inline fn connectLowMemoryWarning(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, level: *gio.MemoryMonitorWarningLevel, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, level: gio.MemoryMonitorWarningLevel, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -31,7 +31,7 @@ pub const MemoryMonitor = extern struct {
pub inline fn connectLowMemoryWarningSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, level: *gio.MemoryMonitorWarningLevel) callconv(.C) void,
callback: *const fn (data: *T, level: gio.MemoryMonitorWarningLevel) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down
8 changes: 4 additions & 4 deletions src/gio/mount_operation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub const MountOperation = extern struct {
pub inline fn connectAskPassword(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, message: [*c]const u8, default_user: [*c]const u8, default_domain: [*c]const u8, flags: *gio.AskPasswordFlags, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, message: [*c]const u8, default_user: [*c]const u8, default_domain: [*c]const u8, flags: gio.AskPasswordFlags, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -192,7 +192,7 @@ pub const MountOperation = extern struct {
pub inline fn connectAskPasswordSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, message: [*c]const u8, default_user: [*c]const u8, default_domain: [*c]const u8, flags: *gio.AskPasswordFlags) callconv(.C) void,
callback: *const fn (data: *T, message: [*c]const u8, default_user: [*c]const u8, default_domain: [*c]const u8, flags: gio.AskPasswordFlags) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down Expand Up @@ -222,7 +222,7 @@ pub const MountOperation = extern struct {
pub inline fn connectReply(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, result: *gio.MountOperationResult, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, result: gio.MountOperationResult, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -232,7 +232,7 @@ pub const MountOperation = extern struct {
pub inline fn connectReplySwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, result: *gio.MountOperationResult) callconv(.C) void,
callback: *const fn (data: *T, result: gio.MountOperationResult) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down
4 changes: 2 additions & 2 deletions src/gio/socket_client.zig
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pub const SocketClient = extern struct {
pub inline fn connectEvent(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, event: *gio.SocketClientEvent, connectable: *gio.SocketConnectable, connection: *gio.IOStream, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, event: gio.SocketClientEvent, connectable: *gio.SocketConnectable, connection: *gio.IOStream, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -208,7 +208,7 @@ pub const SocketClient = extern struct {
pub inline fn connectEventSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, event: *gio.SocketClientEvent, connectable: *gio.SocketConnectable, connection: *gio.IOStream) callconv(.C) void,
callback: *const fn (data: *T, event: gio.SocketClientEvent, connectable: *gio.SocketConnectable, connection: *gio.IOStream) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down
4 changes: 2 additions & 2 deletions src/gio/socket_listener.zig
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub const SocketListener = extern struct {
pub inline fn connectEvent(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, event: *gio.SocketListenerEvent, socket: *gio.Socket, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, event: gio.SocketListenerEvent, socket: *gio.Socket, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -151,7 +151,7 @@ pub const SocketListener = extern struct {
pub inline fn connectEventSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, event: *gio.SocketListenerEvent, socket: *gio.Socket) callconv(.C) void,
callback: *const fn (data: *T, event: gio.SocketListenerEvent, socket: *gio.Socket) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down
4 changes: 2 additions & 2 deletions src/gio/socket_service.zig
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub const SocketService = extern struct {
pub inline fn connectEvent(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, event: *gio.SocketListenerEvent, socket: *gio.Socket, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, event: gio.SocketListenerEvent, socket: *gio.Socket, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -180,7 +180,7 @@ pub const SocketService = extern struct {
pub inline fn connectEventSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, event: *gio.SocketListenerEvent, socket: *gio.Socket) callconv(.C) void,
callback: *const fn (data: *T, event: gio.SocketListenerEvent, socket: *gio.Socket) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down
4 changes: 2 additions & 2 deletions src/gio/threaded_socket_service.zig
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub const ThreadedSocketService = extern struct {
pub inline fn connectEvent(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, event: *gio.SocketListenerEvent, socket: *gio.Socket, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, event: gio.SocketListenerEvent, socket: *gio.Socket, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -200,7 +200,7 @@ pub const ThreadedSocketService = extern struct {
pub inline fn connectEventSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, event: *gio.SocketListenerEvent, socket: *gio.Socket) callconv(.C) void,
callback: *const fn (data: *T, event: gio.SocketListenerEvent, socket: *gio.Socket) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down
4 changes: 2 additions & 2 deletions src/gio/tls_connection.zig
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ pub const TlsConnection = extern struct {
pub inline fn connectAcceptCertificate(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, peer_cert: *gio.TlsCertificate, errors: *gio.TlsCertificateFlags, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, peer_cert: *gio.TlsCertificate, errors: gio.TlsCertificateFlags, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -214,7 +214,7 @@ pub const TlsConnection = extern struct {
pub inline fn connectAcceptCertificateSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, peer_cert: *gio.TlsCertificate, errors: *gio.TlsCertificateFlags) callconv(.C) void,
callback: *const fn (data: *T, peer_cert: *gio.TlsCertificate, errors: gio.TlsCertificateFlags) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down
16 changes: 8 additions & 8 deletions src/gtk/about_dialog.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ pub const AboutDialog = extern struct {
pub inline fn connectDirectionChanged(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, previous_direction: *gtk.TextDirection, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, previous_direction: gtk.TextDirection, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -1028,7 +1028,7 @@ pub const AboutDialog = extern struct {
pub inline fn connectDirectionChangedSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, previous_direction: *gtk.TextDirection) callconv(.C) void,
callback: *const fn (data: *T, previous_direction: gtk.TextDirection) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down Expand Up @@ -1058,7 +1058,7 @@ pub const AboutDialog = extern struct {
pub inline fn connectKeynavFailed(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, direction: *gtk.DirectionType, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, direction: gtk.DirectionType, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -1068,7 +1068,7 @@ pub const AboutDialog = extern struct {
pub inline fn connectKeynavFailedSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, direction: *gtk.DirectionType) callconv(.C) void,
callback: *const fn (data: *T, direction: gtk.DirectionType) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down Expand Up @@ -1118,7 +1118,7 @@ pub const AboutDialog = extern struct {
pub inline fn connectMoveFocus(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, direction: *gtk.DirectionType, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, direction: gtk.DirectionType, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -1128,7 +1128,7 @@ pub const AboutDialog = extern struct {
pub inline fn connectMoveFocusSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, direction: *gtk.DirectionType) callconv(.C) void,
callback: *const fn (data: *T, direction: gtk.DirectionType) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down Expand Up @@ -1198,7 +1198,7 @@ pub const AboutDialog = extern struct {
pub inline fn connectStateFlagsChanged(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, flags: *gtk.StateFlags, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, flags: gtk.StateFlags, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -1208,7 +1208,7 @@ pub const AboutDialog = extern struct {
pub inline fn connectStateFlagsChangedSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, flags: *gtk.StateFlags) callconv(.C) void,
callback: *const fn (data: *T, flags: gtk.StateFlags) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down
16 changes: 8 additions & 8 deletions src/gtk/action_bar.zig
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ pub const ActionBar = extern struct {
pub inline fn connectDirectionChanged(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, previous_direction: *gtk.TextDirection, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, previous_direction: gtk.TextDirection, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -650,7 +650,7 @@ pub const ActionBar = extern struct {
pub inline fn connectDirectionChangedSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, previous_direction: *gtk.TextDirection) callconv(.C) void,
callback: *const fn (data: *T, previous_direction: gtk.TextDirection) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down Expand Up @@ -680,7 +680,7 @@ pub const ActionBar = extern struct {
pub inline fn connectKeynavFailed(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, direction: *gtk.DirectionType, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, direction: gtk.DirectionType, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -690,7 +690,7 @@ pub const ActionBar = extern struct {
pub inline fn connectKeynavFailedSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, direction: *gtk.DirectionType) callconv(.C) void,
callback: *const fn (data: *T, direction: gtk.DirectionType) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down Expand Up @@ -740,7 +740,7 @@ pub const ActionBar = extern struct {
pub inline fn connectMoveFocus(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, direction: *gtk.DirectionType, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, direction: gtk.DirectionType, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -750,7 +750,7 @@ pub const ActionBar = extern struct {
pub inline fn connectMoveFocusSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, direction: *gtk.DirectionType) callconv(.C) void,
callback: *const fn (data: *T, direction: gtk.DirectionType) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down Expand Up @@ -820,7 +820,7 @@ pub const ActionBar = extern struct {
pub inline fn connectStateFlagsChanged(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, flags: *gtk.StateFlags, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, flags: gtk.StateFlags, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -830,7 +830,7 @@ pub const ActionBar = extern struct {
pub inline fn connectStateFlagsChangedSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, flags: *gtk.StateFlags) callconv(.C) void,
callback: *const fn (data: *T, flags: gtk.StateFlags) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down
4 changes: 2 additions & 2 deletions src/gtk/any_filter.zig
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub const AnyFilter = extern struct {
pub inline fn connectChanged(
self: *Self,
comptime T: type,
callback: *const fn (self: *Self, change: *gtk.FilterChange, data: ?*T) callconv(.C) void,
callback: *const fn (self: *Self, change: gtk.FilterChange, data: ?*T) callconv(.C) void,
data: ?*T,
flags: gobject.ConnectFlags
) u64 {
Expand All @@ -130,7 +130,7 @@ pub const AnyFilter = extern struct {
pub inline fn connectChangedSwapped(
self: *Self,
comptime T: type,
callback: *const fn (data: *T, change: *gtk.FilterChange) callconv(.C) void,
callback: *const fn (data: *T, change: gtk.FilterChange) callconv(.C) void,
data: *T,
flags: gobject.ConnectFlags
) u64 {
Expand Down
Loading

0 comments on commit 712f693

Please sign in to comment.