1 /* sourcecomment.c generated by valac, the Vala compiler
2  * generated from sourcecomment.vala, do not modify */
3 
4 /* sourcecomment.vala
5  *
6  * Copyright (C) 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 <gobject/gvaluecollector.h>
31 
32 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
33 #define _g_free0(var) (var = (g_free (var), NULL))
34 typedef struct _ValadocApiParamSpecSourceComment ValadocApiParamSpecSourceComment;
35 
36 struct _ValadocApiSourceCommentPrivate {
37 	ValadocApiSourceFile* _file;
38 	gchar* _content;
39 	gint _first_line;
40 	gint _first_column;
41 	gint _last_line;
42 	gint _last_column;
43 };
44 
45 struct _ValadocApiParamSpecSourceComment {
46 	GParamSpec parent_instance;
47 };
48 
49 static gint ValadocApiSourceComment_private_offset;
50 static gpointer valadoc_api_source_comment_parent_class = NULL;
51 
52 static void valadoc_api_source_comment_set_file (ValadocApiSourceComment* self,
53                                           ValadocApiSourceFile* value);
54 static void valadoc_api_source_comment_set_content (ValadocApiSourceComment* self,
55                                              const gchar* value);
56 static void valadoc_api_source_comment_set_first_line (ValadocApiSourceComment* self,
57                                                 gint value);
58 static void valadoc_api_source_comment_set_first_column (ValadocApiSourceComment* self,
59                                                   gint value);
60 static void valadoc_api_source_comment_set_last_line (ValadocApiSourceComment* self,
61                                                gint value);
62 static void valadoc_api_source_comment_set_last_column (ValadocApiSourceComment* self,
63                                                  gint value);
64 static void valadoc_api_source_comment_finalize (ValadocApiSourceComment * obj);
65 static GType valadoc_api_source_comment_get_type_once (void);
66 
67 static inline gpointer
valadoc_api_source_comment_get_instance_private(ValadocApiSourceComment * self)68 valadoc_api_source_comment_get_instance_private (ValadocApiSourceComment* self)
69 {
70 	return G_STRUCT_MEMBER_P (self, ValadocApiSourceComment_private_offset);
71 }
72 
73 ValadocApiSourceFile*
valadoc_api_source_comment_get_file(ValadocApiSourceComment * self)74 valadoc_api_source_comment_get_file (ValadocApiSourceComment* self)
75 {
76 	ValadocApiSourceFile* result;
77 	ValadocApiSourceFile* _tmp0_;
78 	g_return_val_if_fail (self != NULL, NULL);
79 	_tmp0_ = self->priv->_file;
80 	result = _tmp0_;
81 	return result;
82 }
83 
84 static gpointer
_g_object_ref0(gpointer self)85 _g_object_ref0 (gpointer self)
86 {
87 	return self ? g_object_ref (self) : NULL;
88 }
89 
90 static void
valadoc_api_source_comment_set_file(ValadocApiSourceComment * self,ValadocApiSourceFile * value)91 valadoc_api_source_comment_set_file (ValadocApiSourceComment* self,
92                                      ValadocApiSourceFile* value)
93 {
94 	ValadocApiSourceFile* _tmp0_;
95 	g_return_if_fail (self != NULL);
96 	_tmp0_ = _g_object_ref0 (value);
97 	_g_object_unref0 (self->priv->_file);
98 	self->priv->_file = _tmp0_;
99 }
100 
101 const gchar*
valadoc_api_source_comment_get_content(ValadocApiSourceComment * self)102 valadoc_api_source_comment_get_content (ValadocApiSourceComment* self)
103 {
104 	const gchar* result;
105 	const gchar* _tmp0_;
106 	g_return_val_if_fail (self != NULL, NULL);
107 	_tmp0_ = self->priv->_content;
108 	result = _tmp0_;
109 	return result;
110 }
111 
112 static void
valadoc_api_source_comment_set_content(ValadocApiSourceComment * self,const gchar * value)113 valadoc_api_source_comment_set_content (ValadocApiSourceComment* self,
114                                         const gchar* value)
115 {
116 	gchar* _tmp0_;
117 	g_return_if_fail (self != NULL);
118 	_tmp0_ = g_strdup (value);
119 	_g_free0 (self->priv->_content);
120 	self->priv->_content = _tmp0_;
121 }
122 
123 gint
valadoc_api_source_comment_get_first_line(ValadocApiSourceComment * self)124 valadoc_api_source_comment_get_first_line (ValadocApiSourceComment* self)
125 {
126 	gint result;
127 	g_return_val_if_fail (self != NULL, 0);
128 	result = self->priv->_first_line;
129 	return result;
130 }
131 
132 static void
valadoc_api_source_comment_set_first_line(ValadocApiSourceComment * self,gint value)133 valadoc_api_source_comment_set_first_line (ValadocApiSourceComment* self,
134                                            gint value)
135 {
136 	g_return_if_fail (self != NULL);
137 	self->priv->_first_line = value;
138 }
139 
140 gint
valadoc_api_source_comment_get_first_column(ValadocApiSourceComment * self)141 valadoc_api_source_comment_get_first_column (ValadocApiSourceComment* self)
142 {
143 	gint result;
144 	g_return_val_if_fail (self != NULL, 0);
145 	result = self->priv->_first_column;
146 	return result;
147 }
148 
149 static void
valadoc_api_source_comment_set_first_column(ValadocApiSourceComment * self,gint value)150 valadoc_api_source_comment_set_first_column (ValadocApiSourceComment* self,
151                                              gint value)
152 {
153 	g_return_if_fail (self != NULL);
154 	self->priv->_first_column = value;
155 }
156 
157 gint
valadoc_api_source_comment_get_last_line(ValadocApiSourceComment * self)158 valadoc_api_source_comment_get_last_line (ValadocApiSourceComment* self)
159 {
160 	gint result;
161 	g_return_val_if_fail (self != NULL, 0);
162 	result = self->priv->_last_line;
163 	return result;
164 }
165 
166 static void
valadoc_api_source_comment_set_last_line(ValadocApiSourceComment * self,gint value)167 valadoc_api_source_comment_set_last_line (ValadocApiSourceComment* self,
168                                           gint value)
169 {
170 	g_return_if_fail (self != NULL);
171 	self->priv->_last_line = value;
172 }
173 
174 gint
valadoc_api_source_comment_get_last_column(ValadocApiSourceComment * self)175 valadoc_api_source_comment_get_last_column (ValadocApiSourceComment* self)
176 {
177 	gint result;
178 	g_return_val_if_fail (self != NULL, 0);
179 	result = self->priv->_last_column;
180 	return result;
181 }
182 
183 static void
valadoc_api_source_comment_set_last_column(ValadocApiSourceComment * self,gint value)184 valadoc_api_source_comment_set_last_column (ValadocApiSourceComment* self,
185                                             gint value)
186 {
187 	g_return_if_fail (self != NULL);
188 	self->priv->_last_column = value;
189 }
190 
191 ValadocApiSourceComment*
valadoc_api_source_comment_construct(GType object_type,const gchar * content,ValadocApiSourceFile * file,gint first_line,gint first_column,gint last_line,gint last_column)192 valadoc_api_source_comment_construct (GType object_type,
193                                       const gchar* content,
194                                       ValadocApiSourceFile* file,
195                                       gint first_line,
196                                       gint first_column,
197                                       gint last_line,
198                                       gint last_column)
199 {
200 	ValadocApiSourceComment* self = NULL;
201 	g_return_val_if_fail (content != NULL, NULL);
202 	g_return_val_if_fail (file != NULL, NULL);
203 	self = (ValadocApiSourceComment*) g_type_create_instance (object_type);
204 	valadoc_api_source_comment_set_first_column (self, first_column);
205 	valadoc_api_source_comment_set_last_column (self, last_column);
206 	valadoc_api_source_comment_set_first_line (self, first_line);
207 	valadoc_api_source_comment_set_last_line (self, last_line);
208 	valadoc_api_source_comment_set_content (self, content);
209 	valadoc_api_source_comment_set_file (self, file);
210 	return self;
211 }
212 
213 ValadocApiSourceComment*
valadoc_api_source_comment_new(const gchar * content,ValadocApiSourceFile * file,gint first_line,gint first_column,gint last_line,gint last_column)214 valadoc_api_source_comment_new (const gchar* content,
215                                 ValadocApiSourceFile* file,
216                                 gint first_line,
217                                 gint first_column,
218                                 gint last_line,
219                                 gint last_column)
220 {
221 	return valadoc_api_source_comment_construct (VALADOC_API_TYPE_SOURCE_COMMENT, content, file, first_line, first_column, last_line, last_column);
222 }
223 
224 static void
valadoc_api_value_source_comment_init(GValue * value)225 valadoc_api_value_source_comment_init (GValue* value)
226 {
227 	value->data[0].v_pointer = NULL;
228 }
229 
230 static void
valadoc_api_value_source_comment_free_value(GValue * value)231 valadoc_api_value_source_comment_free_value (GValue* value)
232 {
233 	if (value->data[0].v_pointer) {
234 		valadoc_api_source_comment_unref (value->data[0].v_pointer);
235 	}
236 }
237 
238 static void
valadoc_api_value_source_comment_copy_value(const GValue * src_value,GValue * dest_value)239 valadoc_api_value_source_comment_copy_value (const GValue* src_value,
240                                              GValue* dest_value)
241 {
242 	if (src_value->data[0].v_pointer) {
243 		dest_value->data[0].v_pointer = valadoc_api_source_comment_ref (src_value->data[0].v_pointer);
244 	} else {
245 		dest_value->data[0].v_pointer = NULL;
246 	}
247 }
248 
249 static gpointer
valadoc_api_value_source_comment_peek_pointer(const GValue * value)250 valadoc_api_value_source_comment_peek_pointer (const GValue* value)
251 {
252 	return value->data[0].v_pointer;
253 }
254 
255 static gchar*
valadoc_api_value_source_comment_collect_value(GValue * value,guint n_collect_values,GTypeCValue * collect_values,guint collect_flags)256 valadoc_api_value_source_comment_collect_value (GValue* value,
257                                                 guint n_collect_values,
258                                                 GTypeCValue* collect_values,
259                                                 guint collect_flags)
260 {
261 	if (collect_values[0].v_pointer) {
262 		ValadocApiSourceComment * object;
263 		object = collect_values[0].v_pointer;
264 		if (object->parent_instance.g_class == NULL) {
265 			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
266 		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
267 			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
268 		}
269 		value->data[0].v_pointer = valadoc_api_source_comment_ref (object);
270 	} else {
271 		value->data[0].v_pointer = NULL;
272 	}
273 	return NULL;
274 }
275 
276 static gchar*
valadoc_api_value_source_comment_lcopy_value(const GValue * value,guint n_collect_values,GTypeCValue * collect_values,guint collect_flags)277 valadoc_api_value_source_comment_lcopy_value (const GValue* value,
278                                               guint n_collect_values,
279                                               GTypeCValue* collect_values,
280                                               guint collect_flags)
281 {
282 	ValadocApiSourceComment ** object_p;
283 	object_p = collect_values[0].v_pointer;
284 	if (!object_p) {
285 		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
286 	}
287 	if (!value->data[0].v_pointer) {
288 		*object_p = NULL;
289 	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
290 		*object_p = value->data[0].v_pointer;
291 	} else {
292 		*object_p = valadoc_api_source_comment_ref (value->data[0].v_pointer);
293 	}
294 	return NULL;
295 }
296 
297 GParamSpec*
valadoc_api_param_spec_source_comment(const gchar * name,const gchar * nick,const gchar * blurb,GType object_type,GParamFlags flags)298 valadoc_api_param_spec_source_comment (const gchar* name,
299                                        const gchar* nick,
300                                        const gchar* blurb,
301                                        GType object_type,
302                                        GParamFlags flags)
303 {
304 	ValadocApiParamSpecSourceComment* spec;
305 	g_return_val_if_fail (g_type_is_a (object_type, VALADOC_API_TYPE_SOURCE_COMMENT), NULL);
306 	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
307 	G_PARAM_SPEC (spec)->value_type = object_type;
308 	return G_PARAM_SPEC (spec);
309 }
310 
311 gpointer
valadoc_api_value_get_source_comment(const GValue * value)312 valadoc_api_value_get_source_comment (const GValue* value)
313 {
314 	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_API_TYPE_SOURCE_COMMENT), NULL);
315 	return value->data[0].v_pointer;
316 }
317 
318 void
valadoc_api_value_set_source_comment(GValue * value,gpointer v_object)319 valadoc_api_value_set_source_comment (GValue* value,
320                                       gpointer v_object)
321 {
322 	ValadocApiSourceComment * old;
323 	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_API_TYPE_SOURCE_COMMENT));
324 	old = value->data[0].v_pointer;
325 	if (v_object) {
326 		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALADOC_API_TYPE_SOURCE_COMMENT));
327 		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
328 		value->data[0].v_pointer = v_object;
329 		valadoc_api_source_comment_ref (value->data[0].v_pointer);
330 	} else {
331 		value->data[0].v_pointer = NULL;
332 	}
333 	if (old) {
334 		valadoc_api_source_comment_unref (old);
335 	}
336 }
337 
338 void
valadoc_api_value_take_source_comment(GValue * value,gpointer v_object)339 valadoc_api_value_take_source_comment (GValue* value,
340                                        gpointer v_object)
341 {
342 	ValadocApiSourceComment * old;
343 	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_API_TYPE_SOURCE_COMMENT));
344 	old = value->data[0].v_pointer;
345 	if (v_object) {
346 		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALADOC_API_TYPE_SOURCE_COMMENT));
347 		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
348 		value->data[0].v_pointer = v_object;
349 	} else {
350 		value->data[0].v_pointer = NULL;
351 	}
352 	if (old) {
353 		valadoc_api_source_comment_unref (old);
354 	}
355 }
356 
357 static void
valadoc_api_source_comment_class_init(ValadocApiSourceCommentClass * klass,gpointer klass_data)358 valadoc_api_source_comment_class_init (ValadocApiSourceCommentClass * klass,
359                                        gpointer klass_data)
360 {
361 	valadoc_api_source_comment_parent_class = g_type_class_peek_parent (klass);
362 	((ValadocApiSourceCommentClass *) klass)->finalize = valadoc_api_source_comment_finalize;
363 	g_type_class_adjust_private_offset (klass, &ValadocApiSourceComment_private_offset);
364 }
365 
366 static void
valadoc_api_source_comment_instance_init(ValadocApiSourceComment * self,gpointer klass)367 valadoc_api_source_comment_instance_init (ValadocApiSourceComment * self,
368                                           gpointer klass)
369 {
370 	self->priv = valadoc_api_source_comment_get_instance_private (self);
371 	self->ref_count = 1;
372 }
373 
374 static void
valadoc_api_source_comment_finalize(ValadocApiSourceComment * obj)375 valadoc_api_source_comment_finalize (ValadocApiSourceComment * obj)
376 {
377 	ValadocApiSourceComment * self;
378 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_API_TYPE_SOURCE_COMMENT, ValadocApiSourceComment);
379 	g_signal_handlers_destroy (self);
380 	_g_object_unref0 (self->priv->_file);
381 	_g_free0 (self->priv->_content);
382 }
383 
384 /**
385  * A documentation comment used by valadoc
386  */
387 static GType
valadoc_api_source_comment_get_type_once(void)388 valadoc_api_source_comment_get_type_once (void)
389 {
390 	static const GTypeValueTable g_define_type_value_table = { valadoc_api_value_source_comment_init, valadoc_api_value_source_comment_free_value, valadoc_api_value_source_comment_copy_value, valadoc_api_value_source_comment_peek_pointer, "p", valadoc_api_value_source_comment_collect_value, "p", valadoc_api_value_source_comment_lcopy_value };
391 	static const GTypeInfo g_define_type_info = { sizeof (ValadocApiSourceCommentClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_api_source_comment_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocApiSourceComment), 0, (GInstanceInitFunc) valadoc_api_source_comment_instance_init, &g_define_type_value_table };
392 	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
393 	GType valadoc_api_source_comment_type_id;
394 	valadoc_api_source_comment_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ValadocApiSourceComment", &g_define_type_info, &g_define_type_fundamental_info, 0);
395 	ValadocApiSourceComment_private_offset = g_type_add_instance_private (valadoc_api_source_comment_type_id, sizeof (ValadocApiSourceCommentPrivate));
396 	return valadoc_api_source_comment_type_id;
397 }
398 
399 GType
valadoc_api_source_comment_get_type(void)400 valadoc_api_source_comment_get_type (void)
401 {
402 	static volatile gsize valadoc_api_source_comment_type_id__volatile = 0;
403 	if (g_once_init_enter (&valadoc_api_source_comment_type_id__volatile)) {
404 		GType valadoc_api_source_comment_type_id;
405 		valadoc_api_source_comment_type_id = valadoc_api_source_comment_get_type_once ();
406 		g_once_init_leave (&valadoc_api_source_comment_type_id__volatile, valadoc_api_source_comment_type_id);
407 	}
408 	return valadoc_api_source_comment_type_id__volatile;
409 }
410 
411 gpointer
valadoc_api_source_comment_ref(gpointer instance)412 valadoc_api_source_comment_ref (gpointer instance)
413 {
414 	ValadocApiSourceComment * self;
415 	self = instance;
416 	g_atomic_int_inc (&self->ref_count);
417 	return instance;
418 }
419 
420 void
valadoc_api_source_comment_unref(gpointer instance)421 valadoc_api_source_comment_unref (gpointer instance)
422 {
423 	ValadocApiSourceComment * self;
424 	self = instance;
425 	if (g_atomic_int_dec_and_test (&self->ref_count)) {
426 		VALADOC_API_SOURCE_COMMENT_GET_CLASS (self)->finalize (self);
427 		g_type_free_instance ((GTypeInstance *) self);
428 	}
429 }
430 
431