TYPEMAP
Parrot_Interp   	T_PTR
Parrot_PackFile 	T_PTR
Parrot_STRING   	T_PTR

Parrot_PMC			T_PTROBJ_PARROT
Parrot_Interp		T_PTROBJ_PARROT
Interpreter_struct*	T_PTROBJ_PARROT_STRUCT
PMC_struct*			T_PTROBJ_PARROT_STRUCT

INPUT
T_PTROBJ_PARROT_STRUCT
	if (sv_derived_from($arg, \"${ (my $type = $ntype) =~ s/^(\w+)_struct.*$/Parrot::$1/; \$type}\"))
	{
		IV tmp = SvIV((SV*)SvRV($arg));
		$var = INT2PTR($type, tmp);
	}
	else
		croak(\"$var is not of type Parrot::$ntype\")

T_PTROBJ_PARROT
	if (sv_derived_from($arg, \"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\"))
	{
		IV tmp = SvIV((SV*)SvRV($arg));
		$var = INT2PTR($type, tmp);
	}
	else
		croak(\"$var is not of type ${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\")

OUTPUT
T_PTROBJ_PARROT
	sv_setref_pv($arg, \"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\", (void*)$var);

T_PTROBJ_PARROT_STRUCT
	sv_setref_pv($arg, \"${ (my $type = $ntype) =~ s/^(\w+)_struct.*$/Parrot::$1/; \$type}\", (void*)$var);
