Declare global instance as a stepping stone to an OO ExtUtils::ParseXS
authorJames E. Keenan <jkeenan@cpan.org>
Sat, 27 Mar 2010 16:47:16 +0000 (12:47 -0400)
committerSteffen Mueller <smueller@cpan.org>
Tue, 12 Jul 2011 18:53:52 +0000 (20:53 +0200)
Declare 'our' variable $self and move the first package global ($ProtoUsed) into it.

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm

index 1c07c3a..57ed120 100644 (file)
@@ -30,7 +30,7 @@ our $VERSION = '3';
 $VERSION = eval $VERSION if $VERSION =~ /_/;
 
 our (
-  $ProtoUsed, @InitFileCode, $FH, $proto_re, $Overload, $errors, $Fallback, 
+  @InitFileCode, $FH, $proto_re, $Overload, $errors, $Fallback, 
   $hiertype, $WantPrototypes, $WantVersionChk, $WantLineNumbers, $filepathname, 
   $dir, $filename, %IncludedFiles, %input_expr, %output_expr, 
   %type_kind, %proto_letter, $BLOCK_re, $lastline, $lastline_no, $Package, 
@@ -45,12 +45,14 @@ our (
 );
 our ($DoSetMagic, $newXS, $proto, $Module_cname, $XsubAliases, $Interfaces, $var_num, );
 
+our $self = {};
+
 sub process_file {
 
   # Allow for $package->process_file(%hash) in the future
   my ($pkg, %options) = @_ % 2 ? @_ : (__PACKAGE__, @_);
 
-  $ProtoUsed = exists $options{prototypes};
+  $self->{ProtoUsed} = exists $options{prototypes};
 
   # Set defaults.
   my %args = (
@@ -1061,7 +1063,7 @@ EOF
 EOF
 
   warn("Please specify prototyping behavior for $filename (see perlxs manual)\n")
-    unless $ProtoUsed;
+    unless $self->{ProtoUsed};
 
   chdir($orig_cwd);
   select($orig_fh);
@@ -1434,7 +1436,7 @@ sub PROTOTYPE_handler () {
   # If no prototype specified, then assume empty prototype ""
   $ProtoThisXSUB = 2 unless $specified;
 
-  $ProtoUsed = 1;
+  $self->{ProtoUsed} = 1;
 }
 
 sub SCOPE_handler () {
@@ -1459,7 +1461,8 @@ sub PROTOTYPES_handler () {
 
   $WantPrototypes = 1 if $1 eq 'ENABLE';
   $WantPrototypes = 0 if $1 eq 'DISABLE';
-  $ProtoUsed = 1;
+  $self->{ProtoUsed} = 1;
+
 }
 
 sub PushXSStack {