in reply to Re^2: XS callback to mpv_set_wakeup_callback
in thread XS callback to mpv_set_wakeup_callback
and called it in the constructor in Simple.pmvoid set_ctx() { dTHX; mine = Perl_get_context; } (...) MODULE = MPV::Simple PACKAGE = MPV::Simple (...) void _set_context(ctx) MPV::Simple ctx CODE: set_ctx();
Last I set Perl_Context in callp instead of dTHX:sub new { my ($class) = shift; my $obj = $class->xs_create(); bless $obj; $obj->_set_context(); return $obj; }
Does that make any sense? Or is it ugly and bad? To be honest, I don't really understand the linked thread :-) And I am a little bit worried because of deleting PERL_NO_GET_CONTEXT.. I have to do further tests, whether the binding now works as expected.. Maxvoid callp( SV* data) { //dTHX; PERL_SET_CONTEXT(mine); { dMY_CXT; dSP; ENTER; SAVETMPS; PUSHMARK(SP); PUTBACK; perl_call_sv(MY_CXT.callback,G_DISCARD|G_NOARGS); SPAGAIN; PUTBACK;FREETMPS;LEAVE; } }
|
|---|