Skip to content

Instantly share code, notes, and snippets.

@arnsholt
Created July 10, 2012 18:20
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 arnsholt/3085270 to your computer and use it in GitHub Desktop.
Save arnsholt/3085270 to your computer and use it in GitHub Desktop.
Plan and notes for Zavolaj callbacks
  1. nqp_native_call() needs return and parameter type info to set up the callback.
  2. Likewise, callback_handler() needs the same to marshal the arguments and unpack the return value.
  3. Given 1 and 2, arg_types in the NativeCall REPR needs to be a more expressive type than INTVAL*. struct { INTVAL; PMC * }* perhaps?
  4. 3 implies updating nqp_native_call_build() to build the correct structure.
  5. Finally, postcircumfix:<( )> in role Native of NativeCall.pm6 needs to pass signature info for callback arguments to nqp_native_call_build().

Implementation should probably be backwards, starting with passing information about callbacks and working my way down to actually doing the dyncallback stuff.

Perl 6 callback parameter syntax for when I forget it: < jnthn> sub (int $n, &callback(Str, int, int --> int)) is native { * }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment