Mercurial > hg > Members > Moririn
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/generate_stub.pl Fri Dec 16 19:40:42 2016 +0900 @@ -0,0 +1,50 @@ +#!/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 (/^}/) { + $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"; +} + +# end