Subversion Repositories gelsvn

Rev

Rev 198 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
107 bj 1
package Creator;
2
 
3
# ************************************************************
4
# Description   : Base class for workspace and project creators
5
# Author        : Chad Elliott
6
# Create Date   : 5/13/2002
7
# ************************************************************
8
 
9
# ************************************************************
10
# Pragmas
11
# ************************************************************
12
 
13
use strict;
14
use FileHandle;
15
 
16
use Parser;
17
 
18
use vars qw(@ISA);
19
@ISA = qw(Parser);
20
 
21
# ************************************************************
22
# Data Section
23
# ************************************************************
24
 
217 bj 25
my($assign_key)  = 'assign';
26
my($gassign_key) = 'global_assign';
27
 
107 bj 28
my(@statekeys) = ('global', 'include', 'template', 'ti',
29
                  'dynamic', 'static', 'relative', 'addtemp',
30
                  'addproj', 'progress', 'toplevel', 'baseprojs',
31
                  'feature_file', 'features', 'hierarchy',
32
                  'name_modifier', 'apply_project', 'into', 'use_env',
217 bj 33
                  'expand_vars', 'language',
107 bj 34
                 );
35
 
36
my(%all_written) = ();
217 bj 37
my($onVMS) = ($^O eq 'VMS');
107 bj 38
 
39
# ************************************************************
40
# Subroutine Section
41
# ************************************************************
42
 
43
sub new {
44
  my($class)      = shift;
45
  my($global)     = shift;
46
  my($inc)        = shift;
47
  my($template)   = shift;
48
  my($ti)         = shift;
49
  my($dynamic)    = shift;
50
  my($static)     = shift;
51
  my($relative)   = shift;
52
  my($addtemp)    = shift;
53
  my($addproj)    = shift;
54
  my($progress)   = shift;
55
  my($toplevel)   = shift;
56
  my($baseprojs)  = shift;
57
  my($feature)    = shift;
58
  my($features)   = shift;
59
  my($hierarchy)  = shift;
60
  my($nmodifier)  = shift;
61
  my($applypj)    = shift;
62
  my($into)       = shift;
63
  my($language)   = shift;
64
  my($use_env)    = shift;
65
  my($expandvars) = shift;
66
  my($type)       = shift;
67
  my($self)       = Parser::new($class, $inc);
68
 
69
  $self->{'relative'}        = $relative;
70
  $self->{'template'}        = $template;
71
  $self->{'ti'}              = $ti;
72
  $self->{'global'}          = $global;
73
  $self->{'grammar_type'}    = $type;
74
  $self->{'type_check'}      = $type . '_defined';
75
  $self->{'global_read'}     = 0;
76
  $self->{'current_input'}   = '';
77
  $self->{'progress'}        = $progress;
78
  $self->{'addtemp'}         = $addtemp;
79
  $self->{'addproj'}         = $addproj;
80
  $self->{'toplevel'}        = $toplevel;
81
  $self->{'files_written'}   = {};
82
  $self->{'real_fwritten'}   = [];
83
  $self->{'reading_global'}  = 0;
217 bj 84
  $self->{$gassign_key}      = {};
85
  $self->{$assign_key}       = {};
107 bj 86
  $self->{'baseprojs'}       = $baseprojs;
87
  $self->{'dynamic'}         = $dynamic;
88
  $self->{'static'}          = $static;
89
  $self->{'feature_file'}    = $feature;
90
  $self->{'features'}        = $features;
91
  $self->{'hierarchy'}       = $hierarchy;
92
  $self->{'name_modifier'}   = $nmodifier;
93
  $self->{'apply_project'}   = $applypj;
94
  $self->{'into'}            = $into;
95
  $self->{'language'}        = $language;
96
  $self->{'use_env'}         = $use_env;
97
  $self->{'expand_vars'}     = $expandvars;
98
  $self->{'convert_slashes'} = $self->convert_slashes();
217 bj 99
  $self->{'case_tolerant'}   = $self->case_insensitive();
107 bj 100
 
101
  return $self;
102
}
103
 
104
 
105
sub preprocess_line {
106
  my($self) = shift;
107
  my($fh)   = shift;
108
  my($line) = shift;
109
 
110
  $line = $self->strip_line($line);
111
  while ($line =~ /\\$/) {
112
    $line =~ s/\s*\\$/ /;
113
    my($next) = $fh->getline();
114
    if (defined $next) {
115
      $line .= $self->strip_line($next);
116
    }
117
  }
118
  return $line;
119
}
120
 
121
 
122
sub generate_default_input {
123
  my($self)  = shift;
124
  my($status,
125
     $error) = $self->parse_line(undef, "$self->{'grammar_type'} {");
126
 
127
  if ($status) {
128
    ($status, $error) = $self->parse_line(undef, '}');
129
  }
130
 
131
  if (!$status) {
132
    $self->error($error);
133
  }
134
 
135
  return $status;
136
}
137
 
138
 
139
sub parse_file {
140
  my($self)  = shift;
141
  my($input) = shift;
142
  my($oline) = $self->get_line_number();
143
 
144
  ## Read the input file and get the last line number
145
  my($status, $errorString) = $self->read_file($input);
146
 
147
  if (!$status) {
148
    $self->error($errorString,
149
                 "$input: line " . $self->get_line_number() . ':');
150
  }
151
  elsif ($status && $self->{$self->{'type_check'}}) {
152
    ## If we are at the end of the file and the type we are looking at
153
    ## is still defined, then we have an error
154
    $self->error("Did not " .
155
                 "find the end of the $self->{'grammar_type'}",
156
                 "$input: line " . $self->get_line_number() . ':');
157
    $status = 0;
158
  }
159
  $self->set_line_number($oline);
160
 
161
  return $status;
162
}
163
 
164
 
165
sub generate {
166
  my($self)   = shift;
167
  my($input)  = shift;
168
  my($status) = 1;
169
 
170
  ## Reset the files_written hash array between processing each file
171
  $self->{'files_written'} = {};
172
  $self->{'real_fwritten'} = [];
173
 
174
  ## Allow subclasses to reset values before
175
  ## each call to generate().
176
  $self->reset_values();
177
 
178
  ## Read the global configuration file
179
  if (!$self->{'global_read'}) {
180
    $status = $self->read_global_configuration();
181
    $self->{'global_read'} = 1;
182
  }
183
 
184
  if ($status) {
185
    $self->{'current_input'} = $input;
186
 
187
    ## An empty input file name says that we
188
    ## should generate a default input file and use that
189
    if ($input eq '') {
190
      $status = $self->generate_default_input();
191
    }
192
    else {
193
      $status = $self->parse_file($input);
194
    }
195
  }
196
 
197
  return $status;
198
}
199
 
200
 
201
sub parse_assignment {
202
  my($self)   = shift;
203
  my($line)   = shift;
204
  my($values) = shift;
205
 
217 bj 206
  if ($line =~ /^(\w+(::\w+)*)\s*([\-+]?=)\s*(.*)?/) {
207
    push(@$values, $3, lc($1), $4);
107 bj 208
    return 1;
209
  }
210
 
211
  return 0;
212
}
213
 
214
 
215
sub parse_known {
216
  my($self)        = shift;
217
  my($line)        = shift;
218
  my($status)      = 1;
219
  my($errorString) = undef;
220
  my($type)        = $self->{'grammar_type'};
221
  my(@values)      = ();
222
 
223
  ##
224
  ## Each regexp that looks for the '{' looks for it at the
225
  ## end of the line.  It is purposely this way to decrease
226
  ## the amount of extra lines in each file.  This
227
  ## allows for the most compact file as human readably
228
  ## possible.
229
  ##
230
  if ($line eq '') {
231
  }
232
  elsif ($line =~ /^$type\s*(\([^\)]+\))?\s*(:.*)?\s*{$/) {
233
    my($name)    = $1;
234
    my($parents) = $2;
235
    if ($self->{$self->{'type_check'}}) {
236
      $errorString = "Did not find the end of the $type";
237
      $status = 0;
238
    }
239
    else {
240
      if (defined $parents) {
217 bj 241
        $parents =~ s/^:\s*//;
242
        $parents =~ s/\s+$//;
243
        my(@parents) = split(/\s*,\s*/, $parents);
107 bj 244
        if (!defined $parents[0]) {
245
          ## The : was used, but no parents followed.  This
246
          ## is an error.
247
          $errorString = 'No parents listed';
248
          $status = 0;
249
        }
250
        $parents = \@parents;
251
      }
252
      push(@values, $type, $name, $parents);
253
    }
254
  }
255
  elsif ($line =~ /^}$/) {
256
    if ($self->{$self->{'type_check'}}) {
257
      push(@values, $type, $line);
258
    }
259
    else {
260
      $errorString = "Did not find the beginning of the $type";
261
      $status = 0;
262
    }
263
  }
264
  elsif ($line =~ /^(feature)\s*\(([^\)]+)\)\s*(:.*)?\s*{$/) {
265
    my($type)    = $1;
266
    my($name)    = $2;
267
    my($parents) = $3;
268
    my(@names)   = split(/\s*,\s*/, $name);
269
 
270
    if (defined $parents) {
217 bj 271
      $parents =~ s/^:\s*//;
272
      $parents =~ s/\s+$//;
273
      my(@parents) = split(/\s*,\s*/, $parents);
107 bj 274
      if (!defined $parents[0]) {
275
        ## The : was used, but no parents followed.  This
276
        ## is an error.
277
        $errorString = 'No parents listed';
278
        $status = 0;
279
      }
280
      $parents = \@parents;
281
    }
282
    push(@values, $type, \@names, $parents);
283
  }
284
  elsif (!$self->{$self->{'type_check'}}) {
285
    $errorString = "No $type was defined";
286
    $status = 0;
287
  }
288
  elsif ($self->parse_assignment($line, \@values)) {
289
    ## If this returns true, then we've found an assignment
290
  }
291
  elsif ($line =~ /^(\w+)\s*(\([^\)]+\))?\s*{$/) {
292
    my($comp) = lc($1);
293
    my($name) = $2;
294
 
295
    if (defined $name) {
296
      $name =~ s/^\(\s*//;
297
      $name =~ s/\s*\)$//;
298
    }
299
    else {
300
      $name = $self->get_default_component_name();
301
    }
302
    push(@values, 'component', $comp, $name);
303
  }
304
  else {
305
    $errorString = "Unrecognized line: $line";
306
    $status = -1;
307
  }
308
 
309
  return $status, $errorString, @values;
310
}
311
 
312
 
313
sub parse_scope {
314
  my($self)        = shift;
315
  my($fh)          = shift;
316
  my($name)        = shift;
317
  my($type)        = shift;
318
  my($validNames)  = shift;
319
  my($flags)       = shift;
320
  my($elseflags)   = shift;
321
  my($status)      = 0;
322
  my($errorString) = "Unable to process $name";
323
 
324
  if (!defined $flags) {
325
    $flags = {};
326
  }
327
 
328
  while(<$fh>) {
329
    my($line) = $self->preprocess_line($fh, $_);
330
 
331
    if ($line eq '') {
332
    }
333
    elsif ($line =~ /^}$/) {
334
      ($status, $errorString) = $self->handle_scoped_end($type, $flags);
335
      last;
336
    }
198 bj 337
    elsif ($line =~ /^}\s*else\s*{$/) {
338
      if (defined $elseflags) {
339
        ## From here on out anything after this goes into the $elseflags
340
        $flags = $elseflags;
341
        $elseflags = undef;
107 bj 342
 
198 bj 343
        ## We need to adjust the type also.  If there was a type
344
        ## then the first part of the clause was used.  If there was
345
        ## no type, then the first part was ignored and the second
346
        ## part will be used.
347
        if (defined $type) {
348
          $type = undef;
349
        }
350
        else {
351
          $type = $self->get_default_component_name();
352
        }
107 bj 353
      }
354
      else {
198 bj 355
        $status = 0;
356
        $errorString = 'An else is not allowed in this context';
357
        last;
107 bj 358
      }
359
    }
360
    else {
361
      my(@values) = ();
198 bj 362
      if (defined $validNames && $self->parse_assignment($line, \@values)) {
107 bj 363
        if (defined $$validNames{$values[1]}) {
217 bj 364
          if ($values[0] eq '=') {
107 bj 365
            $self->process_assignment($values[1], $values[2], $flags);
366
          }
217 bj 367
          elsif ($values[0] eq '+=') {
107 bj 368
            $self->process_assignment_add($values[1], $values[2], $flags);
369
          }
217 bj 370
          elsif ($values[0] eq '-=') {
107 bj 371
            $self->process_assignment_sub($values[1], $values[2], $flags);
372
          }
373
        }
374
        else {
375
          ($status,
376
           $errorString) = $self->handle_unknown_assignment($type,
377
                                                            @values);
378
          if (!$status) {
379
            last;
380
          }
381
        }
382
      }
383
      else {
384
        ($status, $errorString) = $self->handle_scoped_unknown($fh,
385
                                                               $type,
386
                                                               $flags,
387
                                                               $line);
388
        if (!$status) {
389
          last;
390
        }
391
      }
392
    }
393
  }
394
  return $status, $errorString;
395
}
396
 
397
 
398
sub base_directory {
399
  my($self) = shift;
217 bj 400
  return $self->mpc_basename($self->getcwd());
107 bj 401
}
402
 
403
 
404
sub generate_default_file_list {
405
  my($self)    = shift;
406
  my($dir)     = shift;
407
  my($exclude) = shift;
217 bj 408
  my($fileexc) = shift;
107 bj 409
  my($recurse) = shift;
410
  my($dh)      = new FileHandle();
411
  my(@files)   = ();
412
 
413
  if (opendir($dh, $dir)) {
414
    my($need_dir) = ($dir ne '.');
415
    my($skip)     = 0;
416
    foreach my $file (grep(!/^\.\.?$/, readdir($dh))) {
217 bj 417
      $file =~ s/\.dir$// if ($onVMS);
198 bj 418
 
107 bj 419
      ## Prefix each file name with the directory only if it's not '.'
420
      my($full) = ($need_dir ? "$dir/" : '') . $file;
421
 
422
      if (defined $$exclude[0]) {
423
        foreach my $exc (@$exclude) {
424
          if ($full eq $exc) {
425
            $skip = 1;
426
            last;
427
          }
428
        }
429
      }
430
 
431
      if ($skip) {
432
        $skip = 0;
217 bj 433
        $$fileexc = 1 if (defined $fileexc);
107 bj 434
      }
435
      else {
436
        if ($recurse && -d $full) {
437
          push(@files,
217 bj 438
               $self->generate_default_file_list($full, $exclude,
439
                                                 $fileexc, $recurse));
107 bj 440
        }
441
        else {
442
          push(@files, $full);
443
        }
444
      }
445
    }
446
 
447
    if ($self->sort_files()) {
448
      @files = sort { $self->file_sorter($a, $b) } @files;
449
    }
450
 
451
    closedir($dh);
452
  }
453
  return @files;
454
}
455
 
456
 
457
sub transform_file_name {
458
  my($self) = shift;
459
  my($name) = shift;
460
 
461
  $name =~ s/[\s\-]/_/g;
462
  return $name;
463
}
464
 
465
 
466
sub file_written {
467
  my($self) = shift;
468
  my($file) = shift;
469
  return (defined $all_written{$self->getcwd() . '/' . $file});
470
}
471
 
472
 
473
sub add_file_written {
474
  my($self) = shift;
475
  my($file) = shift;
476
  my($key)  = lc($file);
477
 
478
  if (defined $self->{'files_written'}->{$key}) {
217 bj 479
    $self->warning("$self->{'grammar_type'} $file " .
480
                   ($self->{'case_tolerant'} ?
481
                           "has been overwritten." :
482
                           "of differing case has been processed."));
107 bj 483
  }
484
  else {
485
    $self->{'files_written'}->{$key} = $file;
486
    push(@{$self->{'real_fwritten'}}, $file);
487
  }
488
 
489
  $all_written{$self->getcwd() . '/' . $file} = 1;
490
}
491
 
492
 
493
sub extension_recursive_input_list {
494
  my($self)    = shift;
495
  my($dir)     = shift;
496
  my($exclude) = shift;
497
  my($ext)     = shift;
498
  my($fh)      = new FileHandle();
499
  my(@files)   = ();
500
 
501
  if (opendir($fh, $dir)) {
502
    foreach my $file (grep(!/^\.\.?$/, readdir($fh))) {
217 bj 503
      $file =~ s/\.dir$// if ($onVMS);
198 bj 504
 
107 bj 505
      my($skip) = 0;
506
      my($full) = ($dir ne '.' ? "$dir/" : '') . $file;
507
 
508
      ## Check for command line exclusions
509
      if (defined $$exclude[0]) {
510
        foreach my $exc (@$exclude) {
511
          if ($full eq $exc) {
512
            $skip = 1;
513
            last;
514
          }
515
        }
516
      }
517
 
518
      ## If we are not skipping this directory or file, then check it out
519
      if (!$skip) {
520
        if (-d $full) {
521
          push(@files, $self->extension_recursive_input_list($full,
522
                                                             $exclude,
523
                                                             $ext));
524
        }
525
        elsif ($full =~ /$ext$/) {
526
          push(@files, $full);
527
        }
528
      }
529
    }
530
    closedir($fh);
531
  }
532
 
533
  return @files;
534
}
535
 
536
 
537
sub modify_assignment_value {
538
  my($self)  = shift;
539
  my($name)  = shift;
540
  my($value) = shift;
541
 
217 bj 542
  if ($self->{'convert_slashes'} && index($name, 'flags') == -1) {
543
    $value =~ s/\//\\/g;
107 bj 544
  }
545
  return $value;
546
}
547
 
548
 
549
sub get_assignment_hash {
550
  ## NOTE: If anything in this block changes, then you must make the
551
  ## same change in process_assignment.
217 bj 552
  my($self) = shift;
553
  return $self->{$self->{'reading_global'} ? $gassign_key : $assign_key};
107 bj 554
}
555
 
556
 
557
sub process_assignment {
558
  my($self)   = shift;
559
  my($name)   = shift;
560
  my($value)  = shift;
561
  my($assign) = shift;
562
 
563
  ## If no hash table was passed in
564
  if (!defined $assign) {
565
    ## NOTE: If anything in this block changes, then you must make the
566
    ## same change in get_assignment_hash.
217 bj 567
    $assign  = $self->{$self->{'reading_global'} ?
568
                               $gassign_key : $assign_key};
107 bj 569
  }
570
 
571
  if (defined $value) {
572
    $value =~ s/^\s+//;
573
    $value =~ s/\s+$//;
574
 
575
    ## Modify the assignment value before saving it
576
    $$assign{$name} = $self->modify_assignment_value($name, $value);
577
  }
578
  else {
579
    $$assign{$name} = undef;
580
  }
581
}
582
 
583
 
584
sub process_assignment_add {
585
  my($self)   = shift;
586
  my($name)   = shift;
587
  my($value)  = shift;
588
  my($assign) = shift;
589
  my($nval)   = $self->get_assignment_for_modification($name, $assign);
590
 
591
  ## Remove all duplicate parts from the value to be added.
592
  ## Whether anything gets removed or not is up to the implementation
593
  ## of the sub classes.
594
  $value = $self->remove_duplicate_addition($name, $value, $nval);
595
 
596
  ## If there is anything to add, then do so
597
  if ($value ne '') {
598
    if (defined $nval) {
599
      if ($self->preserve_assignment_order($name)) {
600
        $nval .= " $value";
601
      }
602
      else {
603
        $nval = "$value $nval";
604
      }
605
    }
606
    else {
607
      $nval = $value;
608
    }
609
    $self->process_assignment($name, $nval, $assign);
610
  }
611
}
612
 
613
 
614
sub process_assignment_sub {
615
  my($self)   = shift;
616
  my($name)   = shift;
617
  my($value)  = shift;
618
  my($assign) = shift;
217 bj 619
  my($nval)   = $self->get_assignment_for_modification($name, $assign);
107 bj 620
 
621
  if (defined $nval) {
622
    ## Remove double quotes if there are any
623
    $value =~ s/^\"(.*)\"$/$1/;
624
 
625
    ## Escape any regular expression special characters
626
    $value = $self->escape_regex_special($value);
627
 
217 bj 628
    my($last)  = 1;
629
    my($found) = undef;
630
    for(my $i = 0; $i <= $last; $i++) {
631
      if ($i == $last) {
632
        ## If we did not find the string to subtract in the original
633
        ## value, try again after expanding template variables for
634
        ## subtraction.
635
        $nval = $self->get_assignment_for_modification($name, $assign, 1);
198 bj 636
      }
217 bj 637
      for(my $j = 0; $j <= $last; $j++) {
638
        ## If we didn't find it the first time, try again with quotes
639
        my($re) = ($j == $last ? '"' . $value . '"' : $value);
640
 
641
        ## Due to the way process_assignment() works, we only need to
642
        ## attempt to remove a value that is either followed by a space
643
        ## or at the end of the line (single values are always at the end
644
        ## of the line).
645
        if ($nval =~ s/$re\s+// || $nval =~ s/$re$//) {
646
          $self->process_assignment($name, $nval, $assign);
647
          $found = 1;
648
          last;
649
        }
650
      }
651
      last if ($found);
198 bj 652
    }
107 bj 653
  }
654
}
655
 
656
 
657
sub fill_type_name {
658
  my($self)  = shift;
659
  my($names) = shift;
660
  my($def)   = shift;
661
  my($array) = ($names =~ /\s/ ? $self->create_array($names) : [$names]);
662
 
663
  $names = '';
664
  foreach my $name (@$array) {
665
    if ($name =~ /\*/) {
666
      my($pre)  = $def . '_';
667
      my($mid)  = '_' . $def . '_';
668
      my($post) = '_' . $def;
669
 
670
      ## Replace the beginning and end first then the middle
671
      $name =~ s/^\*/$pre/;
672
      $name =~ s/\*$/$post/;
673
      $name =~ s/\*/$mid/g;
674
 
675
      ## Remove any trailing underscore or any underscore that is followed
676
      ## by a space.  This value could be a space separated list.
677
      $name =~ s/_$//;
678
      $name =~ s/_\s/ /g;
679
      $name =~ s/\s_/ /g;
680
 
681
      ## If any one word is capitalized then capitalize each word
682
      if ($name =~ /[A-Z][0-9a-z_]+/) {
683
        ## Do the first word
684
        if ($name =~ /^([a-z])([^_]+)/) {
685
          my($first) = uc($1);
686
          my($rest)  = $2;
687
          $name =~ s/^[a-z][^_]+/$first$rest/;
688
        }
689
        ## Do subsequent words
690
        while($name =~ /(_[a-z])([^_]+)/) {
691
          my($first) = uc($1);
692
          my($rest)  = $2;
693
          $name =~ s/_[a-z][^_]+/$first$rest/;
694
        }
695
      }
696
    }
697
 
698
    $names .= $name . ' ';
699
  }
700
  $names =~ s/\s+$//;
701
 
702
  return $names;
703
}
704
 
705
 
706
sub save_state {
707
  my($self)     = shift;
708
  my($selected) = shift;
709
  my(%state)    = ();
710
 
711
  ## Make a deep copy of each state value.  That way our array
712
  ## references and hash references do not get accidentally modified.
713
  foreach my $skey (defined $selected ? $selected : @statekeys) {
714
    if (defined $self->{$skey}) {
715
      if (UNIVERSAL::isa($self->{$skey}, 'ARRAY')) {
716
        $state{$skey} = [];
717
        foreach my $element (@{$self->{$skey}}) {
718
          push(@{$state{$skey}}, $element);
719
        }
720
      }
721
      elsif (UNIVERSAL::isa($self->{$skey}, 'HASH')) {
722
        $state{$skey} = {};
723
        foreach my $key (keys %{$self->{$skey}}) {
724
          $state{$skey}->{$key} = $self->{$skey}->{$key};
725
        }
726
      }
727
      else {
728
        $state{$skey} = $self->{$skey};
729
      }
730
    }
731
  }
732
 
733
  return %state;
734
}
735
 
736
 
737
sub restore_state {
738
  my($self)     = shift;
739
  my($state)    = shift;
740
  my($selected) = shift;
741
 
742
  ## Make a deep copy of each state value.  That way our array
743
  ## references and hash references do not get accidentally modified.
744
  foreach my $skey (defined $selected ? $selected : @statekeys) {
745
    if (defined $state->{$skey}) {
746
      if (UNIVERSAL::isa($state->{$skey}, 'ARRAY')) {
747
        my(@arr) = @{$state->{$skey}};
748
        $self->{$skey} = \@arr;
749
      }
750
      elsif (UNIVERSAL::isa($state->{$skey}, 'HASH')) {
751
        my(%hash) = %{$state->{$skey}};
752
        $self->{$skey} = \%hash;
753
      }
754
      else {
755
        $self->{$skey} = $state->{$skey};
756
      }
757
    }
758
  }
759
}
760
 
761
 
762
sub get_global_cfg {
763
  my($self) = shift;
764
  return $self->{'global'};
765
}
766
 
767
 
768
sub get_template_override {
769
  my($self) = shift;
770
  return $self->{'template'};
771
}
772
 
773
 
774
sub get_ti_override {
775
  my($self) = shift;
776
  return $self->{'ti'};
777
}
778
 
779
 
780
sub get_relative {
781
  my($self) = shift;
782
  return $self->{'relative'};
783
}
784
 
785
 
786
sub get_progress_callback {
787
  my($self) = shift;
788
  return $self->{'progress'};
789
}
790
 
791
 
792
sub get_addtemp {
793
  my($self) = shift;
794
  return $self->{'addtemp'};
795
}
796
 
797
 
798
sub get_addproj {
799
  my($self) = shift;
800
  return $self->{'addproj'};
801
}
802
 
803
 
804
sub get_toplevel {
805
  my($self) = shift;
806
  return $self->{'toplevel'};
807
}
808
 
809
 
810
sub get_into {
811
  my($self) = shift;
812
  return $self->{'into'};
813
}
814
 
815
 
816
sub get_use_env {
817
  my($self) = shift;
818
  return $self->{'use_env'};
819
}
820
 
821
 
822
sub get_expand_vars {
823
  my($self) = shift;
824
  return $self->{'expand_vars'};
825
}
826
 
827
 
828
sub get_files_written {
829
  my($self)  = shift;
830
  return $self->{'real_fwritten'};
831
}
832
 
833
 
834
sub get_assignment {
835
  my($self)   = shift;
836
  my($name)   = shift;
837
  my($assign) = shift;
838
 
839
  ## If no hash table was passed in
840
  if (!defined $assign) {
217 bj 841
    $assign = $self->{$self->{'reading_global'} ?
842
                              $gassign_key : $assign_key};
107 bj 843
  }
844
 
845
  return $$assign{$name};
846
}
847
 
848
 
849
sub get_assignment_for_modification {
850
  my($self)        = shift;
851
  my($name)        = shift;
852
  my($assign)      = shift;
853
  my($subtraction) = shift;
854
  return $self->get_assignment($name, $assign);
855
}
856
 
857
 
858
sub get_baseprojs {
859
  my($self) = shift;
860
  return $self->{'baseprojs'};
861
}
862
 
863
 
864
sub get_dynamic {
865
  my($self) = shift;
866
  return $self->{'dynamic'};
867
}
868
 
869
 
870
sub get_static {
871
  my($self) = shift;
872
  return $self->{'static'};
873
}
874
 
875
 
876
sub get_default_component_name {
877
  #my($self) = shift;
878
  return 'default';
879
}
880
 
881
 
882
sub get_hierarchy {
883
  my($self) = shift;
884
  return $self->{'hierarchy'};
885
}
886
 
887
 
888
sub get_name_modifier {
889
  my($self) = shift;
890
  return $self->{'name_modifier'};
891
}
892
 
893
 
894
sub get_apply_project {
895
  my($self) = shift;
896
  return $self->{'apply_project'};
897
}
898
 
899
 
900
sub get_language {
901
  my($self) = shift;
902
  return $self->{'language'};
903
}
904
 
217 bj 905
 
107 bj 906
sub get_outdir {
907
  my($self) = shift;
908
  if (defined $self->{'into'}) {
909
    my($outdir) = $self->getcwd();
910
    my($re)     = $self->escape_regex_special($self->getstartdir());
911
 
912
    $outdir =~ s/^$re//;
913
    return $self->{'into'} . $outdir;
914
  }
915
  else {
916
    return '.';
917
  }
918
}
919
 
920
# ************************************************************
921
# Virtual Methods To Be Overridden
922
# ************************************************************
923
 
924
sub preserve_assignment_order {
925
  #my($self) = shift;
926
  #my($name) = shift;
927
  return 1;
928
}
929
 
930
 
931
sub compare_output {
932
  #my($self) = shift;
933
  return 0;
934
}
935
 
936
 
937
sub handle_scoped_end {
938
  #my($self)  = shift;
939
  #my($type)  = shift;
940
  #my($flags) = shift;
941
  return 1, undef;
942
}
943
 
944
 
945
sub handle_unknown_assignment {
946
  my($self)   = shift;
947
  my($type)   = shift;
948
  my(@values) = @_;
949
  return 0, "Invalid assignment name: $values[1]";
950
}
951
 
952
 
953
sub handle_scoped_unknown {
954
  my($self)  = shift;
955
  my($fh)    = shift;
956
  my($type)  = shift;
957
  my($flags) = shift;
958
  my($line)  = shift;
959
  return 0, "Unrecognized line: $line";
960
}
961
 
962
 
963
sub remove_duplicate_addition {
964
  my($self)    = shift;
965
  my($name)    = shift;
966
  my($value)   = shift;
967
  my($current) = shift;
968
  return $value;
969
}
970
 
971
 
972
sub generate_recursive_input_list {
973
  #my($self)    = shift;
974
  #my($dir)     = shift;
975
  #my($exclude) = shift;
976
  return ();
977
}
978
 
979
 
980
sub reset_values {
981
  #my($self) = shift;
982
}
983
 
984
 
985
sub sort_files {
986
  #my($self) = shift;
987
  return 1;
988
}
989
 
990
 
991
sub file_sorter {
217 bj 992
  #my($self)  = shift;
993
  #my($left)  = shift;
994
  #my($right) = shift;
995
  return $_[1] cmp $_[2];
107 bj 996
}
997
 
998
 
999
sub read_global_configuration {
1000
  #my($self)  = shift;
1001
  #my($input) = shift;
1002
  return 1;
1003
}
1004
 
1005
 
1006
1;