diff options
author | Steffen Mueller <smueller@cpan.org> | 2011-02-19 16:34:57 +0100 |
---|---|---|
committer | Steffen Mueller <smueller@cpan.org> | 2011-07-12 20:54:50 +0200 |
commit | 18aa1386e655d5052d0770033dea453708506e28 (patch) | |
tree | ebb95285ac65bd7213239137c3af3b12fe7a7110 /dist | |
parent | bb2320f04fbb453056598c13ceb3debffbde54e5 (diff) | |
download | perl-18aa1386e655d5052d0770033dea453708506e28.tar.gz |
Transform some functions into methods on the proto-object
Diffstat (limited to 'dist')
-rw-r--r-- | dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm index 9de9770260..1597a3be21 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm @@ -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'; } |