3 # mkcollections.pl - small perl script to convert GNU Classpath's
4 # Collection classes into its own package for java 1.1
6 # USAGE: mkcollections.pl <Destination-Path>
8 # Copyright (C) 2000 Free Software Foundation, Inc.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2, or (at your option)
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; see the file COPYING. If not, write to
22 # the Free Software Foundation, 51 Franklin St, Fifth Floor,
23 # Boston, MA 02110-1301 USA
25 my $destpath=@COLLECTIONS_PREFIX@
;
27 my @javalangclasses=qw(UnsupportedOperationException
29 my @javautilclasses=qw(AbstractCollection
32 AbstractSequentialList
40 ConcurrentModificationException
48 NoSuchElementException
58 my $destPkg = $destpath;
61 my %imports = ( "Collections" => [ "Enumeration" ],
62 "Hashtable" => [ "Dictionary", "Enumeration" ],
63 "Vector" => [ "Enumeration" ]);
69 if ($dir =~ /^(.*)\/\w
+$/)
72 if (! (-d
$parentdir))
82 my ($file, $infile, $outfile) = @_;
84 open (INPUT
, "<$infile") || die "Could not open ", $infile, " for reading\n";
87 $dir =~ /^(.*)\/\S
+\
.java
$/ and
93 open (OUTPUT
, ">$outfile") || die "Could not open ", $outfile, " for writing\n";
95 /* This file was converted from the GNU Classpath Project by a
96 * perl script, written by Jochen Hoenicke <jochen\@gnu.org>.
100 $_ = "package $destPkg;\n" if ($_ =~ /^package java.(lang|util);$/);
102 next if $_ =~ /^import java.io.Object.*putStream.*Field;$/;
103 next if $_ =~ /^import java.io.ObjectStreamField;$/;
105 for $clazz (@javalangclasses) {
106 $_ =~ s/java.lang.$clazz/$clazz/g;
108 for $clazz (@javautilclasses) {
109 $_ =~ s/java.util.$clazz/$clazz/g;
112 $_ =~ s/abstract (interface)/$1/g;
115 if ($_ =~ /^package $destPkg;$/
116 && exists $imports{$file}) {
117 for $imp (@
{$imports{$file}}) {
118 print OUTPUT
"import java.util.$imp;\n";
128 for $file (@javalangclasses) {
129 my $infile = "$classpath/java/lang/$file.java";
130 my $outfile = "$destpath/$file.java";
132 convert
($file, $infile, $outfile);
135 for $file (@javautilclasses) {
136 my $infile = "$classpath/java/util/$file.java";
137 my $outfile = "$destpath/$file.java";
139 convert
($file, $infile, $outfile);