The patch is really a proposal: it relies on a modified version of
Perl 5.6's Class::Struct. The modification are minimal, and just
ensure that it works with 5.005:
perl5/5.005/Class % diff -uw /floppy/Struct.pm Struct2.pm
--- /floppy/Struct.pm Sat Mar 24 17:50:56 2001
+++ Struct2.pm Sun Mar 25 16:30:39 2001
@@ -1,12 +1,11 @@
-package Class::Struct;
+package Class::Struct2;
## See POD after __END__
-use 5.005_64;
+use 5.005;
use strict;
-use warnings::register;
-our(@ISA, @EXPORT, $VERSION);
+use vars qw(@ISA @EXPORT $VERSION);
use Carp;
@@ -168,8 +167,7 @@
$cnt = 0;
foreach $name (@methods){
if ( do { no strict 'refs'; defined &{$class . "::$name"} } ) {
- warnings::warn "function '$name' already defined, overrides struct
accessor method"
- if warnings::enabled();
+ carp "function '$name' already defined, overrides struct accessor method";
}
else {
$pre = $pst = $cmt = $sel = '';
I still have no idea whether the license makes it possible for us to
distribute and install this file as, say, AutomakeStruct. But before
investigating, I would like to have opinions. This is a significant
simplification of Automake, and given that I plan to use even more
objects in the future, it would drastically simplify a lot of code to
use it.
Index: ChangeLog
from Akim Demaille <[EMAIL PROTECTED]>
* automake.in (®ister_language): Use Class::Struct::new with a
hash.
Index: automake.in
--- automake.in Sun, 25 Mar 2001 16:51:44 +0200 akim (am/f/39_automake.i 1.210 755)
+++ automake.in Sun, 25 Mar 2001 16:52:25 +0200 akim (am/f/39_automake.i 1.210 755)
@@ -28,7 +28,7 @@
# Perl reimplementation by Tom Tromey <[EMAIL PROTECTED]>.
package Language;
-use Class::Struct;
+use Class::Struct2;
struct ('ansi' => '$',
'autodep' => '$',
'compile' => '$',
@@ -5244,70 +5244,7 @@ sub register_language ($%)
$option{'pure'} = 'no'
unless defined $option{'pure'};
- my $lang = new Language;
- while (my ($attr, $value) = each %option)
- {
- if ($attr eq 'ansi')
- {
- $lang->ansi ($value);
- }
- elsif ($attr eq 'autodep')
- {
- $lang->autodep ($value);
- }
- elsif ($attr eq 'compile')
- {
- $lang->compile ($value);
- }
- elsif ($attr eq 'compiler')
- {
- $lang->compiler ($value);
- }
- elsif ($attr eq 'derived-autodep')
- {
- $lang->derived_autodep ($value);
- }
- elsif ($attr eq 'extensions')
- {
- # This array accessor is stupid...
- my $cnt = 0;
- foreach (@{$value})
- {
- $lang->extensions ($cnt, $_);
- ++$cnt;
- }
- }
- elsif ($attr eq 'flags')
- {
- $lang->flags ($value);
- }
- elsif ($attr eq 'linker')
- {
- $lang->linker ($value);
- }
- elsif ($attr eq 'name')
- {
- $lang->name ($value);
- }
- elsif ($attr eq 'output_arg')
- {
- $lang->output_arg ($value);
- }
- elsif ($attr eq 'pure')
- {
- $lang->pure ($value);
- }
- elsif ($attr eq '_finish')
- {
- $lang->_finish ($value);
- }
- else
- {
- prog_error ("register_language: "
- . $lang->name
- . ": invalid attribute: $attr");
- }
- }
+ my $lang = new Language (%option);
# Fill indexes.
grep ($extension_map{$_} = $lang->name, @{$lang->extensions});