changeset 278:98aea649e37b

add gen_stub perl scripts
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Tue, 28 Jan 2020 14:23:29 +0900
parents 0ea4d14c54bd
children 0a74a7bbe765
files src/gearsTools/gen_Stub.pl src/gearsTools/lib/Gears/Stub.pm
diffstat 2 files changed, 70 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gearsTools/gen_Stub.pl	Tue Jan 28 14:23:29 2020 +0900
@@ -0,0 +1,18 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+use Gears::Util;
+use Gears::Stub;
+
+use Getopt::Std;
+use File::Spec;
+
+use DDP {deparse => 1};
+
+my $target_cbc_file = shift;
+my $stubManager = Gears::Stub->new(file_name => File::Spec->rel2abs($target_cbc_file));
+
+$stubManager->findInterfacewImpl($stubManager->slup());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gearsTools/lib/Gears/Stub.pm	Tue Jan 28 14:23:29 2020 +0900
@@ -0,0 +1,52 @@
+package Gears::Stub;
+use strict;
+use warnings;
+use Carp qw/croak/;
+use File::Find;
+use Gears::Util;
+use Gears::Context;
+
+use DDP {deparse => 1};
+
+sub new {
+  my ($class, %args) = @_;
+
+  my $self = {};
+  $self->{file_name} = $args{file_name} || croak 'invalid file_name!'; 
+
+  return bless $self, $class;
+}
+
+
+sub slup {
+  my $self = shift;
+  my @contents = ();
+  open my $fh, '<', $self->{file_name};
+  while (my $line = <$fh>) {
+    push(@contents,$line);
+  }
+  close $fh;
+  return \@contents;
+}
+
+
+sub findInterfacewImpl {
+  my ($self, $cbc_file_content) = @_;
+  my %findInterfaces;
+
+  extraction_dg_compile_sources
+  #for my $i (0..$#{$cbc_file_content}) {
+  #  my $line = $cbc_file_content->[$i];
+  #  if ($line =~ /#interface\s*"([\w.]+)"/) {
+  #      push(@{$findInterfaces{$1}},[$i, $line]);
+  #      next;
+  #  }
+
+  #  if ($line =~ /data_gear\s*"([\w.]+)"/) {
+  #      push(@{$findInterfaces{$1}},[$i, $line]);
+  #  }
+  #}
+  p %findInterfaces;
+}
+
+1;