open(F, "bagel/Bagel.java") || die $!; @contents = ; close(F); open(OUT, ">>ProcessingApplet.java") || die $!; select(OUT); $comments = 0; print "\n\n"; #foreach $line (@contents) { while ($line = shift(@contents)) { $decl = ""; if ($line =~ /\/\*/) { $comments++; } if ($line =~ /\*\//) { $comments--; } next if ($comments > 0); if ($line =~ /^\s*(public \w+ [a-zA-z_]+\(.*$)/) { #print "$1\n"; #$decl .= $line; print $line; $decl .= $line; while (!($line =~ /\)/)) { $line = shift (@contents); $decl .= $line; print $line; #print shift (@contents); } $decl =~ /\s(\S+)\(/; $decl_name = $1; #print "dec $decl_name\n"; print " g.${decl_name}("; $decl =~ s/\s+/ /g; # smush onto a single line $decl =~ s/^.*\(//; $decl =~ s/\).*$//; $prev = 0; @parts = split(', ', $decl); foreach $part (@parts) { ($the_type, $the_arg) = split(' ', $part); $the_arg =~ s/[\[\]]//g; #print "* $the_arg\n"; if ($prev != 0) { print ", "; } print "${the_arg}"; $prev = 1; } print ");\n"; #print "$decl\r\n"; print " }\n\n"; } } print "}\n";