This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use inlineable proxy constant subs for Socket
authorNicholas Clark <nick@ccl4.org>
Fri, 23 Dec 2005 00:37:04 +0000 (00:37 +0000)
committerNicholas Clark <nick@ccl4.org>
Fri, 23 Dec 2005 00:37:04 +0000 (00:37 +0000)
p4raw-id: //depot/perl@26463

ext/Socket/Makefile.PL
lib/ExtUtils/Constant/ProxySubs.pm

index e543689..485b456 100644 (file)
@@ -63,6 +63,7 @@ push @names,
          foreach qw(INADDR_ANY INADDR_LOOPBACK INADDR_NONE INADDR_BROADCAST);
 
 WriteConstants(
+    PROXYSUBS => 1,
     NAME => 'Socket',
     NAMES => \@names,
 );
index 95b5e59..116e2dc 100644 (file)
@@ -39,6 +39,7 @@ $VERSION = '0.01';
      YES => sub { '&PL_sv_yes' },
      NO => sub { '&PL_sv_no' },
      '' => sub { '&PL_sv_yes' },
+     SV => sub {"SvREFCNT_inc($_[0])"},
      );
 
 %type_to_C_value = 
@@ -55,6 +56,7 @@ sub type_to_C_value {
 
 %type_is_a_problem =
     (
+     # The documentation says *mortal SV*, but we now need a non-mortal copy.
      SV => 1,
      );
 
@@ -278,10 +280,14 @@ EOBOOT
        die "Can't find generator code for type $type"
            unless defined $generator;
 
+       print $xs_fh "        {\n";
+       print $xs_fh "        $item->{pre}\n" if $item->{pre};
        printf $xs_fh <<"EOBOOT", $name, &$generator(&$type_to_value($value));
-       ${c_subname}_add_symbol($athx symbol_table, "%s",
-                               $namelen, %s);
+           ${c_subname}_add_symbol($athx symbol_table, "%s",
+                                   $namelen, %s);
 EOBOOT
+       print $xs_fh "        $item->{post}\n" if $item->{post};
+       print $xs_fh "        }\n";
 
         print $xs_fh $self->macro_to_endif($macro);
     }