Mercurial > hg > GearsTemplate
view 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 |
line wrap: on
line source
#!/usr/bin/perl # interface.cbc # typedef struct Worker { # int id; # struct Context* contexts; # enum Code execute; # enum Code taskSend; # enum Code taskRecive; # enum Code shutdown; # struct Queue* tasks; # } Worker; system "rm -rf d"; system "mkdir d"; while (<*.cbc>) { &getDataGear($_); } &generateDataGear(); sub getDataGear { my ($filename) = @_; open my $fd,"<",$filename or die("can't open $filename $!"); while (<$fd>) { if (! $inTypedef) { if (/^typedef struct (\w+) {/) { $inTypedef = 1; $name = $1; $dataGear{$name} = $_; } next; } $dataGear{$name} .= $_; if (/(\w+);$/ and !/^} (\w+)/) { $tmp = $1 . "\n"; if (/{/) { $tmp = "{" . $'; $tmp =~ s/;$//; } $var{$name} .= $tmp; $tmp = $`; $tmp =~ s/^\s*//; $type{$name} .= $tmp . "\n"; } if (/^}/) { $inTypedef = 0; } } } sub generateDataGear { open my $fd,">","d/extern.h" or die("can't open d/extern.h $!"); for my $name ( sort keys %dataGear ) { print $fd $dataGear{$name},"\n"; } print $fd "\n"; open my $fd,">","d/stub.h" or die("can't open d/stub.h $!"); for my $name ( sort keys %dataGear ) { print $fd $var{$name},"\n"; } for my $name ( sort keys %dataGear ) { print $fd $type{$name},"\n"; } print $fd "\n"; } # end