annotate src/parallel_execution/generate_stub.pl @ 217:c34e6aa10967

Fix DataGear access name
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Mon, 09 Jan 2017 01:18:13 +0900
parents 90fa6f8246ca
children 68c03e7057d9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
194
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
1 #!/usr/bin/perl
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
2
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
3 # interface.cbc
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
4 # typedef struct Worker {
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
5 # int id;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
6 # struct Context* contexts;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
7 # enum Code execute;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
8 # enum Code taskSend;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
9 # enum Code taskRecive;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
10 # enum Code shutdown;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
11 # struct Queue* tasks;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
12 # } Worker;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
13
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
14 system "rm -rf d";
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
15 system "mkdir d";
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
16
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
17 while (<*.cbc>) {
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
18 &getDataGear($_);
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
19 }
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
20
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
21 &generateDataGear();
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
22
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
23 sub getDataGear {
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
24 my ($filename) = @_;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
25 open my $fd,"<",$filename or die("can't open $filename $!");
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
26 while (<$fd>) {
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
27 if (! $inTypedef) {
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
28 if (/^typedef struct (\w+) {/) {
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
29 $inTypedef = 1;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
30 $name = $1;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
31 $dataGear{$name} = $_;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
32 }
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
33 next;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
34 }
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
35 $dataGear{$name} .= $_;
195
bd96dffaa76a generate_stub
mir3636
parents: 194
diff changeset
36 if (/(\w+);$/ and !/^} (\w+)/) {
200
207aff30ed34 fix generate_stub.pl
mir3636
parents: 195
diff changeset
37 $tmp = $1 . "\n";
207aff30ed34 fix generate_stub.pl
mir3636
parents: 195
diff changeset
38 if (/{/) {
207aff30ed34 fix generate_stub.pl
mir3636
parents: 195
diff changeset
39 $tmp = "{" . $';
201
mir3636
parents: 200
diff changeset
40 $tmp =~ s/;$//;
200
207aff30ed34 fix generate_stub.pl
mir3636
parents: 195
diff changeset
41 }
207aff30ed34 fix generate_stub.pl
mir3636
parents: 195
diff changeset
42 $var{$name} .= $tmp;
195
bd96dffaa76a generate_stub
mir3636
parents: 194
diff changeset
43 $tmp = $`;
bd96dffaa76a generate_stub
mir3636
parents: 194
diff changeset
44 $tmp =~ s/^\s*//;
bd96dffaa76a generate_stub
mir3636
parents: 194
diff changeset
45 $type{$name} .= $tmp . "\n";
bd96dffaa76a generate_stub
mir3636
parents: 194
diff changeset
46 }
194
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
47 if (/^}/) {
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
48 $inTypedef = 0;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
49 }
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
50 }
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
51 }
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
52
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
53 sub generateDataGear {
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
54 open my $fd,">","d/extern.h" or die("can't open d/extern.h $!");
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
55 for my $name ( sort keys %dataGear ) {
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
56 print $fd $dataGear{$name},"\n";
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
57 }
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
58 print $fd "\n";
195
bd96dffaa76a generate_stub
mir3636
parents: 194
diff changeset
59
bd96dffaa76a generate_stub
mir3636
parents: 194
diff changeset
60 open my $fd,">","d/stub.h" or die("can't open d/stub.h $!");
bd96dffaa76a generate_stub
mir3636
parents: 194
diff changeset
61 for my $name ( sort keys %dataGear ) {
bd96dffaa76a generate_stub
mir3636
parents: 194
diff changeset
62 print $fd $var{$name},"\n";
bd96dffaa76a generate_stub
mir3636
parents: 194
diff changeset
63 }
bd96dffaa76a generate_stub
mir3636
parents: 194
diff changeset
64 for my $name ( sort keys %dataGear ) {
bd96dffaa76a generate_stub
mir3636
parents: 194
diff changeset
65 print $fd $type{$name},"\n";
bd96dffaa76a generate_stub
mir3636
parents: 194
diff changeset
66 }
bd96dffaa76a generate_stub
mir3636
parents: 194
diff changeset
67 print $fd "\n";
194
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
68 }
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
69
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
70 # end