| 1 | package Lang::Tree::Builder::Data; | ||||||||||
| 2 | |||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 4 | ▶ | use Lang::Tree::Builder::Class; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 4 | our $VERSION = '0.01'; | |||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | =head1 NAME | ||||||||||
| 11 | |||||||||||
| 12 | Lang::Tree::Builder::Data - Tree Data | ||||||||||
| 13 | |||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||
| 15 | |||||||||||
| 16 | use Lang::Tree::Builder::Parser; | ||||||||||
| 17 | my $parser = new Lang::Tree::Builder::Parser(); | ||||||||||
| 18 | my $data = $parser->parseFile($datafile); | ||||||||||
| 19 | foreach my $class ($data->classes()) { | ||||||||||
| 20 | my $parent = $class->parent(); | ||||||||||
| 21 | my @args = $class->args(); | ||||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | =head1 DESCRIPTION | ||||||||||
| 25 | |||||||||||
| 26 | =head2 new | ||||||||||
| 27 | |||||||||||
| 28 | my $data = new Lang::Tree::Builder::Data; | ||||||||||
| 29 | |||||||||||
| 30 | Creates and returns a new instance of Data. Don't do this, the parser | ||||||||||
| 31 | does it for you. | ||||||||||
| 32 | |||||||||||
| 33 | =cut | ||||||||||
| 34 | |||||||||||
| 35 | 2 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 36 | 2 | my ($class) = @_; | |||||||||
| 37 | 2 | bless { | |||||||||
| 38 | classes => {}, | ||||||||||
| 39 | }, $class; | ||||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | =head2 add | ||||||||||
| 43 | |||||||||||
| 44 | $data->add($class); | ||||||||||
| 45 | |||||||||||
| 46 | C<$class> is a C<Lang::Tree::Builder::Class>. Again the parser does this for you. | ||||||||||
| 47 | The C<$data> object merely caches the class object. | ||||||||||
| 48 | Note that this is only called for classes that are | ||||||||||
| 49 | declared in the config, not for classes that are just mentioned as argument | ||||||||||
| 50 | types for other constructors. | ||||||||||
| 51 | |||||||||||
| 52 | =cut | ||||||||||
| 53 | |||||||||||
| 54 | 2 | ▶ | sub add { | ||||||||
|
Subroutine
add: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 55 | 2 | my ($self, $class) = @_; | |||||||||
| 56 | 2 | $self->{classes}{$class->name} = $class; | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | =head2 classes | ||||||||||
| 60 | |||||||||||
| 61 | returns an array of classes, or a reference to the same, sorted by name. | ||||||||||
| 62 | |||||||||||
| 63 | =cut | ||||||||||
| 64 | |||||||||||
| 65 | 2 | ▶ | sub classes { | ||||||||
|
Subroutine
classes: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 66 | 2 | my ($self) = @_; | |||||||||
| 67 | 2 | my @classes = @{$self->{classes}}{sort keys %{$self->{classes}}}; | |||||||||
| 68 | 2 | ▶ | return wantarray ? @classes : [@classes]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | =head2 finalize | ||||||||||
| 72 | |||||||||||
| 73 | calls C<substantiate()> on each cached class. | ||||||||||
| 74 | |||||||||||
| 75 | =cut | ||||||||||
| 76 | |||||||||||
| 77 | 2 | ▶ | sub finalize { | ||||||||
|
Subroutine
finalize: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 78 | 2 | my ($self) = @_; | |||||||||
| 79 | 2 | foreach my $key (keys %{$self->{classes}}) { | |||||||||
| 80 | 2 | $self->{classes}{$key}->substantiate(); | |||||||||
| 81 | } | ||||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | =head1 SEE ALSO | ||||||||||
| 85 | |||||||||||
| 86 | L<Lang::Tree::Builder> | ||||||||||
| 87 | |||||||||||
| 88 | =head1 AUTHOR | ||||||||||
| 89 | |||||||||||
| 90 | Bill Hails, E<lt>me@billhails.netE<gt> | ||||||||||
| 91 | |||||||||||
| 92 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 93 | |||||||||||
| 94 | Copyright (C) 2008 by Bill Hails | ||||||||||
| 95 | |||||||||||
| 96 | This library is free software; you can redistribute it and/or modify | ||||||||||
| 97 | it under the same terms as Perl itself, either Perl version 5.8.8 or, | ||||||||||
| 98 | at your option, any later version of Perl 5 you may have available. | ||||||||||
| 99 | |||||||||||
| 100 | =cut | ||||||||||