1 # classes.pl - A perl program to generate most of the contents of
2 # javaprims.h automatically.
4 # Copyright (C) 1998, 1999 Red Hat, Inc.
6 # This file is part of libjava.
8 # This software is copyrighted work licensed under the terms of the
9 # Libjava License. Please consult the file "LIBJAVA_LICENSE" for
12 # Usage: cd <top-srcdir> ; perl classes.pl.
13 # Can also be run from the `include' directory; this lets us
14 # more easily insert the output into javaprims.h (which is where it goes).
28 die "couldn't find java directory\n";
37 local ($dir, $indent) = @_;
38 local (@subdirs) = ();
39 local (%classes) = ();
41 local ($d) = new DirHandle
$dir;
46 while (defined ($name = $d->read))
48 next if $name eq 'CVS';
50 next if $name eq '..';
56 # We only generate decls for java.lang, java.io, and
60 if (-d
($dir . '/' . $name))
62 push (@subdirs, $name);
65 next unless $name =~ /\.java$/;
67 open (FILE
, "< $dir/$name");
70 # NOTE: we don't skip `/*' comments.
72 # For now assume that class names start with upper
74 next unless /(class|interface) ([A-Z][A-Za-z0-9]+)/;
83 local ($spaces) = ' ' x
$indent;
85 ($classname = $dir) =~ s/^.*\///;
86 print $spaces, "namespace ", $classname, "\n";
89 foreach (sort keys %classes)
91 print $spaces, " class ", $_, ";\n";
93 print "\n" if scalar @classes > 0 && scalar @subdirs > 0;
96 foreach (sort @subdirs)
98 print "\n" unless $first;
100 &scan
("$dir/$_", $indent + 2);
103 print $spaces, "};\n";