comparison src/parallel_execution/generate_stub.pl @ 466:831b7f6fd687

Fix warning pointer type
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Thu, 21 Dec 2017 18:52:21 +0900 (2017-12-21)
parents 7d67c9cf09ee
children 4ec61e201c19
comparison
equal deleted inserted replaced
465:b6437feb04ee 466:831b7f6fd687
160 # continuation case 160 # continuation case
161 if ($args =~ s/^(\s)*\_\_code\s+(\w+)\(([^)]*)\)//) { 161 if ($args =~ s/^(\s)*\_\_code\s+(\w+)\(([^)]*)\)//) {
162 my $next = $2; 162 my $next = $2;
163 my @args = split(/,/,$3); 163 my @args = split(/,/,$3);
164 push(@{$code{$name}->{$method}},"\_\_code $next"); 164 push(@{$code{$name}->{$method}},"\_\_code $next");
165 } elsif ($args =~ s/^(struct|union)?\s*(\w+)(\*)*+\s(\w+)//) { 165 } elsif ($args =~ s/^(struct|union)?\s*(\w+)(\**)\s+(\w+)//) {
166 my $structType = $1; 166 my $structType = $1;
167 my $typeName = $2; 167 my $typeName = $2;
168 my $ptrType = $3;
168 my $varName = $4; 169 my $varName = $4;
169 my $typeField = lcfirst($typeName); 170 my $typeField = lcfirst($typeName);
170 push(@{$code{$name}->{$method}},"$typeName $varName"); 171 push(@{$code{$name}->{$method}},"$typeName$ptrType $varName");
171 } elsif ($args =~ s/(.*,)//) { 172 } elsif ($args =~ s/(.*,)//) {
172 } else { 173 } else {
173 last; 174 last;
174 } 175 }
175 } 176 }
209 print $fd "\n} \n\n"; 210 print $fd "\n} \n\n";
210 return 1; 211 return 1;
211 } 212 }
212 213
213 sub generateStubArgs { 214 sub generateStubArgs {
214 my($codeGearName, $varName, $typeName, $typeField, $interface,$output) = @_; 215 my($codeGearName, $varName, $typeName, $ptrType, $typeField, $interface,$output) = @_;
215 my $varname1 = $output?"O_$varName":$varName; 216 my $varname1 = $output?"O_$varName":$varName;
216 for my $n ( @{$dataGearVar{$codeGearName}} ) { 217 for my $n ( @{$dataGearVar{$codeGearName}} ) {
217 # we already have it 218 # we already have it
218 return 0 if ( $n eq $varname1); 219 return 0 if ( $n eq $varname1);
219 } 220 }
226 for my $ivar (keys %{$var{$interface}}) { 227 for my $ivar (keys %{$var{$interface}}) {
227 # input data gear field 228 # input data gear field
228 if ($varName eq $ivar) { 229 if ($varName eq $ivar) {
229 if ($typeName eq $var{$interface}->{$ivar}) { 230 if ($typeName eq $var{$interface}->{$ivar}) {
230 if ($output) { 231 if ($output) {
231 $dataGearName{$codeGearName} .= "\t$typeName** O_$varName = &Gearef(context, $interface)->$varName;\n"; 232 $dataGearName{$codeGearName} .= "\t$typeName$ptrType* O_$varName = &Gearef(context, $interface)->$varName;\n";
232 $outputVar{$codeGearName} .= "\t$typeName* $varName;\n"; 233 $outputVar{$codeGearName} .= "\t$typeName$ptrType $varName;\n";
233 return 1; 234 return 1;
234 } 235 }
235 236
236 $dataGearName{$codeGearName} .= "\t$typeName* $varName = Gearef(context, $interface)->$varName;\n"; 237 $dataGearName{$codeGearName} .= "\t$typeName$ptrType $varName = Gearef(context, $interface)->$varName;\n";
237 return 1; 238 return 1;
238 } 239 }
239 } 240 }
240 } 241 }
241 for my $cName (keys %{$code{$interface}}) { 242 for my $cName (keys %{$code{$interface}}) {
245 return 1; 246 return 1;
246 } 247 }
247 } 248 }
248 # global or local variable case 249 # global or local variable case
249 if ($typeName eq "Code") { 250 if ($typeName eq "Code") {
250 $dataGearName{$codeGearName} .= "\tenum $typeName $varName = Gearef(context, $interface)->$varName;\n"; 251 $dataGearName{$codeGearName} .= "\tenum $typeName$ptrType $varName = Gearef(context, $interface)->$varName;\n";
251 return 1; 252 return 1;
252 } 253 }
253 $dataGearName{$codeGearName} .= "\t$typeName* $varName = Gearef(context, $typeName);\n"; 254 $dataGearName{$codeGearName} .= "\t$typeName$ptrType $varName = Gearef(context, $typeName);\n";
254 return 1; 255 return 1;
255 } 256 }
256 } 257 }
257 258
258 sub generateDataGear { 259 sub generateDataGear {
338 } 339 }
339 # continuation case 340 # continuation case
340 if ($args =~ s/^(\s)*\_\_code\s+(\w+)\(([^)]*)\)//) { 341 if ($args =~ s/^(\s)*\_\_code\s+(\w+)\(([^)]*)\)//) {
341 my $next = $2; 342 my $next = $2;
342 my @args = split(/,/,$3); 343 my @args = split(/,/,$3);
343 if (&generateStubArgs($codeGearName, $next, "Code", $next, $interface,0) ) { 344 if (&generateStubArgs($codeGearName, $next, "Code", "", $next, $interface,0) ) {
344 $newArgs .= "enum Code $next"; 345 $newArgs .= "enum Code $next";
345 } 346 }
346 # analyze continuation arguments 347 # analyze continuation arguments
347 # output arguments are defined in the Interface take the pointer of these 348 # output arguments are defined in the Interface take the pointer of these
348 # output arguments are put into the Interface DataGear just before the goto 349 # output arguments are put into the Interface DataGear just before the goto
349 for my $arg (@args) { 350 for my $arg (@args) {
350 $arg =~ s/^\s*//; 351 $arg =~ s/^\s*//;
351 last if ($arg =~ /\.\.\./); 352 last if ($arg =~ /\.\.\./);
352 $arg =~ s/^(struct|union) (\w+)(\*)+\s(\w+)//; 353 $arg =~ s/^(struct|union)? (\w+)(\**)\s(\w+)//;
353 my $structType = $1; 354 my $structType = $1;
354 my $typeName = $2; 355 my $typeName = $2;
356 my $ptrType = $3;
355 my $varName = $4; 357 my $varName = $4;
356 my $typeField = lcfirst($typeName); 358 my $typeField = lcfirst($typeName);
357 push(@{$outputArgs{$codeGearName}->{$next}}, $varName); 359 push(@{$outputArgs{$codeGearName}->{$next}}, $varName);
358 if (&generateStubArgs($codeGearName, $varName, $typeName, $typeField, $interface,1)) { 360 if (&generateStubArgs($codeGearName, $varName, $typeName, $ptrType, $typeField, $interface,1)) {
359 $newArgs .= ",$structType $typeName **O_$varName"; 361 $newArgs .= ",$structType $typeName **O_$varName";
360 } 362 }
361 } 363 }
362 } elsif ($args =~ s/^(struct|union) (\w+)(\*)+\s(\w+)//) { 364 } elsif ($args =~ s/^(struct|union)? (\w+)(\**)\s(\w+)//) {
363 my $structType = $1; 365 my $structType = $1;
364 my $typeName = $2; 366 my $typeName = $2;
367 my $ptrType = $3;
365 my $varName = $4; 368 my $varName = $4;
366 my $typeField = lcfirst($typeName); 369 my $typeField = lcfirst($typeName);
367 $newArgs .= $&; # assuming no duplicate 370 $newArgs .= $&; # assuming no duplicate
368 &generateStubArgs($codeGearName, $varName, $typeName, $typeField, $interface,0); 371 &generateStubArgs($codeGearName, $varName, $typeName, $ptrType, $typeField, $interface,0);
369 } elsif ($args =~ s/(.*,)//) { 372 } elsif ($args =~ s/(.*,)//) {
370 $newArgs .= $1; 373 $newArgs .= $1;
371 } else { 374 } else {
372 $newArgs .= $args; 375 $newArgs .= $args;
373 last; 376 last;
425 if ($arg =~ /(\w+)\(.*\)/) { 428 if ($arg =~ /(\w+)\(.*\)/) {
426 print $fd "\tGearef(context, $ntype)->$pName = $1;\n"; 429 print $fd "\tGearef(context, $ntype)->$pName = $1;\n";
427 } else { 430 } else {
428 print $fd "\tGearef(context, $ntype)->$pName = C_$arg;\n"; 431 print $fd "\tGearef(context, $ntype)->$pName = C_$arg;\n";
429 } 432 }
430 } elsif ($pType =~ s/Data$//){ 433 } elsif ($pType =~ /Data\**$/){
431 print $fd "\tGearef(context, $ntype)->$pName = (union Data*) $arg;\n"; 434 print $fd "\tGearef(context, $ntype)->$pName = (union $pType) $arg;\n";
432 } else { 435 } else {
433 print $fd "\tGearef(context, $ntype)->$pName = $arg;\n"; 436 print $fd "\tGearef(context, $ntype)->$pName = $arg;\n";
434 } 437 }
435 $i++; 438 $i++;
436 } 439 }