blob: ff399654c977295df5da3322976e4e95dca3da66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/usr/bin/perl
$/ = "\n{\n";
while (<>) {
chop; next unless chop($_) eq "{";
s/[^\0]*\n\n//;
$* = 1;
s/^#.*\n//g;
$* = 0;
tr/\n/ /;
s#\*/#\200#g;
s#/\*[^\200]*\200##g;
/\b\w+\(/ || next;
$funtype = $`;
$name = $&;
$_ = $';
/\)\s*/ || next;
$args = $`;
$types = $';
$args =~ tr/ \t//d;
@args = split(/,/,$args);
@types = split(/;\s*/, $types);
%type = ();
foreach $type (@types) {
$type =~ /.*\b(\w+)/;
$type{$1} = $type;
}
foreach $arg (@args) {
$arg = $type{$arg} || $arg;
$arg =~ s/register //;
}
$funtype =~ s/\* $/*/;
$funtype =~ s/^ *//;
chop $name;
if (@args) {
print $funtype, $name, " P((", join(', ', @args), "));\n";
}
else {
print $funtype, $name, " P((void));\n";
}
}
|