The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
TYPEMAP
char *		O_CHAR
const char *	T_PV
GeoIP *		O_OBJECT
GeoIPRecord *   O_OBJECT
float		T_FLOAT

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 blessed SV reference\" );
            XSRETURN_UNDEF;
    }

# this is just here because a O_CHAR input is required to compile,
# should be same as if O_CHAR wasn't defined
O_CHAR
        $var = ($type)SvPVbyte_nolen ($arg)

OUTPUT

# The Perl object is blessed into 'CLASS', which should be a
# char* having the name of the package for the blessing.
O_OBJECT
        sv_setref_pv( $arg, (char *)CLASS, (void*)$var );

# prevent memory leaks with malloc'ed returned char * strings
O_CHAR
    if($var != NULL) {
        $arg = newSVpv($var, strlen($var));
        free($var);
        sv_2mortal($arg);
    }