Skip to content

Instantly share code, notes, and snippets.

@Xliff
Last active April 3, 2020 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xliff/83a071845e6b2f0bf1d1a49bf84e9399 to your computer and use it in GitHub Desktop.
Save Xliff/83a071845e6b2f0bf1d1a49bf84e9399 to your computer and use it in GitHub Desktop.
Cannot invoke this object (REPR: P6int; uint32)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment