comparison src/parallel_execution/generate_stub.pl @ 194:081607dcf893

create generate_stub.pl
author mir3636
date Fri, 16 Dec 2016 19:40:42 +0900
parents
children bd96dffaa76a
comparison
equal deleted inserted replaced
193:af4dec989aa1 194:081607dcf893
1 #!/usr/bin/perl
2
3 # interface.cbc
4 # typedef struct Worker {
5 # int id;
6 # struct Context* contexts;
7 # enum Code execute;
8 # enum Code taskSend;
9 # enum Code taskRecive;
10 # enum Code shutdown;
11 # struct Queue* tasks;
12 # } Worker;
13
14 system "rm -rf d";
15 system "mkdir d";
16
17 while (<*.cbc>) {
18 &getDataGear($_);
19 }
20
21 &generateDataGear();
22
23 sub getDataGear {
24 my ($filename) = @_;
25 open my $fd,"<",$filename or die("can't open $filename $!");
26 while (<$fd>) {
27 if (! $inTypedef) {
28 if (/^typedef struct (\w+) {/) {
29 $inTypedef = 1;
30 $name = $1;
31 $dataGear{$name} = $_;
32 }
33 next;
34 }
35 $dataGear{$name} .= $_;
36 if (/^}/) {
37 $inTypedef = 0;
38 }
39 }
40 }
41
42 sub generateDataGear {
43 open my $fd,">","d/extern.h" or die("can't open d/extern.h $!");
44 for my $name ( sort keys %dataGear ) {
45 print $fd $dataGear{$name},"\n";
46 }
47 print $fd "\n";
48 }
49
50 # end