diff src/gearsTools/generate_stub.pl @ 323:6d96bba13d5d

merged
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Fri, 07 Feb 2020 14:58:30 +0900
parents edc8e6c71dc6 42a37a8a02c9
children fde5f96c6ff1
line wrap: on
line diff
--- a/src/gearsTools/generate_stub.pl	Fri Feb 07 14:48:24 2020 +0900
+++ b/src/gearsTools/generate_stub.pl	Fri Feb 07 14:58:30 2020 +0900
@@ -75,7 +75,7 @@
 
 sub getDataGear {
     my ($filename) = @_;
-    my ($codeGearName, $name, $inTypedef);
+    my ($codeGearName, $name, $inTypedef,$described_data_gear);
     open my $fd,"<",$filename or die("can't open $filename $!");
     while (<$fd>) {
         if (! $inTypedef) {
@@ -110,7 +110,7 @@
                 if ( -f "$codeGearName.cbc") {
                     &getCodeGear("$codeGearName.cbc");
                 }
-			} elsif(/^#interface "(.*)"/) {
+            } elsif(/^#interface "(.*)"/) {
                 # use interface
                 my $interfaceHeader = $1;
                 next if ($interfaceHeader =~ /context.h/);
@@ -141,8 +141,25 @@
                     $ttype = "const $2";
                 }
             }
+            $described_data_gear = 1;
             $var{$name}->{$tname} = $ttype;
         }
+        if (/__code (\w+)/) {
+            next if $described_data_gear;
+            my $args = $';
+            while ($args =~ /\s*(struct|union|const)?\s*([\w\[\]_]+)\*?\s*(\w+),?/g) {
+              #$args eq  (Impl* vm, pde_t* pgdir, char* init, uint sz, __code next(...));
+              my $const_type = $1;
+              my $ttype = $2;
+              my $tname = $3;
+
+              $ttype =~ s/(Impl|Isa|Type)/Data/;
+              if ($const_type eq 'const') {
+                $ttype = "const $ttype";
+              }
+              $var{$name}->{$tname} = $ttype;
+            }
+        }
         if (/^}/) {
             $inTypedef = 0;
         }