-
Notifications
You must be signed in to change notification settings - Fork 0
/
mydef_decl.def
50 lines (46 loc) · 1.51 KB
/
mydef_decl.def
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
43
44
45
46
47
48
49
page: mydef_decl
type:
output_dir: script
my @c_list
my $inc
$foreach $a in @ARGV
$if $a=~/\.c$/
push @c_list, $a
$elif $a=~/\.inc/
$inc = $a
$if $inc and @c_list
$foreach $f in @c_list
load_declare($f)
&call open_w, $inc
$if @auto_struct_list
print Out "S ", join(", ", @auto_struct_list), "\n"
$foreach $name in @struct_list
print Out "struct $name\{\n"
$foreach $l in @{$struct_list{$name}}
print Out $l
print Out "};\n"
$foreach $name in @decl_list
print Out "F $decl_list{$name}\n"
fncode: load_declare($f)
$global %decl_list, @decl_list
$global %struct_list, @struct_list, @auto_struct_list
&call open_r, $f
$if /^(\S.+)\s+(\w+)\((.*)\);/
my ($type, $name, $param)=($1, $2, $3)
$if !$decl_list{$name}
$if $type !~/^static/
$decl_list{$name}="$type $name($param)"
push @decl_list, $name
$elif /^struct\s+(\w+)\s*{\s*(.*)$/
my ($name, $comment) = ($1, $2)
my @t
$while <In>
$if /^}/
last
$else
push @t, $_
$if $comment=~/public/
$struct_list{$name}=\@t
push @struct_list, $name
$else
push @auto_struct_list, $name