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

« back to all changes in this revision

Viewing changes to ccode/valaccodestruct.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 "valaccodestruct.h"
 
23
#include <ccode/valaccodestruct.h>
24
24
#include <gee/arraylist.h>
25
25
#include <gee/list.h>
26
26
#include <gee/collection.h>
27
 
#include <ccode/valaccodestruct.h>
28
27
#include <ccode/valaccodevariabledeclarator.h>
29
28
#include <ccode/valaccodedeclarator.h>
30
29
 
42
41
static void vala_ccode_struct_dispose (GObject * obj);
43
42
 
44
43
 
45
 
ValaCCodeStruct* vala_ccode_struct_new (const char* name)
46
 
{
 
44
ValaCCodeStruct* vala_ccode_struct_new (const char* name) {
47
45
        ValaCCodeStruct * self;
48
46
        g_return_val_if_fail (name != NULL, NULL);
49
47
        self = g_object_newv (VALA_TYPE_CCODE_STRUCT, 0, NULL);
57
55
 *
58
56
 * @param decl a variable declaration
59
57
 */
60
 
void vala_ccode_struct_add_declaration (ValaCCodeStruct* self, ValaCCodeDeclaration* decl)
61
 
{
 
58
void vala_ccode_struct_add_declaration (ValaCCodeStruct* self, ValaCCodeDeclaration* decl) {
62
59
        g_return_if_fail (VALA_IS_CCODE_STRUCT (self));
63
60
        g_return_if_fail (VALA_IS_CCODE_DECLARATION (decl));
64
61
        gee_collection_add (GEE_COLLECTION (self->priv->declarations), decl);
71
68
 * @param type_name field type
72
69
 * @param name      member name
73
70
 */
74
 
void vala_ccode_struct_add_field (ValaCCodeStruct* self, const char* type_name, const char* name)
75
 
{
 
71
void vala_ccode_struct_add_field (ValaCCodeStruct* self, const char* type_name, const char* name) {
76
72
        ValaCCodeDeclaration* decl;
77
 
        ValaCCodeVariableDeclarator* __temp0;
 
73
        ValaCCodeVariableDeclarator* _tmp0;
78
74
        g_return_if_fail (VALA_IS_CCODE_STRUCT (self));
79
75
        g_return_if_fail (type_name != NULL);
80
76
        g_return_if_fail (name != NULL);
81
77
        decl = vala_ccode_declaration_new (type_name);
82
 
        __temp0 = NULL;
83
 
        vala_ccode_declaration_add_declarator (decl, VALA_CCODE_DECLARATOR ((__temp0 = vala_ccode_variable_declarator_new (name))));
84
 
        (__temp0 == NULL ? NULL : (__temp0 = (g_object_unref (__temp0), NULL)));
 
78
        _tmp0 = NULL;
 
79
        vala_ccode_declaration_add_declarator (decl, VALA_CCODE_DECLARATOR ((_tmp0 = vala_ccode_variable_declarator_new (name))));
 
80
        (_tmp0 == NULL ? NULL : (_tmp0 = (g_object_unref (_tmp0), NULL)));
85
81
        vala_ccode_struct_add_declaration (self, decl);
86
82
        (decl == NULL ? NULL : (decl = (g_object_unref (decl), NULL)));
87
83
}
88
84
 
89
85
 
90
 
static void vala_ccode_struct_real_write (ValaCCodeNode* base, ValaCCodeWriter* writer)
91
 
{
 
86
static void vala_ccode_struct_real_write (ValaCCodeNode* base, ValaCCodeWriter* writer) {
92
87
        ValaCCodeStruct * self;
93
 
        self = ((ValaCCodeStruct*) base);
 
88
        self = VALA_CCODE_STRUCT (base);
94
89
        g_return_if_fail (VALA_IS_CCODE_WRITER (writer));
95
90
        vala_ccode_writer_write_string (writer, "struct ");
96
91
        vala_ccode_writer_write_string (writer, vala_ccode_struct_get_name (self));
116
111
}
117
112
 
118
113
 
119
 
char* vala_ccode_struct_get_name (ValaCCodeStruct* self)
120
 
{
 
114
char* vala_ccode_struct_get_name (ValaCCodeStruct* self) {
121
115
        g_return_val_if_fail (VALA_IS_CCODE_STRUCT (self), NULL);
122
116
        return self->priv->_name;
123
117
}
124
118
 
125
119
 
126
 
void vala_ccode_struct_set_name (ValaCCodeStruct* self, const char* value)
127
 
{
128
 
        char* __temp2;
 
120
void vala_ccode_struct_set_name (ValaCCodeStruct* self, const char* value) {
 
121
        char* _tmp1;
129
122
        g_return_if_fail (VALA_IS_CCODE_STRUCT (self));
130
 
        __temp2 = NULL;
131
 
        self->priv->_name = (__temp2 = g_strdup (value), (self->priv->_name = (g_free (self->priv->_name), NULL)), __temp2);
 
123
        _tmp1 = NULL;
 
124
        self->priv->_name = (_tmp1 = g_strdup (value), (self->priv->_name = (g_free (self->priv->_name), NULL)), _tmp1);
132
125
}
133
126
 
134
127
 
135
 
static void vala_ccode_struct_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec)
136
 
{
 
128
static void vala_ccode_struct_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
137
129
        ValaCCodeStruct * self;
138
130
        self = VALA_CCODE_STRUCT (object);
139
131
        switch (property_id) {
140
132
                case VALA_CCODE_STRUCT_NAME:
141
133
                g_value_set_string (value, vala_ccode_struct_get_name (self));
142
134
                break;
 
135
                default:
 
136
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
137
                break;
143
138
        }
144
139
}
145
140
 
146
141
 
147
 
static void vala_ccode_struct_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec)
148
 
{
 
142
static void vala_ccode_struct_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
149
143
        ValaCCodeStruct * self;
150
144
        self = VALA_CCODE_STRUCT (object);
151
145
        switch (property_id) {
152
146
                case VALA_CCODE_STRUCT_NAME:
153
147
                vala_ccode_struct_set_name (self, g_value_get_string (value));
154
148
                break;
 
149
                default:
 
150
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
151
                break;
155
152
        }
156
153
}
157
154
 
158
155
 
159
 
static void vala_ccode_struct_class_init (ValaCCodeStructClass * klass)
160
 
{
 
156
static void vala_ccode_struct_class_init (ValaCCodeStructClass * klass) {
161
157
        vala_ccode_struct_parent_class = g_type_class_peek_parent (klass);
162
158
        g_type_class_add_private (klass, sizeof (ValaCCodeStructPrivate));
163
159
        G_OBJECT_CLASS (klass)->get_property = vala_ccode_struct_get_property;
164
160
        G_OBJECT_CLASS (klass)->set_property = vala_ccode_struct_set_property;
165
161
        G_OBJECT_CLASS (klass)->dispose = vala_ccode_struct_dispose;
166
162
        VALA_CCODE_NODE_CLASS (klass)->write = vala_ccode_struct_real_write;
167
 
        g_object_class_install_property (G_OBJECT_CLASS (klass), VALA_CCODE_STRUCT_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));
 
163
        g_object_class_install_property (G_OBJECT_CLASS (klass), VALA_CCODE_STRUCT_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));
168
164
}
169
165
 
170
166
 
171
 
static void vala_ccode_struct_init (ValaCCodeStruct * self)
172
 
{
 
167
static void vala_ccode_struct_init (ValaCCodeStruct * self) {
173
168
        self->priv = VALA_CCODE_STRUCT_GET_PRIVATE (self);
174
169
        self->priv->declarations = GEE_LIST (gee_array_list_new (g_object_ref, g_object_unref, g_direct_equal));
175
170
}
176
171
 
177
172
 
178
 
static void vala_ccode_struct_dispose (GObject * obj)
179
 
{
 
173
static void vala_ccode_struct_dispose (GObject * obj) {
180
174
        ValaCCodeStruct * self;
181
 
        ValaCCodeStructClass * klass;
182
 
        GObjectClass * parent_class;
183
175
        self = VALA_CCODE_STRUCT (obj);
184
176
        (self->priv->_name = (g_free (self->priv->_name), NULL));
185
177
        (self->priv->declarations == NULL ? NULL : (self->priv->declarations = (g_object_unref (self->priv->declarations), NULL)));
186
 
        klass = VALA_CCODE_STRUCT_CLASS (g_type_class_peek (VALA_TYPE_CCODE_STRUCT));
187
 
        parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
188
 
        parent_class->dispose (obj);
 
178
        G_OBJECT_CLASS (vala_ccode_struct_parent_class)->dispose (obj);
189
179
}
190
180
 
191
181
 
192
 
GType vala_ccode_struct_get_type (void)
193
 
{
 
182
GType vala_ccode_struct_get_type (void) {
194
183
        static GType vala_ccode_struct_type_id = 0;
195
184
        if (G_UNLIKELY (vala_ccode_struct_type_id == 0)) {
196
185
                static const GTypeInfo g_define_type_info = { sizeof (ValaCCodeStructClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ccode_struct_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCCodeStruct), 0, (GInstanceInitFunc) vala_ccode_struct_init };