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
20 * Florian Brosch <flo.brosch@gmail.com>
24 using Valadoc
.Content
;
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
;
47 public override NodeType node_type
{
48 get { return NodeType
.PROPERTY_ACCESSOR
; }
52 * Returns the name of this property accessor as it is used in C.
54 public string?
get_cname () {
61 public override void accept (Visitor visitor
) {
65 * Specifies whether this accessor may be used to construct the property.
67 public bool is_construct
{
69 return (type
& PropertyAccessorType
.CONSTRUCT
) != 0;
74 * Specifies whether this accessor is a setter.
78 return (type
& PropertyAccessorType
.SET
) != 0;
83 * Specifies whether this accessor is a getter.
87 return (type
& PropertyAccessorType
.GET
) != 0;
92 * Specifies whether the property is owned.
94 public bool is_owned
{
96 return ownership
== Ownership
.OWNED
;
103 protected override Inline
build_signature () {
104 var signature
= new
SignatureBuilder ();
108 return signature
.get ();
111 if (((Property
) parent
).accessibility
!= accessibility
) {
112 signature
.append_keyword (accessibility
.to_string ());
115 if (is_set
|| is_construct
) {
117 signature
.append_keyword ("construct");
120 signature
.append_keyword ("set");
124 signature
.append_keyword ("owned");
126 signature
.append_keyword ("get");
128 signature
.append (";", false);
130 return signature
.get ();