diff options
-rw-r--r-- | ext/XS-Typemap/Typemap.pm | 1 | ||||
-rw-r--r-- | ext/XS-Typemap/Typemap.xs | 5 | ||||
-rw-r--r-- | ext/XS-Typemap/t/Typemap.t | 10 | ||||
-rw-r--r-- | lib/ExtUtils/typemap | 2 |
4 files changed, 16 insertions, 2 deletions
diff --git a/ext/XS-Typemap/Typemap.pm b/ext/XS-Typemap/Typemap.pm index 49cebddd65..c1b5505e8a 100644 --- a/ext/XS-Typemap/Typemap.pm +++ b/ext/XS-Typemap/Typemap.pm @@ -41,6 +41,7 @@ our @EXPORT = (qw/ T_SV_output T_SVREF T_SVREF_REFCOUNT_FIXED + T_SVREF_REFCOUNT_FIXED_output T_AVREF T_AVREF_REFCOUNT_FIXED T_HVREF diff --git a/ext/XS-Typemap/Typemap.xs b/ext/XS-Typemap/Typemap.xs index 14417da3be..d0703be2e5 100644 --- a/ext/XS-Typemap/Typemap.xs +++ b/ext/XS-Typemap/Typemap.xs @@ -297,6 +297,11 @@ T_SVREF_REFCOUNT_FIXED( svref ) OUTPUT: RETVAL +void +T_SVREF_REFCOUNT_FIXED_output( OUT svref ) + SVREF_FIXED svref + CODE: + svref = newSVpvn("test", 4); ## T_AVREF diff --git a/ext/XS-Typemap/t/Typemap.t b/ext/XS-Typemap/t/Typemap.t index 7422e6c5bd..835b35caf0 100644 --- a/ext/XS-Typemap/t/Typemap.t +++ b/ext/XS-Typemap/t/Typemap.t @@ -6,7 +6,7 @@ BEGIN { } } -use Test::More tests => 158; +use Test::More tests => 161; use strict; #catch WARN_INTERNAL type errors, and anything else unexpected @@ -55,6 +55,14 @@ is( ${ T_SVREF_REFCOUNT_FIXED($svref) }, $$svref ); eval { T_SVREF_REFCOUNT_FIXED( "fail - not ref" ) }; ok( $@ ); +# output only +SKIP:{ + my $svr; + is_deeply([ T_SVREF_REFCOUNT_FIXED_output($svr) ], [ ], "call with non-ref lvalue, no return value"); + ok(ref $svr, "output parameter now a reference") + or skip "Not a reference", 1; + is($$svr, "test", "reference to correct value"); +} # T_AVREF - reference to a perl Array note("T_AVREF"); diff --git a/lib/ExtUtils/typemap b/lib/ExtUtils/typemap index adac80fd1c..0c943ef73f 100644 --- a/lib/ExtUtils/typemap +++ b/lib/ExtUtils/typemap @@ -319,7 +319,7 @@ T_SV T_SVREF $arg = newRV((SV*)$var); T_SVREF_REFCOUNT_FIXED - $arg = newRV_noinc((SV*)$var); + ${ "$var" eq "RETVAL" ? \"$arg = newRV_noinc((SV*)$var);" : \"sv_setrv_noinc($arg, (SV*)$var);" } T_AVREF $arg = newRV((SV*)$var); T_AVREF_REFCOUNT_FIXED |