changeset 699:4d99aad53969

replace include at generate_stub
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sat, 22 Aug 2020 08:22:34 +0900
parents 73ebf05f48ee
children 8416928992fc
files src/parallel_execution/examples/pop_and_push/StackTestImpl.cbc src/parallel_execution/generate_stub.pl src/parallel_execution/lib/Gears/Interface.pm
diffstat 3 files changed, 27 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/examples/pop_and_push/StackTestImpl.cbc	Fri Aug 21 19:00:53 2020 +0900
+++ b/src/parallel_execution/examples/pop_and_push/StackTestImpl.cbc	Sat Aug 22 08:22:34 2020 +0900
@@ -3,7 +3,7 @@
 #interface "Stack.h"
 #include <stdio.h>
 
-#include "/Users/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/examples/pop_and_push/String.h"
+#include "String.h"
 
 // ----
 // typedef struct StackTestImpl <Type, Isa> impl StackTest {
--- a/src/parallel_execution/generate_stub.pl	Fri Aug 21 19:00:53 2020 +0900
+++ b/src/parallel_execution/generate_stub.pl	Sat Aug 22 08:22:34 2020 +0900
@@ -522,6 +522,24 @@
                 my $interfaceHeader = $1;
                 # #interface not write
                 next unless ($interfaceHeader =~ /context.h/);
+            } elsif (/^#include "(.*).h"$/) {
+                my $headerName = $1;
+                if ($headerName =~ m|/?context$|) {
+                  print $fd $_;
+                  next;
+                }
+
+                # This process assumes that there are no header files of the same name
+                my $path = $interfaceNameToHeaderPath->{$headerName};
+                unless ($path) {
+                  print $fd $_;
+                  next;
+                }
+
+                print $fd '#include "' .$path . '"';
+                print $fd "\n";
+                next;
+
             } elsif (/^\_\_code (\w+)\((.*)\)(.*)/) {
                 $inCode = 1;
                 %localVarType = ();
@@ -838,6 +856,7 @@
     my $files = Gears::Util->find_headers_from_path($search_root);
     my $interface_name2headerpath = {};
 
+    #This process assumes that there are no header files of the same name
     for my $file (@{$files}) {
       if ($file =~ m|/(\w+)\.\w+$|) {
         my $file_name = $1;
@@ -904,12 +923,9 @@
 
 sub get_indent_len {
   my $prev = shift;
-  my $indent = '';
-  my @chars = split //, $prev;
-  for my $w (@chars) {
-    last if ($w !~ /\s/);
-    $indent .= $w;
+  if ($prev =~ /^(\s+).*$/) {
+    return $1;
   }
-  return $indent;
+  return "";
 }
 
--- a/src/parallel_execution/lib/Gears/Interface.pm	Fri Aug 21 19:00:53 2020 +0900
+++ b/src/parallel_execution/lib/Gears/Interface.pm	Sat Aug 22 08:22:34 2020 +0900
@@ -2,7 +2,8 @@
 use strict;
 use warnings;
 use Carp qw/croak carp/;
-
+use File::Basename qw/dirname/;
+use File::Spec;
 
 use Gears::Util;
 
@@ -19,11 +20,7 @@
   my $line = <$fh>;
   my $static_data_gear_write_mode = 0;
 
-  my $directory_containing_file = "";
-
-  if ($file  =~ m<([\.\w/]+)/\w+\.(?:cbc|h|c)>) {
-     $directory_containing_file = $1;
-  }
+  my $dir_name = dirname(File::Spec->rel2abs($file));
 
 
   while ($line =~ /#include\s+"([\w\/\.]+)"/) {
@@ -31,7 +28,7 @@
     if ($header_file =~ m|\./context\.h|) {
       next;
      }
-    push(@{$ir->{cbc_context_include_headers}}, "$directory_containing_file/$header_file");
+    push(@{$ir->{cbc_context_include_headers}}, "$dir_name/$header_file");
     $line = <$fh>;
   }