Release 0.41.92
[vala-gnome.git] / libvaladoc / api / propertyaccessor.vala
blob89de374bb54a0a1dee4724ea727d3805ef4a4b2e
1 /* propertyaccessor.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;
26 /**
27 * Represents a get or set accessor of a property.
29 public class Valadoc.Api.PropertyAccessor : Symbol {
30 private PropertyAccessorType type;
31 private Ownership ownership;
32 private string? cname;
34 public PropertyAccessor (Property parent, SourceFile file, string name, SymbolAccessibility accessibility,
35 string? cname, PropertyAccessorType type, Ownership ownership, Vala.PropertyAccessor data)
37 base (parent, file, name, accessibility, data);
39 this.ownership = ownership;
40 this.cname = cname;
41 this.type = type;
44 /**
45 * {@inheritDoc}
47 public override NodeType node_type {
48 get { return NodeType.PROPERTY_ACCESSOR; }
51 /**
52 * Returns the name of this property accessor as it is used in C.
54 public string? get_cname () {
55 return cname;
58 /**
59 * {@inheritDoc}
61 public override void accept (Visitor visitor) {
64 /**
65 * Specifies whether this accessor may be used to construct the property.
67 public bool is_construct {
68 get {
69 return (type & PropertyAccessorType.CONSTRUCT) != 0;
73 /**
74 * Specifies whether this accessor is a setter.
76 public bool is_set {
77 get {
78 return (type & PropertyAccessorType.SET) != 0;
82 /**
83 * Specifies whether this accessor is a getter.
85 public bool is_get {
86 get {
87 return (type & PropertyAccessorType.GET) != 0;
91 /**
92 * Specifies whether the property is owned.
94 public bool is_owned {
95 get {
96 return ownership == Ownership.OWNED;
101 * {@inheritDoc}
103 protected override Inline build_signature () {
104 var signature = new SignatureBuilder ();
106 // FIXME
107 if (!do_document) {
108 return signature.get ();
111 if (((Property) parent).accessibility != accessibility) {
112 signature.append_keyword (accessibility.to_string ());
115 if (is_set || is_construct) {
116 if (is_construct) {
117 signature.append_keyword ("construct");
119 if (is_set) {
120 signature.append_keyword ("set");
122 } else if (is_get) {
123 if (is_owned) {
124 signature.append_keyword ("owned");
126 signature.append_keyword ("get");
128 signature.append (";", false);
130 return signature.get ();