Mercurial > hg > CbC > old > device
view conv_func.pl @ 237:1933266f1efa
long long ia32 (imcomplete)
author | kono |
---|---|
date | Fri, 30 Apr 2004 11:47:51 +0900 |
parents | aac62d1e30a6 |
children | da2e3f2d127d |
line wrap: on
line source
#!/usr/bin/perl $in="conv_func.tbl"; $out="conv/conv.h"; $def="conv/convdef.h"; $nul="conv/null.c"; open(IN,"<$in") or die("can't open $in"); open(OUT,">$out") or die("can't open $out"); print OUT "/* Do not edit this file. This is automatically generated. */\n"; print OUT "/* Edit $in */\n"; open(DEF,">$def") or die("can't open $def"); print DEF "/* Do not edit this file. This is automatically generated. */\n"; print DEF "/* Edit $in */\n"; open(NUL,">$nul") or die("can't open $nul"); print NUL "/* Do not edit this file. This is automatically generated. */\n"; print NUL "/* Edit $in */\n"; print OUT "typedef struct converter {\n"; print NUL "#define EXTERN /**/\n"; print NUL "#include \"mc.h\"\n"; print NUL "#include \"conv/convdef.h\"\n\n"; print NUL "#include \"conv/null.h\"\n\n"; while(<IN>) { if (/([^\s]*)\s+([_a-zA-Z0-9]*)\((.*)\)/) { $type=$1; $name=$2; $arg=$3; # print OUT "$type=$name=$arg\n"; $return = ($type && $type ne "void")? "return ($type)0;" : ""; print OUT " $type (*$name)($arg);\n"; print NUL "static $type\n$name($arg)\n{ $return}\n\n"; print DEF "static $_"; } } print OUT "} Converter;\n"; foreach $def ('conv/c.h','conv/null.h' ) { $def =~ m-conv/(.*)\.h-; $m = $1; open(DEF,">$def") or die("can't open $def"); print DEF "/* Do not edit this file. This is automatically generated. */\n"; print OUT "extern Converter ${m}_converter;\n"; print DEF "\nextern Converter $1_converter;\n"; print DEF "\n\n\nConverter $1_converter = {\n"; open(IN,"<$in") or die("can't open $in"); while(<IN>) { if (/([^\s]*)\s+([_a-zA-Z0-9]*)\((.*)\)/) { $type=$1; $name=$2; $arg=$3; print DEF " \&$name,\n"; } } print DEF "};\n"; }