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

« back to all changes in this revision

Viewing changes to vala/valaenumvalue.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
1
/* valaenumvalue.vala
2
2
 *
3
 
 * Copyright (C) 2006-2009  Jürg Billeter
 
3
 * Copyright (C) 2006-2010  Jürg Billeter
4
4
 *
5
5
 * This library is free software; you can redistribute it and/or
6
6
 * modify it under the terms of the GNU Lesser General Public
25
25
/**
26
26
 * Represents an enum member in the source code.
27
27
 */
28
 
public class Vala.EnumValue : Symbol {
29
 
        /**
30
 
         * Specifies the numerical representation of this enum value.
31
 
         */
32
 
        public Expression value { get; set; }
33
 
 
34
 
        public Comment comment { get; set; }
35
 
 
36
 
        private string cname;
37
 
 
38
 
        /**
39
 
         * Creates a new enum value.
40
 
         *
41
 
         * @param name enum value name
42
 
         * @return     newly created enum value
43
 
         */
44
 
        public EnumValue (string name, SourceReference? source_reference = null, Comment? comment = null) {
45
 
                base (name, source_reference);
46
 
                this.comment = comment;
47
 
        }
48
 
 
 
28
public class Vala.EnumValue : Constant {
49
29
        /**
50
30
         * Creates a new enum value with the specified numerical representation.
51
31
         *
53
33
         * @param value numerical representation
54
34
         * @return      newly created enum value
55
35
         */
56
 
        public EnumValue.with_value (string name, Expression value, SourceReference? source_reference = null, Comment? comment = null) {
57
 
                this (name, source_reference, comment);
58
 
                this.value = value;
 
36
        public EnumValue (string name, Expression? value, SourceReference? source_reference = null, Comment? comment = null) {
 
37
                base (name, null, value, source_reference, comment);
59
38
        }
60
39
        
61
40
        /**
95
74
                }
96
75
        }
97
76
 
98
 
        /**
99
 
         * Process all associated attributes.
100
 
         */
101
 
        public void process_attributes () {
102
 
                foreach (Attribute a in attributes) {
103
 
                        if (a.name == "CCode" && a.has_argument("cname")) {
104
 
                                cname = a.get_string ("cname");
105
 
                        } else if (a.name == "Deprecated") {
106
 
                                process_deprecated_attribute (a);
107
 
                        }
108
 
                }
109
 
        }
110
 
 
111
 
        /**
112
 
         * Returns the name of this enum value as it is used in C code.
113
 
         *
114
 
         * @return the name to be used in C code
115
 
         */
116
 
        public string get_cname () {
117
 
                if (cname == null) {
118
 
                        cname = get_default_cname ();
119
 
                }
120
 
                return cname;
121
 
        }
122
 
 
123
 
        public string get_default_cname () {
 
77
        public override string get_default_cname () {
124
78
                var en = (Enum) parent_symbol;
125
79
                return "%s%s".printf (en.get_cprefix (), name);
126
80
        }
127
81
 
128
 
        /**
129
 
         * Sets the name of this enum value to be used in C code.
130
 
         *
131
 
         * @param cname the name to be used in C code
132
 
         */
133
 
        public void set_cname (string cname) {
134
 
                this.cname = cname;
135
 
        }
136
 
 
137
82
        public override bool check (SemanticAnalyzer analyzer) {
138
83
                if (checked) {
139
84
                        return !error;