Mercurial > hg > Gears > Gears
annotate src/parallel_execution/generate_stub.pl @ 714:d5bd1c640db0
impl name space at gears
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 28 Aug 2020 12:24:42 +0900 |
parents | ed7183a46dca |
children | fd9b9fa4ec98 |
rev | line source |
---|---|
194 | 1 #!/usr/bin/perl |
2 | |
250 | 3 use strict; |
670
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
4 use warnings; |
629
90309637c4c8
Getopt::Std to Getopt::Long
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
625
diff
changeset
|
5 use Getopt::Long; |
670
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
6 use File::Path qw/make_path/; |
669
e8800c60811a
fix search cbc file
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
668
diff
changeset
|
7 use File::Basename qw/basename dirname/; |
661
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
8 |
658 | 9 use FindBin; |
10 use lib "$FindBin::Bin/lib"; | |
11 | |
693
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
12 use Gears::Interface; |
661
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
13 use Gears::Util; |
250 | 14 |
482
5859bed4edff
Refactoring spawnTasks method
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
15 # interface.h |
194 | 16 # typedef struct Worker { |
17 # int id; | |
18 # struct Context* contexts; | |
19 # enum Code execute; | |
20 # enum Code taskSend; | |
21 # enum Code taskRecive; | |
22 # enum Code shutdown; | |
23 # struct Queue* tasks; | |
24 # } Worker; | |
25 | |
630
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
26 our($opt_o,$opt_d,$opt_h, $opt_project); |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
27 |
629
90309637c4c8
Getopt::Std to Getopt::Long
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
625
diff
changeset
|
28 GetOptions( |
631
5189c60b9707
update gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
630
diff
changeset
|
29 "o=s" => \$opt_o, |
5189c60b9707
update gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
630
diff
changeset
|
30 "d=s" => \$opt_d, |
5189c60b9707
update gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
630
diff
changeset
|
31 "h" => \$opt_h, |
5189c60b9707
update gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
630
diff
changeset
|
32 "project=s" => \$opt_project, |
629
90309637c4c8
Getopt::Std to Getopt::Long
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
625
diff
changeset
|
33 ); |
255 | 34 |
35 my $dir = "."; | |
36 if ($opt_d) { | |
37 $dir = $opt_d; | |
38 if (! -d $dir) { | |
393 | 39 make_path $dir; |
255 | 40 } |
41 } | |
254 | 42 |
630
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
43 |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
44 |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
45 my %projects = ( |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
46 gears => { cotnext => "context" }, |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
47 xv6 => { context => "cbc_context" }, |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
48 ); |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
49 |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
50 |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
51 my $context_name = "context"; |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
52 if ($opt_project && exists $projects{$opt_project}) { |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
53 $context_name = $projects{$opt_project}->{context}; |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
54 } |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
55 |
677
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
56 |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
57 |
250 | 58 my %var; |
59 my %code; | |
60 my %dataGearVar; | |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
61 my %outputVar; # output var initializer |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
62 my %outputArgs; # continuation's output variables |
250 | 63 my %dataGear; |
64 my %dataGearName; | |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
65 my %generic; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
66 my %dataGearVarType; |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
67 my %codeGear; |
661
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
68 my %call_interfaces; |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
69 my $headerNameToInfo = createHeaderNameToInfo($FindBin::Bin); |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
70 my $searchCbCFromCodeGearNameWCurrentFrileName = createSearchCbCFromCodeGearNameWCurrentFrileName($FindBin::Bin); |
676 | 71 my %filename2EachCodeGearArgs; |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
72 my %stub; |
668 | 73 |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
74 my $implInterfaceInfo = {isImpl => undef, implementation => undef, interface => undef, parsedInterfaceInfo => undef, genConstructor => undef}; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
75 my $generateHaveOutputStub = { counter => undef, list => undef }; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
76 my $replaceCodeGearNames = {}; |
665 | 77 |
78 | |
79 # this for statement is main routine | |
80 for my $fn (@ARGV) { | |
81 next if ($fn !~ /\.cbc$/); | |
82 getDataGear($fn); | |
83 generateDataGear($fn); | |
84 } | |
85 | |
250 | 86 |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
87 # interface definision |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
88 # |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
89 # typedef struct Stack<Type, Impl>{ |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
90 # Type* stack; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
91 # Type* data; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
92 # Type* data1; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
93 # __code whenEmpty(...); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
94 # __code clear(Impl* stack,__code next(...)); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
95 # __code push(Impl* stack,Type* data, __code next(...)); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
96 # __code pop(Impl* stack, __code next(Type*, ...)); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
97 # __code pop2(Impl* stack, Type** data, Type** data1, __code next(Type**, Type**, ...)); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
98 # __code isEmpty(Impl* stack, __code next(...), __code whenEmpty(...)); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
99 # __code get(Impl* stack, Type** data, __code next(...)); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
100 # __code get2(Impl* stack,..., __code next(...)); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
101 # __code next(...); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
102 # } Stack; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
103 # |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
104 # calling example |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
105 # |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
106 # goto nodeStack->push((union Data*)node, stackTest3); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
107 # |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
108 # generated meta level code |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
109 # |
442
481fce540daf
Fix goto implement method of generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
424
diff
changeset
|
110 # Gearef(context, Stack)->stack = (union Data*)nodeStack; |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
111 # Gearef(context, Stack)->data = (union Data*)node; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
112 # Gearef(context, Stack)->next = C_stackTest3; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
113 # goto meta(context, nodeStack->push); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
114 |
194 | 115 sub getDataGear { |
116 my ($filename) = @_; | |
647
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
117 |
679
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
118 my ($codeGearName, $name, $inTypedef,$described_data_gear, $currentCodeGear, $codeGearInfo); |
194 | 119 open my $fd,"<",$filename or die("can't open $filename $!"); |
120 while (<$fd>) { | |
121 if (! $inTypedef) { | |
675 | 122 #this scope is usually parsing cbc file |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
123 if (/^typedef struct (\w+)\s*<(.*)>/) { |
194 | 124 $inTypedef = 1; |
125 $name = $1; | |
126 $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
|
127 $var{$name} = {}; |
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
255
diff
changeset
|
128 $code{$name} = {}; |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
129 $generic{$name} = \split(/,/,$2); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
130 } elsif (/^typedef struct (\w+)/) { |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
131 $inTypedef = 1; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
132 $name = $1; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
133 $dataGear{$name} = $_; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
134 $var{$name} = {}; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
135 $code{$name} = {}; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
136 $generic{$name} = []; |
677
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
137 } elsif (/^(\w+)(\*)+ create(\w+)\(/) { # this case implementation constructor |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
138 if (defined $implInterfaceInfo->{interface} ) { |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
139 die "duplicate interface $implInterfaceInfo->{interface}\n"; |
249 | 140 } |
677
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
141 my $interfaceName = $1; |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
142 $implInterfaceInfo->{isImpl} = 1; |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
143 $implInterfaceInfo->{interface} = $interfaceName; |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
144 $implInterfaceInfo->{implementation} = $3; |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
145 my $cbc_source_path = $searchCbCFromCodeGearNameWCurrentFrileName->($interfaceName, $filename); |
677
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
146 if ($cbc_source_path) { |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
147 # Probably not executed |
677
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
148 &getDataGear($cbc_source_path); |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
149 } |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
150 $implInterfaceInfo->{genConstructor} = 0; |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
151 } elsif(/^(.*)par goto (\w+)\((.*)\)/) { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
152 my $codeGearName = $2; |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
153 my $cbc_source_path = $searchCbCFromCodeGearNameWCurrentFrileName->($codeGearName, $filename); |
675 | 154 if ($cbc_source_path) { |
155 &getCodeGear($cbc_source_path); | |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
156 } |
595 | 157 } elsif(/^#interface "(.*)"/) { |
468
ac244346c85d
Change used interface syntax from #include to #interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
158 # use interface |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
159 my $interfaceHeader = $1; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
160 next if ($interfaceHeader =~ /context.h/); |
661
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
161 $interfaceHeader =~ m|(\w+)\.\w+$|; #remove filename extention |
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
162 my $interfaceName = $1; |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
163 includeInterface(\%call_interfaces, $filename, $interfaceName, $headerNameToInfo); |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
164 } elsif(/^#impl "(.*)"/) { |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
165 # use interface |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
166 my $interfaceHeader = $1; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
167 $interfaceHeader =~ m|(\w+)\.\w+$|; #remove filename extention |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
168 my $interfaceName = $1; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
169 includeInterface(\%call_interfaces, $filename, $interfaceName, $headerNameToInfo); |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
170 my $interfacePATH = $headerNameToInfo->{$interfaceName}->{path}; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
171 |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
172 my $implName = basename $filename; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
173 $implName =~ s/\.cbc$//; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
174 |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
175 $implInterfaceInfo->{isImpl} = 1; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
176 $implInterfaceInfo->{interface} = $interfaceName; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
177 $implInterfaceInfo->{implementation} = $implName; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
178 $implInterfaceInfo->{genConstructor} = 1; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
179 $implInterfaceInfo->{parsedInterfaceInfo} = Gears::Interface->separate_code_and_data_gear_after_parse($interfacePATH); |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
180 |
527
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
181 } elsif (/^\_\_code (\w+)\((.*)\)(.*)/) { |
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
182 my $codeGearName = $1; |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
183 my $args = $2; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
184 |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
185 if ($codeGearName =~ /_stub$/) { |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
186 $stub{$codeGearName}->{static} = 1; |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
187 $stub{$codeGearName}->{wrote} = 1; |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
188 $currentCodeGear = undef; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
189 next; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
190 } |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
191 |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
192 if ($implInterfaceInfo->{parsedInterfaceInfo}) { |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
193 if (exists_codegear_in_interface({codeGearName => $codeGearName, parsedInfo => $implInterfaceInfo->{parsedInterfaceInfo}})) { |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
194 my $replaceCodeGear = "${codeGearName}$implInterfaceInfo->{implementation}"; #${pop}SingleLinkedStack |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
195 $replaceCodeGearNames->{$codeGearName} = $replaceCodeGear; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
196 $codeGearName = $replaceCodeGear; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
197 } |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
198 } |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
199 |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
200 my $cbc_source_path = $searchCbCFromCodeGearNameWCurrentFrileName->($codeGearName, $filename); |
675 | 201 if ($cbc_source_path) { |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
202 &getCodeGear($cbc_source_path); |
527
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
203 } |
700
8416928992fc
impl collect_codegears_from_all_cbc_sources
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
699
diff
changeset
|
204 my $vname2type = Gears::Util->parseCodeGearDeclarationArg($args); |
679
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
205 for my $vname (keys %$vname2type) { |
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
206 $codeGearInfo->{$codeGearName}->{arg}->{$vname} = $vname2type->{$vname}; |
675 | 207 } |
677
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
208 $currentCodeGear = $codeGearName; |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
209 } elsif ((/^\s*(union|struct|const|enum)?\s*(\w+)(\*)\s+(\w+)\s+=/) && $currentCodeGear) { # collect local variables |
679
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
210 my $structType = $1; |
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
211 my $interfaceName = $2; |
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
212 my $instance = $4; |
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
213 $codeGearInfo->{$currentCodeGear}->{localVar}->{$instance} = $interfaceName; |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
214 } elsif (/^(.*)goto (\w+)\-\>(\w+)\((.*)\);/) { |
675 | 215 # handling goto statement |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
216 # determine the interface you are using, and in the case of a goto CodeGear with output, create a special stub flag |
675 | 217 my $prev = $1; |
679
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
218 my $instance = $2; |
675 | 219 my $method = $3; |
220 my $tmpArgs = $4; | |
679
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
221 my $typeName = $codeGearInfo->{$currentCodeGear}->{arg}->{$instance}; |
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
222 unless ($typeName) { |
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
223 #this case is not __code arguments. |
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
224 for my $localVar (keys %{$codeGearInfo->{$currentCodeGear}->{localVar}}) { |
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
225 if ($localVar eq $instance) { |
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
226 $typeName = $codeGearInfo->{$currentCodeGear}->{localVar}->{$localVar}; |
681 | 227 last; |
679
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
228 } |
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
229 } |
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
230 unless ($typeName){ |
693
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
231 die "[ERROR] not found $instance type $.: $_\n"; |
679
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
232 } |
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
233 } |
704
d05e327cbc50
removed trailing space in stub codegear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
700
diff
changeset
|
234 unless (exists $call_interfaces{$filename}->{$typeName}) { |
705
cf82fc3512dd
fix collect local variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
704
diff
changeset
|
235 warn "[AUTOINCLUDE] Forget #interface '$typeName' declaration in $filename"; |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
236 includeInterface(\%call_interfaces, $filename, $typeName, $headerNameToInfo); |
704
d05e327cbc50
removed trailing space in stub codegear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
700
diff
changeset
|
237 } |
d05e327cbc50
removed trailing space in stub codegear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
700
diff
changeset
|
238 |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
239 |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
240 if ($implInterfaceInfo->{parsedInterfaceInfo}) { |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
241 if (exists_codegear_in_interface({codeGearName => $tmpArgs, parsedInfo => $implInterfaceInfo->{parsedInterfaceInfo}})) { |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
242 my $replaceCodeGear = "${tmpArgs}$implInterfaceInfo->{implementation}"; #${pop}SingleLinkedStack |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
243 $tmpArgs = $replaceCodeGear; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
244 } |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
245 } |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
246 |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
247 my $nextOutPutArgs = findExistsOutputDataGear($typeName, $method); |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
248 my $outputStubElem = { modifyEnumCode => $currentCodeGear, createStubName => $tmpArgs }; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
249 |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
250 if ($nextOutPutArgs) { |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
251 my $tmpArgHash = {}; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
252 map { $tmpArgHash->{$_} = $typeName } @$nextOutPutArgs; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
253 |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
254 $outputStubElem->{args} = $tmpArgHash; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
255 |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
256 #We're assuming that $tmpArgs only contains the name of the next CodeGear. |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
257 #Eventually we need to parse the contents of the argument. (eg. @parsedArgs) |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
258 my @parsedArgs = split /,/ , $tmpArgs; # |
704
d05e327cbc50
removed trailing space in stub codegear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
700
diff
changeset
|
259 if (scalar(@parsedArgs) != 1) { |
d05e327cbc50
removed trailing space in stub codegear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
700
diff
changeset
|
260 warn '[WARN] TBD'; |
d05e327cbc50
removed trailing space in stub codegear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
700
diff
changeset
|
261 } |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
262 |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
263 $generateHaveOutputStub->{counter}->{$tmpArgs}++; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
264 $outputStubElem->{counter} = $generateHaveOutputStub->{counter}->{$tmpArgs}; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
265 $generateHaveOutputStub->{list}->{$currentCodeGear} = $outputStubElem; |
697 | 266 } |
679
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
267 } elsif (/^}$/) { |
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
268 $currentCodeGear = undef; |
226 | 269 } |
194 | 270 next; |
271 } | |
661
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
272 |
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
273 #this scope does parsing of header files |
249 | 274 # gather type name and type |
194 | 275 $dataGear{$name} .= $_; |
385 | 276 if (/^\s*(.*)\s+(\w+);$/ ) { |
280 | 277 my $ttype = $1; |
278 my $tname = $2; | |
670
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
279 if ($ttype =~ /^(union|struct|const|enum)\s*(\w+)/) { |
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
280 my $structType = $1; |
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
281 my $vname = $2; |
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
282 if ($structType ne 'const') { |
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
283 $ttype = $vname; |
598 | 284 } else { |
670
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
285 if ($structType =~ /(const|enum)/) { |
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
286 $ttype = "$structType $vname"; |
625 | 287 } |
598 | 288 } |
280 | 289 } |
598 | 290 $described_data_gear = 1; |
280 | 291 $var{$name}->{$tname} = $ttype; |
250 | 292 } |
595 | 293 if (/__code (\w+)/) { |
598 | 294 next if $described_data_gear; |
595 | 295 my $args = $'; |
700
8416928992fc
impl collect_codegears_from_all_cbc_sources
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
699
diff
changeset
|
296 my $tname2type = Gears::Util->parseCodeGearDeclarationArg($args); |
675 | 297 for my $tname (keys %$tname2type) { |
298 $var{$name}->{$tname} = $tname2type->{$tname}; | |
595 | 299 } |
300 } | |
194 | 301 if (/^}/) { |
302 $inTypedef = 0; | |
303 } | |
304 } | |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
305 |
679
c65f8f00ba6f
analyze the interface when goto using the interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
677
diff
changeset
|
306 $filename2EachCodeGearArgs{$filename} = $codeGearInfo; |
676 | 307 |
194 | 308 } |
309 | |
705
cf82fc3512dd
fix collect local variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
704
diff
changeset
|
310 sub includeInterface { |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
311 my ($call_interfaces, $filename, $interfaceName, $headerNameToInfo) = @_; |
705
cf82fc3512dd
fix collect local variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
704
diff
changeset
|
312 $call_interfaces->{$filename}->{$interfaceName} = 1; |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
313 my $interface_path = $headerNameToInfo->{$interfaceName}->{path}; |
705
cf82fc3512dd
fix collect local variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
704
diff
changeset
|
314 if ($interface_path) { |
cf82fc3512dd
fix collect local variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
704
diff
changeset
|
315 getDataGear($interface_path); |
cf82fc3512dd
fix collect local variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
704
diff
changeset
|
316 getCodeGear($interface_path); |
cf82fc3512dd
fix collect local variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
704
diff
changeset
|
317 } |
cf82fc3512dd
fix collect local variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
704
diff
changeset
|
318 } |
cf82fc3512dd
fix collect local variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
704
diff
changeset
|
319 |
675 | 320 |
385 | 321 sub getCodeGear { |
322 my ($filename) = @_; | |
323 open my $fd,"<",$filename or die("can't open $filename $!"); | |
324 my ($name,$impln); | |
325 while (<$fd>) { | |
633
8b295624ea4b
bug fix drop interface whitespace
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
631
diff
changeset
|
326 if (/^(\w+)\s*(\*)+ create(\w+)\(/) { |
385 | 327 $name = $1; |
328 $impln = $3; | |
633
8b295624ea4b
bug fix drop interface whitespace
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
631
diff
changeset
|
329 } elsif(/^typedef struct (\w+)\s*<.*>\s*{/) { |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
330 $name = $1; |
385 | 331 } |
332 if (defined $name) { | |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
333 if (/^\s*\_\_code (\w+)\((.*)\);/) { |
385 | 334 my $args = $2; |
335 my $method = $1; | |
336 $code{$name}->{$method} = []; | |
337 while($args) { | |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
338 # replace comma |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
339 $args =~ s/(^\s*,\s*)//; |
385 | 340 # continuation case |
341 if ($args =~ s/^(\s)*\_\_code\s+(\w+)\(([^)]*)\)//) { | |
342 my $next = $2; | |
343 my @args = split(/,/,$3); | |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
344 push(@{$code{$name}->{$method}},"\_\_code $next"); |
598 | 345 } elsif ($args =~ s/^(struct|union|const)?\s*(\w+)(\**)\s+(\w+)//) { |
385 | 346 my $structType = $1; |
347 my $typeName = $2; | |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
348 my $ptrType = $3; |
385 | 349 my $varName = $4; |
350 my $typeField = lcfirst($typeName); | |
670
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
351 if ($structType && ($structType =~ /const/)) { |
598 | 352 $typeName = "$structType $typeName"; |
353 } | |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
354 push(@{$code{$name}->{$method}},"$typeName$ptrType $varName"); |
385 | 355 } elsif ($args =~ s/(.*,)//) { |
356 } else { | |
357 last; | |
358 } | |
359 } | |
360 } | |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
361 } elsif (/^\_\_code (\w+)\((.*)\)(.*)/) { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
362 my $codeGearName = $1; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
363 my $args = $2; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
364 my $inputCount = 0; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
365 my $outputCount = 0; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
366 my $inputIncFlag = 1; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
367 while($args) { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
368 if ($args =~ s/(^\s*,\s*)//) { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
369 } |
404
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
370 if ($args =~ s/^(\s)*\_\_code\s+(\w+)\((.*?)\)//) { |
527
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
371 $codeGear{$codeGearName}->{"code"}->{$2} = "\_\_code"; |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
372 $inputIncFlag = 0; |
527
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
373 my @outputs = split(/,/,$3); |
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
374 for my $output (@outputs) { |
598 | 375 if ($output =~ /\s*(struct|union|const)?\s*(\w+)(\*)?+\s(\w+)/) { |
376 my $structType = $1; | |
527
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
377 my $type = $2; |
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
378 my $varName = $4; |
598 | 379 if ($structType =~ /const/) { |
380 $type = "$structType $type"; | |
381 } | |
527
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
382 $codeGear{$codeGearName}->{"var"}->{$varName} = "$type $outputCount"; |
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
383 $outputCount++; |
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
384 } |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
385 } |
598 | 386 } elsif ($args =~ s/^(struct|union|const)?\s*(\w+)(\*)?+\s(\w+)// && $inputIncFlag) { |
387 my $structType = $1; | |
527
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
388 my $type = $2; |
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
389 my $varName = $4; |
598 | 390 if ($structType =~ /const/) { |
391 $type = "$structType $type"; | |
392 } | |
527
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
393 $codeGear{$codeGearName}->{"var"}->{$varName} = "$type $inputCount"; |
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
394 $inputCount++; |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
395 } elsif ($args =~ s/(.*,)//) { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
396 } else { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
397 last; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
398 } |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
399 } |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
400 $codeGear{$codeGearName}->{"input"} = $inputCount; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
401 $codeGear{$codeGearName}->{"output"} = $outputCount; |
385 | 402 } |
403 } | |
404 } | |
405 | |
250 | 406 sub generateStub { |
251 | 407 my($fd,$prevCodeGearName,$dataGearName) = @_; |
630
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
408 print $fd "__code ", $prevCodeGearName ,"_stub(struct Context* $context_name) {\n"; |
251 | 409 print $fd $dataGearName; |
704
d05e327cbc50
removed trailing space in stub codegear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
700
diff
changeset
|
410 print $fd "\n}\n\n"; |
251 | 411 return 1; |
250 | 412 } |
413 | |
697 | 414 sub generateImplStubArgs { |
415 my ($codeGearName, $varName, $typeName, $ptrType, $output, $interfaceName, $isImpl) = @_; | |
416 return 0 unless $isImpl; | |
417 for my $ivar (keys %{$var{$interfaceName}}) { | |
418 # input data gear field | |
419 if ($varName eq $ivar) { | |
420 if ($typeName eq $var{$interfaceName}->{$ivar}) { | |
421 if ($output) { | |
422 $dataGearName{$codeGearName} .= "\t$typeName$ptrType* O_$varName = &Gearef($context_name, $interfaceName)->$varName;\n"; | |
423 $outputVar{$codeGearName} .= "\t$typeName$ptrType $varName __attribute__((unused)) = *O_$varName;\n"; | |
424 return 1; | |
425 } | |
426 $dataGearName{$codeGearName} .= "\t$typeName$ptrType $varName = Gearef($context_name, $interfaceName)->$varName;\n"; | |
427 return 1; | |
428 } | |
429 } | |
430 } | |
431 | |
432 # interface continuation | |
433 for my $cName (keys %{$code{$interfaceName}}) { | |
434 if ($varName eq $cName) { | |
435 # continuation field | |
436 $dataGearName{$codeGearName} .= "\tenum Code $varName = Gearef($context_name, $interfaceName)->$varName;\n"; | |
437 return 1; | |
438 } | |
439 } | |
440 } | |
441 | |
253 | 442 sub generateStubArgs { |
677
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
443 my($codeGearName, $varName, $typeName, $ptrType, $typeField, $implInterfaceInfo,$output) = @_; |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
444 |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
445 my $isImpl = $implInterfaceInfo->{isImpl}; |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
446 my $interfaceName = $implInterfaceInfo->{interface}; |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
447 my $implName = $implInterfaceInfo->{implementation}; |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
448 |
672 | 449 my $varname1 = $output ? "O_$varName" : $varName; |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
450 for my $n ( @{$dataGearVar{$codeGearName}} ) { |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
451 # we already have it |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
452 return 0 if ( $n eq $varname1); |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
453 } |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
454 push @{$dataGearVar{$codeGearName}}, $varname1; |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
455 push @{$dataGearVarType{$codeGearName}}, $typeName; |
697 | 456 |
677
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
457 if ($isImpl){ |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
458 if ($implName eq $typeName) { |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
459 # get implementation |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
460 $dataGearName{$codeGearName} .= "\t$typeName* $varName = ($typeName*)GearImpl($context_name, $interfaceName, $varName);\n"; |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
461 return 1; |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
462 } |
655
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
463 } |
670
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
464 |
697 | 465 return 1 if generateImplStubArgs($codeGearName, $varName, $typeName, $ptrType, $output, $interfaceName, $isImpl); |
655
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
466 |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
467 # par goto var |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
468 for my $var (keys %{$codeGear{$codeGearName}->{"var"}}) { |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
469 # input data gear field |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
470 if ($varName eq $var) { |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
471 my ($type, $count) = split(/\s/, $codeGear{$codeGearName}->{"var"}->{$var}); |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
472 if ($typeName eq $type) { |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
473 if ($output) { |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
474 $dataGearName{$codeGearName} .= "\t$typeName$ptrType* O_$varName = ($typeName $ptrType*)&${context_name}->data[${context_name}\->odg + $count];\n"; |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
475 $outputVar{$codeGearName} .= "\t$typeName$ptrType $varName = *O_$varName;\n"; |
527
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
476 return 1; |
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
477 } |
655
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
478 $dataGearName{$codeGearName} .= "\t$typeName$ptrType $varName = &${context_name}->data[${context_name}\->idg + $count]->$typeName;\n"; |
527
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
479 return 1; |
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
480 } |
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
481 } |
655
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
482 } |
527
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
483 |
655
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
484 # par goto continuation |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
485 for my $cName (keys %{$codeGear{$codeGearName}->{"code"}}) { |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
486 if ($varName eq $cName) { |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
487 # continuation field |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
488 $dataGearName{$codeGearName} .= "\tenum Code $varName = ${context_name}\->next;\n"; |
389 | 489 return 1; |
490 } | |
655
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
491 } |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
492 |
670
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
493 |
655
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
494 # par goto continuation |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
495 # global or local variable case |
677
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
496 if (($typeName eq "Code") && $isImpl) { |
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
497 $dataGearName{$codeGearName} .= "\tenum $typeName$ptrType $varName = Gearef(${context_name}, $interfaceName)->$varName;\n"; |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
498 return 1; |
253 | 499 } |
655
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
500 $dataGearName{$codeGearName} .= "\t$typeName$ptrType $varName = Gearef($context_name, $typeName);\n"; |
4846c5f8ccbf
tweak generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
653
diff
changeset
|
501 return 1; |
253 | 502 } |
503 | |
693
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
504 |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
505 |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
506 sub findExistsOutputDataGear { |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
507 my ($interfaceName, $method) = @_; |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
508 |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
509 my $interfacePATH = $headerNameToInfo->{$interfaceName}->{path}; |
693
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
510 unless ($interfacePATH) { |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
511 return undef; |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
512 } |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
513 |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
514 my $parsedInterface = Gears::Interface->separate_code_and_data_gear_after_parse($interfacePATH); |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
515 |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
516 unless ($parsedInterface) { |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
517 return undef; |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
518 } |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
519 |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
520 unless (exists $parsedInterface->{hasOutputArgs}->{$method}) { |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
521 return undef; |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
522 } |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
523 |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
524 my $vname2types = $parsedInterface->{hasOutputArgs}->{$method}; |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
525 |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
526 my @outputArgs = keys %$vname2types; |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
527 return \@outputArgs; |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
528 } |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
529 |
aeab4866ee36
defined separate_code_and_data_gear_after_parse test
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
681
diff
changeset
|
530 |
194 | 531 sub generateDataGear { |
647
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
532 my ($filename) = @_; |
249 | 533 open my $in,"<",$filename or die("can't open $filename $!"); |
254 | 534 |
535 my $fn; | |
536 if ($opt_o) { | |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
537 $fn = $opt_o; |
254 | 538 } else { |
539 my $fn1 = $filename; | |
540 $fn1 =~ s/\.cbc/.c/; | |
541 my $i = 1; | |
255 | 542 $fn = "$dir/$fn1"; |
254 | 543 while ( -f $fn) { |
255 | 544 $fn = "$dir/$fn1.$i"; |
254 | 545 $i++; |
546 } | |
250 | 547 } |
259
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
255
diff
changeset
|
548 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
|
549 if (! -d $1) { |
393 | 550 make_path $1; |
259
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
255
diff
changeset
|
551 } |
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
255
diff
changeset
|
552 } |
249 | 553 open my $fd,">",$fn or die("can't write $fn $!"); |
254 | 554 |
249 | 555 my $prevCodeGearName; |
250 | 556 my $inTypedef = 0; |
278 | 557 my $inStub = 0; |
546 | 558 my $hasParGoto = 0; |
418 | 559 my $inMain = 0 ; |
598 | 560 my $inCode = 0 ; |
251 | 561 my $codeGearName; |
444
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
562 my %localVarType; |
254 | 563 |
249 | 564 while (<$in>) { |
418 | 565 if (! $inTypedef && ! $inStub && ! $inMain) { |
633
8b295624ea4b
bug fix drop interface whitespace
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
631
diff
changeset
|
566 if (/^typedef struct (\w+)\s*\{/) { |
249 | 567 $inTypedef = 1; |
454 | 568 } elsif (/^int main\((.*)\) \{/) { |
418 | 569 $inMain = 1; |
468
ac244346c85d
Change used interface syntax from #include to #interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
570 } elsif(/^#interface "(.*)"/) { |
462
8d7e5d48cad3
Running CPU examples
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
571 my $interfaceHeader = $1; |
468
ac244346c85d
Change used interface syntax from #include to #interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
572 # #interface not write |
462
8d7e5d48cad3
Running CPU examples
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
573 next unless ($interfaceHeader =~ /context.h/); |
699
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
574 } elsif (/^#include "(.*).h"$/) { |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
575 my $headerName = $1; |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
576 if ($headerName =~ m|/?context$|) { |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
577 print $fd $_; |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
578 next; |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
579 } |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
580 |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
581 # This process assumes that there are no header files of the same name |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
582 my $path = $headerNameToInfo->{$headerName}->{path}; |
699
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
583 unless ($path) { |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
584 print $fd $_; |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
585 next; |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
586 } |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
587 |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
588 print $fd '#include "' .$path . '"'; |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
589 print $fd "\n"; |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
590 next; |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
591 |
253 | 592 } elsif (/^\_\_code (\w+)\((.*)\)(.*)/) { |
598 | 593 $inCode = 1; |
670
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
594 %localVarType = (); |
251 | 595 $codeGearName = $1; |
253 | 596 my $args = $2; |
597 my $tail = $3; | |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
598 |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
599 #replace Code Gear Name to Implemenatation |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
600 if (exists $replaceCodeGearNames->{$codeGearName}) { |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
601 $codeGearName = $replaceCodeGearNames->{$codeGearName}; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
602 } |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
603 |
250 | 604 if ($codeGearName =~ /_stub$/) { |
262 | 605 # don't touch already existing stub |
278 | 606 $inStub = 1; |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
607 $stub{$codeGearName}->{static} = 1; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
608 $stub{$codeGearName}->{wrote} = 1; |
250 | 609 print $fd $_; |
610 next; | |
611 } | |
249 | 612 if (defined $prevCodeGearName) { |
262 | 613 # stub is generated just before next CodeGear |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
614 if (defined $stub{$prevCodeGearName."_stub"}->{wrote}) { |
250 | 615 undef $prevCodeGearName; |
278 | 616 } else { |
617 &generateStub($fd,$prevCodeGearName,$dataGearName{$prevCodeGearName}); | |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
618 $stub{$prevCodeGearName."_stub"}->{wrote} = 1; |
250 | 619 } |
249 | 620 } |
262 | 621 # analyzing CodeGear argument |
622 # these arguments are extract from current context's arugment DataGear Interface | |
623 # and passed to the CodeGear | |
624 # struct Implementaion needs special handling | |
625 # __code next(...) ---> enum Code next | |
253 | 626 $prevCodeGearName = $codeGearName; |
627 $dataGearVar{$codeGearName} = []; | |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
628 $outputVar{$codeGearName} = ""; |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
629 $outputArgs{$codeGearName} = {}; |
630
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
630 my $newArgs = "struct Context *${context_name},"; |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
631 if ($args=~/^struct Context\s*\*\s*${context_name}/) { |
305 | 632 $newArgs = ""; |
633 } | |
521
393e1d2d06f2
fix about no argument code gear of generate_stub.pl
mir3636
parents:
509
diff
changeset
|
634 if (!$args){ |
630
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
635 $newArgs = "struct Context *${context_name}"; |
521
393e1d2d06f2
fix about no argument code gear of generate_stub.pl
mir3636
parents:
509
diff
changeset
|
636 } |
253 | 637 while($args) { |
638 if ($args =~ s/(^\s*,\s*)//) { | |
639 $newArgs .= $1; | |
640 } | |
262 | 641 # continuation case |
280 | 642 if ($args =~ s/^(\s)*\_\_code\s+(\w+)\(([^)]*)\)//) { |
643 my $next = $2; | |
644 my @args = split(/,/,$3); | |
677
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
645 if (generateStubArgs($codeGearName, $next, "Code", "", $next, $implInterfaceInfo,0) ) { |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
646 $newArgs .= "enum Code $next"; |
258 | 647 } |
262 | 648 # analyze continuation arguments |
649 # output arguments are defined in the Interface take the pointer of these | |
650 # output arguments are put into the Interface DataGear just before the goto | |
253 | 651 for my $arg (@args) { |
652 $arg =~ s/^\s*//; | |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
653 last if ($arg =~ /\.\.\./); |
625 | 654 $arg =~ s/^(struct|union|const|enum)?\s*(\w+)(\**)\s(\w+)//; |
253 | 655 my $structType = $1; |
656 my $typeName = $2; | |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
657 my $ptrType = $3; |
253 | 658 my $varName = $4; |
625 | 659 if ($structType =~ /(const|enum)/) { |
598 | 660 $typeName = "$structType $typeName"; |
661 } | |
253 | 662 my $typeField = lcfirst($typeName); |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
663 push(@{$outputArgs{$codeGearName}->{$next}}, $varName); |
677
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
664 if (generateStubArgs($codeGearName, $varName, $typeName, $ptrType, $typeField, $implInterfaceInfo,1)) { |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
665 $newArgs .= ",$structType $typeName **O_$varName"; |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
666 } |
253 | 667 } |
625 | 668 } elsif ($args =~ s/^(struct|union|const|enum)?\s*(\w+)(\**)\s(\w+)//) { |
253 | 669 my $structType = $1; |
670 my $typeName = $2; | |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
671 my $ptrType = $3; |
253 | 672 my $varName = $4; |
598 | 673 $newArgs .= $&; # assuming no duplicate |
670
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
674 if ($structType && ($structType =~ /(const|enum)/)) { |
598 | 675 $typeName = "$structType $typeName"; |
676 } | |
253 | 677 my $typeField = lcfirst($typeName); |
677
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
678 generateStubArgs($codeGearName, $varName, $typeName, $ptrType, $typeField, $implInterfaceInfo,0); |
255 | 679 } elsif ($args =~ s/(.*,)//) { |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
680 $newArgs .= $1; |
255 | 681 } else { |
682 $newArgs .= $args; | |
683 last; | |
253 | 684 } |
685 } | |
262 | 686 # generate goto statement from stub to the CodeGear in the buffer |
630
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
687 $dataGearName{$codeGearName} .= "\tgoto $codeGearName(${context_name}"; |
253 | 688 for my $arg ( @{$dataGearVar{$codeGearName}}) { |
689 $dataGearName{$codeGearName} .= ", $arg"; | |
690 } | |
691 $dataGearName{$codeGearName} .= ");"; | |
262 | 692 # generate CodeGear header with new arguments |
253 | 693 print $fd "__code $codeGearName($newArgs)$tail\n"; |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
694 if ($outputVar{$codeGearName} ne "") { |
324 | 695 # output data var can be use before write |
696 # it should be initialze by gearef | |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
697 print $fd $outputVar{$codeGearName}; |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
698 } |
250 | 699 next; |
598 | 700 } elsif (! $inCode) { |
670
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
701 s/new\s+(\w+)\(\)/\&ALLOCATE(${context_name}, $1)->$1/g; # replacing new |
598 | 702 print $fd $_; |
703 next; | |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
704 } elsif (/^(.*)goto (\w+)\-\>(\w+)\((.*)\);/) { |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
705 # handling goto statement |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
706 # convert it to the meta call form with two arugments, that is context and enum Code |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
707 my $prev = $1; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
708 my $next = $2; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
709 my $method = $3; |
529
e5e3025f503a
Generate twice stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
528
diff
changeset
|
710 my $tmpArgs = $4; |
698 | 711 my $indent = get_indent_len($prev); |
708
4e80cdea307d
not add C_ to a goto predefined variable
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
706
diff
changeset
|
712 my $currentCodeGearInfo = $filename2EachCodeGearArgs{$filename}->{$codeGearName}; |
548 | 713 #$tmpArgs =~ s/\(.*\)/\(\)/; |
529
e5e3025f503a
Generate twice stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
528
diff
changeset
|
714 my @args = split(/,/,$tmpArgs); |
598 | 715 if (! defined $dataGearVarType{$codeGearName}) { |
716 print $fd $_ ; | |
717 next ; | |
718 } | |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
719 my @types = @{$dataGearVarType{$codeGearName}}; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
720 my $ntype; |
415 | 721 my $ftype; |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
722 for my $v (@{$dataGearVar{$codeGearName}}) { |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
723 my $t = shift @types; |
528
82ff74c2f162
Delete stub for bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
527
diff
changeset
|
724 if ($v eq $next || $v eq "O_$next") { |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
725 $ntype = $t; |
415 | 726 $ftype = lcfirst($ntype); |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
727 } |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
728 } |
444
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
729 if (!defined $ntype) { |
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
730 $ntype = $localVarType{$next}; |
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
731 $ftype = lcfirst($ntype); |
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
732 } |
698 | 733 print $fd "${indent}Gearef(${context_name}, $ntype)->$ftype = (union Data*) $next;\n"; |
415 | 734 # Put interface argument |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
735 my $prot = $code{$ntype}->{$method}; |
385 | 736 my $i = 1; |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
737 for my $arg (@args) { |
415 | 738 my $pType; |
739 my $pName; | |
385 | 740 my $p = @$prot[$i]; |
457
2b36a1878c6f
Refactor TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
447
diff
changeset
|
741 next if ($p eq $arg); |
387 | 742 $p =~ s/^(.*)\s(\w+)//; |
415 | 743 $pType = $1; |
744 $pName = $2; | |
387 | 745 $arg =~ s/^(\s)*(\w+)/$2/; |
746 if ($pType =~ s/\_\_code$//) { | |
444
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
747 if ($arg =~ /(\w+)\(.*\)/) { |
698 | 748 print $fd "${indent}Gearef(${context_name}, $ntype)->$pName = $1;\n"; |
444
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
749 } else { |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
750 my $hasGotoArgOrLocalVar = undef; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
751 my $outputStubElem = $generateHaveOutputStub->{list}->{$codeGearName}; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
752 |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
753 if ($implInterfaceInfo->{parsedInterfaceInfo}) { |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
754 if (exists_codegear_in_interface({codeGearName => $arg, parsedInfo => $implInterfaceInfo->{parsedInterfaceInfo}})) { |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
755 my $replaceCodeGear = "${arg}$implInterfaceInfo->{implementation}"; #${pop}SingleLinkedStack |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
756 $arg = $replaceCodeGear; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
757 } |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
758 } |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
759 |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
760 if ($outputStubElem && !$stub{$outputStubElem->{createStubName}."_stub"}->{static}) { |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
761 my $pick_next = "$outputStubElem->{createStubName}_$outputStubElem->{counter}"; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
762 print $fd "${indent}Gearef(${context_name}, $ntype)->$pName = C_$pick_next;\n"; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
763 $i++; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
764 next; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
765 } |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
766 |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
767 # find __code of argument or local variable |
708
4e80cdea307d
not add C_ to a goto predefined variable
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
706
diff
changeset
|
768 for my $localVarType (qw/arg localVar/) { |
4e80cdea307d
not add C_ to a goto predefined variable
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
706
diff
changeset
|
769 my $foundVarType = $currentCodeGearInfo->{$localVarType}->{$arg}; |
4e80cdea307d
not add C_ to a goto predefined variable
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
706
diff
changeset
|
770 if ($foundVarType && $foundVarType eq '__code') { |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
771 $hasGotoArgOrLocalVar = 1; |
708
4e80cdea307d
not add C_ to a goto predefined variable
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
706
diff
changeset
|
772 } |
4e80cdea307d
not add C_ to a goto predefined variable
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
706
diff
changeset
|
773 } |
4e80cdea307d
not add C_ to a goto predefined variable
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
706
diff
changeset
|
774 |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
775 # inteface case |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
776 |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
777 if ($arg =~ /->/) { |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
778 print $fd "${indent}Gearef(${context_name}, $ntype)->$pName = $arg;\n"; #Gearef->()->next = bar->baz; |
708
4e80cdea307d
not add C_ to a goto predefined variable
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
706
diff
changeset
|
779 $i++; |
4e80cdea307d
not add C_ to a goto predefined variable
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
706
diff
changeset
|
780 next; |
4e80cdea307d
not add C_ to a goto predefined variable
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
706
diff
changeset
|
781 } |
4e80cdea307d
not add C_ to a goto predefined variable
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
706
diff
changeset
|
782 |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
783 if ($hasGotoArgOrLocalVar) { |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
784 print $fd "${indent}Gearef(${context_name}, $ntype)->$pName = $arg;\n"; #Gearef->()->next = next; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
785 $i++; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
786 next; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
787 } |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
788 |
698 | 789 print $fd "${indent}Gearef(${context_name}, $ntype)->$pName = C_$arg;\n"; |
708
4e80cdea307d
not add C_ to a goto predefined variable
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
706
diff
changeset
|
790 $i++; |
4e80cdea307d
not add C_ to a goto predefined variable
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
706
diff
changeset
|
791 next; |
444
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
792 } |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
793 } elsif ($pType =~ /Data\**$/){ |
698 | 794 print $fd "${indent}Gearef(${context_name}, $ntype)->$pName = (union $pType) $arg;\n"; |
387 | 795 } else { |
698 | 796 print $fd "${indent}Gearef(${context_name}, $ntype)->$pName = $arg;\n"; |
387 | 797 } |
385 | 798 $i++; |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
799 } |
641
b486bf9d1280
update generate_*.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
633
diff
changeset
|
800 print $fd "${prev}goto meta(${context_name}, $next->$method);\n"; |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
801 next; |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
802 } elsif(/^(.*)par goto (\w+)\((.*)\);/) { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
803 # handling par goto statement |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
804 # convert it to the parallel |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
805 my $prev = $1; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
806 my $codeGearName = $2; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
807 my $args = $3; |
401
408b4aab7610
Supported par goto iterate statement for perl script
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
808 my $inputCount = $codeGear{$codeGearName}->{'input'}; |
408b4aab7610
Supported par goto iterate statement for perl script
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
809 my $outputCount = $codeGear{$codeGearName}->{'output'}; |
403
83c9aeb1fe3e
Generate MultiDimIterator by perl script
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
810 my @iterateCounts; |
401
408b4aab7610
Supported par goto iterate statement for perl script
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
811 # parse examples 'par goto(.., iterate(10), exit);' |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
812 if ($args =~ /iterate\((.*)?\),/) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
813 @iterateCounts = split(/,/,$1);; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
814 $inputCount--; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
815 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
816 # replace iterate keyword |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
817 $args =~ s/iterate\((.*)?\),//; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
818 my @dataGears = split(/,\s*/, $args); |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
819 my $nextCodeGear = pop(@dataGears); |
546 | 820 if (! $hasParGoto) { |
821 $hasParGoto = 1; | |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
822 print $fd "${prev}struct Element* element;\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
823 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
824 my $initTask = << "EOFEOF"; |
630
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
825 ${prev}${context_name}\->task = NEW(struct Context); |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
826 ${prev}initContext(${context_name}\->task); |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
827 ${prev}${context_name}\->task->next = C_$codeGearName; |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
828 ${prev}${context_name}\->task->idgCount = $inputCount; |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
829 ${prev}${context_name}\->task->idg = ${context_name}\->task->dataNum; |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
830 ${prev}${context_name}\->task->maxIdg = ${context_name}\->task->idg + $inputCount; |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
831 ${prev}${context_name}\->task->odg = ${context_name}\->task->maxIdg; |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
832 ${prev}${context_name}\->task->maxOdg = ${context_name}\->task->odg + $outputCount; |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
833 EOFEOF |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
834 print $fd $initTask; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
835 if (@iterateCounts) { |
630
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
836 print $fd "${prev}${context_name}\->task->iterate = 0;\n"; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
837 my $len = @iterateCounts; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
838 if ($len == 1) { |
630
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
839 print $fd "${prev}${context_name}\->task->iterator = createMultiDimIterator(${context_name}, $iterateCounts[0], 1, 1);\n"; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
840 } elsif ($len == 2) { |
630
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
841 print $fd "${prev}${context_name}\->task->iterator = createMultiDimIterator(${context_name}, $iterateCounts[0], $iterateCounts[1], 1);\n"; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
842 } elsif ($len == 3) { |
630
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
843 print $fd "${prev}${context_name}\->task->iterator = createMultiDimIterator(${context_name}, $iterateCounts[0], $iterateCounts[1], $iterateCounts[2]);\n"; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
844 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
845 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
846 for my $dataGear (@dataGears) { |
630
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
847 print $fd "${prev}GET_META($dataGear)->wait = createSynchronizedQueue(${context_name});\n"; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
848 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
849 for my $i (0..$inputCount-1) { |
670
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
850 print $fd "${prev}${context_name}\->task->data[${context_name}\->task->idg+$i] = (union Data*)$dataGears[$i];\n"; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
851 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
852 for my $i (0..$outputCount-1) { |
670
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
853 print $fd "${prev}${context_name}\->task->data[${context_name}\->task->odg+$i] = (union Data*)$dataGears[$inputCount+$i];\n"; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
854 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
855 my $putTask = << "EOFEOF"; |
630
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
856 ${prev}element = &ALLOCATE(${context_name}, Element)->Element; |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
857 ${prev}element->data = (union Data*)${context_name}\->task; |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
858 ${prev}element->next = ${context_name}\->taskList; |
0baef27a18f4
common perl scripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
629
diff
changeset
|
859 ${prev}${context_name}\->taskList = element; |
398
fc4fcd441700
Fix spanwTasks
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
397
diff
changeset
|
860 EOFEOF |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
861 print $fd $putTask; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
862 next; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
863 } elsif (/^(.*)goto (\w+)\((.*)\);/) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
864 # handling goto statement |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
865 # convert it to the meta call form with two arugments, that is context and enum Code |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
866 my $prev = $1; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
867 my $next = $2; |
527
929aa06a12f9
Generate par goto code gear stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
521
diff
changeset
|
868 my @args = split(/,/, $3); |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
869 my $v = 0; |
647
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
870 my $arg_context = $context_name; |
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
871 if ($prev =~ /kernel/) { |
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
872 $prev = ""; |
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
873 $arg_context = "kernel"; |
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
874 } |
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
875 |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
876 for my $n ( @{$dataGearVar{$codeGearName}} ) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
877 # continuation arguments |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
878 $v = 1 if ( $n eq $next); |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
879 } |
677
47910f7c731e
remove some global variables
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
676
diff
changeset
|
880 if ($v || ($implInterfaceInfo->{isImpl} && defined $code{$implInterfaceInfo->{interface}}->{$next})) { |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
881 # write continuation's arguments into the interface arguments |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
882 # we may need a commit for a shared DataGear |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
883 for my $arg ( @{$outputArgs{$codeGearName}->{$next}} ) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
884 my $v = shift(@args); |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
885 print $fd "\t*O_$arg = $v;\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
886 } |
546 | 887 if ($hasParGoto) { |
647
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
888 print $fd "${prev}Gearef(${arg_context}, TaskManager)->taskList = ${arg_context}->taskList;\n"; |
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
889 print $fd "${prev}Gearef(${arg_context}, TaskManager)->next1 = C_$next;\n"; |
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
890 print $fd "${prev}goto meta(${arg_context}, C_$next);\n"; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
891 } else { |
647
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
892 print $fd "${prev}goto meta(${arg_context}, $next);\n"; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
893 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
894 next; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
895 } |
546 | 896 if ($hasParGoto) { |
647
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
897 print $fd "${prev}Gearef(${arg_context}, TaskManager)->taskList = ${arg_context}\->taskList;\n"; |
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
898 print $fd "${prev}Gearef(${arg_context}, TaskManager)->next1 = C_$next;\n"; |
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
899 print $fd "${prev}goto parGotoMeta(${arg_context}, C_$next);\n"; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
900 next; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
901 } elsif ($next eq "meta") { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
902 print $fd $_; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
903 next; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
904 } else { |
647
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
905 print $fd "${prev}goto meta(${arg_context}, C_$next);\n"; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
906 next; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
907 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
908 } elsif(/^.*(struct|union)?\s(\w+)\*\s(\w+)\s?[=;]/) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
909 my $type = $2; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
910 my $varName = $3; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
911 $localVarType{$varName} = $type; |
670
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
912 s/new\s+(\w+)\(\)/\&ALLOCATE(${context_name}, $1)->$1/g; # replacing new |
462
8d7e5d48cad3
Running CPU examples
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
913 } elsif(/^}/) { |
546 | 914 $hasParGoto = 0; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
915 } else { |
670
f8b98e469256
use warnings at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
669
diff
changeset
|
916 s/new\s+(\w+)\(\)/\&ALLOCATE(${context_name}, $1)->$1/g; # replacing new |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
917 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
918 # gather type name and type |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
919 } elsif ($inMain) { |
631
5189c60b9707
update gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
630
diff
changeset
|
920 if (/^(.*)goto start_code\(main_${context_name}\);/) { |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
921 print $fd $_; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
922 next; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
923 } elsif (/^(.*)goto (\w+)\((.*)\);/) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
924 my $prev = $1; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
925 my $next = $2; |
631
5189c60b9707
update gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
630
diff
changeset
|
926 print $fd "${prev}struct Context* main_${context_name} = NEW(struct Context);\n"; |
5189c60b9707
update gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
630
diff
changeset
|
927 print $fd "${prev}initContext(main_${context_name});\n"; |
5189c60b9707
update gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
630
diff
changeset
|
928 print $fd "${prev}main_${context_name}->next = C_$next;\n"; |
5189c60b9707
update gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
630
diff
changeset
|
929 print $fd "${prev}goto start_code(main_${context_name});\n"; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
930 next; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
931 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
932 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
933 if (/^}/) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
934 $inStub = 0; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
935 $inTypedef = 0; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
936 $inMain = 0; |
598 | 937 $inCode = 0; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
938 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
939 print $fd $_; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
940 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
941 if (defined $prevCodeGearName) { |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
942 if (!defined $stub{$prevCodeGearName."_stub"}->{wrote}) { |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
943 $stub{$prevCodeGearName."_stub"} = &generateStub($fd,$prevCodeGearName,$dataGearName{$codeGearName}); |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
944 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
945 } |
697 | 946 |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
947 |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
948 |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
949 #Create a stub when the output is a different interface |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
950 for my $modifyEnumCodeCodeGear (keys %{$generateHaveOutputStub->{list}}) { |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
951 my $outputStubElem = $generateHaveOutputStub->{list}->{$modifyEnumCodeCodeGear}; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
952 my $targetStubName = $outputStubElem->{createStubName}; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
953 my $createStubName = "$outputStubElem->{createStubName}_$outputStubElem->{counter}"; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
954 my $replaceArgs = $outputStubElem->{args}; |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
955 my $replaceStubContents = $dataGearName{$targetStubName}; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
956 |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
957 #If the stub was handwritten, skip |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
958 if ($stub{"${targetStubName}_stub"}->{static}) { |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
959 next; |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
960 } |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
961 |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
962 for my $arg (keys %$replaceArgs) { |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
963 my $interface = $replaceArgs->{$arg}; |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
964 $replaceStubContents =~ s/,(.*)\)->$arg/, $interface)->$arg/; |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
965 } |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
966 |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
967 generateStub($fd,$createStubName,$replaceStubContents); |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
968 } |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
969 |
194 | 970 } |
971 | |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
972 sub createHeaderNameToInfo { |
663 | 973 my $search_root = shift; |
974 my $files = Gears::Util->find_headers_from_path($search_root); | |
661
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
975 my $interface_name2headerpath = {}; |
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
976 |
699
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
977 #This process assumes that there are no header files of the same name |
661
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
978 for my $file (@{$files}) { |
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
979 if ($file =~ m|/(\w+)\.\w+$|) { |
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
980 my $file_name = $1; |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
981 my $isInterface = Gears::Interface->isThisFileInterface($file); |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
982 $interface_name2headerpath->{$file_name} = { path => $file, isInterface => $isInterface }; |
661
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
983 } |
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
984 } |
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
985 |
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
986 return $interface_name2headerpath; |
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
987 } |
b6a3e1638f3a
Search headerfile first at generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
988 |
663 | 989 sub create_cbc_name_to_source_path { |
668 | 990 # create this structure |
991 # | |
992 # { | |
993 # SemaphoreImpl.cbc [ | |
994 # [0] "/Users/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/SemaphoreImpl.cbc", | |
995 # [1] "/Users/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/examples/boundedBuffer/SemaphoreImpl.cbc" | |
996 # ], | |
997 # SingleLinkedQueue.cbc [ | |
998 # [0] "/Users/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/SingleLinkedQueue.cbc" | |
999 # ], | |
1000 # } | |
663 | 1001 my $search_root = shift; |
1002 my $files = Gears::Util->find_cbc_sources_from_path($search_root); | |
647
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
1003 |
663 | 1004 my $cbc_name2_source_path = {}; |
1005 for my $file (@{$files}) { | |
1006 my $cbc_name = basename $file; | |
1007 $cbc_name =~ s/\.cbc//; | |
1008 push(@{$cbc_name2_source_path->{$cbc_name}},$file); | |
1009 } | |
1010 return $cbc_name2_source_path; | |
1011 } | |
647
dac9cc4dd52d
bump generate_stub.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
646
diff
changeset
|
1012 |
709
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
1013 sub createSearchCbCFromCodeGearNameWCurrentFrileName { |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
1014 #Find the cbc file that contains CodeGear. |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
1015 #If there are more than one cbc file, the one whose namespace is the same as the filename has priority. |
ed7183a46dca
create a stub when the output is a different interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
1016 |
668 | 1017 my $search_root = shift; |
1018 my $cbc_name2_source_path = create_cbc_name_to_source_path($search_root); | |
1019 | |
1020 # return sub is create clojure | |
1021 return sub { | |
1022 my ($codeGearName, $filename) = @_; | |
672 | 1023 my $cbc_files = $cbc_name2_source_path->{$codeGearName} // []; |
668 | 1024 |
672 | 1025 if (scalar(@{$cbc_files}) == 0) { # Not Found |
668 | 1026 return 0; #false case |
1027 } | |
1028 | |
672 | 1029 if (scalar(@{$cbc_files}) == 1) { # this case $codeGearName.cbc is single (SingleLinkedQueue.cbc) |
1030 return $cbc_files->[0]; # return "/Users/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/SingleLinkedQueue.cbc" | |
668 | 1031 } |
1032 | |
669
e8800c60811a
fix search cbc file
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
668
diff
changeset
|
1033 my $cbc_dir_name = dirname $filename; |
e8800c60811a
fix search cbc file
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
668
diff
changeset
|
1034 |
672 | 1035 for my $cbc_file (@{$cbc_files}) { |
669
e8800c60811a
fix search cbc file
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
668
diff
changeset
|
1036 if ($cbc_file =~ /$cbc_dir_name/) { |
e8800c60811a
fix search cbc file
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
668
diff
changeset
|
1037 return $cbc_file; |
e8800c60811a
fix search cbc file
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
668
diff
changeset
|
1038 } |
e8800c60811a
fix search cbc file
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
668
diff
changeset
|
1039 } |
e8800c60811a
fix search cbc file
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
668
diff
changeset
|
1040 |
e8800c60811a
fix search cbc file
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
668
diff
changeset
|
1041 return 0; # Not found |
668 | 1042 } |
1043 } | |
698 | 1044 |
1045 sub get_indent_len { | |
1046 my $prev = shift; | |
699
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
1047 if ($prev =~ /^(\s+).*$/) { |
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
1048 return $1; |
698 | 1049 } |
699
4d99aad53969
replace include at generate_stub
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
698
diff
changeset
|
1050 return ""; |
698 | 1051 } |
1052 | |
714
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
1053 sub exists_codegear_in_interface { |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
1054 my $arg = shift; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
1055 |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
1056 my $codeGearName = $arg->{codeGearName}; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
1057 my $parsedInterfaceInfo = $arg->{parsedInfo}; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
1058 my @res = grep { $_->{name} eq $codeGearName } @{$parsedInterfaceInfo->{codes}}; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
1059 return @res; |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
1060 } |
d5bd1c640db0
impl name space at gears
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
709
diff
changeset
|
1061 |