summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dragan <bulk88@hotmail.com>2014-12-12 05:16:50 -0500
committerTony Cook <tony@develop-help.com>2014-12-16 10:59:22 +1100
commit3f6e436ff0889330b44f87823bf8f712a6da6aba (patch)
tree6f69a94bab9ef0ee9869d3adb7b6ada8dab15b8f
parent3b91d897677547cb4be755c60725a628ac435fe1 (diff)
downloadperl-3f6e436ff0889330b44f87823bf8f712a6da6aba.tar.gz
document + improve ancient optimization in ParseXS
From commit 8990e30710 "perl 5.0 alpha 6". The DESTROY XSUB with T_PTROBJ as INPUT arg was refusing to obey my custom typemap for T_PTROBJ, but all other XSUBs followed the custom T_PTROBJ override. Extend this optimization to other rarely used typemap types and document this behavior.
-rw-r--r--dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm5
-rw-r--r--dist/ExtUtils-ParseXS/lib/perlxstypemap.pod15
2 files changed, 17 insertions, 3 deletions
diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
index 8c7b09d4ed..fedc4943c4 100644
--- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
+++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
@@ -1867,7 +1867,10 @@ sub generate_init {
my $typem = $typemaps->get_typemap(ctype => $type);
my $xstype = $typem->xstype;
- $xstype =~ s/OBJ$/REF/ if $self->{func_name} =~ /DESTROY$/;
+ #this is an optimization from perl 5.0 alpha 6, class check is skipped
+ #T_REF_IV_REF is missing since it has no untyped analog at the moment
+ $xstype =~ s/OBJ$/REF/ || $xstype =~ s/^T_REF_IV_PTR$/T_PTRREF/
+ if $self->{func_name} =~ /DESTROY$/;
if ($xstype eq 'T_PV' and exists $self->{lengthof}->{$var}) {
print "\t$var" unless $printed_name;
print " = ($type)SvPV($arg, STRLEN_length_of_$var);\n";
diff --git a/dist/ExtUtils-ParseXS/lib/perlxstypemap.pod b/dist/ExtUtils-ParseXS/lib/perlxstypemap.pod
index 5b1c639293..7d1f73c525 100644
--- a/dist/ExtUtils-ParseXS/lib/perlxstypemap.pod
+++ b/dist/ExtUtils-ParseXS/lib/perlxstypemap.pod
@@ -469,6 +469,9 @@ The pointer is blessed into a class that is derived from the name
of type of the pointer but with all '*' in the name replaced with
'Ptr'.
+For C<DESTROY> XSUBs only, a T_PTROBJ is optimized to a T_PTRREF. This means
+the class check is skipped.
+
=item T_REF_IV_REF
NOT YET
@@ -477,12 +480,16 @@ NOT YET
Similar to T_PTROBJ in that the pointer is blessed into a scalar object.
The difference is that when the object is passed back into XS it must be
-of the correct type (inheritance is not supported).
+of the correct type (inheritance is not supported) while T_PTROBJ supports
+inheritance.
The pointer is blessed into a class that is derived from the name
of type of the pointer but with all '*' in the name replaced with
'Ptr'.
+For C<DESTROY> XSUBs only, a T_REF_IV_PTR is optimized to a T_PTRREF. This
+means the class check is skipped.
+
=item T_PTRDESC
NOT YET
@@ -498,7 +505,11 @@ are no known users in core or on CPAN.
=item T_REFOBJ
-NOT YET
+Like T_REFREF, except it does strict type checking (inheritance is not
+supported).
+
+For C<DESTROY> XSUBs only, a T_REFOBJ is optimized to a T_REFREF. This means
+the class check is skipped.
=item T_OPAQUEPTR