TYPEMAP
void *                  T_VPTR
char_len *              T_CHAR_LEN
const char_len *        T_CONST_CHAR_LEN

######################################################################
OUTPUT
T_POOLOBJ
	sv_setref_pv($arg, \"${ntype}\", (void*)$var);

T_APACHEOBJ
	sv_setref_pv($arg, \"${ntype}\", (void*)$var);

T_HASHOBJ
	$arg = modperl_hash_tie(aTHX_ \"${ntype}\", $arg, $var);

T_VPTR
	sv_setiv($arg, PTR2IV($var));

T_UVPTR
	sv_setuv($arg, PTR2UV($var));

T_APR_TIME
	sv_setnv($arg, (NV)(apr_time_sec($var)));

T_UVOBJ
	modperl_perl_sv_setref_uv(aTHX_ $arg, \"${ntype}\", (UV)$var);

######################################################################
INPUT
T_PTROBJ
	if (SvROK($arg) && sv_derived_from($arg, \"${ntype}\")) {
	    IV tmp = SvIV((SV*)SvRV($arg));
	    $var = INT2PTR($type, tmp);
	}
	else {
	    Perl_croak(aTHX_ SvROK($arg) ?
                       \"$var is not of type ${ntype}\" :
                       \"$var is not a blessed reference\");
        }

T_POOLOBJ
	if (SvROK($arg) && sv_derived_from($arg, \"${ntype}\")) {
	    IV tmp = SvIV((SV*)SvRV($arg));
            if (tmp == 0) {
                Perl_croak(aTHX_ \"invalid pool object (already destroyed?)\");
            }
	    $var = INT2PTR($type, tmp);
	}
	else {
	    Perl_croak(aTHX_ SvROK($arg) ?
                       \"$var is not of type ${ntype}\" :
                       \"$var is not a blessed reference\");
        }

T_UVOBJ
	if (SvROK($arg) && sv_derived_from($arg, \"${ntype}\")) {
	    UV tmp = SvUV((SV*)SvRV($arg));
	    $var = INT2PTR($type, tmp);
	}
	else {
	    Perl_croak(aTHX_ SvROK($arg) ?
                       \"$var is not of type ${ntype}\" :
                       \"$var is not a blessed reference\");
        }

T_APACHEOBJ
	$var = modperl_xs_sv2request_rec(aTHX_ $arg, \"$ntype\", cv)
    
T_HASHOBJ
	$var = modperl_hash_tied_object(aTHX_ \"${ntype}\", $arg)

T_APACHEREF
	$var = modperl_xs_sv2request_rec(aTHX_ $arg, \"$ntype\", cv)

T_VPTR
	$var = INT2PTR($type, SvIV(SvROK($arg) ? SvRV($arg) : $arg))

T_UVPTR
	$var = INT2PTR($type, SvUV(SvROK($arg) ? SvRV($arg) : $arg))

T_APR_TIME
	$var = (apr_time_t)(apr_time_from_sec(SvNV($arg)))

T_CHAR_LEN
        $var = (char *)SvPV($arg, ${var}_len)

T_CONST_CHAR_LEN
        $var = (const char *)SvPV($arg, ${var}_len)
