SV = RV(0x1840114) at 0x194968c <<<<<<<<<< This is the value I receive in the XS code.
REFCNT = 1
FLAGS = (TEMP,ROK)
RV = 0x226004 <<<<<<<<<<<<<<<<<<<<<<<< This is the value I see in the Perl code
SV = PVCV(0x1824094) at 0x226004
REFCNT = 2
FLAGS = ()
IV = 0
NV = 0
COMP_STASH = 0x2251d0 "main"
START = 0x19588d4 ===> 11609
ROOT = 0x1958890
XSUB = 0x0
XSUBANY = 0
GVGV::GV = 0x1959798 "main" :: "recorder"
FILE = "P:\test\test.pl"
DEPTH = 0
FLAGS = 0x0
OUTSIDE_SEQ = 951
PADLIST = 0x226010
PADNAME = 0x22601c(0x1826a5c) PAD = 0x22604c(0x182ebb4)
OUTSIDE = 0x2253c8 (MAIN)
r:226004 <<<<<<<<< Printed from Perl
r:194968c <<<<<<<<< Printed from XS
####
sv_2cv
Using various gambits, try to get a CV from an SV; in addition, try if possible to set *st and *gvp to the stash and GV associated with it.
CV* sv_2cv(SV* sv, HV** st, GV** gvp, I32 lref)
####
#! perl -slw
use strict;
use Inline 'NoClean', 'FORCE', 'INFO' ;
use Inline Config => WARNINGS => 4;
use Inline 'C' => 'DATA', NAME =>'test';
use Devel::Peek;
sub recorder{ print "record: @_"; }
sub player{ print "player: @_"; }
print Dump \&recorder;
printf "r:%x p:%x\n", \&recorder, \&player;
setCallbacks( \&recorder, \&player );
#record( 'test' );
play( 'test' );
__DATA__
__C__
SV *g_rec = (SV*)NULL;
SV *g_play = (SV*)NULL;
int setCallbacks( SV *rec, SV *play ) {
printf( "r:%x p:%x\n", rec, play );
g_rec = newSVsv( rec ); // updated.
// SvREFCNT_inc( g_rec );
g_play = newSVsv( play ); // updated
// SvREFCNT_inc( g_play );
return 0;
}
int record( SV *m ) {
call_sv( g_rec, G_VOID );
return 0;
}
int play( SV *m ) {
call_sv( g_play, G_VOID );
return 0;
}