changeset 180:f9df567f7f2d

tweak_gen_context.pl
author anatofuz
date Mon, 20 Jan 2020 16:44:55 +0900
parents 2842d9e65751
children f431400da994
files src/gearsTools/generate_context.pl src/gearsTools/lib/Gears/Context.pm
diffstat 2 files changed, 16 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/gearsTools/generate_context.pl	Mon Jan 20 11:24:39 2020 +0900
+++ b/src/gearsTools/generate_context.pl	Mon Jan 20 16:44:55 2020 +0900
@@ -77,13 +77,13 @@
 
   my $output     = $opt_w ? "context.h" : "stdout";
 
+  use Data::Dumper;
   my @cbc_files;
   map { push(@cbc_files,File::Spec->rel2abs($_)); }  @ARGV;
   my $gears      = Gears::Context->new(compile_sources => \@cbc_files, find_root => "$FindBin::Bin/../", output => $output);
   my $data_gears = $gears->extraction_dg_compile_sources();
-  my $g          = $gears->set_data_gear_header_path();
+  my $g          = $gears->set_data_gear_header_path(keys %{$data_gears->{impl}},keys %{$data_gears->{interfaces}});
 
-  #use DDP {deparse =>1};
   my $dg2path    = $gears->update_dg_each_header_path($data_gears,$g);
   my $tree = $gears->createImplTree_from_header($dg2path);
   $gears->tree2create_context_h($tree);
--- a/src/gearsTools/lib/Gears/Context.pm	Mon Jan 20 11:24:39 2020 +0900
+++ b/src/gearsTools/lib/Gears/Context.pm	Mon Jan 20 16:44:55 2020 +0900
@@ -31,13 +31,11 @@
     open my $fh , '<', $cbc_file;
     while (my $line = <$fh>) {
         if ($line =~ m|//\s*:skip|) {
-         print "ddddddddd\n";
          next;
         }
 
        if ($line =~ /#interface\s*"(.*)\.h"/ || $line =~ /^\/\/\s*data_gear\s*"(.*)\.(?:h|dg)?"/) {
-          push(@{$counter{interfaces}->{$1}},$.);
-          push(@{$self->{data_gears_with_count}->{$1}->{caller}->{$cbc_file}},$.);
+          push(@{$counter{interfaces}->{$1}->{$cbc_file}},$.);
           next;
        }
 
@@ -59,37 +57,32 @@
 
        if ($line =~ /Gearef\(context,\s*(\w+)\)/) {
           my $implementation = $1;
-          push(@{$counter{impl}->{$implementation}},$.);
-          push(@{$self->{data_gears_with_count}->{$implementation}->{caller}->{$cbc_file}},$.);
+          push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
           next;
        }
 
     #Element* element = &ALLOCATE(cbc_context, Element)->Element;
        if ($line =~ /ALLOCATE\w*\((?:cbc_)?context,\s*(\w+)\)/) {
           my $implementation = $1;
-          push(@{$counter{impl}->{$implementation}},$.);
-          push(@{$self->{data_gears_with_count}->{$implementation}->{caller}->{$cbc_file}},$.);
+          push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
           next;
        }
 
        if ($line =~ /ALLOCATE_(?:PTR_)?ARRAY\((?:cbc_)?context,\s*(\w+),[\s\w]+\)/) {
           my $implementation = $1;
-          push(@{$counter{impl}->{$implementation}},$.);
-          push(@{$self->{data_gears_with_count}->{$implementation}->{caller}->{$cbc_file}},$.);
+          push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
           next;
        }
 
        if ($line =~ /new\s+(\w+?)\([\w\s]*\);/) {
           my $implementation = $1;
-          push(@{$counter{impl}->{$implementation}},$.);
-          push(@{$self->{data_gears_with_count}->{$implementation}->{caller}->{$cbc_file}},$.);
+          push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
           next;
        }
 
        if ($line =~ /ALLOCATE_DATA_GEAR\((\w+),\s*(\w+)\)/) {
           my $implementation = $2;
-          push(@{$counter{impl}->{$implementation}},$.);
-          push(@{$self->{data_gears_with_count}->{$implementation}->{caller}->{$cbc_file}},$.);
+          push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
           next;
        }
 
@@ -97,18 +90,16 @@
        if ($line =~ /\((\w+)\*\)GearImpl\(context,\s*(\w+),\s*(\w+)\)/) {
           my $interface = $2;
           my $implementation = $1;
-          push(@{$counter{impl}->{$implementation}},$.);
-          push(@{$counter{interfaces}->{$interface}},$.);
-          push(@{$self->{data_gears_with_count}->{$interface}->{caller}->{$cbc_file}},$.);
+          push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
+          push(@{$counter{interfaces}->{$interface}->{$cbc_file}},$.);
           next;
        }
 
        if ($line =~ /^__code/) {
          while ($line =~ /struct (\w+)\s*\*/g) {
            next if $1 eq "Context";
-           push(@{$self->{data_gears_with_count}->{$1}->{caller}->{$cbc_file}},$.);
            next if (exists $counter{interfaces}->{$1});
-           $counter{impl}->{$1}++;
+           push(@{$counter{impl}->{$1}->{$cbc_file}},$.);
          }
        }
     }
@@ -118,17 +109,17 @@
   $counter{interfaces}->{TaskManager}++;
   $self->{data_gears_with_count}->{Meta}++;
   $self->{data_gears_with_count}->{TaskManager}++;
+  use Data::Dumper;
+  print "-----------\n";
+  print Dumper \%counter;
+  print "-----------\n";
   return \%counter;
 }
 
 sub set_data_gear_header_path {
   my $self = shift;
   my @data_gears_name;
-  if (@_) {
-    @data_gears_name = @_;
-  } else {
-    map { push (@data_gears_name,$_) if $_ ne "Context" } keys %{$self->{data_gears_with_count}};
-  }
+  map { push (@data_gears_name,$_) if $_ ne "Context" } @_;
   return _find_headers($self->{find_root},\@data_gears_name);
 }