changeset 687:90a35ebecac5

...
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Fri, 21 Aug 2020 14:54:27 +0900
parents 3c37a86646ce
children 317ff12ab253
files src/parallel_execution/cleanup.sh src/parallel_execution/lib/Gears/Util.pm src/parallel_execution/perlTests/util.t
diffstat 3 files changed, 43 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/cleanup.sh	Fri Aug 21 14:29:43 2020 +0900
+++ b/src/parallel_execution/cleanup.sh	Fri Aug 21 14:54:27 2020 +0900
@@ -1,2 +1,2 @@
 #!/bin/sh
-rm -rf cmake_install.cmake c CMakeFiles CMakeCache.txt context.h
+rm -rf cmake_install.cmake c CMakeFiles CMakeCache.txt context.h build.ninja
--- a/src/parallel_execution/lib/Gears/Util.pm	Fri Aug 21 14:29:43 2020 +0900
+++ b/src/parallel_execution/lib/Gears/Util.pm	Fri Aug 21 14:54:27 2020 +0900
@@ -100,7 +100,7 @@
     return undef;
   }
 
-  my @tmp_args;
+  my @data_gears;
   while ($line = <$fh>) {
     chomp $line;
     if ($line =~ m|\s*/\*|) {
@@ -115,8 +115,12 @@
     next if ($line =~ m[^\}\s*$ir->{name};]);
 
     if ($line =~ m|__code (\w+)|) {
-      push(@tmp_args,"enum Code $1;");
+
+      push(@data_gears,"enum Code $1;"); #this case insert __code name (__code hoge -> enum Code hoge;)
+
+      #In the case of writing field variables one line at a time, cancel the following
       next if $static_data_gear_write_mode;
+
       my $args = $';
       #$args eq  (Impl* vm, pde_t* pgdir, char* init, uint sz, __code next(...));
       while ($args =~ /\s*(struct|union|const|enum)?\s*([\w*\[\]_]+)\s*(\w+)?,?/g) {
@@ -126,18 +130,20 @@
         next if ($type eq '__code');
         next unless $vname; # __code hoge(int ret, __code next(ret, ...); this is second "ret" case
         $type =~ s/^(?:Impl|Type|Isa)\s*(\*)?/union Data$1/;
+
         my $val = "$type $vname;";
-        push(@tmp_args, $const_type ?  "$const_type $val" : $val);
+        push(@data_gears, $const_type ?  "$const_type $val" : $val);
       }
       next;
     }
 
+    #this is a case of writing field variables one line at a time
     $line =~ s/^\s+//;
-    push(@tmp_args,$line);
+    push(@data_gears,$line);
     $static_data_gear_write_mode = 1;
   }
 
-  push(@{$ir->{content}}, _uniq(@tmp_args));
+  push(@{$ir->{content}}, _uniq(@data_gears));
   return $ir;
 }
 
--- a/src/parallel_execution/perlTests/util.t	Fri Aug 21 14:29:43 2020 +0900
+++ b/src/parallel_execution/perlTests/util.t	Fri Aug 21 14:54:27 2020 +0900
@@ -3,7 +3,7 @@
 use warnings;
 use FindBin;
 
-use Test::More  tests => 3; #subtests
+use Test::More  tests => 4; #subtests
 
 use_ok "Gears::Util"; #use test
 
@@ -21,6 +21,36 @@
   is $found_file, $exists_file;
 };
 
+subtest 'parse' => sub {
+  subtest 'parsing_stack' => sub {
+
+    my $stack_header = "$FindBin::Bin/../Stack.h";
+    my $expand = {
+          name => 'Stack',
+          file_name => $stack_header,
+          content => [
+                         'union Data* stack;',
+                         'union Data* data;',
+                         'union Data* data1;',
+                         'enum Code whenEmpty;',
+                         'enum Code clear;',
+                         'enum Code push;',
+                         'enum Code pop;',
+                         'enum Code pop2;',
+                         'enum Code isEmpty;',
+                         'enum Code get;',
+                         'enum Code get2;',
+                         'enum Code next;'
+                       ]
+     };
+
+     my $res = Gears::Util->parse($stack_header);
+
+     is_deeply ($res, $expand, "parsing stack.h");
+
+  };
+};
+
 subtest 'parse_interface' => sub {
 
   subtest 'invalid_case' => sub {