Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

rsteinke's scratchpad

by rsteinke (Scribe)
on Aug 10, 2004 at 00:09 UTC ( #381399=scratchpad: print w/replies, xml ) Need Help??

# This is typemap code which represents a binary C object as a tied ha +sh in perl. # TestObjImpl is a typedef, # # typedef TestObj TestObjImpl; # # which lets XS know whether you're passing in a tied hash (most of th +e time), # or the bare blessed object (for FETCH, STORE, DESTROY, etc.). In mos +t cases, # usage of TestObjImpl is limited to the .xs file which implements the + TestObj # class, with other .xs files (implementing other classes) taking Test +Obj # as their argument (since they expect to be passed a hash). # The O_OBJECT typemap code is stolen directly from Dean Roehrich's pe TYPEMAP TestObj * T_TIED_HASH TestObjImpl * O_OBJECT INPUT O_OBJECT if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a bles +sed SV reference\" ) ; XSRETURN_UNDEF; } T_TIED_HASH { MAGIC* magic; if( SvROK($arg) && (SvTYPE(SvRV($arg)) == SVt_PVHV) && ((magic = mg_find(SvRV($arg), PERL_MAGIC_ti +ed)) != NULL) && sv_isobject(magic->mg_obj) && (SvTYPE(SvRV(magic->mg_obj)) == SVt_PVMG) ) + { $var = ($type)SvIV((SV*)SvRV(magic->mg_obj)); } else { warn( \"${Package}::$func_name() -- $var is no +t a tied hash refere nce\" ); if(!magic) warn(\"No magic\"); else if (!sv_isobject(magic->mg_obj)) warn(\"No magic object\"); else warn(\"Wrong object type\"); XSRETURN_UNDEF; } } OUTPUT T_TIED_HASH { SV* tie = sv_newmortal(); HV* hash = newHV(); /* Get a blessed reference to the pointer, */ sv_setref_pv(tie, CLASS, (void*)$var); /* and tie it to a hash. */ hv_magic(hash, (GV*)tie, PERL_MAGIC_tied); $arg = sv_2mortal((SV*)newRV_noinc((SV*)hash)); }
Log In?

What's my password?
Create A New User
[marto]: more so than the previous show I saw
[Corion]: marto: Well, I think they go a tour every two years and I think it's hard to even get a connection with the crowd at a 20k people concert... But maybe after this time I'll stop too ;)
[Corion]: I still have to see the Pet Shop Boys live before they stop touring at all
[marto]: yeah, I think that as a group creatively they're done. I can understand how it'd be hard to stop the process, album/tour, album/tour, if that's pretty much all you've ever done :)
[marto]: Corion yes I saw them Pandemonium_Tour
[Corion]: marto: Yeah, and I doubt that they'll ever get back to something like Violator/Songs of Faith and Devotion - it would either alienate their "regular" crowd, or be "too much Violator" ;)
LanX needs to see Freddy Mercury'
[Corion]: marto: Yeah, I have that on DVD even, and I missed them last year because I was in London at the time ironically ;)
[marto]: put me in the mood to listen to this now :)
[Corion]: LanX: Well, grab a shovel :)

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (12)
As of 2017-03-24 11:41 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (301 votes). Check out past polls.