This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Transform some functions into methods on the proto-object
authorSteffen Mueller <smueller@cpan.org>
Sat, 19 Feb 2011 15:34:57 +0000 (16:34 +0100)
committerSteffen Mueller <smueller@cpan.org>
Tue, 12 Jul 2011 18:54:50 +0000 (20:54 +0200)
dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm

index 9de9770..1597a3b 100644 (file)
@@ -78,7 +78,7 @@ sub process_file {
     # Establish set of global symbols with max length 28, since xsubpp
     # will later add the 'XS_' prefix.
     require ExtUtils::XSSymSet;
-    $SymSet = new ExtUtils::XSSymSet 28;
+    $SymSet = ExtUtils::XSSymSet->new(28);
   }
   @{ $self->{XSStack} } = ({type => 'none'});
   $self->{InitFileCode} = [ @ExtUtils::ParseXS::Constants::InitFileCode ];
@@ -298,7 +298,7 @@ EOM
     my $xsreturn = 0;
 
     $_ = shift(@{ $self->{line} });
-    while (my $kwd = check_keyword("REQUIRE|PROTOTYPES|FALLBACK|VERSIONCHECK|INCLUDE(?:_COMMAND)?|SCOPE")) {
+    while (my $kwd = $self->check_keyword("REQUIRE|PROTOTYPES|FALLBACK|VERSIONCHECK|INCLUDE(?:_COMMAND)?|SCOPE")) {
       no strict 'refs';
       &{"${kwd}_handler"}();
       use strict 'refs';
@@ -306,7 +306,7 @@ EOM
       $_ = shift(@{ $self->{line} });
     }
 
-    if (check_keyword("BOOT")) {
+    if ($self->check_keyword("BOOT")) {
       check_conditional_preprocessor_statements($self);
       push (@{ $BootCode_ref }, "#line $self->{line_no}->[@{ $self->{line_no} } - @{ $self->{line} }] \"$self->{filepathname}\"")
         if $self->{WantLineNumbers} && $self->{line}->[0] !~ /^\s*#\s*line\b/;
@@ -553,9 +553,9 @@ EOF
     push(@{ $self->{line} }, "$END:");
     push(@{ $self->{line_no} }, $self->{line_no}->[-1]);
     $_ = '';
-    check_conditional_preprocessor_statements($self);
+    $self->check_conditional_preprocessor_statements();
     while (@{ $self->{line} }) {
-      CASE_handler() if check_keyword("CASE");
+      CASE_handler() if $self->check_keyword("CASE");
       print Q(<<"EOF");
 #   $self->{except} [[
 EOF
@@ -568,7 +568,7 @@ EOF
       $self->{gotRETVAL} = 0;
 
       INPUT_handler();
-      process_keyword("INPUT|PREINIT|INTERFACE_MACRO|C_ARGS|ALIAS|ATTRS|PROTOTYPE|SCOPE|OVERLOAD");
+      $self->process_keyword("INPUT|PREINIT|INTERFACE_MACRO|C_ARGS|ALIAS|ATTRS|PROTOTYPE|SCOPE|OVERLOAD");
 
       print Q(<<"EOF") if $self->{ScopeThisXSUB};
 #   ENTER;
@@ -623,15 +623,15 @@ EOF
         }
         print $self->{deferred};
 
-        process_keyword("INIT|ALIAS|ATTRS|PROTOTYPE|INTERFACE_MACRO|INTERFACE|C_ARGS|OVERLOAD");
+        $self->process_keyword("INIT|ALIAS|ATTRS|PROTOTYPE|INTERFACE_MACRO|INTERFACE|C_ARGS|OVERLOAD");
 
-        if (check_keyword("PPCODE")) {
+        if ($self->check_keyword("PPCODE")) {
           print_section();
           death( $self, "PPCODE must be last thing") if @{ $self->{line} };
           print "\tLEAVE;\n" if $self->{ScopeThisXSUB};
           print "\tPUTBACK;\n\treturn;\n";
         }
-        elsif (check_keyword("CODE")) {
+        elsif ($self->check_keyword("CODE")) {
           print_section();
         }
         elsif (defined($class) and $func_name eq "DESTROY") {
@@ -673,7 +673,7 @@ EOF
       # $wantRETVAL set if 'RETVAL =' autogenerated
       ($wantRETVAL, $self->{ret_type}) = (0, 'void') if $RETVAL_no_return;
       undef %{ $self->{outargs} };
-      process_keyword("POSTCALL|OUTPUT|ALIAS|ATTRS|PROTOTYPE|OVERLOAD");
+      $self->process_keyword("POSTCALL|OUTPUT|ALIAS|ATTRS|PROTOTYPE|OVERLOAD");
 
       generate_output( {
         type        => $self->{var_types}->{$_},
@@ -748,7 +748,7 @@ EOF
       } ) for @{ $outlist_ref };
 
       # do cleanup
-      process_keyword("CLEANUP|ALIAS|ATTRS|PROTOTYPE|OVERLOAD");
+      $self->process_keyword("CLEANUP|ALIAS|ATTRS|PROTOTYPE|OVERLOAD");
 
       print Q(<<"EOF") if $self->{ScopeThisXSUB};
 #   ]]
@@ -767,7 +767,7 @@ EOF
 #    sprintf(errbuf, "%s: %s\\tpropagated", Xname, Xreason);
 #    ENDHANDLERS
 EOF
-      if (check_keyword("CASE")) {
+      if ($self->check_keyword("CASE")) {
         blurt( $self, "Error: No `CASE:' at top of function")
           unless $self->{condnum};
         $_ = "CASE: $_";    # Restore CASE: label
@@ -987,10 +987,11 @@ EOF
 
 sub report_error_count { $self->{errors} }
 
-# Input:  ($_, @{ $self->{line} }) == unparsed input.
+# Input:  ($self, $_, @{ $self->{line} }) == unparsed input.
 # Output: ($_, @{ $self->{line} }) == (rest of line, following lines).
 # Return: the matched keyword if found, otherwise 0
 sub check_keyword {
+  my $self = shift;
   $_ = shift(@{ $self->{line} }) while !/\S/ && @{ $self->{line} };
   s/^(\s*)($_[0])\s*:\s*(?:#.*)?/$1/s && $2;
 }
@@ -1021,13 +1022,13 @@ sub merge_section {
   return $in;
 }
 
-sub process_keyword($) {
-  my($pattern) = @_;
+sub process_keyword {
+  my($self, $pattern) = @_;
   my $kwd;
 
   no strict 'refs';
   &{"${kwd}_handler"}()
-    while $kwd = check_keyword($pattern);
+    while $kwd = $self->check_keyword($pattern);
   use strict 'refs';
 }