#!/usr/local/bin/perl -w # # usage: # def file # # Will create a test file for a builder class. # # get module name first $_ = <> || die("no file man"); chop; m/(^[A-Za-z]+)/; $module_name = $1; $_ = $'; m/([A-Za-z]+[A-Za-z \/]+[A-Za-z\/]+)/; # chop leading and trailing spaces $description = $1; # for description string # read all the function types, which will be defined with the following # format: # # long namemnemonictype $long_name = ""; $mnemonic = ""; $type = ""; @facet = (); while ( <> ) { ( $long_name, $mnemonic, $type ) = split; #print $long_name, " ", $mnemonic, " ", $type, "\n"; push @facet, [ $long_name, $mnemonic, $type ]; } print <\n\n"; print < #include #else #include #include #endif #ifdef WIN32 using namespace std; #endif #include #include #include #include int main( int argc, char** argv ) { if ( ! argv[1] ) { EOS # print "cerr << \"usage: \" << argv[0] << \" ", uc($module_name) ; print " module \" << endl;\n"; print <[1], "( "; if ( $i->[2] eq "A" ) { print "\"", $i->[0], "\""; } elsif ( $i->[2] eq "I" ) { print $j; } elsif ( $i->[2] eq "R" ) { print $j; } else { print "bogus value ", $i->[2], "\n"; exit( -1 ); } print " ) );\n\n"; $j++; } print "cout << ", lc($module_name), " << endl;\n"; print "}\n\n"; print "exit(0);\n"; print "}\n";