libvaladoc: Replace void* with corresponding Vala API
[vala-gnome.git] / libvaladoc / api / delegate.vala
blobd7afcb17e405bfa538c128687ea49a87a08b5bf6
1 /* delegate.vala
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
19 * Author:
20 * Florian Brosch <flo.brosch@gmail.com>
24 using Valadoc.Content;
27 /**
28 * Represents a Delegate.
30 public class Valadoc.Api.Delegate : TypeSymbol, Callable {
31 private string? cname;
33 /**
34 * {@inheritDoc}
36 internal string? implicit_array_length_cparameter_name {
37 get;
38 set;
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;
48 this.cname = cname;
51 /**
52 * Returns the name of this delegate as it is used in C.
54 public string? get_cname () {
55 return cname;
58 /**
59 * {@inheritDoc}
61 public TypeReference? return_type {
62 set;
63 get;
66 /**
67 * {@inheritDoc}
69 public override NodeType node_type {
70 get { return NodeType.DELEGATE; }
73 /**
74 * {@inheritDoc}
76 public override void accept (Visitor visitor) {
77 visitor.visit_delegate (this);
80 /**
81 * Specifies whether this delegate is static
83 public bool is_static {
84 private set;
85 get;
88 /**
89 * {@inheritDoc}
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);
102 bool first = true;
103 foreach (Item param in type_parameters) {
104 if (!first) {
105 signature.append (",", false);
107 signature.append_content (param.signature, false);
108 first = false;
110 signature.append (">", false);
113 signature.append ("(");
115 bool first = true;
116 foreach (Node param in get_children_by_type (NodeType.FORMAL_PARAMETER, false)) {
117 if (!first) {
118 signature.append (",", false);
120 signature.append_content (param.signature, !first);
121 first = false;
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");
129 first = true;
130 foreach (Node param in exceptions) {
131 if (!first) {
132 signature.append (",", false);
134 signature.append_type (param);
135 first = false;
139 return signature.get ();