# HG changeset patch # User anatofuz # Date 1583126389 -32400 # Node ID 36ed64fea8c13f4cbade2c5e07f466b1097c0acb # Parent efef0767b1bc4af4c39aa0ada0cbd1d39ef89688 emit context.h diff -r efef0767b1bc -r 36ed64fea8c1 src/data_gear/file.dg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/data_gear/file.dg Mon Mar 02 14:19:49 2020 +0900 @@ -0,0 +1,9 @@ +typedef struct file { + enum { FD_NONE, FD_PIPE, FD_INODE } type; + int ref; // reference count + char readable; + char writable; + struct pipe *pipe; + struct inode *ip; + uint off; +} file; diff -r efef0767b1bc -r 36ed64fea8c1 src/data_gear/inode.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/data_gear/inode.h Mon Mar 02 14:19:49 2020 +0900 @@ -0,0 +1,16 @@ +typedef struct inode { +#ifndef INODE_STRUCT + uint dev; // Device number + uint inum; // Inode number + int ref; // Reference count + int flags; // I_BUSY, I_VALID + + short type; // copy of disk inode + short major; + short minor; + short nlink; + uint size; + uint addrs[NDIRECT+1]; +#define INODE_STRUCT +#endif +} inode; diff -r efef0767b1bc -r 36ed64fea8c1 src/gearsTools/generate_context.pl --- a/src/gearsTools/generate_context.pl Sun Mar 01 18:10:05 2020 +0900 +++ b/src/gearsTools/generate_context.pl Mon Mar 02 14:19:49 2020 +0900 @@ -132,7 +132,12 @@ if (/struct (\w+) \{/) { $dataGear{$1} = 'struct'; } elsif (/^\s{4}(\w+) (\w+);/) { # primitive type - $dataGear{$1} = 'primitive'; + my $vtype = $1; + my $vname = $2; + if (exists $dataGear{$vname}) { + next; + } + $dataGear{$vtype} = 'primitive'; } $dataGear{"Context"} = "struct"; } diff -r efef0767b1bc -r 36ed64fea8c1 src/gearsTools/lib/Gears/Context.pm --- a/src/gearsTools/lib/Gears/Context.pm Sun Mar 01 18:10:05 2020 +0900 +++ b/src/gearsTools/lib/Gears/Context.pm Mon Mar 02 14:19:49 2020 +0900 @@ -165,6 +165,8 @@ $context .= "${space}} $h2context->{name};\n"; $context .= "#define ". uc($h2context->{name}) ."_STRUCT \n"; + $context .= "#else\n"; + $context .= "${space}struct $h2context->{name};\n"; $context .= "#endif\n"; return $context; } diff -r efef0767b1bc -r 36ed64fea8c1 src/interface/io.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/interface/io.h Mon Mar 02 14:19:49 2020 +0900 @@ -0,0 +1,6 @@ +typedef struct IO { + __code read(Impl* io, char* addr, __code next(...)); + __code write(Impl* io, char* addr, int n, __code next(...)); + __code close(Impl* io,int fd, __code next(...)); + __code next(...); +} IO;