Skip to content

Instantly share code, notes, and snippets.

@ruoso
Created January 12, 2010 14:45
Show Gist options
  • Save ruoso/275249 to your computer and use it in GitHub Desktop.
Save ruoso/275249 to your computer and use it in GitHub Desktop.
OUTPUT
# The Perl object is blessed into 'CLASS', which should be a
# char* having the name of the package for the blessing.
O_OBJECT
void*[] pointers = malloc(2 * sizeof(void*));
pointers[0] = (void*)$var;
pointers[1] = (void*)my_perl;
sv_setref_pv( $arg, CLASS, (void*)pointers );
INPUT
O_OBJECT
if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) {
void*[] pointers = ($type)SvIV((SV*)SvRV( $arg ));
$var = pointers[0];
} else if ($arg == 0) {
XSRETURN(0);
} else {
XSRETURN_UNDEF;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment