I work with the NativeCall interface.
The library will call my callback function a bunch of times.
It works great. I can simply declare my signature callback, pass it as a callback, and the library calls well.
It also has the ability to set the payload void * pointer to anything I want, and it will include this in a call to my callback function.
Is it possible to hide Perl Str, for example, in a payload and successfully bypass it?
sub set_userdata(Pointer) returns int32 is native { ... } sub set_callback(&callback(Pointer $userdata --> int32)) returns int32 is native { ... } sub callback(Pointer $userdata) returns int32 { my Str $mystring = ??? ... } my Str $my-userdata-string; set_userdata(???); set_callback(&callback);
It looks like it could work with some binding spell, "this is rw", nativecast () and / or .deref.
source share