diff src/gearsTools/generate_stub.pl @ 242:26be78edaf83

impl auto collection for data gears from interface
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Mon, 03 Feb 2020 17:12:35 +0900
parents d419660ad71d
children 4f72a447d518
line wrap: on
line diff
--- a/src/gearsTools/generate_stub.pl	Sun Feb 02 13:31:03 2020 +0900
+++ b/src/gearsTools/generate_stub.pl	Mon Feb 03 17:12:35 2020 +0900
@@ -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/);
@@ -139,6 +139,21 @@
             }
             $var{$name}->{$tname} = $ttype;
         }
+        if (/__code (\w+)/) {
+            my $args = $';
+            while ($args =~ /((?: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/struct $name/;
+              if ($const_type eq 'const') {
+                $ttype = "const $ttype";
+              }
+              $var{$name}->{$tname} = $ttype;
+            }
+        }
         if (/^}/) {
             $inTypedef = 0;
         }