Release 0.7.8
[vala-lang.git] / vala / valamember.vala
blob602c06a65a16dea0c7b44a9a4bf7caff01b1e638
1 /* valamember.vala
3 * Copyright (C) 2006-2008 Raffaele Sandrini, Jürg Billeter
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 * Raffaele Sandrini <raffaele@sandrini.ch>
23 using GLib;
25 /**
26 * Represents a general class member.
28 public abstract class Vala.Member : Symbol {
29 public Comment comment { get; set; }
31 private List<string> cheader_filenames = new ArrayList<string> ();
33 /**
34 * Specifies whether this method explicitly hides a member of a base
35 * type.
37 public bool hides { get; set; }
39 public Member (string? name, SourceReference? source_reference, Comment? comment = null) {
40 base (name, source_reference);
41 this.comment = comment;
44 public override void accept (CodeVisitor visitor) {
45 visitor.visit_member (this);
48 public override List<string> get_cheader_filenames () {
49 if (cheader_filenames.size == 0 && parent_symbol != null) {
50 /* default to header filenames of the namespace */
51 foreach (string filename in parent_symbol.get_cheader_filenames ()) {
52 add_cheader_filename (filename);
55 if (cheader_filenames.size == 0 && source_reference != null && !external_package) {
56 // don't add default include directives for VAPI files
57 cheader_filenames.add (source_reference.file.get_cinclude_filename ());
60 return new ReadOnlyList<string> (cheader_filenames);
64 /**
65 * Adds a filename to the list of C header filenames users of this data
66 * type must include.
68 * @param filename a C header filename
70 public void add_cheader_filename (string filename) {
71 cheader_filenames.add (filename);
74 public Symbol? get_hidden_member () {
75 Symbol sym = null;
77 if (parent_symbol is Class) {
78 var cl = ((Class) parent_symbol).base_class;
79 while (cl != null) {
80 sym = cl.scope.lookup (name);
81 if (sym != null && sym.access != SymbolAccessibility.PRIVATE) {
82 return sym;
84 cl = cl.base_class;
86 } else if (parent_symbol is Struct) {
87 var st = ((Struct) parent_symbol).base_struct;
88 while (st != null) {
89 sym = st.scope.lookup (name);
90 if (sym != null && sym.access != SymbolAccessibility.PRIVATE) {
91 return sym;
93 st = st.base_struct;
97 return null;
101 public enum MemberBinding {
102 INSTANCE,
103 CLASS,
104 STATIC