OSDN Git Service

Version 5.91
[vbslib/main.git] / GPL_bin_fullset / NaturalDocs / Modules / NaturalDocs / Languages / Advanced / Scope.pm
1 ###############################################################################
2 #
3 #   Class: NaturalDocs::Languages::Advanced::Scope
4 #
5 ###############################################################################
6 #
7 #   A class used to store a scope level.
8 #
9 ###############################################################################
10
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
14
15 use strict;
16 use integer;
17
18 package NaturalDocs::Languages::Advanced::Scope;
19
20 #
21 #   Constants: Implementation
22 #
23 #   The object is implemented as a blessed arrayref.  The constants below are used as indexes.
24 #
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.
28 #
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.
31
32
33 #
34 #   Function: New
35 #
36 #   Creates and returns a new object.
37 #
38 #   Parameters:
39 #
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.
43 #
44 #       If package is set to undef, it is assumed that it inherits the value of the previous scope on the stack.
45 #
46 sub New #(closingSymbol, package, using)
47     {
48     # Dependency: This depends on the order of the parameters matching the constants, and that there are no inherited
49     # members.
50     my $package = shift;
51
52     my $object = [ @_ ];
53     bless $object, $package;
54
55     if (defined $object->[USING])
56         {  $object->[USING] = [ @{$object->[USING]} ];  };
57
58     return $object;
59     };
60
61
62 # Function: ClosingSymbol
63 # Returns the closing symbol character of the scope.
64 sub ClosingSymbol
65     {  return $_[0]->[CLOSING_SYMBOL];  };
66
67 # Function: Package
68 # Returns the package <SymbolString> of the scope, or undef if none.
69 sub Package
70     {  return $_[0]->[PACKAGE];  };
71
72 # Function: SetPackage
73 # Sets the package <SymbolString> of the scope.
74 sub SetPackage #(package)
75     {  $_[0]->[PACKAGE] = $_[1];  };
76
77 # Function: Using
78 # Returns an arrayref of <SymbolStrings> for using statements, or undef if none
79 sub Using
80     {  return $_[0]->[USING];  };
81
82 # Function: AddUsing
83 # Adds a <SymbolString> to the <Using()> array.
84 sub AddUsing #(using)
85     {
86     my ($self, $using) = @_;
87
88     if (!defined $self->[USING])
89         {  $self->[USING] = [ ];  };
90
91     push @{$self->[USING]}, $using;
92     };
93
94
95
96 1;