changeset 736:89de0bea70d7

...
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sat, 12 Dec 2020 14:33:24 +0900
parents 8794269d2c09
children ff5c5ab7b95f
files src/parallel_execution/lib/Gears/Context.pm src/parallel_execution/lib/Gears/Interface.pm src/parallel_execution/lib/Gears/Stub.pm src/parallel_execution/tools/trans_impl.pl
diffstat 4 files changed, 27 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/lib/Gears/Context.pm	Thu Dec 10 17:51:24 2020 +0900
+++ b/src/parallel_execution/lib/Gears/Context.pm	Sat Dec 12 14:33:24 2020 +0900
@@ -14,9 +14,9 @@
   my ($class, %args) = @_;
   my $self = {
     data_gears_with_count => {},
-    find_root => $args{find_root} // ".",
-    output    => $args{output},
-    template  => $args{template}  // "Gears::Context::Template",
+    find_root             => $args{find_root} // ".",
+    output                => $args{output},
+    template              => $args{template}  // "Gears::Context::Template",
   };
 
   if ($args{compile_sources}) {
@@ -38,7 +38,7 @@
     open my $fh , '<', $cbc_file;
     while (my $line = <$fh>) {
         if ($line =~ m|//\s*:skip|) {
-         next;
+          next;
         }
 
        if ($line =~ /#interface\s*"(.*)\.h"/) {
@@ -52,15 +52,15 @@
        }
 
        if ($line =~ m|//\s*Skip:\s*generate_context|) {
-         $line = <$fh>;
-         next;
+          $line = <$fh>;
+          next;
        }
 
 
        if ($line =~ /^(\w+)\*\s*create(\w+)\(([*\w\s]+)\)/) {
-          my $interface = $1;
+          my $interface      = $1;
           my $implementation = $2;
-          my $arg = $3;
+          my $arg            = $3;
           if ($arg eq "") {
             next;
           }
@@ -104,8 +104,8 @@
 
        #TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager);
        if ($line =~ /\((\w+)\*\)GearImpl\(context,\s*(\w+),\s*(\w+)\)/) {
-          my $interface = $2;
           my $implementation = $1;
+          my $interface      = $2;
           push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
           push(@{$counter{interfaces}->{$interface}->{$cbc_file}},$.);
           next;
--- a/src/parallel_execution/lib/Gears/Interface.pm	Thu Dec 10 17:51:24 2020 +0900
+++ b/src/parallel_execution/lib/Gears/Interface.pm	Sat Dec 12 14:33:24 2020 +0900
@@ -8,9 +8,7 @@
 use Gears::Util;
 
 sub parse {
-
     # create this data structure
-
   my ($class, $file) = @_;
   my $ir  = {};
   $ir->{file_name} = $file;
@@ -157,8 +155,8 @@
           my $outputArgs = $1;
           while ($outputArgs =~ /(struct|union|const|enum)?\s*([\w*]+)\s(\w+),?/g) {
             my $structType = $1;
-            my $ttype = $2;
-            my $tname = $3;
+            my $ttype      = $2;
+            my $tname      = $3;
             $ir->{hasOutputArgs}->{$codeGearName}->{$tname} = $ttype;
           }
         }
@@ -175,9 +173,12 @@
 
 sub isThisFileInterface {
   my ($class, $filename) = @_;
+
   open my $fh, '<', $filename;
   my $line = <$fh>;
+
   return 0 unless ($line =~ /typedef struct \w+\s?<.*>([\s\w{]+)/);
+
   my $annotation = $1;
   return 0 if ($annotation =~ /impl/);
 
@@ -188,7 +189,7 @@
 sub collect_interfaces_from_all_headers {
   my ($class, $find_path) = @_;
   my $header_files = Gears::Util->find_headers_from_path($find_path);
-  my @result = sort grep { Gears::Interface->isThisFileInterface($_) } @$header_files;
+  my @result       = sort grep { Gears::Interface->isThisFileInterface($_) } @$header_files;
   return \@result;
 }
 
--- a/src/parallel_execution/lib/Gears/Stub.pm	Thu Dec 10 17:51:24 2020 +0900
+++ b/src/parallel_execution/lib/Gears/Stub.pm	Sat Dec 12 14:33:24 2020 +0900
@@ -16,7 +16,7 @@
   my $impl_file_name      = $impl_info->{file_name} // croak "[WARN] require filename $impl_name";
 
   my $interface_ir = Gears::Interface->detailed_parse($interface_file_name);
-  my $impl_ir  = Gears::Interface->detailed_parse($impl_file_name);
+  my $impl_ir      = Gears::Interface->detailed_parse($impl_file_name);
 
   my $interface_var_name = shift @{$interface_ir->{data}} // _decamelize($interface_name);
 
@@ -79,11 +79,11 @@
   for my $datum (@$data) {
         $datum =~ s|//[\s\w]+||;
         if ($datum =~ /^\s+#/) {
-          next;
+            next;
         }
 
         if ($datum =~ /\w+\s\w+\*\s(\w+)/) {
-           push(@generate_lines, "    ${varTypeName}->$1 = NULL;\n");
+            push(@generate_lines, "    ${varTypeName}->$1 = NULL;\n");
             next;
         }
         if ($datum =~ /\w+\s\w+\s(\w+)/) {
--- a/src/parallel_execution/tools/trans_impl.pl	Thu Dec 10 17:51:24 2020 +0900
+++ b/src/parallel_execution/tools/trans_impl.pl	Sat Dec 12 14:33:24 2020 +0900
@@ -34,10 +34,11 @@
 my $impl_var_name  = decamelize($impl_ir->{name});
 
 my $interface = {ir => $inter_ir, var_name => $interface_var_name};
-my $impl = {ir => $impl_ir, var_name => $impl_var_name};
+my $impl      = {ir => $impl_ir,  var_name => $impl_var_name};
 
 my $output_file = $impl_file;
 $output_file =~ s/\.h/.cbc/;
+
 my $stdout    = *STDOUT;
 
 my $context_deeps = () = $impl_file =~ /\//g;
@@ -47,12 +48,15 @@
       update_file($output_file, $interface, $impl, $impl_file, $context_deeps);
       exit 0;
     }
+
     open $stdout, '>', $output_file;
+
 } elsif ($opt{o}) {
     if(-f $opt{o}) {
       update_file($opt{o}, $interface, $impl, $impl_file, $context_deeps);
       exit 0;
     }
+
     open $stdout, '>', $opt{o};
 }
 
@@ -95,10 +99,10 @@
   my $inter_ir = $interface->{ir};
   my $impl_ir  = $impl->{ir};
 
-  my $impl_name = $impl_ir->{name};
+  my $impl_name      = $impl_ir->{name};
   my $interface_name = $inter_ir->{name};
 
-  my $impl_var_name = $impl->{var_name};
+  my $impl_var_name      = $impl->{var_name};
   my $interface_var_name = $interface->{var_name};
 
   my @inter_data = @{$inter_ir->{data}};
@@ -202,9 +206,9 @@
 sub find_using_interface_header {
   my ($header_name, $find_path) = @_;
 
-  my $header_list = Gears::Util->find_headers_from_path($find_path);
+  my $header_list  = Gears::Util->find_headers_from_path($find_path);
 
-  my @find_headers =  grep { $_ =~ /\/$header_name\.(h|dg)$/} @{$header_list};
+  my @find_headers = grep { $_ =~ /\/$header_name\.(h|dg)$/} @{$header_list};
 
   if (scalar(@find_headers) > 1) { # @find_headers == (hoge.h, hoge.dg)
       @find_headers =  grep { $_ =~ /\/$header_name\.dg/} @find_headers; #only dg