Bug database broken / Generating interfaces / ChangeLog suggestion

Frohwalt Egerer froh at iconsult.com
Wed Nov 10 14:13:12 PST 1999



Hello everybody,

  today I've got three things on my mind:

1. The bug database on www.kaffe.org still seems to be broken,
   browsing to www.kaffe.org and clicking on the Bug Database link in
   the navigational frame just opens another navigational bar and
   kaffe homepage in my browser.

2. Since I'm needing JDBC 2.0 I'll probably enhance Kaffe's JDBC
   support. Are there any objections in generating the needed
   interfaces by using reflection on Sun's classes? Or is that "too
   close to Sun's source" to be cleanroom. If I'm just supposed to
   read the docs only, how am I supposed to find out the values for
   static constants?

   By the way, last week I've thrown together a perl script that reads
   JavaDoc and creates interfaces/class skeletons from what it
   finds. I'll append it below in case anybody finds it useful.

3. The ChangeLog for Kaffe seems to be maintained manually. Do you
   know there's a nice Perl script which generates ChangeLog files
   from CVS' commit messages?  Have a look at it at
   http://www.red-bean.com/~kfogel/cvs2cl.shtml

Froh





And here's the skeleton generator, have fun with it.


#!/usr/bin/perl -w

#
# Parseapidoc
#
# A simple, fast hack to parse openly available Java documentation and generate
# interfaces from it. There's no warranty attached to this, if it breaks you
# keep the pieces. Use, copy and modify this as much as you like.
#
# In case Sun changes javadoc's output this script has to be changed ;-)
#

foreach $file (@ARGV)
{
    undef $@;

    if ($file !~ m/package-/)  # filter out package-tree etc.
    {
	eval
	{
	    open(IN, "<$file") || die("Cannot open $file: $!\n");
	    $in =  \*IN;
	    
	    $outfile = $file;
	    $outfile =~ s|/|.|g;
	    $outfile =~ s|\.html|.java|;

	    open (OUT, ">$outfile") || die("Cannot open $outfile for writing: $!\n");
	    $out = \*OUT;
# 	    $out = \*STDOUT;

	    print $out ("/* Automatically generated from $file by parseapidoc.pl */\n\n");
	    

	    classdecl();
	    fields();
	    
	    print $out "}\n\n";
	};
    }
    
    warn ("$@\t... propagated for $file\n") if ($@);
    
    close(IN);
    close(OUT);
}


sub classdecl()
{
    while (<$in>)
    {
	chomp;
	last if m/======== START OF CLASS DATA ========/;
    }

    <$in>      || die "premature EOF";    # Eat the <H2>
    <$in>      || die "premature EOF";    # Eat the <FONT SIZE>

    $pkg=<$in> || die "premature EOF";    # Contains pack.age.foo</FONT>
    chomp $pkg;
    $pkg = removetags($pkg);
    print $out "package $pkg;\n\n";

    while (<$in>)
    {
	last if m/<HR>/;
    }

    <$in>        || die "premature EOF";   # Eat the <DL>

    $cls = <$in> || die "premature EOF";   # contains the declaration.
    chomp $cls;
    $cls = removetags($cls);
    $cls =~ s/abstract interface/interface/g;
    $cls =~ s/ *extends/\n    extends/g;
    $cls =~ s/ *implements/\n    implements/g;
    print $out "$cls\n{\n";

}

# Also handles constructors and methods ...
sub fields()
{
    while (<$in>)
    {
	chomp;
	last if m/FIELD DETAIL/;
    }

    while (1)
    {

	while (<$in>)
	{
	    last   if m/<PRE>/i;
	    return if m/END OF CLASS DATA/;
	}

	my $done = 0;
	my $val = "";

	while (!$done)
	{
	    chomp;

	    $done = 1 if m|</PRE>|i;
	    $_ = removetags($_);
	    $val .= $_;
	    $_ = <$in> || die "premature EOF";
	}

	$val =~ s| *, *|, |g;
	$val =~ s| *\( *|(|g;
        $val =~ s| *throws| throws|g;

	print $out "    $val;\n";
    }
}

sub removetags
{
    my ($s) = @_;

    $s =~ s/<.*?>/ /g;
    $s =~ s/&nbsp;/ /g;
    $s =~ s/ +/ /g;
    $s =~ s/^ *//;
    $s =~ s/ *$//;

    return $s;
}


More information about the kaffe mailing list