diff options
author | gfx <gfuji@cpan.org> | 2010-12-10 21:57:22 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2010-12-10 22:10:42 -0800 |
commit | 88b5a879c6c933e03b179ffd0a0ae87336c8afca (patch) | |
tree | 37e9d865898d2820792c8170c2205317c8734908 /lib/ExtUtils | |
parent | b2ef6d44c7d3e6463abb48b4fc82b08e88b5127a (diff) | |
download | perl-88b5a879c6c933e03b179ffd0a0ae87336c8afca.tar.gz |
Fix XS types in typemap in order to deal with references with get magics correctly
Diffstat (limited to 'lib/ExtUtils')
-rw-r--r-- | lib/ExtUtils/typemap | 72 |
1 files changed, 48 insertions, 24 deletions
diff --git a/lib/ExtUtils/typemap b/lib/ExtUtils/typemap index f88858762d..202425509c 100644 --- a/lib/ExtUtils/typemap +++ b/lib/ExtUtils/typemap @@ -58,33 +58,57 @@ INPUT T_SV $var = $arg T_SVREF - if (SvROK($arg)) - $var = (SV*)SvRV($arg); - else - Perl_croak(aTHX_ \"%s: %s is not a reference\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\") + STMT_START { + SV* const xsub_tmp_sv = $arg; + SvGETMAGIC(xsub_tmp_sv); + if (SvROK(xsub_tmp_sv)){ + $var = SvRV(xsub_tmp_sv); + } + else{ + Perl_croak(aTHX_ \"%s: %s is not a reference\", + ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, + \"$var\"); + } + } STMT_END T_AVREF - if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) - $var = (AV*)SvRV($arg); - else - Perl_croak(aTHX_ \"%s: %s is not an array reference\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\") + STMT_START { + SV* const xsub_tmp_sv = $arg; + SvGETMAGIC(xsub_tmp_sv); + if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVAV){ + $var = (AV*)SvRV(xsub_tmp_sv); + } + else{ + Perl_croak(aTHX_ \"%s: %s is not an ARRAY reference\", + ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, + \"$var\"); + } + } STMT_END T_HVREF - if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVHV) - $var = (HV*)SvRV($arg); - else - Perl_croak(aTHX_ \"%s: %s is not a hash reference\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\") + STMT_START { + SV* const xsub_tmp_sv = $arg; + SvGETMAGIC(xsub_tmp_sv); + if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVHV){ + $var = (AV*)SvRV(xsub_tmp_sv); + } + else{ + Perl_croak(aTHX_ \"%s: %s is not a HASH reference\", + ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, + \"$var\"); + } + } STMT_END T_CVREF - if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVCV) - $var = (CV*)SvRV($arg); - else - Perl_croak(aTHX_ \"%s: %s is not a code reference\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\") + STMT_START { + SV* const xsub_tmp_sv = $arg; + SvGETMAGIC(xsub_tmp_sv); + if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVCV){ + $var = (AV*)SvRV(xsub_tmp_sv); + } + else{ + Perl_croak(aTHX_ \"%s: %s is not a CODE reference\", + ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, + \"$var\"); + } + } STMT_END T_SYSRET $var NOT IMPLEMENTED T_UV |