I have a script that throws this error whenever I hit a keystroke. I hope the important bits are communicated in this, as th these are code segments from a larger project.
I think this is the direct call in question:
%data<stdin> = GLib::IOChannel.unix_new($*IN.native-descriptor);
%data<stdin>.add_watch(G_IO_IN, -> *@a --> gboolean {
handle-keyboard;
1
});
And Raku version:
This is Rakudo version 2020.02.1-256-g156356eae built on MoarVM version 2020.02.1-67-g3438ad2a4
implementing Raku 6.d.
For completeness, here is the nativecall definition of add_watch:
sub g_io_add_watch (
GIOChannel $channel,
guint $condition, # GIOCondition $condition,
&func (GIOChannel, guint, gpointer --> gboolean),
gpointer $user_data
)
returns guint
is native(glib)
is export
{ * }
And for more completeness? The definition of handle-keyboard():
sub handle-keyboard {
CATCH { default { .message.say } }
my ($in, $, $, $rc) = %data<stdin>.read_line;
return unless $rc = G_IO_STATUS_NORMAL;
given $in.substr(0, 1) {
when 'p' | 'P' {
%data<playing> .= not;
%data<pipeline>.set_state(
%data<playing> ?? GST_STATE_PLAYING !! GST_STATE_PAUSED
);
}
when 's' | 'S' {
%data<rate> *= $_ eq 'S' ?? 2 !! 0.5;
send-seek-event;
}
when 'D' | 'd' {
%data<rate> *= -1;
send-seek-event;
}
when 'N' | 'n' {
reset-sink;
%data<video-sink>.send-event(
GStreamer::Event.new(
:step,
GST_FORMAT_BUFFERS,
1,
%data<rate>.abs,
True,
False
)
);
say 'Stepping one frame';
}
when 'q' | 'Q' { %data<loop>.quit }
}
# cw: Do we have to worry about freeing $in??
}
And Raku version:
This is Rakudo version 2020.02.1-256-g156356eae built on MoarVM version 2020.02.1-67-g3438ad2a4
implementing Raku 6.d.