Mercurial > hg > GearsTemplate
changeset 561:aa4bef31cbfd
add write mode
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 19 Nov 2019 13:37:37 +0900 |
parents | 2276952ed717 |
children | b7db5cb2e2c1 |
files | src/parallel_execution/trans_impl.pl |
diffstat | 1 files changed, 18 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/trans_impl.pl Tue Nov 19 13:24:21 2019 +0900 +++ b/src/parallel_execution/trans_impl.pl Tue Nov 19 13:37:37 2019 +0900 @@ -6,18 +6,32 @@ use lib "$FindBin::Bin/lib"; use Gears::Util; -use DDP { deparse => 1}; +use Getopt::Std; + +my %opt; +getopts("w" => \%opt); my $impl_file = shift or die 'require impl file'; my $impl_ir = Gears::Util->parse_code_verbose($impl_file); my $interface_file = Gears::Util->find_header($impl_ir->{isa},"$FindBin::Bin"); my $inter_ir = Gears::Util->parse_code_verbose($interface_file); -my $stdout = *STDOUT; + + +my $output_file = $impl_file; +$output_file =~ s/\.h/.cbc/; +open my $fh, '>', $output_file; +my $stdout = $fh; + +unless ($opt{w}) { + $stdout = *STDOUT; +} + emit_include_part($stdout, $inter_ir->{name}); +emit_impl_header_in_comment($stdout, $impl_file); emit_constracutor($stdout,$impl_ir,$inter_ir); emit_code_gears($stdout,$impl_ir,$inter_ir); -#emit_impl_header_in_comment($stdout, $impl_file); +close $fh; sub emit_include_part { my ($out, $interface) = @_; @@ -33,7 +47,7 @@ my $line = Gears::Util->slup($impl_file); print $out "// ----\n"; map { print $out "// $_\n" } split /\n/, $line; - print $out "// ----\n"; + print $out "// ----\n\n"; } sub emit_constracutor {