1 /* enum.c generated by valac, the Vala compiler
2 * generated from enum.vala, do not modify */
3
4 /* enum.vala
5 *
6 * Copyright (C) 2008-2011 Florian Brosch
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 * Author:
23 * Florian Brosch <flo.brosch@gmail.com>
24 */
25
26 #include "valadoc.h"
27 #include <stdlib.h>
28 #include <string.h>
29 #include <glib.h>
30 #include <vala.h>
31 #include <valacodegen.h>
32
33 enum {
34 VALADOC_API_ENUM_0_PROPERTY,
35 VALADOC_API_ENUM_NODE_TYPE_PROPERTY,
36 VALADOC_API_ENUM_NUM_PROPERTIES
37 };
38 static GParamSpec* valadoc_api_enum_properties[VALADOC_API_ENUM_NUM_PROPERTIES];
39 #define _g_free0(var) (var = (g_free (var), NULL))
40 #define _valadoc_api_signature_builder_unref0(var) ((var == NULL) ? NULL : (var = (valadoc_api_signature_builder_unref (var), NULL)))
41
42 struct _ValadocApiEnumPrivate {
43 gchar* cname;
44 gchar* type_id;
45 };
46
47 static gint ValadocApiEnum_private_offset;
48 static gpointer valadoc_api_enum_parent_class = NULL;
49
50 static void valadoc_api_enum_real_accept (ValadocApiNode* base,
51 ValadocApiVisitor* visitor);
52 static ValadocContentInline* valadoc_api_enum_real_build_signature (ValadocApiItem* base);
53 static void valadoc_api_enum_finalize (GObject * obj);
54 static GType valadoc_api_enum_get_type_once (void);
55 static void _vala_valadoc_api_enum_get_property (GObject * object,
56 guint property_id,
57 GValue * value,
58 GParamSpec * pspec);
59
60 static inline gpointer
valadoc_api_enum_get_instance_private(ValadocApiEnum * self)61 valadoc_api_enum_get_instance_private (ValadocApiEnum* self)
62 {
63 return G_STRUCT_MEMBER_P (self, ValadocApiEnum_private_offset);
64 }
65
66 ValadocApiEnum*
valadoc_api_enum_construct(GType object_type,ValadocApiNode * parent,ValadocApiSourceFile * file,const gchar * name,ValaSymbolAccessibility accessibility,ValadocApiSourceComment * comment,ValaEnum * data)67 valadoc_api_enum_construct (GType object_type,
68 ValadocApiNode* parent,
69 ValadocApiSourceFile* file,
70 const gchar* name,
71 ValaSymbolAccessibility accessibility,
72 ValadocApiSourceComment* comment,
73 ValaEnum* data)
74 {
75 ValadocApiEnum * self = NULL;
76 gchar* _tmp0_;
77 gchar* _tmp1_;
78 g_return_val_if_fail (parent != NULL, NULL);
79 g_return_val_if_fail (file != NULL, NULL);
80 g_return_val_if_fail (name != NULL, NULL);
81 g_return_val_if_fail (data != NULL, NULL);
82 self = (ValadocApiEnum*) valadoc_api_typesymbol_construct (object_type, parent, file, name, accessibility, comment, FALSE, (ValaTypeSymbol*) data);
83 _tmp0_ = vala_get_ccode_name ((ValaCodeNode*) data);
84 _g_free0 (self->priv->cname);
85 self->priv->cname = _tmp0_;
86 _tmp1_ = vala_get_ccode_type_id ((ValaCodeNode*) data);
87 _g_free0 (self->priv->type_id);
88 self->priv->type_id = _tmp1_;
89 return self;
90 }
91
92 ValadocApiEnum*
valadoc_api_enum_new(ValadocApiNode * parent,ValadocApiSourceFile * file,const gchar * name,ValaSymbolAccessibility accessibility,ValadocApiSourceComment * comment,ValaEnum * data)93 valadoc_api_enum_new (ValadocApiNode* parent,
94 ValadocApiSourceFile* file,
95 const gchar* name,
96 ValaSymbolAccessibility accessibility,
97 ValadocApiSourceComment* comment,
98 ValaEnum* data)
99 {
100 return valadoc_api_enum_construct (VALADOC_API_TYPE_ENUM, parent, file, name, accessibility, comment, data);
101 }
102
103 /**
104 * Returns the name of this enum as it is used in C.
105 */
106 gchar*
valadoc_api_enum_get_cname(ValadocApiEnum * self)107 valadoc_api_enum_get_cname (ValadocApiEnum* self)
108 {
109 const gchar* _tmp0_;
110 gchar* _tmp1_;
111 gchar* result = NULL;
112 g_return_val_if_fail (self != NULL, NULL);
113 _tmp0_ = self->priv->cname;
114 _tmp1_ = g_strdup (_tmp0_);
115 result = _tmp1_;
116 return result;
117 }
118
119 /**
120 * Returns the C symbol representing the runtime type id for this data type.
121 */
122 gchar*
valadoc_api_enum_get_type_id(ValadocApiEnum * self)123 valadoc_api_enum_get_type_id (ValadocApiEnum* self)
124 {
125 const gchar* _tmp0_;
126 gchar* _tmp1_;
127 gchar* result = NULL;
128 g_return_val_if_fail (self != NULL, NULL);
129 _tmp0_ = self->priv->type_id;
130 _tmp1_ = g_strdup (_tmp0_);
131 result = _tmp1_;
132 return result;
133 }
134
135 static ValadocApiNodeType
valadoc_api_enum_real_get_node_type(ValadocApiNode * base)136 valadoc_api_enum_real_get_node_type (ValadocApiNode* base)
137 {
138 ValadocApiNodeType result;
139 ValadocApiEnum* self;
140 self = (ValadocApiEnum*) base;
141 result = VALADOC_API_NODE_TYPE_ENUM;
142 return result;
143 }
144
145 /**
146 * {@inheritDoc}
147 */
148 static void
valadoc_api_enum_real_accept(ValadocApiNode * base,ValadocApiVisitor * visitor)149 valadoc_api_enum_real_accept (ValadocApiNode* base,
150 ValadocApiVisitor* visitor)
151 {
152 ValadocApiEnum * self;
153 self = (ValadocApiEnum*) base;
154 g_return_if_fail (visitor != NULL);
155 valadoc_api_visitor_visit_enum (visitor, self);
156 }
157
158 /**
159 * {@inheritDoc}
160 */
161 static ValadocContentInline*
valadoc_api_enum_real_build_signature(ValadocApiItem * base)162 valadoc_api_enum_real_build_signature (ValadocApiItem* base)
163 {
164 ValadocApiEnum * self;
165 ValadocApiSignatureBuilder* _tmp0_;
166 ValadocApiSignatureBuilder* _tmp1_;
167 ValaSymbolAccessibility _tmp2_;
168 ValaSymbolAccessibility _tmp3_;
169 const gchar* _tmp4_;
170 ValadocApiSignatureBuilder* _tmp5_;
171 ValadocApiSignatureBuilder* _tmp6_;
172 ValadocApiSignatureBuilder* _tmp7_;
173 ValadocContentRun* _tmp8_;
174 ValadocContentInline* _tmp9_;
175 ValadocContentInline* result = NULL;
176 self = (ValadocApiEnum*) base;
177 _tmp0_ = valadoc_api_signature_builder_new ();
178 _tmp1_ = _tmp0_;
179 _tmp2_ = valadoc_api_symbol_get_accessibility ((ValadocApiSymbol*) self);
180 _tmp3_ = _tmp2_;
181 _tmp4_ = vala_symbol_accessibility_to_string (_tmp3_);
182 _tmp5_ = valadoc_api_signature_builder_append_keyword (_tmp1_, _tmp4_, TRUE);
183 _tmp6_ = valadoc_api_signature_builder_append_keyword (_tmp5_, "enum", TRUE);
184 _tmp7_ = valadoc_api_signature_builder_append_symbol (_tmp6_, (ValadocApiNode*) self, TRUE);
185 _tmp8_ = valadoc_api_signature_builder_get (_tmp7_);
186 _tmp9_ = (ValadocContentInline*) _tmp8_;
187 _valadoc_api_signature_builder_unref0 (_tmp1_);
188 result = _tmp9_;
189 return result;
190 }
191
192 static void
valadoc_api_enum_class_init(ValadocApiEnumClass * klass,gpointer klass_data)193 valadoc_api_enum_class_init (ValadocApiEnumClass * klass,
194 gpointer klass_data)
195 {
196 valadoc_api_enum_parent_class = g_type_class_peek_parent (klass);
197 g_type_class_adjust_private_offset (klass, &ValadocApiEnum_private_offset);
198 ((ValadocApiNodeClass *) klass)->accept = (void (*) (ValadocApiNode*, ValadocApiVisitor*)) valadoc_api_enum_real_accept;
199 ((ValadocApiItemClass *) klass)->build_signature = (ValadocContentInline* (*) (ValadocApiItem*)) valadoc_api_enum_real_build_signature;
200 VALADOC_API_NODE_CLASS (klass)->get_node_type = valadoc_api_enum_real_get_node_type;
201 G_OBJECT_CLASS (klass)->get_property = _vala_valadoc_api_enum_get_property;
202 G_OBJECT_CLASS (klass)->finalize = valadoc_api_enum_finalize;
203 /**
204 * {@inheritDoc}
205 */
206 g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_API_ENUM_NODE_TYPE_PROPERTY, valadoc_api_enum_properties[VALADOC_API_ENUM_NODE_TYPE_PROPERTY] = g_param_spec_enum ("node-type", "node-type", "node-type", VALADOC_API_TYPE_NODE_TYPE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
207 }
208
209 static void
valadoc_api_enum_instance_init(ValadocApiEnum * self,gpointer klass)210 valadoc_api_enum_instance_init (ValadocApiEnum * self,
211 gpointer klass)
212 {
213 self->priv = valadoc_api_enum_get_instance_private (self);
214 }
215
216 static void
valadoc_api_enum_finalize(GObject * obj)217 valadoc_api_enum_finalize (GObject * obj)
218 {
219 ValadocApiEnum * self;
220 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_API_TYPE_ENUM, ValadocApiEnum);
221 _g_free0 (self->priv->cname);
222 _g_free0 (self->priv->type_id);
223 G_OBJECT_CLASS (valadoc_api_enum_parent_class)->finalize (obj);
224 }
225
226 /**
227 * Represents an enum declaration.
228 */
229 static GType
valadoc_api_enum_get_type_once(void)230 valadoc_api_enum_get_type_once (void)
231 {
232 static const GTypeInfo g_define_type_info = { sizeof (ValadocApiEnumClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_api_enum_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocApiEnum), 0, (GInstanceInitFunc) valadoc_api_enum_instance_init, NULL };
233 GType valadoc_api_enum_type_id;
234 valadoc_api_enum_type_id = g_type_register_static (VALADOC_API_TYPE_TYPESYMBOL, "ValadocApiEnum", &g_define_type_info, 0);
235 ValadocApiEnum_private_offset = g_type_add_instance_private (valadoc_api_enum_type_id, sizeof (ValadocApiEnumPrivate));
236 return valadoc_api_enum_type_id;
237 }
238
239 GType
valadoc_api_enum_get_type(void)240 valadoc_api_enum_get_type (void)
241 {
242 static volatile gsize valadoc_api_enum_type_id__volatile = 0;
243 if (g_once_init_enter (&valadoc_api_enum_type_id__volatile)) {
244 GType valadoc_api_enum_type_id;
245 valadoc_api_enum_type_id = valadoc_api_enum_get_type_once ();
246 g_once_init_leave (&valadoc_api_enum_type_id__volatile, valadoc_api_enum_type_id);
247 }
248 return valadoc_api_enum_type_id__volatile;
249 }
250
251 static void
_vala_valadoc_api_enum_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)252 _vala_valadoc_api_enum_get_property (GObject * object,
253 guint property_id,
254 GValue * value,
255 GParamSpec * pspec)
256 {
257 ValadocApiEnum * self;
258 self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_API_TYPE_ENUM, ValadocApiEnum);
259 switch (property_id) {
260 case VALADOC_API_ENUM_NODE_TYPE_PROPERTY:
261 g_value_set_enum (value, valadoc_api_node_get_node_type ((ValadocApiNode*) self));
262 break;
263 default:
264 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
265 break;
266 }
267 }
268
269