File: Prototype.pm

package info (click to toggle)
naturaldocs 1.51-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,304 kB
  • sloc: perl: 17,534; javascript: 1,925; makefile: 6; sh: 1
file content (93 lines) | stat: -rw-r--r-- 2,750 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
###############################################################################
#
#   Class: NaturalDocs::Languages::Prototype
#
###############################################################################
#
#   A data class for storing parsed prototypes.
#
###############################################################################

# This file is part of Natural Docs, which is Copyright  2003-2010 Greg Valure
# Natural Docs is licensed under version 3 of the GNU Affero General Public License (AGPL)
# Refer to License.txt for the complete details

use strict;
use integer;

use NaturalDocs::Languages::Prototype::Parameter;


package NaturalDocs::Languages::Prototype;

use NaturalDocs::DefineMembers 'BEFORE_PARAMETERS', 'BeforeParameters()', 'SetBeforeParameters()',
                                                 'AFTER_PARAMETERS', 'AfterParameters()', 'SetAfterParameters()',
                                                 'PARAMETERS', 'Parameters()';
# Dependency: New(), constant order, no parents.


#
#   Function: New
#
#   Creates and returns a new prototype object.
#
#   Parameters:
#
#       beforeParameters - The part of the prototype before the parameter list.
#       afterParameters - The part of the prototype after the parameter list.
#
#   You cannot set the parameters from here.  Use <AddParameter()>.
#
sub New #(beforeParameters, afterParameters)
    {
    my ($package, @params) = @_;

    # Dependency: Constant order, no parents.

    my $object = [ @params ];
    bless $object, $package;

    return $object;
    };


#
#   Functions: Members
#
#   BeforeParameters - Returns the part of the prototype before the parameter list.  If there is no parameter list, this will be the
#                                only thing that returns content.
#   SetBeforeParameters - Replaces the part of the prototype before the parameter list.
#   AfterParameters - Returns the part of the prototype after the parameter list, if any.
#   SetAfterParameters - Replaces the part of the prototype after the parameter list.
#   Parameters - Returns the parameter list as an arrayref of <NaturalDocs::Languages::Prototype::Parameters>, or undef if none.
#

#
#   Function: AddParameter
#
#   Adds a <NaturalDocs::Languages::Prototype::Parameter> to the list.
#
sub AddParameter #(parameter)
    {
    my ($self, $parameter) = @_;

    if (!defined $self->[PARAMETERS])
        {  $self->[PARAMETERS] = [ ];  };

    push @{$self->[PARAMETERS]}, $parameter;
    };


#
#   Function: OnlyBeforeParameters
#
#   Returns whether <BeforeParameters()> is the only thing set.
#
sub OnlyBeforeParameters
    {
    my $self = shift;
    return (!defined $self->[PARAMETERS] && !defined $self->[AFTER_PARAMETERS]);
    };


1;