changeset 128:7ce72e373d9b

fix initialize data gears
author anatofuz
date Tue, 03 Dec 2019 11:12:52 +0900
parents 46d792f92156
children 833f40b7b1ce
files src/gearsTools/trans_impl.pl src/impl/SysReadImpl.h src/impl/SysReadImplTmp.h src/interface/SysRead.h
diffstat 4 files changed, 25 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/gearsTools/trans_impl.pl	Tue Dec 03 10:45:46 2019 +0900
+++ b/src/gearsTools/trans_impl.pl	Tue Dec 03 11:12:52 2019 +0900
@@ -82,6 +82,16 @@
         if ($datum =~ /\w+ \w+ (\w+)/) {
             print $out "    ${instance_impl}->$1 = 0;\n";
         }
+
+        if ($datum =~ /\w+(\*)? (\w+)/) {
+            my $is_pointer = $1;
+            my $var_name = $2;
+            if ($1) {
+                print $out "    ${instance_impl}->$var_name = NULL;\n";
+            } else {
+                print $out "    ${instance_impl}->$var_name  = 0;\n";
+            }
+        }
   }
 
   for my $datum (@inter_data) {
@@ -91,6 +101,16 @@
         }
         if ($datum =~ /\w+ \w+ (\w+)/) {
             print $out "    ${instance_inter}->$1 = 0;\n";
+            next;
+        }
+        if ($datum =~ /\w+(\*)? (\w+)/) {
+            my $is_pointer = $1;
+            my $var_name = $2;
+            if ($1) {
+                print $out "    ${instance_impl}->$var_name = NULL;\n";
+            } else {
+                print $out "    ${instance_impl}->$var_name  = 0;\n";
+            }
         }
   }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/impl/SysReadImpl.h	Tue Dec 03 11:12:52 2019 +0900
@@ -0,0 +1,3 @@
+typedef struct SysReadImpl <Type, Isa> impl SysRead {
+
+} SysReadImpl;
--- a/src/impl/SysReadImplTmp.h	Tue Dec 03 10:45:46 2019 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-typedef struct SysReadImplTmp <Type, Isa> impl SysRead {
-
-} SysRead;
--- a/src/interface/SysRead.h	Tue Dec 03 10:45:46 2019 +0900
+++ b/src/interface/SysRead.h	Tue Dec 03 11:12:52 2019 +0900
@@ -1,7 +1,7 @@
 typedef struct SysRead<Type, Impl>{
    union  Data* sys_read;
-   struct Integer* num;
-   struct String *str;
+   int num;
+   char* str;
    __code read(Impl* sys_read, __code next(...));
    //__code ret(Impl* cbc_sys_file, UInteger* num);
    __code next(...);