annotate src/gearsTools/generate_context.pl @ 357:e194c940c664

fix Getopt
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Mon, 15 Jun 2020 18:41:01 +0900
parents 045299ad7e97
children d2389a757323
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #!/usr/bin/perl
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
3 use Getopt::Long;
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 use strict;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 # generrate Gears OS context heaader and initializer from CbC sources
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 # CodeGear
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 # get stub information from # *.c
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
12 # __code taskManager_stub(struct Context* context) {
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 #
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 # generate CodeGear indexn in context.h
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 # C_taskManager,
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 #
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 # generate CodeGear stub reference in context.h
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 # extern __code taskManager_stub(struct Context*);
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 #
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 # generate CodeGear stub reference in $name-context.h for each module
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
21 # context->code[C_taskManager] = taskManager_stub;
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 # DataGear
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 # get DataGear information from context.h
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 # struct Worker {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 # int id;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 # struct Context* contexts;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 # enum Code execute;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 # enum Code taskSend;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 # enum Code taskRecive;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 # enum Code shutdown;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 # struct Queue* tasks;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 # } Worker;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 #
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 # generate typedefs and DataGear index in context.h
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 # typedef struct Worker Worker;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 # D_Worker,
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 #
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 # generate DataGear allocator in context.h
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 # ALLOC_DATA(context, Worker);
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 #
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 my $ddir = "c";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
46 our($opt_o,$opt_d,$opt_h,$opt_w, $opt_project);
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
47 GetOptions(
357
e194c940c664 fix Getopt
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
48 "o=s" => \$opt_o,
e194c940c664 fix Getopt
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
49 "d=s" => \$opt_d,
e194c940c664 fix Getopt
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
50 "h" => \$opt_h,
e194c940c664 fix Getopt
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
51 "w" => \$opt_w,
e194c940c664 fix Getopt
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
52 "project=s" => \$opt_project,
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
53 );
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
54
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 my $name = $opt_o?$opt_o:"gears";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 if ($opt_d) {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 $ddir = $opt_d;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 if ( ! -d $ddir) {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 mkdir $ddir;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 if ($opt_h) {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 print "$0 [-d distdir] [-h]\n";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 exit;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
71 my %projects = (
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
72 gears => { name => "gears", cotnext => "context" , template => "Gears::Context::Template"},
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
73 xv6 => { name => "xv6" , context => "cbc_context" , template => "Gears::Context::Template::XV6"},
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
74 );
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
75
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
76
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
77 my $context_name = "context";
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
78
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
79 my $project = $projects{gears};
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
80
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
81 if ($opt_project && exists $projects{$opt_project}) {
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
82 $context_name = $projects{$opt_project}->{context};
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
83 }
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
84
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
85
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
86
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 my %codeGear;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 my %dataGear;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 my %constructor;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90
111
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
91 {
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
92 use FindBin;
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
93 use lib "$FindBin::Bin/lib";
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
94
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
95 use File::Spec;
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
96 use Cwd 'getcwd';
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
97
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
98 use Gears::Context;
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
99 use Getopt::Std;
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
100
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
101 my $output = $opt_w ? "context.h" : "stdout";
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
102
180
f9df567f7f2d tweak_gen_context.pl
anatofuz
parents: 111
diff changeset
103 use Data::Dumper;
111
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
104 my @cbc_files;
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
105 map { push(@cbc_files,File::Spec->rel2abs($_)); } @ARGV;
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
106 my $gears = Gears::Context->new(compile_sources => \@cbc_files, find_root => "$FindBin::Bin/../", output => $output, template => $project->{template});
233
49a70efcbd3a fix_arguments...
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
107 my $data_gears = $gears->extraction_dg_compile_sources($gears->{compile_sources});
180
f9df567f7f2d tweak_gen_context.pl
anatofuz
parents: 111
diff changeset
108 my $g = $gears->set_data_gear_header_path(keys %{$data_gears->{impl}},keys %{$data_gears->{interfaces}});
111
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
109
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
110 my $dg2path = $gears->update_dg_each_header_path($data_gears,$g);
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
111 my $tree = $gears->createImplTree_from_header($dg2path);
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
112 $gears->tree2create_context_h($tree);
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
113 }
239bd73abac6 add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 53
diff changeset
114
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 # gather module Information for code table initialization
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 for (@ARGV) {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 next if (/context.c/);
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 &getStubInfo($_);
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
120
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 my (%mCodeGear) = (%codeGear);
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 # anyway we gather all Gears Information
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 while (<*.c test/*.c>) {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 next if (/context.c/);
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 &getStubInfo($_);
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
128
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 &generateContext();
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
130
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 sub getStubInfo {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 my ($filename) = @_;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 open my $fd,"<",$filename or die("can't open $filename $!");
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 while (<$fd>) {
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
135 if (/^__code (\w+)_stub\(struct *Context *\* *${context_name}\)/) {
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 $codeGear{$1} = $filename;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 } elsif (/^(\w+)(\*)+ *create(\w+)\(([^]]*)\)/) {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 my $interface = $1;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 my $implementation = $3;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 my $constructorArgs = $4;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 $constructor{$implementation} = [$interface, $constructorArgs];
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 open my $cx,"<","context.h" or die("can't open context.h $!");
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 my $inUnionData = 0;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 while (<$cx>) {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 if (! $inUnionData) {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 if ( /^union Data/) {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 $inUnionData = 1;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 next;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 last if (/union Data end/);
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 if (/struct (\w+) \{/) {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 $dataGear{$1} = 'struct';
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 } elsif (/^\s{4}(\w+) (\w+);/) { # primitive type
346
36ed64fea8c1 emit context.h
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 233
diff changeset
158 my $vtype = $1;
36ed64fea8c1 emit context.h
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 233
diff changeset
159 my $vname = $2;
36ed64fea8c1 emit context.h
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 233
diff changeset
160 if (exists $dataGear{$vname}) {
36ed64fea8c1 emit context.h
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 233
diff changeset
161 next;
36ed64fea8c1 emit context.h
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 233
diff changeset
162 }
36ed64fea8c1 emit context.h
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 233
diff changeset
163 $dataGear{$vtype} = 'primitive';
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 $dataGear{"Context"} = "struct";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 sub generateContext {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 $codeGear{"start_code"} = "$ddir/$name-context.c";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 $codeGear{"exit_code"} = "$ddir/$name-context.c";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 $mCodeGear{"start_code"} = "$ddir/$name-context.c";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 $mCodeGear{"exit_code"} = "$ddir/$name-context.c";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 open my $fd,">","$ddir/extern.h" or die("can't open $ddir/extern.h $!");
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 for my $code ( sort keys %codeGear ) {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 print $fd "extern __code ${code}_stub(struct Context*);\n";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 for my $impl ( sort keys %constructor ) {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 my ($interface, $constructorArgs) = @{$constructor{$impl}};
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 print $fd "extern ${interface}* create${impl}($constructorArgs);\n";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 print $fd "\n";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 open my $fd,">","$ddir/enumCode.h" or die("can't open $ddir/enumCode.h $!");
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 print $fd "enum Code {\n";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 for my $code ( sort keys %codeGear ) {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 print $fd " C_${code},\n";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 print $fd "};\n";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
190
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 my $code_init = '';
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 for my $code ( sort keys %mCodeGear ) {
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
193 $code_init .= " context->code[C_${code}] = ${code}_stub;\n";
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 my $data_num = keys(%dataGear);
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 $data_num++;
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
198 my $context_c;
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
199 if ($project->{name} eq "xv6") {
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
200 $context_c .= << "EOFEOF";
47
233a68a261fe ifdef cbcxv6
mir3636
parents: 46
diff changeset
201 #ifndef CBCXV6
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 #include <stdlib.h>
47
233a68a261fe ifdef cbcxv6
mir3636
parents: 46
diff changeset
203 #endif
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
204 EOFEOF
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
205 } else {
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
206 $context_c .= << "EOFEOF";
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
207 #include <stdlib.h>
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
208 EOFEOF
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
209 }
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
210
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
211 $context_c .= << "EOFEOF";
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
212
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 #include "../context.h"
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
214
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
215 void initContext(struct Context* $context_name) {
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
216 ${context_name}\->heapLimit = sizeof(union Data)*ALLOCATE_SIZE;
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
217 ${context_name}\->code = (__code(**) (struct Context*)) NEWN(ALLOCATE_SIZE, void*);
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
218 ${context_name}\->data = NEWN(ALLOCATE_SIZE, union Data*);
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
219 ${context_name}\->heapStart = NEWN(${context_name}\->heapLimit, char);
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
220 ${context_name}\->heap = ${context_name}\->heapStart;
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
221 // ${context_name}\->codeNum = Exit;
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 $code_init
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
224
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 #include "dataGearInit.c"
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
226 ${context_name}\->dataNum = $data_num;
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 EOFEOF
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
229
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 open my $fd,">","$ddir/$name-context.c" or die("can't open $ddir/$name-context.c $!");
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 print $fd $context_c;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 my $meta_call = <<"EOFEOF";
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
234 __code meta(struct Context* ${context_name}, enum Code next) {
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 // printf("meta %d\\n",next);
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
236 goto (${context_name}\->code[next])(${context_name});
45
5f19e9554c30 supless warning
k.fukuda
parents:
diff changeset
237 }
5f19e9554c30 supless warning
k.fukuda
parents:
diff changeset
238
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
239 __code parGotoMeta(struct Context* ${context_name}, enum Code next) {
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
240 ${context_name}->task = NULL;
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
241 ${context_name}->taskList = NULL;
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
242 goto (${context_name}\->code[Gearef(${context_name}, TaskManager)->taskManager->TaskManager.spawnTasks])(${context_name});
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
243 }
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
244
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
245 __code start_code(struct Context* ${context_name}) {
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
246 goto meta(${context_name}, ${context_name}\->next);
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
248
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
249 __code start_code_stub(struct Context* ${context_name}) {
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
250 goto start_code(${context_name});
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
251 }
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
252 EOFEOF
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
253
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
254 if ($project->{name} eq "gears") {
355
anatofuz
parents: 354
diff changeset
255 $meta_call .= <<"EOFEOF";
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
256 __code exit_code(struct Context* ${context_name}) {
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
257 free(${context_name}->code);
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
258 free(${context_name}->data);
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
259 free(${context_name}->heapStart);
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
260 goto exit(0);
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 }
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
262 EOFEOF
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
263
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
264 } else {
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
265
355
anatofuz
parents: 354
diff changeset
266 $meta_call .= <<"EOFEOF";
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
267 __code exit_code(struct Context* ${context_name}) {
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
268 // free(${context_name}->code);
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
269 // free(${context_name}->data);
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
270 // free(${context_name}->heapStart);
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
271 goto exit_code(cbc_context);
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
272 }
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
273 EOFEOF
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
275
355
anatofuz
parents: 354
diff changeset
276 $meta_call .= <<"EOFEOF";
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
277 __code exit_code_stub(struct Context* ${context_name}) {
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
278 goto exit_code(${context_name});
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
280
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 // end context_c
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 EOFEOF
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
283
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 print $fd $meta_call;
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
285
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 open my $fd,">","$ddir/enumData.h" or die("can't open $ddir/enumData.h $!");
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 print $fd "enum DataType {\n";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 print $fd " D_Code,\n";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 for my $data ( sort keys %dataGear ) {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 print $fd " D_${data},\n";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 print $fd "};\n\n";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
293
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 open my $fd,">","$ddir/typedefData.h" or die("can't open $ddir/typedefData.h $!");
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 for my $data ( sort keys %dataGear ) {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 if ($dataGear{$data} eq 'struct') {
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 print $fd "typedef struct ${data} ${data};\n";
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
300
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 open my $fd,">","$ddir/dataGearInit.c" or die("can't open $ddir/dataGearInit.c $!");
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 for my $data ( sort keys %dataGear ) {
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
303 print $fd " ALLOC_DATA(${context_name}, ${data});\n";
44
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 }
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
306
94ca6db2ee9c add perl script
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 # end