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 /ext | |
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 'ext')
-rw-r--r-- | ext/XS-APItest/APItest.xs | 30 | ||||
-rwxr-xr-x | ext/XS-APItest/t/refs.t | 34 |
2 files changed, 64 insertions, 0 deletions
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs index 325681ab5a..71551ee696 100644 --- a/ext/XS-APItest/APItest.xs +++ b/ext/XS-APItest/APItest.xs @@ -2586,6 +2586,36 @@ CODE: } +SV* +take_svref(SVREF sv) +CODE: + RETVAL = newRV_inc(sv); +OUTPUT: + RETVAL + +SV* +take_avref(AV* av) +CODE: + RETVAL = newRV_inc((SV*)av); +OUTPUT: + RETVAL + +SV* +take_hvref(HV* hv) +CODE: + RETVAL = newRV_inc((SV*)hv); +OUTPUT: + RETVAL + + +SV* +take_cvref(CV* cv) +CODE: + RETVAL = newRV_inc((SV*)cv); +OUTPUT: + RETVAL + + BOOT: { HV* stash; diff --git a/ext/XS-APItest/t/refs.t b/ext/XS-APItest/t/refs.t new file mode 100755 index 0000000000..5755ddd086 --- /dev/null +++ b/ext/XS-APItest/t/refs.t @@ -0,0 +1,34 @@ +#!perl + +use strict; +use warnings; + +use Test::More tests => 8; + +use Tie::Scalar; + +use_ok('XS::APItest'); + +my $a; +my $sr = \$a; +my $ar = []; +my $hr = {}; +my $cr = sub{}; + +is XS::APItest::take_svref($sr), $sr; +is XS::APItest::take_avref($ar), $ar; +is XS::APItest::take_hvref($hr), $hr; +is XS::APItest::take_cvref($cr), $cr; + +my $obj = tie my $ref, 'Tie::StdScalar'; +${$obj} = $sr; +is XS::APItest::take_svref($sr), $sr; + +${$obj} = $ar; +is XS::APItest::take_avref($ar), $ar; + +${$obj} = $hr; +is XS::APItest::take_hvref($hr), $hr; + +${$obj} = $cr; +is XS::APItest::take_cvref($cr), $cr; |