annotate src/parallel_execution/generate_stub.pl @ 259:195518ab62fc

fix type gathering pattern match in generate_stub.pl
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 28 Jan 2017 12:37:22 +0900
parents 79bbe2c63fb0
children 6b5444bbea8a
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
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
3 use strict;
254
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
4 use Getopt::Std;
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
5
194
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
6 # interface.cbc
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
7 # typedef struct Worker {
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
8 # int id;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
9 # struct Context* contexts;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
10 # enum Code execute;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
11 # enum Code taskSend;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
12 # enum Code taskRecive;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
13 # enum Code shutdown;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
14 # struct Queue* tasks;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
15 # } Worker;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
16
255
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
17 our($opt_o,$opt_d,$opt_h);
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
18 getopts('o:d:h');
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
19
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
20 my $dir = ".";
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
21 if ($opt_d) {
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
22 $dir = $opt_d;
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
23 if (! -d $dir) {
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
24 mkdir $dir;
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
25 }
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
26 }
254
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
27
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
28 for my $fn (@ARGV) {
255
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
29 next if ($fn !~ /\.cbc$/);
249
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
30 &getDataGear($fn);
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
31 &generateDataGear($fn);
194
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
32 }
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
33
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
34 my %var;
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
35 my %code;
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
36 my %dataGearVar;
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
37 my %dataGear;
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
38 my %dataGearName;
253
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
39 my $implementation;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
40 my $interface;
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
41
194
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
42 sub getDataGear {
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
43 my ($filename) = @_;
253
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
44 my ($codeGearName, $name, $inTypedef);
194
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
45 open my $fd,"<",$filename or die("can't open $filename $!");
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
46 while (<$fd>) {
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
47 if (! $inTypedef) {
259
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
48 if (/^typedef struct (\w+)/) {
194
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
49 $inTypedef = 1;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
50 $name = $1;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
51 $dataGear{$name} = $_;
259
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
52 $var{$name} = {};
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
53 $code{$name} = {};
249
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
54 } elsif (/^(\w+)\* create(\w+)\(/) {
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
55 if (defined $interface) {
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
56 die "duplicate interface $interface\n";
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
57 }
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
58 $interface = $1;
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
59 $implementation = $2;
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
60 if ( -f "$interface.cbc") {
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
61 &getDataGear("$interface.cbc");
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
62 }
226
68c03e7057d9 get arg
mir3636
parents: 201
diff changeset
63 }
194
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
64 next;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
65 }
249
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
66 # gather type name and type
194
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
67 $dataGear{$name} .= $_;
259
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
68 if (/^\s*(.*)\s+(\w+);$/ ) {
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
69 $var{$name}->{$2} = $1;
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
70 } elsif (/\_\_code (\w+)\(/) {
259
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
71 $code{$name}->{$1} = 1;
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
72 }
194
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
73 if (/^}/) {
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
74 $inTypedef = 0;
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
75 }
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
76 }
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
77 }
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
78
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
79 sub generateStub {
251
0ab52d6e2fd9 fix sub generateStub
mir3636
parents: 250
diff changeset
80 my($fd,$prevCodeGearName,$dataGearName) = @_;
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
81 print $fd "__code ", $prevCodeGearName ,"_stub (struct Context* context) {\n";
251
0ab52d6e2fd9 fix sub generateStub
mir3636
parents: 250
diff changeset
82 print $fd $dataGearName;
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
83 print $fd "\n} \n\n";
251
0ab52d6e2fd9 fix sub generateStub
mir3636
parents: 250
diff changeset
84 return 1;
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
85 }
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
86
253
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
87 sub generateStubArgs {
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
88 my($codeGearName, $varName, $typeName, $typeField, $interface) = @_;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
89 push @{$dataGearVar{$codeGearName}},$varName;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
90 if ($typeField ne $varName) {
259
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
91 $dataGearName{$codeGearName} .= "\t$typeName* $varName = ($typeName*)GearImpl(context, $interface, $varName);\n";
253
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
92 } else {
259
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
93 for my $ivar (keys %{$var{$interface}}) {
253
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
94 if ($varName eq $ivar) {
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
95 $dataGearName{$codeGearName} .= "\t$typeName* $varName = Gearef(context, $interface)->$varName;\n";
259
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
96 return;
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
97 }
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
98 }
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
99 for my $cName (keys %{$code{$interface}}) {
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
100 if ($varName eq $cName) {
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
101 $dataGearName{$codeGearName} .= "\tenum Code $varName = Gearef(context, $interface)->$varName;\n";
253
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
102 return;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
103 }
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
104 }
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
105 $dataGearName{$codeGearName} .= "\t$typeName* $varName = Gearef(context, $typeName)->$typeField;\n";
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
106 }
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
107 }
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
108
194
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
109 sub generateDataGear {
249
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
110 my ($filename) = @_;
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
111 open my $in,"<",$filename or die("can't open $filename $!");
254
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
112
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
113 my $fn;
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
114 if ($opt_o) {
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
115 $fn = $opt_o;
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
116 } else {
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
117 my $fn1 = $filename;
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
118 $fn1 =~ s/\.cbc/.c/;
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
119 my $i = 1;
255
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
120 $fn = "$dir/$fn1";
254
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
121 while ( -f $fn) {
255
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
122 $fn = "$dir/$fn1.$i";
254
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
123 $i++;
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
124 }
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
125 }
259
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
126 if ( $fn =~ m=(.*)/[^/]+$= ) {
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
127 if (! -d $1) {
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
128 mkdir $1;
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
129 }
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
130 }
249
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
131 open my $fd,">",$fn or die("can't write $fn $!");
254
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
132
249
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
133 my $prevCodeGearName;
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
134 my $inTypedef = 0;
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
135 my %stub;
251
0ab52d6e2fd9 fix sub generateStub
mir3636
parents: 250
diff changeset
136 my $codeGearName;
254
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 253
diff changeset
137
249
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
138 while (<$in>) {
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
139 if (! $inTypedef) {
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
140 if (/^typedef struct (\w+) {/) {
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
141 $inTypedef = 1;
253
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
142 } elsif (/^\_\_code (\w+)\((.*)\)(.*)/) {
251
0ab52d6e2fd9 fix sub generateStub
mir3636
parents: 250
diff changeset
143 $codeGearName = $1;
253
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
144 my $args = $2;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
145 my $tail = $3;
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
146 if ($codeGearName =~ /_stub$/) {
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
147 $stub{$codeGearName} = 1;
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
148 print $fd $_;
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
149 next;
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
150 }
249
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
151 if (defined $prevCodeGearName) {
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
152 if (defined $stub{$prevCodeGearName."_stub"}) {
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
153 undef $prevCodeGearName;
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
154 print $fd $_;
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
155 next;
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
156 }
253
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
157 $stub{$prevCodeGearName."_stub"} = &generateStub($fd,$prevCodeGearName,$dataGearName{$prevCodeGearName});
249
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
158 }
253
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
159 $prevCodeGearName = $codeGearName;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
160 $dataGearVar{$codeGearName} = [];
259
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
161 my $newArgs = "struct Context *context,";
253
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
162 while($args) {
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
163 if ($args =~ s/(^\s*,\s*)//) {
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
164 $newArgs .= $1;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
165 }
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
166 # replace __code next
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
167 if ($args =~ s/^\_\_code\s(\w+)\([^)]*\)//) {
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
168 my $next = $1;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
169 my @args = split(/,/,$2);
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
170 $newArgs .= "enum Code $next";
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
171 for my $arg (@args) {
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
172 $arg =~ s/^\s*//;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
173 $arg =~ s/^(struct|union) (\w+)(\*)+\s(\w+)//;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
174 my $structType = $1;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
175 my $typeName = $2;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
176 my $varName = $4;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
177 my $typeField = lcfirst($typeName);
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
178 &generateStubArgs($codeGearName, $varName, $typeName, $typeField, $interface);
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
179 }
259
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
180 &generateStubArgs($codeGearName, $next, "Code", $next, $interface);
253
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
181 } elsif ($args =~ s/^(struct|union) (\w+)(\*)+\s(\w+)//) {
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
182 my $structType = $1;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
183 my $typeName = $2;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
184 my $varName = $4;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
185 my $typeField = lcfirst($typeName);
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
186 $newArgs .= $&;
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
187 &generateStubArgs($codeGearName, $varName, $typeName, $typeField, $interface);
255
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
188 } elsif ($args =~ s/(.*,)//) {
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
189 $newArgs .= $1;
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
190 } else {
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
191 $newArgs .= $args;
79bbe2c63fb0 cmake generate c from cbc
mir3636
parents: 254
diff changeset
192 last;
253
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
193 }
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
194 }
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
195 $dataGearName{$codeGearName} .= "\tgoto $codeGearName(context";
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
196 for my $arg ( @{$dataGearVar{$codeGearName}}) {
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
197 $dataGearName{$codeGearName} .= ", $arg";
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
198 }
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
199 $dataGearName{$codeGearName} .= ");";
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
200 print $fd "__code $codeGearName($newArgs)$tail\n";
ebc13549394c generate stubArgs
mir3636
parents: 252
diff changeset
201 next;
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
202 } elsif (/^(.*)goto next\(\.\.\.(.*)\);/) {
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
203 my $prev = $1;
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
204 my $args = $2;
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
205 print $fd "${prev}goto meta(context, next);\n";
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
206 next;
259
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
207 } else {
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
208 s/new\s+(\w+)\(\)/\&ALLOCATE(context, \1)->\1/g; # replacing new
249
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
209 }
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
210 # gather type name and type
259
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 255
diff changeset
211 } elsif (/^}/) {
249
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
212 $inTypedef = 0;
afa1e02e4386 fix generate stub
mir3636
parents: 243
diff changeset
213 }
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
214 print $fd $_;
194
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
215 }
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
216 if (defined $prevCodeGearName) {
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
217 if (!defined $stub{$prevCodeGearName."_stub"}) {
251
0ab52d6e2fd9 fix sub generateStub
mir3636
parents: 250
diff changeset
218 $stub{$prevCodeGearName."_stub"} = &generateStub($fd,$prevCodeGearName,$dataGearName{$codeGearName});
250
8a8963ce9858 fix generate_stub
mir3636
parents: 249
diff changeset
219 }
228
55260ff44c8c generate stub
mir3636
parents: 226
diff changeset
220 }
194
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
221 }
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
222
081607dcf893 create generate_stub.pl
mir3636
parents:
diff changeset
223 # end