1/* field.vala 2 * 3 * Copyright (C) 2008-2011 Florian Brosch 4 * 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. 9 * 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. 14 * 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 18 * 19 * Author: 20 * Florian Brosch <flo.brosch@gmail.com> 21 */ 22 23 24using Valadoc.Content; 25 26/** 27 * Represents a field. 28 */ 29public class Valadoc.Api.Field : Symbol { 30 private string? cname; 31 32 public Field (Node parent, SourceFile file, string name, Vala.SymbolAccessibility accessibility, 33 SourceComment? comment, 34 Vala.Field data) 35 { 36 base (parent, file, name, accessibility, comment, data); 37 38 this.is_static = !(parent is Namespace) && data.binding == Vala.MemberBinding.STATIC; 39 this.is_class = data.binding == Vala.MemberBinding.CLASS; 40 this.is_volatile = data.is_volatile; 41 42 this.cname = Vala.get_ccode_name (data); 43 } 44 45 /** 46 * Returns the name of this field as it is used in C. 47 */ 48 public string? get_cname () { 49 return cname; 50 } 51 52 /** 53 * The field type. 54 */ 55 public TypeReference? field_type { 56 set; 57 get; 58 } 59 60 /** 61 * Specifies whether the field is static. 62 */ 63 public bool is_static { 64 private set; 65 get; 66 } 67 68 /** 69 * Specifies whether this field is a class field. 70 */ 71 public bool is_class { 72 private set; 73 get; 74 } 75 76 /** 77 * Specifies whether the field is volatile. 78 */ 79 public bool is_volatile { 80 private set; 81 get; 82 } 83 84 /** 85 * {@inheritDoc} 86 */ 87 protected override Inline build_signature () { 88 var signature = new SignatureBuilder (); 89 90 signature.append_keyword (accessibility.to_string ()); 91 if (is_static) { 92 signature.append_keyword ("static"); 93 } else if (is_class) { 94 signature.append_keyword ("class"); 95 } 96 if (is_volatile) { 97 signature.append_keyword ("volatile"); 98 } 99 100 signature.append_content (field_type.signature); 101 signature.append_symbol (this); 102 return signature.get (); 103 } 104 105 /** 106 * {@inheritDoc} 107 */ 108 public override NodeType node_type { 109 get { return NodeType.FIELD; } 110 } 111 112 /** 113 * {@inheritDoc} 114 */ 115 public override void accept (Visitor visitor) { 116 visitor.visit_field (this); 117 } 118} 119 120