Convert Fcntl, File::Glob, I18N::Langinfo and Socket to an XS AUTOLOAD.
authorNicholas Clark <nick@ccl4.org>
Wed, 20 Oct 2010 07:32:16 +0000 (09:32 +0200)
committerNicholas Clark <nick@ccl4.org>
Thu, 21 Oct 2010 06:42:19 +0000 (08:42 +0200)
All 4 use ExtUtils::Constant::ProxySubs, and only have an AUTOLOAD to deal with
failed constant lookups.

ext/Fcntl/Fcntl.pm
ext/Fcntl/Makefile.PL
ext/File-Glob/Glob.pm
ext/File-Glob/Makefile.PL
ext/I18N-Langinfo/Langinfo.pm
ext/I18N-Langinfo/Makefile.PL
ext/Socket/Makefile.PL
ext/Socket/Socket.pm

index 6e1c1af..b1d2051 100644 (file)
@@ -56,7 +56,7 @@ See L<perlfunc/stat> about the S_I* constants.
 =cut
 
 use strict;
-our($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $AUTOLOAD);
+our($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
 
 require Exporter;
 require XSLoader;
@@ -183,10 +183,4 @@ XSLoader::load();
        O_NOTRANS
 ), map {@{$_}} values %EXPORT_TAGS);
 
-sub AUTOLOAD {
-    (my $constname = $AUTOLOAD) =~ s/.*:://;
-    die "&Fcntl::constant not defined" if $constname eq 'constant';
-    constant($constname);
-}
-
 1;
index 470291f..cb8a8e6 100644 (file)
@@ -39,7 +39,7 @@ my @names = (qw(
             {name=>"SEEK_END", default=>["IV", "2"]},
             {name=>"_S_IFMT", macro=>"S_IFMT", value=>"S_IFMT"});
 WriteConstants(
-    PROXYSUBS => {croak_on_error => 1},
+    PROXYSUBS => {autoload => 1},
     NAME => 'Fcntl',
     NAMES => \@names,
 );
index acb53d6..de2362f 100644 (file)
@@ -1,8 +1,7 @@
 package File::Glob;
 
 use strict;
-our($VERSION, @ISA, @EXPORT_OK, @EXPORT_FAIL, %EXPORT_TAGS,
-    $AUTOLOAD, $DEFAULT_FLAGS);
+our($VERSION, @ISA, @EXPORT_OK, @EXPORT_FAIL, %EXPORT_TAGS, $DEFAULT_FLAGS);
 
 require XSLoader;
 use feature 'switch';
@@ -57,15 +56,6 @@ sub import {
     } @_);
 }
 
-sub AUTOLOAD {
-    # This AUTOLOAD is used to 'autoload' constants from the constant()
-    # XS function.
-
-    my $constname;
-    ($constname = $AUTOLOAD) =~ s/.*:://;
-    constant($constname);
-}
-
 XSLoader::load();
 
 $DEFAULT_FLAGS = GLOB_CSH();
index 5f2b4f3..b26dc31 100644 (file)
@@ -22,7 +22,7 @@ sub MY::cflags {
 }
 
 WriteConstants(
-    PROXYSUBS => {croak_on_error => 1},
+    PROXYSUBS => {autoload => 1},
     NAME => 'File::Glob',
     NAMES => [qw(GLOB_ABEND GLOB_ALPHASORT GLOB_ALTDIRFUNC GLOB_BRACE GLOB_ERR
                  GLOB_LIMIT GLOB_MARK GLOB_NOCASE GLOB_NOCHECK GLOB_NOMAGIC
index 48e44ce..8af32de 100644 (file)
@@ -74,17 +74,6 @@ our @EXPORT_OK = qw(
 
 our $VERSION = '0.07';
 
-sub AUTOLOAD {
-    # This AUTOLOAD is used to 'autoload' constants from the constant()
-    # XS function.
-
-    my $constname;
-    our $AUTOLOAD;
-    ($constname = $AUTOLOAD) =~ s/.*:://;
-    croak "&I18N::Langinfo::constant not defined" if $constname eq 'constant';
-    constant($constname);
-}
-
 XSLoader::load();
 
 1;
index 2cc590a..b5ed77f 100644 (file)
@@ -30,7 +30,7 @@ push @names,           # This lot are only enums for __SVR4_I386_ABI_L1__:
       foreach qw (CRNCYSTR THOUSEP RADIXCHAR);
 
 ExtUtils::Constant::WriteConstants(
-                                  PROXYSUBS => {croak_on_error => 1},
+                                  PROXYSUBS => {autoload => 1},
                                   NAME => 'I18N::Langinfo',
                                   NAMES => \@names,
                                  );
index d81a5c3..7167aa4 100644 (file)
@@ -72,7 +72,7 @@ push @names,
          foreach qw(INADDR_ANY INADDR_LOOPBACK INADDR_NONE INADDR_BROADCAST);
 
 WriteConstants(
-    PROXYSUBS => {croak_on_error => 1},
+    PROXYSUBS => {autoload => 1},
     NAME => 'Socket',
     NAMES => \@names,
 );
index a46d2fe..da70114 100644 (file)
@@ -431,13 +431,6 @@ sub sockaddr_un {
     }
 }
 
-sub AUTOLOAD {
-    my($constname);
-    ($constname = $AUTOLOAD) =~ s/.*:://;
-    croak "&Socket::constant not defined" if $constname eq 'constant';
-    constant($constname);
-}
-
 XSLoader::load();
 
 1;