aboutsummaryrefslogtreecommitdiff
path: root/harness/tools/genintf.pl
blob: 6f5395192f0d647cd07d11b144ee964675b4a6e4 (plain) (blame)
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
#!/usr/bin/env perl

$comment="";

print "#ifndef _PLUG_INTF\n";
print "#define _PLUG_INTF\n";
print "\n#include <stdint.h>\n";
print "\ntypedef void* opqst_t;\n";
while (<>) {
  if (/^\s*\/\*/) {
    $_ =~ s/^\s*//;
    $comment="$_";
  }

  if (/^\s*\*/) {
    $_ =~ s/^\s*/ /;
    $comment="$comment$_";
  }

  if (/^\s*EXPORT_INCLUDE\((.*)\)/) {
    print "#include $1\n";
  } elsif (/^\s*EXPORT\(\s*((?:\w|\s*\*\s*)+)\s*\(\*(\w+)\)\s*\((.*)\)\);/) {
    print "$comment";
    print "$1 $2($3);\n\n";
    $comment="";
  } elsif (/^\s*EXPORT\((.*)\)/) {
    print "$1\n";
  }
}
print "#endif /* _PLUG_INTF */\n";