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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-dev/] [fsf-gcc-snapshot-1-mar-12/] [or1k-gcc/] [libjava/] [classpath/] [lib/] [mkcollections.pl.in] - Diff between revs 781 and 783

Only display areas with differences | Details | Blame | View Log

Rev 781 Rev 783
#!@PERL@
#!@PERL@
#
#
# mkcollections.pl - small perl script to convert GNU Classpath's
# mkcollections.pl - small perl script to convert GNU Classpath's
#                    Collection classes into its own package for java 1.1
#                    Collection classes into its own package for java 1.1
#
#
# USAGE: mkcollections.pl 
# USAGE: mkcollections.pl 
#
#
# Copyright (C) 2000 Free Software Foundation, Inc.
# Copyright (C) 2000 Free Software Foundation, Inc.
#
#
# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# any later version.
#
#
# This program is distributed in the hope that it will be useful,
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING.  If not, write to
# along with this program; see the file COPYING.  If not, write to
# the Free Software Foundation, 51 Franklin St, Fifth Floor,
# the Free Software Foundation, 51 Franklin St, Fifth Floor,
# Boston, MA  02110-1301  USA
# Boston, MA  02110-1301  USA
my $destpath=@COLLECTIONS_PREFIX@;
my $destpath=@COLLECTIONS_PREFIX@;
my $classpath=pop;
my $classpath=pop;
my @javalangclasses=qw(UnsupportedOperationException
my @javalangclasses=qw(UnsupportedOperationException
                       Comparable
                       Comparable
                       Iterable);
                       Iterable);
my @javautilclasses=qw(AbstractCollection
my @javautilclasses=qw(AbstractCollection
                       AbstractList
                       AbstractList
                       AbstractMap
                       AbstractMap
                       AbstractSequentialList
                       AbstractSequentialList
                       AbstractSet
                       AbstractSet
                       ArrayList
                       ArrayList
                       Arrays
                       Arrays
                       List
                       List
                       Collection
                       Collection
                       Collections
                       Collections
                       Comparator
                       Comparator
                       ConcurrentModificationException
                       ConcurrentModificationException
                       HashMap
                       HashMap
                       HashSet
                       HashSet
                       Hashtable
                       Hashtable
                       Iterator
                       Iterator
                       LinkedList
                       LinkedList
                       ListIterator
                       ListIterator
                       Map
                       Map
                       NoSuchElementException
                       NoSuchElementException
                       Random
                       Random
                       RandomAccess
                       RandomAccess
                       Set
                       Set
                       SortedMap
                       SortedMap
                       SortedSet
                       SortedSet
                       TreeMap
                       TreeMap
                       TreeSet
                       TreeSet
                       Vector);
                       Vector);
my @externalclasses=qw(AbstractQueue
my @externalclasses=qw(AbstractQueue
                       ArrayDeque
                       ArrayDeque
                       Deque
                       Deque
                       NavigableMap
                       NavigableMap
                       NavigableSet
                       NavigableSet
                       Queue);
                       Queue);
my $destPkg = $destpath;
my $destPkg = $destpath;
$destPkg  =~ s!/!.!g;
$destPkg  =~ s!/!.!g;
my %imports = ( "Collections" => [ "Enumeration" ],
my %imports = ( "Collections" => [ "Enumeration" ],
                "Hashtable" => [ "Dictionary", "Enumeration" ],
                "Hashtable" => [ "Dictionary", "Enumeration" ],
                "Vector" => [ "Enumeration" ]);
                "Vector" => [ "Enumeration" ]);
sub mymkdir ($)
sub mymkdir ($)
  {
  {
    my ($dir) = @_;
    my ($dir) = @_;
    if ($dir =~ /^(.*)\/\w+$/)
    if ($dir =~ /^(.*)\/\w+$/)
      {
      {
        $parentdir = "$1";
        $parentdir = "$1";
        if (! (-d $parentdir))
        if (! (-d $parentdir))
          {
          {
            mymkdir ($parentdir);
            mymkdir ($parentdir);
          }
          }
      }
      }
    print "$dir";
    print "$dir";
    mkdir ($dir, 0777);
    mkdir ($dir, 0777);
  }
  }
sub convert($$$) {
sub convert($$$) {
    my ($file, $infile, $outfile) = @_;
    my ($file, $infile, $outfile) = @_;
    open (INPUT, "<$infile") || die "Could not open ", $infile, " for reading\n";
    open (INPUT, "<$infile") || die "Could not open ", $infile, " for reading\n";
    my $dir = "$outfile";
    my $dir = "$outfile";
    $dir =~ /^(.*)\/\S+\.java$/ and
    $dir =~ /^(.*)\/\S+\.java$/ and
        $dir = "$1";
        $dir = "$1";
    if (! (-d $dir)) {
    if (! (-d $dir)) {
        mymkdir ($dir);
        mymkdir ($dir);
    }
    }
    open (OUTPUT, ">$outfile") || die "Could not open ", $outfile, " for writing\n";
    open (OUTPUT, ">$outfile") || die "Could not open ", $outfile, " for writing\n";
    print OUTPUT <<'EOF';
    print OUTPUT <<'EOF';
/* This file was converted from the GNU Classpath Project by a
/* This file was converted from the GNU Classpath Project by a
 * perl script, written by Jochen Hoenicke .
 * perl script, written by Jochen Hoenicke .
 */
 */
EOF
EOF
    while () {
    while () {
        $_ = "package $destPkg;\n" if ($_ =~ /^package java.(lang|util);$/);
        $_ = "package $destPkg;\n" if ($_ =~ /^package java.(lang|util);$/);
        next if $_ =~ /^import java.io.Object.*putStream.*Field;$/;
        next if $_ =~ /^import java.io.Object.*putStream.*Field;$/;
        next if $_ =~ /^import java.io.ObjectStreamField;$/;
        next if $_ =~ /^import java.io.ObjectStreamField;$/;
        for $clazz (@javalangclasses) {
        for $clazz (@javalangclasses) {
            $_ =~ s/java.lang.$clazz/$clazz/g;
            $_ =~ s/java.lang.$clazz/$clazz/g;
        }
        }
        for $clazz (@javautilclasses) {
        for $clazz (@javautilclasses) {
            $_ =~ s/java.util.$clazz/$clazz/g;
            $_ =~ s/java.util.$clazz/$clazz/g;
        }
        }
        for $clazz (@externalclasses) {
        for $clazz (@externalclasses) {
            $_ =~ s/java.util.$clazz/$clazz/g;
            $_ =~ s/java.util.$clazz/$clazz/g;
        }
        }
        $_ =~ s/abstract (interface)/$1/g;
        $_ =~ s/abstract (interface)/$1/g;
        print OUTPUT $_;
        print OUTPUT $_;
        if ($_ =~ /^package $destPkg;$/
        if ($_ =~ /^package $destPkg;$/
            && exists $imports{$file}) {
            && exists $imports{$file}) {
            for $imp (@{$imports{$file}}) {
            for $imp (@{$imports{$file}}) {
                print OUTPUT "import java.util.$imp;\n";
                print OUTPUT "import java.util.$imp;\n";
            }
            }
        }
        }
    }
    }
    close (OUTPUT);
    close (OUTPUT);
    close (INPUT);
    close (INPUT);
}
}
my $file;
my $file;
for $file (@javalangclasses) {
for $file (@javalangclasses) {
    my $infile = "$classpath/java/lang/$file.java";
    my $infile = "$classpath/java/lang/$file.java";
    my $outfile = "$destpath/$file.java";
    my $outfile = "$destpath/$file.java";
    print "$outfile\n";
    print "$outfile\n";
    convert ($file, $infile, $outfile);
    convert ($file, $infile, $outfile);
}
}
for $file (@javautilclasses) {
for $file (@javautilclasses) {
    my $infile = "$classpath/java/util/$file.java";
    my $infile = "$classpath/java/util/$file.java";
    my $outfile = "$destpath/$file.java";
    my $outfile = "$destpath/$file.java";
    print "$outfile\n";
    print "$outfile\n";
    convert ($file, $infile, $outfile);
    convert ($file, $infile, $outfile);
}
}
for $file (@externalclasses) {
for $file (@externalclasses) {
    my $infile = "$classpath/external/jsr166/java/util/$file.java";
    my $infile = "$classpath/external/jsr166/java/util/$file.java";
    my $outfile = "$destpath/$file.java";
    my $outfile = "$destpath/$file.java";
    print "$outfile\n";
    print "$outfile\n";
    convert ($file, $infile, $outfile);
    convert ($file, $infile, $outfile);
}
}
 
 

powered by: WebSVN 2.1.0

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