1 ###############################################################################
3 # Class: NaturalDocs::Languages::Advanced::Scope
5 ###############################################################################
7 # A class used to store a scope level.
9 ###############################################################################
11 # This file is part of Natural Docs, which is Copyright © 2003-2010 Greg Valure
12 # Natural Docs is licensed under version 3 of the GNU Affero General Public License (AGPL)
13 # Refer to License.txt for the complete details
18 package NaturalDocs::Languages::Advanced::Scope;
21 # Constants: Implementation
23 # The object is implemented as a blessed arrayref. The constants below are used as indexes.
25 # CLOSING_SYMBOL - The closing symbol character of the scope.
26 # PACKAGE - The package <SymbolString> of the scope.
27 # USING - An arrayref of <SymbolStrings> for using statements, or undef if none.
29 use NaturalDocs::DefineMembers 'CLOSING_SYMBOL', 'PACKAGE', 'USING';
30 # Dependency: New() depends on the order of these constants as well as that there is no inherited members.
36 # Creates and returns a new object.
40 # closingSymbol - The closing symbol character of the scope.
41 # package - The package <SymbolString> of the scope.
42 # using - An arrayref of using <SymbolStrings>, or undef if none. The contents of the array will be duplicated.
44 # If package is set to undef, it is assumed that it inherits the value of the previous scope on the stack.
46 sub New #(closingSymbol, package, using)
48 # Dependency: This depends on the order of the parameters matching the constants, and that there are no inherited
53 bless $object, $package;
55 if (defined $object->[USING])
56 { $object->[USING] = [ @{$object->[USING]} ]; };
62 # Function: ClosingSymbol
63 # Returns the closing symbol character of the scope.
65 { return $_[0]->[CLOSING_SYMBOL]; };
68 # Returns the package <SymbolString> of the scope, or undef if none.
70 { return $_[0]->[PACKAGE]; };
72 # Function: SetPackage
73 # Sets the package <SymbolString> of the scope.
74 sub SetPackage #(package)
75 { $_[0]->[PACKAGE] = $_[1]; };
78 # Returns an arrayref of <SymbolStrings> for using statements, or undef if none
80 { return $_[0]->[USING]; };
83 # Adds a <SymbolString> to the <Using()> array.
86 my ($self, $using) = @_;
88 if (!defined $self->[USING])
89 { $self->[USING] = [ ]; };
91 push @{$self->[USING]}, $using;