Source

opycaml / classes.pl

Full commit
#!/usr/bin/perl

while(<>){
    if( /^type\s+_([A-Z][A-Za-z]+)\s*=/ ){
	$cls = $1;
	if( !$done{$cls} ){
	    print STDERR "CLASS: $cls\n";
	    $done{$cls} = 1;
	}
	$_ = $';
    }
}

$str="";
open(IN, "classes.h.in");
while(<IN>){
    $str = "$str$_";
}
open(OUT, "> autoclasses.h");
for $cls (keys %done) {
    if( $cls ne "Object" ){ $cls = $cls . "Object"; }
    $mystr = $str;
    $mystr =~ s/##name##/$cls/g;
    print OUT $mystr;
}
close OUT;

$str="";
open(IN, "classes.idl.in");
while(<IN>){
    $str = "$str$_";
}
open(OUT, "> autoclasses.idl");
for $cls (keys %done) {
    if( $cls ne "Object" ){ $cls = $cls . "Object"; }
    $mystr = $str;
    $mystr =~ s/##name##/$cls/g;
    print OUT $mystr;
}
close OUT;