3 * Copyright (C) 2008-2011 Florian Brosch
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Florian Brosch <flo.brosch@gmail.com>
24 using Valadoc
.Content
;
28 * Represents a Delegate.
30 public class Valadoc
.Api
.Delegate
: TypeSymbol
, Callable
{
31 private string? cname
;
36 internal string? implicit_array_length_cparameter_name
{
42 public Delegate (Node parent
, SourceFile file
, string name
, SymbolAccessibility accessibility
,
43 SourceComment? comment
, string? cname
, bool is_static
, Vala
.Delegate data
)
45 base (parent
, file
, name
, accessibility
, comment
, null, null, null, null, false, data
);
47 this
.is_static
= is_static
;
52 * Returns the name of this delegate as it is used in C.
54 public string?
get_cname () {
61 public TypeReference? return_type
{
69 public override NodeType node_type
{
70 get { return NodeType
.DELEGATE
; }
76 public override void accept (Visitor visitor
) {
77 visitor
.visit_delegate (this
);
81 * Specifies whether this delegate is static
83 public bool is_static
{
91 protected override Inline
build_signature () {
92 var signature
= new
SignatureBuilder ();
94 signature
.append_keyword (accessibility
.to_string ());
95 signature
.append_keyword ("delegate");
96 signature
.append_content (return_type
.signature
);
97 signature
.append_symbol (this
);
99 var type_parameters
= get_children_by_type (NodeType
.TYPE_PARAMETER
);
100 if (type_parameters
.size
> 0) {
101 signature
.append ("<", false);
103 foreach (Item param
in type_parameters
) {
105 signature
.append (",", false);
107 signature
.append_content (param
.signature
, false);
110 signature
.append (">", false);
113 signature
.append ("(");
116 foreach (Node param
in get_children_by_type (NodeType
.FORMAL_PARAMETER
, false)) {
118 signature
.append (",", false);
120 signature
.append_content (param
.signature
, !first
);
124 signature
.append (")", false);
126 var exceptions
= get_children_by_types ({NodeType
.ERROR_DOMAIN
, NodeType
.CLASS
});
127 if (exceptions
.size
> 0) {
128 signature
.append_keyword ("throws");
130 foreach (Node param
in exceptions
) {
132 signature
.append (",", false);
134 signature
.append_type (param
);
139 return signature
.get ();