~ubuntu-branches/ubuntu/vivid/vala/vivid

« back to all changes in this revision

Viewing changes to vala/valamember.vala

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2010-07-28 07:58:01 UTC
  • mfrom: (1.5.5 upstream) (7.3.14 experimental)
  • Revision ID: james.westby@ubuntu.com-20100728075801-18u9cg5hv5oety6m
Tags: 0.9.4-1
New upstream development release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* valamember.vala
2
 
 *
3
 
 * Copyright (C) 2006-2008  Raffaele Sandrini, Jürg Billeter
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
 
 *      Raffaele Sandrini <raffaele@sandrini.ch>
21
 
 */
22
 
 
23
 
using GLib;
24
 
 
25
 
/**
26
 
 * Represents a general class member.
27
 
 */
28
 
public abstract class Vala.Member : Symbol {
29
 
        public Comment comment { get; set; }
30
 
 
31
 
        private List<string> cheader_filenames = new ArrayList<string> ();
32
 
 
33
 
        /**
34
 
         * Specifies whether this method explicitly hides a member of a base
35
 
         * type.
36
 
         */
37
 
        public bool hides { get; set; }
38
 
 
39
 
        public Member (string? name, SourceReference? source_reference, Comment? comment = null) {
40
 
                base (name, source_reference);
41
 
                this.comment = comment;
42
 
        }
43
 
 
44
 
        public override void accept (CodeVisitor visitor) {
45
 
                visitor.visit_member (this);
46
 
        }
47
 
 
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);
53
 
                        }
54
 
 
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 ());
58
 
                        }
59
 
                }
60
 
                return cheader_filenames;
61
 
        }
62
 
 
63
 
        
64
 
        /**
65
 
         * Adds a filename to the list of C header filenames users of this data
66
 
         * type must include.
67
 
         *
68
 
         * @param filename a C header filename
69
 
         */
70
 
        public void add_cheader_filename (string filename) {
71
 
                cheader_filenames.add (filename);
72
 
        }
73
 
 
74
 
        public Symbol? get_hidden_member () {
75
 
                Symbol sym = null;
76
 
 
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;
83
 
                                }
84
 
                                cl = cl.base_class;
85
 
                        }
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;
92
 
                                }
93
 
                                st = st.base_struct;
94
 
                        }
95
 
                }
96
 
 
97
 
                return null;
98
 
        }
99
 
}
100
 
 
101
 
public enum MemberBinding {
102
 
        INSTANCE,
103
 
        CLASS,
104
 
        STATIC
105
 
}
106