diff options
author | elliott_c <ocielliottc@users.noreply.github.com> | 2003-04-10 19:15:04 +0000 |
---|---|---|
committer | elliott_c <ocielliottc@users.noreply.github.com> | 2003-04-10 19:15:04 +0000 |
commit | 1e531c59d9c8f36ba2f62eafca00822cfb0e135b (patch) | |
tree | 51bd747583ebf7233e17f2b1c8fbc6a206428c69 | |
parent | 9a3d0d794702c7e1212989fca138f5e27d74189d (diff) | |
download | MPC-1e531c59d9c8f36ba2f62eafca00822cfb0e135b.tar.gz |
ChangeLogTag: Thu Apr 10 14:14:17 2003 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r-- | modules/Creator.pm | 93 | ||||
-rw-r--r-- | modules/ProjectCreator.pm | 37 | ||||
-rw-r--r-- | modules/WorkspaceCreator.pm | 87 |
3 files changed, 151 insertions, 66 deletions
diff --git a/modules/Creator.pm b/modules/Creator.pm index 552f4140..c1400dda 100644 --- a/modules/Creator.pm +++ b/modules/Creator.pm @@ -277,6 +277,66 @@ sub parse_known { } +sub parse_scope { + my($self) = shift; + my($fh) = shift; + my($name) = shift; + my($type) = shift; + my($validNames) = shift; + my($flags) = shift; + my($status) = 0; + my($errorString) = "ERROR: Unable to process $name"; + + if (!defined $flags) { + $flags = {}; + } + + while(<$fh>) { + my($line) = $self->strip_line($_); + + if ($line eq '') { + } + elsif ($line =~ /^}/) { + $status = 1; + $errorString = ''; + $self->handle_scoped_end($type, $flags); + last; + } + else { + my(@values) = (); + if ($self->parse_assignment($line, \@values)) { + if (defined $$validNames{$values[1]}) { + if ($values[0] eq 'assignment') { + $self->process_assignment($values[1], $values[2], $flags); + } + elsif ($values[0] eq 'assign_add') { + $self->process_assignment_add($values[1], $values[2], $flags); + } + elsif ($values[0] eq 'assign_sub') { + $self->process_assignment_sub($values[1], $values[2], $flags); + } + } + else { + $status = 0; + $errorString = "ERROR: Invalid assignment name: $values[1]"; + last; + } + } + else { + ($status, $errorString) = $self->handle_scoped_unknown($fh, + $type, + $flags, + $line); + if (!$status) { + last; + } + } + } + } + return $status, $errorString; +} + + sub base_directory { my($self) = shift; return basename($self->getcwd()); @@ -419,6 +479,7 @@ sub process_assignment_add { my($value) = shift; my($assign) = shift; my($nval) = $self->get_assignment($name, $assign); + if (defined $nval) { $nval = "$value $nval"; } @@ -550,10 +611,17 @@ sub get_files_written { sub get_assignment { - my($self) = shift; - my($name) = shift; - my($tag) = ($self->{'reading_global'} ? 'global_assign' : 'assign'); - return $self->{$tag}->{$name}; + my($self) = shift; + my($name) = shift; + my($assign) = shift; + + ## If no hash table was passed in + if (!defined $assign) { + my($tag) = ($self->{'reading_global'} ? 'global_assign' : 'assign'); + $assign = $self->{$tag}; + } + + return $$assign{$name}; } @@ -578,6 +646,23 @@ sub get_static { # Virtual Methods To Be Overridden # ************************************************************ +sub handle_scoped_end { + #my($self) = shift; + #my($type) = shift; + #my($flags) = shift; +} + + +sub handle_scoped_unknown { + my($self) = shift; + my($fh) = shift; + my($type) = shift; + my($flags) = shift; + my($line) = shift; + return 0, "ERROR: Unrecognized line: $line"; +} + + sub process_duplicate_modification { #my($self) = shift; #my($name) = shift; diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm index 1af95d62..112e6f75 100644 --- a/modules/ProjectCreator.pm +++ b/modules/ProjectCreator.pm @@ -128,6 +128,8 @@ sub new { $self->{'valid_components'} = \%vc; $self->{'exclude_components'} = \%ec; $self->{'skeleton_endings'} = [ 'C', 'S' ]; + $self->{'type_specific_assign'} = {}; + $self->{'pctype'} = $self->extractType("$self"); ## Allow subclasses to override the default extensions $self->set_component_extensions(); @@ -177,6 +179,14 @@ sub parse_line { ## Fill in all the default values $self->generate_defaults(); + ## Fill in type specific assignments + my($tsa) = $self->{'type_specific_assign'}->{$self->{'pctype'}}; + if (defined $tsa) { + foreach my $key (keys %$tsa) { + $self->process_assignment_add($key, $$tsa{$key}); + } + } + ## Perform any additions, subtractions ## or overrides for the project values. my($addproj) = $self->get_addproj(); @@ -209,6 +219,7 @@ sub parse_line { } $self->{'assign'} = {}; $self->{'verbatim'} = {}; + $self->{'type_specific_assign'} = {}; } } $self->{$typecheck} = 0; @@ -349,6 +360,11 @@ sub parse_line { $status = 0; } } + elsif ($comp eq 'specific') { + ($status, $errorString) = $self->parse_scope( + $ih, $values[1], $values[2], \%validNames, + $self->{'type_specific_assign'}->{$self->{'pctype'}}); + } else { $errorString = "ERROR: Invalid component name: $comp"; $status = 0; @@ -517,6 +533,22 @@ sub parse_verbatim { } +sub handle_scoped_end { + my($self) = shift; + my($type) = shift; + my($flags) = shift; + + if (defined $self->{'type_specific_assign'}->{$type}) { + foreach my $key (keys %$flags) { + $self->{'type_specific_assign'}->{$type}->{$key} = $$flags{$key}; + } + } + else { + $self->{'type_specific_assign'}->{$type} = $flags; + } +} + + sub process_duplicate_modification { my($self) = shift; my($name) = shift; @@ -1284,7 +1316,7 @@ sub need_to_write_project { } } } - + return 0; } @@ -1490,9 +1522,8 @@ sub update_project_info { sub get_verbatim { my($self) = shift; my($marker) = shift; - my($type) = $self->extractType("$self"); my($str) = undef; - my($thash) = $self->{'verbatim'}->{$type}; + my($thash) = $self->{'verbatim'}->{$self->{'pctype'}}; if (defined $thash) { if (defined $thash->{$marker}) { diff --git a/modules/WorkspaceCreator.pm b/modules/WorkspaceCreator.pm index 55e6409b..2901fdac 100644 --- a/modules/WorkspaceCreator.pm +++ b/modules/WorkspaceCreator.pm @@ -189,7 +189,10 @@ sub parse_line { } } elsif ($values[0] eq 'component') { - ($status, $errorString) = $self->parse_scope($ih, $values[1]); + ($status, $errorString) = $self->parse_scope($ih, + $values[1], + $values[2], + \%validNames); } else { $errorString = "ERROR: Unrecognized line: $line"; @@ -205,68 +208,34 @@ sub parse_line { } -sub parse_scope { - my($self) = shift; - my($fh) = shift; - my($name) = shift; - my($status) = 0; - my($errorString) = "ERROR: Unable to process $name"; - my(%flags) = (); - - while(<$fh>) { - my($line) = $self->strip_line($_); - - if ($line eq '') { - } - elsif ($line =~ /^}/) { - $status = 1; - $errorString = ''; - last; +sub handle_scoped_unknown { + my($self) = shift; + my($fh) = shift; + my($type) = shift; + my($flags) = shift; + my($line) = shift; + + if (-e $line) { + if (-d $line) { + ## This would be too hard to track which files + ## got the scoped assignments, so we ignore these. + print "WARNING: Scoped directory " . + "assignments will be ignored: $line\n"; } else { - my(@values) = (); - if ($self->parse_assignment($line, \@values)) { - if (defined $validNames{$values[1]}) { - if ($values[0] eq 'assignment') { - $self->process_assignment($values[1], $values[2], \%flags); - } - elsif ($values[0] eq 'assign_add') { - $self->process_assignment_add($values[1], $values[2], \%flags); - } - elsif ($values[0] eq 'assign_sub') { - $self->process_assignment_sub($values[1], $values[2], \%flags); - } - } - else { - $status = 0; - $errorString = "ERROR: Invalid assignment name: $values[1]"; - last; - } - } - else { - if (-e $line) { - if (-d $line) { - ## This would be too hard to track which files - ## got the scoped assignments, so we ignore these. - print "WARNING: Scoped directory " . - "assignments will be ignored: $line\n"; - } - else { - ## Assignment store - $self->{'scoped_assign'}->{$line} = \%flags; - } - } - else { - ## We couldn't determine if it was an mpc file or - ## a directory, so we ignore these. - print "WARNING: Scoped file does not " . - "exist, so assignments will be ignored: $line\n"; - } - push(@{$self->{'project_files'}}, $line); - } + ## Assignment store + $self->{'scoped_assign'}->{$line} = $flags; } } - return $status, $errorString; + else { + ## We couldn't determine if it was an mpc file or + ## a directory, so we ignore these. + print "WARNING: Scoped file does not " . + "exist, so assignments will be ignored: $line\n"; + } + push(@{$self->{'project_files'}}, $line); + + return 1, ''; } |