INPUT T_PTROBJ if (sv_derived_from($arg, \"${ntype}\")) { IV tmp = SvIV((SV*)SvRV($arg)); $var = INT2PTR($type,tmp); } else croak(\"$var is not of type ${ntype}\") OUTPUT T_PTROBJ sv_setref_pv($arg, \"${ntype}\", (void*)$var);