summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2021-09-06 15:09:49 +1000
committerTony Cook <tony@develop-help.com>2021-09-13 10:05:02 +1000
commit83b243fa48968f4349136fe6943f0c21313b217e (patch)
tree4efd832bfd2f8727899ff001e077648b9a24c49b
parentade1dcccb274812424b79cdbce70a7110d5285a7 (diff)
downloadperl-83b243fa48968f4349136fe6943f0c21313b217e.tar.gz
test and fix using T_HVREF_REFCOUNT as an output parameter
-rw-r--r--ext/XS-Typemap/Typemap.pm1
-rw-r--r--ext/XS-Typemap/Typemap.xs6
-rw-r--r--ext/XS-Typemap/t/Typemap.t10
-rw-r--r--lib/ExtUtils/typemap2
4 files changed, 17 insertions, 2 deletions
diff --git a/ext/XS-Typemap/Typemap.pm b/ext/XS-Typemap/Typemap.pm
index c1b5505e8a..d6e86da86a 100644
--- a/ext/XS-Typemap/Typemap.pm
+++ b/ext/XS-Typemap/Typemap.pm
@@ -46,6 +46,7 @@ our @EXPORT = (qw/
T_AVREF_REFCOUNT_FIXED
T_HVREF
T_HVREF_REFCOUNT_FIXED
+ T_HVREF_REFCOUNT_FIXED_output
T_CVREF
T_CVREF_REFCOUNT_FIXED
T_SYSRET_fail T_SYSRET_pass
diff --git a/ext/XS-Typemap/Typemap.xs b/ext/XS-Typemap/Typemap.xs
index d0703be2e5..353e04fb45 100644
--- a/ext/XS-Typemap/Typemap.xs
+++ b/ext/XS-Typemap/Typemap.xs
@@ -348,6 +348,12 @@ T_HVREF_REFCOUNT_FIXED( hv )
OUTPUT:
RETVAL
+void
+T_HVREF_REFCOUNT_FIXED_output( OUT hvref)
+ HV_FIXED *hvref;
+ CODE:
+ hvref = newHV();
+ hv_stores(hvref, "test", newSVpvs("value"));
## T_CVREF
diff --git a/ext/XS-Typemap/t/Typemap.t b/ext/XS-Typemap/t/Typemap.t
index 835b35caf0..33f4e45306 100644
--- a/ext/XS-Typemap/t/Typemap.t
+++ b/ext/XS-Typemap/t/Typemap.t
@@ -6,7 +6,7 @@ BEGIN {
}
}
-use Test::More tests => 161;
+use Test::More tests => 164;
use strict;
#catch WARN_INTERNAL type errors, and anything else unexpected
@@ -96,6 +96,14 @@ is( T_HVREF_REFCOUNT_FIXED(\%hash), \%hash);
eval { T_HVREF_REFCOUNT_FIXED( \@array ) };
ok( $@ );
+# output only
+SKIP:{
+ my $hvr;
+ is_deeply([ T_HVREF_REFCOUNT_FIXED_output($hvr) ], [ ], "call with non-ref lvalue, no return value");
+ ok(ref $hvr, "output parameter now a reference")
+ or skip "Not a reference", 1;
+ is($hvr->{test}, "value", "has expected key");
+}
# T_CVREF - reference to perl subroutine
note("T_CVREF");
diff --git a/lib/ExtUtils/typemap b/lib/ExtUtils/typemap
index 0c943ef73f..4cedca4025 100644
--- a/lib/ExtUtils/typemap
+++ b/lib/ExtUtils/typemap
@@ -327,7 +327,7 @@ T_AVREF_REFCOUNT_FIXED
T_HVREF
$arg = newRV((SV*)$var);
T_HVREF_REFCOUNT_FIXED
- $arg = newRV_noinc((SV*)$var);
+ ${ "$var" eq "RETVAL" ? \"$arg = newRV_noinc((SV*)$var);" : \"sv_setrv_noinc($arg, (SV*)$var);" }
T_CVREF
$arg = newRV((SV*)$var);
T_CVREF_REFCOUNT_FIXED