# HG changeset patch # User anatofuz # Date 1580717555 -32400 # Node ID 26be78edaf838b21f02eb7f818c5f40d88c3d6ce # Parent 875ad11af59621a9f2454d2e2ab65aa1fc6d77fe impl auto collection for data gears from interface diff -r 875ad11af596 -r 26be78edaf83 src/gearsTools/generate_stub.pl --- 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; } diff -r 875ad11af596 -r 26be78edaf83 src/gearsTools/lib/Gears/Util.pm --- a/src/gearsTools/lib/Gears/Util.pm Sun Feb 02 13:31:03 2020 +0900 +++ b/src/gearsTools/lib/Gears/Util.pm Mon Feb 03 17:12:35 2020 +0900 @@ -3,6 +3,7 @@ use warnings; use Carp qw/croak/; use File::Find; +use List::Util qw/uniq/; sub parse { my ($class, $file_name) = @_; @@ -40,6 +41,7 @@ } } + my @tmp_args; while ($line = <$fh>) { if ($line =~ m|\s*/\*|) { while ( $line !~ m|\*/|) { @@ -52,13 +54,27 @@ next if ($line =~ m[^\s*//]); next if ($line =~ m[^\}\s*$ir->{name};]); - if ($line =~ m|__code (\w+)\(([()\.\*\s\w,_]+)\)|) { - $line = "enum Code $1;\n"; + if ($line =~ m|__code (\w+)|) { + push(@tmp_args,"enum Code $1;\n"); + my $args = $'; + #$args eq (Impl* vm, pde_t* pgdir, char* init, uint sz, __code next(...)); + while ($args =~ /((?:struct|union|const)\s+)?([\w*\[\]_]+)\s*(\w+),?/g) { + my $const_type = $1; + my $type = $2; + my $vname = $3; + next if ($type eq '__code'); + $type =~ s/(?:Impl|Type|Isa)/union Data/; + my $val = "$type $vname;\n"; + push(@tmp_args, $const_type ? "$const_type$val" : $val); + } + next; } - push(@{$ir->{content}},$line); + $line =~ s/^\s+//; + push(@tmp_args,$line); } + push(@{$ir->{content}}, uniq(@tmp_args)); return $ir; } @@ -298,5 +314,4 @@ return \%res; } - 1; diff -r 875ad11af596 -r 26be78edaf83 src/impl/pipe.h --- a/src/impl/pipe.h Sun Feb 02 13:31:03 2020 +0900 +++ b/src/impl/pipe.h Mon Feb 03 17:12:35 2020 +0900 @@ -9,8 +9,10 @@ int writeopen; // write fd is still open int ref; // reference count + /* char readable; char writable; + */ unsigned int off; // interface field diff -r 875ad11af596 -r 26be78edaf83 src/impl/vm_impl.h --- a/src/impl/vm_impl.h Sun Feb 02 13:31:03 2020 +0900 +++ b/src/impl/vm_impl.h Mon Feb 03 17:12:35 2020 +0900 @@ -39,8 +39,8 @@ __code uva2ka_check_pe_types(Type* vm_impl, pde_t* pgdir, char* uva, __code next(...)); __code paging_intvm_impl(Type* vm_impl, uint phy_low, uint phy_hi, __code next(...)); __code copyout_loopvm_impl(Type* vm_impl, pde_t* pgdir, uint va, void* pp, uint len, __code next(...)); - __code switchuvm_check_pgdirvm_impl(struct vm_impl* vm_impl, struct proc* p, __code next(...)); - __code init_inituvm_check_sz(struct vm_impl* vm_impl, pde_t* pgdir, char* init, uint sz, __code next(...)); + __code switchuvm_check_pgdirvm_impl(Type* vm_impl, proc_struct* p, __code next(...)); + __code init_inituvm_check_sz(Type* vm_impl, pde_t* pgdir, char* init, uint sz, __code next(...)); __code void_ret(Type* vm_impl); __code next(...); } vm_impl;