~ubuntu-branches/ubuntu/hardy/vala/hardy

« back to all changes in this revision

Viewing changes to vala/valaattribute.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge, Marc-Andre Lureau, Sebastian Dröge
  • Date: 2007-10-15 14:37:51 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071015143751-zy7hqcyjutdyfkg3
Tags: 0.1.4-1
[ Marc-Andre Lureau ]
* New Upstream Version
* debian/patches:
  + Remove patch no longer needed in 0.1.4
* debian/rules
  + Add xsltproc build dependency for the Vala manual.
  + Add libenchant-dev build dependency for enchant test case.
* debian/control, debian/vala-doc.install:
  + Add a "vala-doc" documentation package.

[ Sebastian Dröge ]
* debian/control:
  + Let vala-doc suggest valac/devhelp and don't depend on libvala0.
* debian/libvala-dev.install:
  + Add the new vapicheck utility.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
7
7
 * License as published by the Free Software Foundation; either
8
 
 * version 2 of the License, or (at your option) any later version.
 
8
 * version 2.1 of the License, or (at your option) any later version.
9
9
 
10
10
 * This library is distributed in the hope that it will be useful,
11
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
20
 *      Jürg Billeter <j@bitron.ch>
21
21
 */
22
22
 
23
 
#include "valaattribute.h"
 
23
#include <vala/valaattribute.h>
24
24
#include <gee/arraylist.h>
25
25
#include <gee/collection.h>
26
26
#include <vala/valasourcereference.h>
27
 
#include <vala/valaattribute.h>
28
27
#include <vala/valanamedargument.h>
29
28
#include <vala/valaliteralexpression.h>
30
29
#include <vala/valaliteral.h>
51
50
 * @param source_reference reference to source code
52
51
 * @return                 newly created attribute
53
52
 */
54
 
ValaAttribute* vala_attribute_new (const char* name, ValaSourceReference* source_reference)
55
 
{
 
53
ValaAttribute* vala_attribute_new (const char* name, ValaSourceReference* source_reference) {
56
54
        ValaAttribute * self;
57
55
        g_return_val_if_fail (name != NULL, NULL);
58
56
        g_return_val_if_fail (source_reference == NULL || VALA_IS_SOURCE_REFERENCE (source_reference), NULL);
68
66
 *
69
67
 * @param arg named argument
70
68
 */
71
 
void vala_attribute_add_argument (ValaAttribute* self, ValaNamedArgument* arg)
72
 
{
 
69
void vala_attribute_add_argument (ValaAttribute* self, ValaNamedArgument* arg) {
73
70
        g_return_if_fail (VALA_IS_ATTRIBUTE (self));
74
71
        g_return_if_fail (VALA_IS_NAMED_ARGUMENT (arg));
75
72
        gee_collection_add (GEE_COLLECTION (self->args), arg);
82
79
 * @param name argument name
83
80
 * @return     true if the argument has been found, false otherwise
84
81
 */
85
 
gboolean vala_attribute_has_argument (ValaAttribute* self, const char* name)
86
 
{
 
82
gboolean vala_attribute_has_argument (ValaAttribute* self, const char* name) {
87
83
        g_return_val_if_fail (VALA_IS_ATTRIBUTE (self), FALSE);
88
84
        g_return_val_if_fail (name != NULL, FALSE);
89
85
        {
97
93
                        {
98
94
                                /* FIXME: use hash table*/
99
95
                                if (g_utf8_collate (vala_named_argument_get_name (arg), name) == 0) {
100
 
                                        gboolean __temp0;
101
 
                                        return (__temp0 = TRUE, (arg == NULL ? NULL : (arg = (g_object_unref (arg), NULL))), (arg_it == NULL ? NULL : (arg_it = (g_object_unref (arg_it), NULL))), __temp0);
 
96
                                        gboolean _tmp0;
 
97
                                        return (_tmp0 = TRUE, (arg == NULL ? NULL : (arg = (g_object_unref (arg), NULL))), (arg_it == NULL ? NULL : (arg_it = (g_object_unref (arg_it), NULL))), _tmp0);
102
98
                                }
103
99
                                (arg == NULL ? NULL : (arg = (g_object_unref (arg), NULL)));
104
100
                        }
115
111
 * @param name argument name
116
112
 * @return     string value
117
113
 */
118
 
char* vala_attribute_get_string (ValaAttribute* self, const char* name)
119
 
{
 
114
char* vala_attribute_get_string (ValaAttribute* self, const char* name) {
120
115
        g_return_val_if_fail (VALA_IS_ATTRIBUTE (self), NULL);
121
116
        g_return_val_if_fail (name != NULL, NULL);
122
117
        {
131
126
                                /* FIXME: use hash table*/
132
127
                                if (g_utf8_collate (vala_named_argument_get_name (arg), name) == 0) {
133
128
                                        if (VALA_IS_LITERAL_EXPRESSION (vala_named_argument_get_argument (arg))) {
134
 
                                                ValaLiteral* __temp2;
 
129
                                                ValaLiteral* _tmp0;
135
130
                                                ValaLiteral* lit;
136
 
                                                __temp2 = NULL;
137
 
                                                lit = (__temp2 = vala_literal_expression_get_literal ((VALA_LITERAL_EXPRESSION (vala_named_argument_get_argument (arg)))), (__temp2 == NULL ? NULL : g_object_ref (__temp2)));
 
131
                                                _tmp0 = NULL;
 
132
                                                lit = (_tmp0 = vala_literal_expression_get_literal ((VALA_LITERAL_EXPRESSION (vala_named_argument_get_argument (arg)))), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
138
133
                                                if (VALA_IS_STRING_LITERAL (lit)) {
139
 
                                                        char* __temp3;
140
 
                                                        __temp3 = NULL;
141
 
                                                        return (__temp3 = vala_string_literal_eval ((VALA_STRING_LITERAL (lit))), (lit == NULL ? NULL : (lit = (g_object_unref (lit), NULL))), (arg == NULL ? NULL : (arg = (g_object_unref (arg), NULL))), (arg_it == NULL ? NULL : (arg_it = (g_object_unref (arg_it), NULL))), __temp3);
 
134
                                                        char* _tmp1;
 
135
                                                        _tmp1 = NULL;
 
136
                                                        return (_tmp1 = vala_string_literal_eval ((VALA_STRING_LITERAL (lit))), (lit == NULL ? NULL : (lit = (g_object_unref (lit), NULL))), (arg == NULL ? NULL : (arg = (g_object_unref (arg), NULL))), (arg_it == NULL ? NULL : (arg_it = (g_object_unref (arg_it), NULL))), _tmp1);
142
137
                                                }
143
138
                                                (lit == NULL ? NULL : (lit = (g_object_unref (lit), NULL)));
144
139
                                        }
158
153
 * @param name argument name
159
154
 * @return     integer value
160
155
 */
161
 
gint vala_attribute_get_integer (ValaAttribute* self, const char* name)
162
 
{
 
156
gint vala_attribute_get_integer (ValaAttribute* self, const char* name) {
163
157
        g_return_val_if_fail (VALA_IS_ATTRIBUTE (self), 0);
164
158
        g_return_val_if_fail (name != NULL, 0);
165
159
        {
174
168
                                /* FIXME: use hash table*/
175
169
                                if (g_utf8_collate (vala_named_argument_get_name (arg), name) == 0) {
176
170
                                        if (VALA_IS_LITERAL_EXPRESSION (vala_named_argument_get_argument (arg))) {
177
 
                                                ValaLiteral* __temp5;
 
171
                                                ValaLiteral* _tmp0;
178
172
                                                ValaLiteral* lit;
179
 
                                                __temp5 = NULL;
180
 
                                                lit = (__temp5 = vala_literal_expression_get_literal ((VALA_LITERAL_EXPRESSION (vala_named_argument_get_argument (arg)))), (__temp5 == NULL ? NULL : g_object_ref (__temp5)));
 
173
                                                _tmp0 = NULL;
 
174
                                                lit = (_tmp0 = vala_literal_expression_get_literal ((VALA_LITERAL_EXPRESSION (vala_named_argument_get_argument (arg)))), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
181
175
                                                if (VALA_IS_INTEGER_LITERAL (lit)) {
182
 
                                                        gint __temp6;
183
 
                                                        return (__temp6 = atoi (vala_integer_literal_get_value ((VALA_INTEGER_LITERAL (lit)))), (lit == NULL ? NULL : (lit = (g_object_unref (lit), NULL))), (arg == NULL ? NULL : (arg = (g_object_unref (arg), NULL))), (arg_it == NULL ? NULL : (arg_it = (g_object_unref (arg_it), NULL))), __temp6);
 
176
                                                        gint _tmp1;
 
177
                                                        return (_tmp1 = atoi (vala_integer_literal_get_value ((VALA_INTEGER_LITERAL (lit)))), (lit == NULL ? NULL : (lit = (g_object_unref (lit), NULL))), (arg == NULL ? NULL : (arg = (g_object_unref (arg), NULL))), (arg_it == NULL ? NULL : (arg_it = (g_object_unref (arg_it), NULL))), _tmp1);
184
178
                                                }
185
179
                                                (lit == NULL ? NULL : (lit = (g_object_unref (lit), NULL)));
186
180
                                        }
200
194
 * @param name argument name
201
195
 * @return     boolean value
202
196
 */
203
 
gboolean vala_attribute_get_bool (ValaAttribute* self, const char* name)
204
 
{
 
197
gboolean vala_attribute_get_bool (ValaAttribute* self, const char* name) {
205
198
        g_return_val_if_fail (VALA_IS_ATTRIBUTE (self), FALSE);
206
199
        g_return_val_if_fail (name != NULL, FALSE);
207
200
        {
216
209
                                /* FIXME: use hash table*/
217
210
                                if (g_utf8_collate (vala_named_argument_get_name (arg), name) == 0) {
218
211
                                        if (VALA_IS_LITERAL_EXPRESSION (vala_named_argument_get_argument (arg))) {
219
 
                                                ValaLiteral* __temp8;
 
212
                                                ValaLiteral* _tmp0;
220
213
                                                ValaLiteral* lit;
221
 
                                                __temp8 = NULL;
222
 
                                                lit = (__temp8 = vala_literal_expression_get_literal ((VALA_LITERAL_EXPRESSION (vala_named_argument_get_argument (arg)))), (__temp8 == NULL ? NULL : g_object_ref (__temp8)));
 
214
                                                _tmp0 = NULL;
 
215
                                                lit = (_tmp0 = vala_literal_expression_get_literal ((VALA_LITERAL_EXPRESSION (vala_named_argument_get_argument (arg)))), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
223
216
                                                if (VALA_IS_BOOLEAN_LITERAL (lit)) {
224
 
                                                        gboolean __temp9;
225
 
                                                        return (__temp9 = vala_boolean_literal_get_value ((VALA_BOOLEAN_LITERAL (lit))), (lit == NULL ? NULL : (lit = (g_object_unref (lit), NULL))), (arg == NULL ? NULL : (arg = (g_object_unref (arg), NULL))), (arg_it == NULL ? NULL : (arg_it = (g_object_unref (arg_it), NULL))), __temp9);
 
217
                                                        gboolean _tmp1;
 
218
                                                        return (_tmp1 = vala_boolean_literal_get_value ((VALA_BOOLEAN_LITERAL (lit))), (lit == NULL ? NULL : (lit = (g_object_unref (lit), NULL))), (arg == NULL ? NULL : (arg = (g_object_unref (arg), NULL))), (arg_it == NULL ? NULL : (arg_it = (g_object_unref (arg_it), NULL))), _tmp1);
226
219
                                                }
227
220
                                                (lit == NULL ? NULL : (lit = (g_object_unref (lit), NULL)));
228
221
                                        }
236
229
}
237
230
 
238
231
 
239
 
char* vala_attribute_get_name (ValaAttribute* self)
240
 
{
 
232
char* vala_attribute_get_name (ValaAttribute* self) {
241
233
        g_return_val_if_fail (VALA_IS_ATTRIBUTE (self), NULL);
242
234
        return self->priv->_name;
243
235
}
244
236
 
245
237
 
246
 
void vala_attribute_set_name (ValaAttribute* self, const char* value)
247
 
{
248
 
        char* __temp12;
 
238
void vala_attribute_set_name (ValaAttribute* self, const char* value) {
 
239
        char* _tmp1;
249
240
        g_return_if_fail (VALA_IS_ATTRIBUTE (self));
250
 
        __temp12 = NULL;
251
 
        self->priv->_name = (__temp12 = g_strdup (value), (self->priv->_name = (g_free (self->priv->_name), NULL)), __temp12);
 
241
        _tmp1 = NULL;
 
242
        self->priv->_name = (_tmp1 = g_strdup (value), (self->priv->_name = (g_free (self->priv->_name), NULL)), _tmp1);
252
243
}
253
244
 
254
245
 
255
 
static void vala_attribute_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec)
256
 
{
 
246
static void vala_attribute_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
257
247
        ValaAttribute * self;
258
248
        self = VALA_ATTRIBUTE (object);
259
249
        switch (property_id) {
260
250
                case VALA_ATTRIBUTE_NAME:
261
251
                g_value_set_string (value, vala_attribute_get_name (self));
262
252
                break;
 
253
                default:
 
254
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
255
                break;
263
256
        }
264
257
}
265
258
 
266
259
 
267
 
static void vala_attribute_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec)
268
 
{
 
260
static void vala_attribute_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
269
261
        ValaAttribute * self;
270
262
        self = VALA_ATTRIBUTE (object);
271
263
        switch (property_id) {
272
264
                case VALA_ATTRIBUTE_NAME:
273
265
                vala_attribute_set_name (self, g_value_get_string (value));
274
266
                break;
 
267
                default:
 
268
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
269
                break;
275
270
        }
276
271
}
277
272
 
278
273
 
279
 
static void vala_attribute_class_init (ValaAttributeClass * klass)
280
 
{
 
274
static void vala_attribute_class_init (ValaAttributeClass * klass) {
281
275
        vala_attribute_parent_class = g_type_class_peek_parent (klass);
282
276
        g_type_class_add_private (klass, sizeof (ValaAttributePrivate));
283
277
        G_OBJECT_CLASS (klass)->get_property = vala_attribute_get_property;
284
278
        G_OBJECT_CLASS (klass)->set_property = vala_attribute_set_property;
285
279
        G_OBJECT_CLASS (klass)->dispose = vala_attribute_dispose;
286
 
        g_object_class_install_property (G_OBJECT_CLASS (klass), VALA_ATTRIBUTE_NAME, g_param_spec_string ("name", "foo", "bar", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
 
280
        g_object_class_install_property (G_OBJECT_CLASS (klass), VALA_ATTRIBUTE_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
287
281
}
288
282
 
289
283
 
290
 
static void vala_attribute_init (ValaAttribute * self)
291
 
{
 
284
static void vala_attribute_init (ValaAttribute * self) {
292
285
        self->priv = VALA_ATTRIBUTE_GET_PRIVATE (self);
293
286
        self->args = GEE_LIST (gee_array_list_new (g_object_ref, g_object_unref, g_direct_equal));
294
287
}
295
288
 
296
289
 
297
 
static void vala_attribute_dispose (GObject * obj)
298
 
{
 
290
static void vala_attribute_dispose (GObject * obj) {
299
291
        ValaAttribute * self;
300
 
        ValaAttributeClass * klass;
301
 
        GObjectClass * parent_class;
302
292
        self = VALA_ATTRIBUTE (obj);
303
293
        (self->priv->_name = (g_free (self->priv->_name), NULL));
304
294
        (self->args == NULL ? NULL : (self->args = (g_object_unref (self->args), NULL)));
305
 
        klass = VALA_ATTRIBUTE_CLASS (g_type_class_peek (VALA_TYPE_ATTRIBUTE));
306
 
        parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
307
 
        parent_class->dispose (obj);
 
295
        G_OBJECT_CLASS (vala_attribute_parent_class)->dispose (obj);
308
296
}
309
297
 
310
298
 
311
 
GType vala_attribute_get_type (void)
312
 
{
 
299
GType vala_attribute_get_type (void) {
313
300
        static GType vala_attribute_type_id = 0;
314
301
        if (G_UNLIKELY (vala_attribute_type_id == 0)) {
315
302
                static const GTypeInfo g_define_type_info = { sizeof (ValaAttributeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_attribute_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaAttribute), 0, (GInstanceInitFunc) vala_attribute_init };