Debian Codegraph @

util/trans

raw
1 #!/usr/bin/perl
2 =pod
3 Translate the header file plot.h to xsub declarations.
4 use with gnu libplot
5 =cut
6
7
8 while(<>) {
9 next unless /^int|^double|^FILE/;
10 chomp;
11 print "# $_ \n";
12 ($return_type,$name,$arglist) =
13 /(\S+)\s+(\w+)\s*___P\s*\(\(([^\)]*)\)\)/;
14 @args = split('\s*,\s*',$arglist);
15 @argtype=();
16 @argname=();
17 foreach $arg (@args) {
18 $arg =~ s/___const\s+//g;
19 $arg =~ s/^s*//; $arg =~ s/\s*$//;
20 ($argtype,$argname) = split('\s+',$arg);
21 next unless defined $argtype and defined $argname;
22 push @argtype,$argtype;
23 push @argname,$argname;
24 }
25 print $return_type,"\n";
26 print "$name(";
27 # print "$name\n";
28 for($i=0;$i<@argname;$i++) {
29 $outname = $argname[$i];
30 $outname =~ s/\*//g;
31 print $outname;
32 print "," unless $i == $#argname;
33 }
34 print ")\n";
35 for($i=0;$i<@argname;$i++) {
36 print " $argtype[$i] $argname[$i]\n";
37 }
38 print "\n\n";
39 }
40
41
42
43
44
45
46
47