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
30 my @javautilclasses=qw(AbstractCollection
33 AbstractSequentialList
41 ConcurrentModificationException
49 NoSuchElementException
58 my @externalclasses=qw(AbstractQueue
65 my $destPkg = $destpath;
68 my %imports = ( "Collections" => [ "Enumeration" ],
69 "Hashtable" => [ "Dictionary", "Enumeration" ],
70 "Vector" => [ "Enumeration" ]);
76 if ($dir =~ /^(.*)\/\w
+$/)
79 if (! (-d
$parentdir))
89 my ($file, $infile, $outfile) = @_;
91 open (INPUT
, "<$infile") || die "Could not open ", $infile, " for reading\n";
94 $dir =~ /^(.*)\/\S
+\
.java
$/ and
100 open (OUTPUT
, ">$outfile") || die "Could not open ", $outfile, " for writing\n";
101 print OUTPUT
<<'EOF';
102 /* This file was converted from the GNU Classpath Project by a
103 * perl script, written by Jochen Hoenicke <jochen\@gnu.org>.
107 $_ = "package $destPkg;\n" if ($_ =~ /^package java.(lang|util);$/);
109 next if $_ =~ /^import java.io.Object.*putStream.*Field;$/;
110 next if $_ =~ /^import java.io.ObjectStreamField;$/;
112 for $clazz (@javalangclasses) {
113 $_ =~ s/java.lang.$clazz/$clazz/g;
115 for $clazz (@javautilclasses) {
116 $_ =~ s/java.util.$clazz/$clazz/g;
118 for $clazz (@externalclasses) {
119 $_ =~ s/java.util.$clazz/$clazz/g;
122 $_ =~ s/abstract (interface)/$1/g;
125 if ($_ =~ /^package $destPkg;$/
126 && exists $imports{$file}) {
127 for $imp (@
{$imports{$file}}) {
128 print OUTPUT
"import java.util.$imp;\n";
138 for $file (@javalangclasses) {
139 my $infile = "$classpath/java/lang/$file.java";
140 my $outfile = "$destpath/$file.java";
142 convert
($file, $infile, $outfile);
145 for $file (@javautilclasses) {
146 my $infile = "$classpath/java/util/$file.java";
147 my $outfile = "$destpath/$file.java";
149 convert
($file, $infile, $outfile);
152 for $file (@externalclasses) {
153 my $infile = "$classpath/external/jsr166/java/util/$file.java";
154 my $outfile = "$destpath/$file.java";
156 convert
($file, $infile, $outfile);