OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [classpath/] [lib/] [mkcollections.pl.in] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
#!@PERL@
2
#
3
# mkcollections.pl - small perl script to convert GNU Classpath's
4
#                    Collection classes into its own package for java 1.1
5
#
6
# USAGE: mkcollections.pl 
7
#
8
# Copyright (C) 2000 Free Software Foundation, Inc.
9
#
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)
13
# any later version.
14
#
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.
19
#
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
24
 
25
my $destpath=pop || "gnu/java/util/collections";
26
my $classpath="..";
27
my @javalangclasses=qw(UnsupportedOperationException
28
                       Comparable);
29
my @javautilclasses=qw(AbstractCollection
30
                       AbstractList
31
                       AbstractMap
32
                       AbstractSequentialList
33
                       AbstractSet
34
                       ArrayList
35
                       Arrays
36
                       BasicMapEntry
37
                       List
38
                       Collection
39
                       Collections
40
                       Comparator
41
                       ConcurrentModificationException
42
                       HashMap
43
                       HashSet
44
                       Hashtable
45
                       Iterator
46
                       LinkedList
47
                       ListIterator
48
                       Map
49
                       NoSuchElementException
50
                       Random
51
                       Set
52
                       SortedMap
53
                       SortedSet
54
                       TreeMap
55
                       TreeSet
56
                       Vector);
57
 
58
my $destPkg = $destpath;
59
$destPkg  =~ s!/!.!g;
60
 
61
my %imports = ( "Collections" => [ "Enumeration" ],
62
                "Hashtable" => [ "Dictionary", "Enumeration" ],
63
                "Vector" => [ "Enumeration" ]);
64
 
65
 
66
sub mymkdir ($)
67
  {
68
    my ($dir) = @_;
69
    if ($dir =~ /^(.*)\/\w+$/)
70
      {
71
        $parentdir = "$1";
72
        if (! (-d $parentdir))
73
          {
74
            mymkdir ($parentdir);
75
          }
76
      }
77
    print "$dir";
78
    mkdir ($dir, 0777);
79
  }
80
 
81
sub convert($$$) {
82
    my ($file, $infile, $outfile) = @_;
83
 
84
    open (INPUT, "<$infile") || die "Could not open ", $infile, " for reading\n";
85
 
86
    my $dir = "$outfile";
87
    $dir =~ /^(.*)\/\S+\.java$/ and
88
        $dir = "$1";
89
    if (! (-d $dir)) {
90
        mymkdir ($dir);
91
    }
92
 
93
    open (OUTPUT, ">$outfile") || die "Could not open ", $outfile, " for writing\n";
94
    print OUTPUT <<'EOF';
95
/* This file was converted from the GNU Classpath Project by a
96
 * perl script, written by Jochen Hoenicke .
97
 */
98
EOF
99
    while () {
100
        $_ = "package $destPkg;\n" if ($_ =~ /^package java.(lang|util);$/);
101
 
102
        next if $_ =~ /^import java.io.Object.*putStream.*Field;$/;
103
        next if $_ =~ /^import java.io.ObjectStreamField;$/;
104
 
105
        for $clazz (@javalangclasses) {
106
            $_ =~ s/java.lang.$clazz/$clazz/g;
107
        }
108
        for $clazz (@javautilclasses) {
109
            $_ =~ s/java.util.$clazz/$clazz/g;
110
        }
111
 
112
        $_ =~ s/abstract (interface)/$1/g;
113
 
114
        print OUTPUT $_;
115
        if ($_ =~ /^package $destPkg;$/
116
            && exists $imports{$file}) {
117
            for $imp (@{$imports{$file}}) {
118
                print OUTPUT "import java.util.$imp;\n";
119
            }
120
        }
121
    }
122
    close (OUTPUT);
123
    close (INPUT);
124
}
125
 
126
my $file;
127
 
128
for $file (@javalangclasses) {
129
    my $infile = "$classpath/java/lang/$file.java";
130
    my $outfile = "$destpath/$file.java";
131
    print "$outfile\n";
132
    convert ($file, $infile, $outfile);
133
}
134
 
135
for $file (@javautilclasses) {
136
    my $infile = "$classpath/java/util/$file.java";
137
    my $outfile = "$destpath/$file.java";
138
    print "$outfile\n";
139
    convert ($file, $infile, $outfile);
140
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.