Shlomi Fish avatar Shlomi Fish committed a9b6714

Get rid of AUTOLOAD completely.

- Apply 0002-XML-LibXML-Error-avoid-AUTOLOAD.patch from
https://rt.cpan.org/Public/Bug/Display.html?id=68575 - get rid of
AUTOLOAD completely.
-- Applied by SHLOMIF.
-- Thanks to Aaron Crane.

Comments (0)

Files changed (2)

 1.71pre
    - turn XML_LIBXML_PARSE_DEFAULTS constant to $XML::LibXML::XML_LIBXML_PARSE_DEFAULTS
    - Apply 0001-XML-LibXML-Error-no-need-to-AUTOLOAD-domain.patch from
-     https://rt.cpan.org/Public/Bug/Display.html?id=68575 - no need to AUTLOAD
-     'domain' because a method like that exists.
+     https://rt.cpan.org/Public/Bug/Display.html?id=68575 - no need to
+     AUTOLOAD 'domain' because a method like that exists.
         -- Applied by SHLOMIF.
         -- Thanks to Aaron Crane.
-
+    - Apply 0002-XML-LibXML-Error-avoid-AUTOLOAD.patch from
+      https://rt.cpan.org/Public/Bug/Display.html?id=68575 - get rid of
+      AUTOLOAD completely.
+        -- Applied by SHLOMIF.
+        -- Thanks to Aaron Crane.
 
 1.70
    - various fixes and improvements in the documentation

lib/XML/LibXML/Error.pm

 package XML::LibXML::Error;
 
 use strict;
-use vars qw($AUTOLOAD @error_domains $VERSION $WARNINGS);
+use vars qw(@error_domains $VERSION $WARNINGS);
 use Carp;
 use overload 
   '""' => \&as_string,
 		  "Relax-NG parser", "Relax-NG validity",
 		  "Catalog", "C14N", "XSLT", "validity");
 
+for my $field (qw<code _prev level file line nodename message column context
+                  str1 str2 str3 num1 num2>) {
+    my $method = sub { $_[0]{$field} };
+    no strict 'refs';
+    *$field = $method;
+}
+
 { 
 
   sub new {
 }
 
 
-sub AUTOLOAD {
-  my $self=shift;
-  return undef unless ref($self);
-  my $sub = $AUTOLOAD;
-  $sub =~ s/.*:://;
-  if ($sub=~/^(?:code|_prev|level|file|line|nodename|message|column|context|str[123]|num[12])$/) {
-    return $self->{$sub};
-  } else {
-    croak("Unknown error field $sub");
-  }
-}
-
 # backward compatibility
 sub int1 { $_[0]->num1 }
 sub int2 { $_[0]->num2 }
 
-sub DESTROY {}
-
 sub domain {
     my ($self)=@_;
     return undef unless ref($self);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.