changeset 238:4d76280758db

move context.pm to util.pm ...
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Tue, 28 Jan 2020 16:50:07 +0900
parents 21a5761e3e7a
children 40b1b7476e77
files src/gearsTools/gen_Stub.pl src/gearsTools/lib/Gears/Context.pm src/gearsTools/lib/Gears/Stub.pm src/gearsTools/lib/Gears/Util.pm src/impl/vm_impl_private.cbc
diffstat 5 files changed, 43 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/src/gearsTools/gen_Stub.pl	Tue Jan 28 15:20:34 2020 +0900
+++ b/src/gearsTools/gen_Stub.pl	Tue Jan 28 16:50:07 2020 +0900
@@ -15,4 +15,5 @@
 my $target_cbc_file = shift;
 my $stubManager = Gears::Stub->new(file_name => File::Spec->rel2abs($target_cbc_file));
 
-$stubManager->findInterfacewImpl(File::Spec->rel2abs($target_cbc_file));
+my $interface_w_impl = $stubManager->findInterfacewImpl(File::Spec->rel2abs($target_cbc_file));
+
--- a/src/gearsTools/lib/Gears/Context.pm	Tue Jan 28 15:20:34 2020 +0900
+++ b/src/gearsTools/lib/Gears/Context.pm	Tue Jan 28 16:50:07 2020 +0900
@@ -33,7 +33,7 @@
   my $self = shift;
   my @data_gears_name;
   map { push (@data_gears_name,$_) if $_ ne "Context" } @_;
-  return _find_headers($self->{find_root},\@data_gears_name);
+  return Gears::Util->docking_header_name_to_path($self->{find_root},\@data_gears_name);
 }
 
 sub update_dg_each_header_path {
@@ -110,26 +110,4 @@
   return \%dg_str;
 }
 
-sub _find_headers {
-  my ($search_bash_path, $targets) = @_;
-  my %res;
-  map { $res{$_}++ } @$targets;
-
-  my $header_paths = Gears::Util->find_headers_path($search_bash_path);
-  map {
-    if (/(\w+)\.(?:h|dg)$/) {
-        my $header_file = $1;
-        if (exists $res{$header_file}) {
-          if ($res{$header_file} =~ /^\d+$/){
-            $res{$header_file} = $_;
-          } elsif (($_ =~ /\.dg$/) && ($res{$header_file} =~ /\.h$/)) {
-            $res{$header_file} = $_;
-          }
-        }
-    }
-  } sort @$header_paths;
-  return \%res;
-}
-
-
 1;
--- a/src/gearsTools/lib/Gears/Stub.pm	Tue Jan 28 15:20:34 2020 +0900
+++ b/src/gearsTools/lib/Gears/Stub.pm	Tue Jan 28 16:50:07 2020 +0900
@@ -22,7 +22,18 @@
   my $self     = shift;
   my $cbc_file = shift // $self->{file_name};
   my $findInterfaces = Gears::Util->extraction_dg_compile_sources([$cbc_file]);
-  p $findInterfaces;
+  my $edgcs = Gears::Util->extraction_dg_compile_sources([$cbc_file]);
+  my $findInterfaces = {};
+
+  my %ifs = ();
+  map { $ifs{$_}++ } keys %{$edgcs->{interfaces}};
+  delete $ifs{Meta};
+  delete $ifs{TaskManager};
+
+  push(@{$findInterfaces->{interfaces}}, keys %ifs);
+  push(@{$findInterfaces->{impls}}, keys %{$edgcs->{impl}});
+
+  return $findInterfaces;
 }
 
 1;
--- a/src/gearsTools/lib/Gears/Util.pm	Tue Jan 28 15:20:34 2020 +0900
+++ b/src/gearsTools/lib/Gears/Util.pm	Tue Jan 28 16:50:07 2020 +0900
@@ -191,15 +191,13 @@
        }
 
 
-       #if ($line =~ /^(\w+)(\*)+  *create(\w+)\(([^]]*)\)/) {
-       #   my $interface = $1;
-       #   my $implementation = $3;
-       #   $self->{data_gears_with_count}->{$interface}->{caller}->{$cbc_file}++;
-       #   $self->{data_gears_with_count}->{$implementation}->{caller}->{$cbc_file}++;
-       #   $counter{interfaces}->{$interface}++;
-       #   $counter{impl}->{$implementation}++;
-       #   next;
-       #}
+       if ($line =~ /^(\w+)\*\s*create(\w+)\(/) {
+          my $interface = $1;
+          my $implementation = $2;
+          push(@{$counter{interfaces}->{$interface}->{$cbc_file}},$.);
+          push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
+          next;
+       }
 
        if ($line =~ /Gearef\(context,\s*(\w+)\)/) {
           my $implementation = $1;
@@ -279,6 +277,26 @@
   return \%counter;
 }
 
+sub docking_header_name_to_path {
+  my ($class, $search_bash_path, $targets) = @_;
+  my %res;
+  map { $res{$_}++ } @$targets;
+
+  my $header_paths = Gears::Util->find_headers_path($search_bash_path);
+  map {
+    if (/(\w+)\.(?:h|dg)$/) {
+        my $header_file = $1;
+        if (exists $res{$header_file}) {
+          if ($res{$header_file} =~ /^\d+$/){
+            $res{$header_file} = $_;
+          } elsif (($_ =~ /\.dg$/) && ($res{$header_file} =~ /\.h$/)) {
+            $res{$header_file} = $_;
+          }
+        }
+    }
+  } sort @$header_paths;
+  return \%res;
+}
 
 
 1;
--- a/src/impl/vm_impl_private.cbc	Tue Jan 28 15:20:34 2020 +0900
+++ b/src/impl/vm_impl_private.cbc	Tue Jan 28 16:50:07 2020 +0900
@@ -6,7 +6,7 @@
 #interface "vm_impl.h"
 
 /*
-vm_impl* createvm_impl2();
+vm_impl* createvm_impl2(); //:skip
 */
 
 __code loaduvm_ptesize_checkvm_impl(struct vm_impl* vm_impl, __code next(int ret, ...)) {