Can't locate object method "bump" via package "Short" at ./p_passing_blessed line 58.
####
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=87654321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
####
package Short;
use Inline C;
use strict;
# no strict 'refs';
1;
##
#
__DATA__
__C__
#ifndef Newx
# define Newx(v,n,t) New(0,v,n,t)
#endif
typedef struct {
UV index;
UV simtime;
} Thing;
// --------------------------------------------------------
// shamelessly stolen from Inline::C-Cookbook
//
SV* newthing( const char * classname ) {
Thing * thing;
SV * obj;
SV * obj_ref;
Newx( thing, 1, Thing );
thing->index = 0;
thing->simtime = 0;
obj = newSViv( (IV)thing );
obj_ref = newRV_noinc(obj);
sv_bless( obj_ref, gv_stashpv( classname, GV_ADD ) );
SvREADONLY_on( obj );
return obj_ref;
}
// --------------------------------------------------------
//
void DESTROY(SV* obj) {
Thing* thing = (Thing*)SvIV(SvRV(obj));
printf("FREE thing size : %d\n", sizeof( thing ) );
Safefree( thing );
}
// --------------------------------------------------------
//
void bump( SV* obj, UV simtime ) {
Thing* thing = (Thing*)SvIV(SvRV(obj));
printf("obj size : %lu\n", sizeof( obj ) );
printf("obj val : %lx\n", (unsigned long)obj );
printf("thing size : %d\n", sizeof( thing ) );
printf("thing val : %lu\n", (unsigned long)thing );
printf("thing simtime p : %lu\n", simtime );
printf("thing simtime A : %lu\n", thing->simtime );
printf("thing index A : %lu\n", thing->index );
thing->simtime = simtime;
thing->index += 1;
printf("thing simtime B : %lu\n", thing->simtime );
printf("thing index B : %lu\n", thing->index );
}
####
# ---------------------
Devel::Peek::Dump output so we can compare values:
SV = IV(0x2bf2d8) at 0x2bf2d8
REFCNT = 1
FLAGS = (PADMY,ROK)
RV = 0x2216b0
SV = PVMG(0x4372c8) at 0x2216b0
REFCNT = 1
FLAGS = (OBJECT,IOK,READONLY,pIOK)
IV = 7888424
NV = 0
PV = 0
STASH = 0x30a5e8 "Short"
# ---------------------
perl passing simtime: 20
obj size : 4
obj val : 2bf2d8
thing size : 4
thing val : 7888424
thing simtime p : 0 << should be 20
thing simtime A : 0
thing index A : 0
thing simtime B : 0 << should be 20
thing index B : 0 << should be 1
perl passing simtime: 40
obj size : 4
obj val : 2bf2d8
thing size : 4
thing val : 7888424
thing simtime p : 0 << should be 40
thing simtime A : 0
thing index A : 0
thing simtime B : 0 << should be 40
thing index B : 0 << should be 2
FREE thing size : 4