1 /* tagletreturn.c generated by valac, the Vala compiler
2  * generated from tagletreturn.vala, do not modify */
3 
4 /* taglet.vala
5  *
6  * Copyright (C) 2008-2009 Didier Villevalois
7  * Copyright (C) 2008-2012 Florian Brosch
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
22  *
23  * Author:
24  * 	Didier 'Ptitjes Villevalois <ptitjes@free.fr>
25  */
26 
27 #include "valadoc.h"
28 #include <stdlib.h>
29 #include <string.h>
30 #include <glib.h>
31 #include <valagee.h>
32 #include <glib-object.h>
33 
34 enum  {
35 	VALADOC_TAGLETS_RETURN_0_PROPERTY,
36 	VALADOC_TAGLETS_RETURN_NUM_PROPERTIES
37 };
38 static GParamSpec* valadoc_taglets_return_properties[VALADOC_TAGLETS_RETURN_NUM_PROPERTIES];
39 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
40 #define _g_free0(var) (var = (g_free (var), NULL))
41 #define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
42 
43 static gpointer valadoc_taglets_return_parent_class = NULL;
44 static ValadocContentTagletIface * valadoc_taglets_return_valadoc_content_taglet_parent_iface = NULL;
45 static ValadocContentBlockIface * valadoc_taglets_return_valadoc_content_block_parent_iface = NULL;
46 
47 static ValadocRule* valadoc_taglets_return_real_get_parser_rule (ValadocContentTaglet* base,
48                                                           ValadocRule* run_rule);
49 static void valadoc_taglets_return_real_check (ValadocContentContentElement* base,
50                                         ValadocApiTree* api_root,
51                                         ValadocApiNode* container,
52                                         const gchar* file_path,
53                                         ValadocErrorReporter* reporter,
54                                         ValadocSettings* settings);
55 static void valadoc_taglets_return_real_accept (ValadocContentContentElement* base,
56                                          ValadocContentContentVisitor* visitor);
57 static ValaList* valadoc_taglets_return_real_get_inheritable_documentation (ValadocContentTaglet* base);
58 static gboolean valadoc_taglets_return_real_inheritable (ValadocContentTaglet* base,
59                                                   ValadocContentTaglet* taglet);
60 static ValadocContentContentElement* valadoc_taglets_return_real_copy (ValadocContentContentElement* base,
61                                                                 ValadocContentContentElement* new_parent);
62 G_GNUC_INTERNAL void valadoc_content_content_element_set_parent (ValadocContentContentElement* self,
63                                                  ValadocContentContentElement* value);
64 G_GNUC_INTERNAL ValadocContentBlockContent* valadoc_content_block_content_construct (GType object_type);
65 static GType valadoc_taglets_return_get_type_once (void);
66 
67 static gpointer
_g_object_ref0(gpointer self)68 _g_object_ref0 (gpointer self)
69 {
70 	return self ? g_object_ref (self) : NULL;
71 }
72 
73 static ValadocRule*
valadoc_taglets_return_real_get_parser_rule(ValadocContentTaglet * base,ValadocRule * run_rule)74 valadoc_taglets_return_real_get_parser_rule (ValadocContentTaglet* base,
75                                              ValadocRule* run_rule)
76 {
77 	ValadocTagletsReturn * self;
78 	ValadocRule* _tmp0_;
79 	ValadocRule* result = NULL;
80 	self = (ValadocTagletsReturn*) base;
81 	g_return_val_if_fail (run_rule != NULL, NULL);
82 	_tmp0_ = _g_object_ref0 (run_rule);
83 	result = _tmp0_;
84 	return result;
85 }
86 
87 static void
valadoc_taglets_return_real_check(ValadocContentContentElement * base,ValadocApiTree * api_root,ValadocApiNode * container,const gchar * file_path,ValadocErrorReporter * reporter,ValadocSettings * settings)88 valadoc_taglets_return_real_check (ValadocContentContentElement* base,
89                                    ValadocApiTree* api_root,
90                                    ValadocApiNode* container,
91                                    const gchar* file_path,
92                                    ValadocErrorReporter* reporter,
93                                    ValadocSettings* settings)
94 {
95 	ValadocTagletsReturn * self;
96 	ValadocApiTypeReference* type_ref = NULL;
97 	gboolean creation_method = FALSE;
98 	gboolean _tmp12_ = FALSE;
99 	gboolean _tmp13_ = FALSE;
100 	ValadocApiTypeReference* _tmp14_;
101 	self = (ValadocTagletsReturn*) base;
102 	g_return_if_fail (api_root != NULL);
103 	g_return_if_fail (container != NULL);
104 	g_return_if_fail (file_path != NULL);
105 	g_return_if_fail (reporter != NULL);
106 	g_return_if_fail (settings != NULL);
107 	type_ref = NULL;
108 	creation_method = FALSE;
109 	if (VALADOC_API_IS_METHOD (container)) {
110 		gboolean _tmp0_;
111 		gboolean _tmp1_;
112 		ValadocApiTypeReference* _tmp2_;
113 		ValadocApiTypeReference* _tmp3_;
114 		ValadocApiTypeReference* _tmp4_;
115 		_tmp0_ = valadoc_api_method_get_is_constructor (G_TYPE_CHECK_INSTANCE_CAST (container, VALADOC_API_TYPE_METHOD, ValadocApiMethod));
116 		_tmp1_ = _tmp0_;
117 		creation_method = _tmp1_;
118 		_tmp2_ = valadoc_api_callable_get_return_type ((ValadocApiCallable*) G_TYPE_CHECK_INSTANCE_CAST (container, VALADOC_API_TYPE_METHOD, ValadocApiMethod));
119 		_tmp3_ = _tmp2_;
120 		_tmp4_ = _g_object_ref0 (_tmp3_);
121 		_g_object_unref0 (type_ref);
122 		type_ref = _tmp4_;
123 	} else {
124 		if (VALADOC_API_IS_CALLABLE (container)) {
125 			ValadocApiTypeReference* _tmp5_;
126 			ValadocApiTypeReference* _tmp6_;
127 			ValadocApiTypeReference* _tmp7_;
128 			_tmp5_ = valadoc_api_callable_get_return_type (G_TYPE_CHECK_INSTANCE_CAST (container, VALADOC_API_TYPE_CALLABLE, ValadocApiCallable));
129 			_tmp6_ = _tmp5_;
130 			_tmp7_ = _g_object_ref0 (_tmp6_);
131 			_g_object_unref0 (type_ref);
132 			type_ref = _tmp7_;
133 		} else {
134 			gchar* _tmp8_;
135 			gchar* _tmp9_;
136 			gchar* _tmp10_;
137 			gchar* _tmp11_;
138 			_tmp8_ = valadoc_api_node_get_full_name (container);
139 			_tmp9_ = _tmp8_;
140 			_tmp10_ = g_strdup_printf ("%s: %s: @return", file_path, _tmp9_);
141 			_tmp11_ = _tmp10_;
142 			valadoc_error_reporter_simple_warning (reporter, _tmp11_, "@return used outside method/delegate/signal context");
143 			_g_free0 (_tmp11_);
144 			_g_free0 (_tmp9_);
145 		}
146 	}
147 	_tmp14_ = type_ref;
148 	if (_tmp14_ != NULL) {
149 		ValadocApiTypeReference* _tmp15_;
150 		ValadocApiItem* _tmp16_;
151 		ValadocApiItem* _tmp17_;
152 		_tmp15_ = type_ref;
153 		_tmp16_ = valadoc_api_typereference_get_data_type (_tmp15_);
154 		_tmp17_ = _tmp16_;
155 		_tmp13_ = _tmp17_ == NULL;
156 	} else {
157 		_tmp13_ = FALSE;
158 	}
159 	if (_tmp13_) {
160 		_tmp12_ = !creation_method;
161 	} else {
162 		_tmp12_ = FALSE;
163 	}
164 	if (_tmp12_) {
165 		gchar* _tmp18_;
166 		gchar* _tmp19_;
167 		gchar* _tmp20_;
168 		gchar* _tmp21_;
169 		_tmp18_ = valadoc_api_node_get_full_name (container);
170 		_tmp19_ = _tmp18_;
171 		_tmp20_ = g_strdup_printf ("%s: %s: @return", file_path, _tmp19_);
172 		_tmp21_ = _tmp20_;
173 		valadoc_error_reporter_simple_warning (reporter, _tmp21_, "Return description declared for void function");
174 		_g_free0 (_tmp21_);
175 		_g_free0 (_tmp19_);
176 	}
177 	VALADOC_CONTENT_CONTENT_ELEMENT_CLASS (valadoc_taglets_return_parent_class)->check ((ValadocContentContentElement*) G_TYPE_CHECK_INSTANCE_CAST (self, VALADOC_CONTENT_TYPE_BLOCK_CONTENT, ValadocContentBlockContent), api_root, container, file_path, reporter, settings);
178 	_g_object_unref0 (type_ref);
179 }
180 
181 static void
valadoc_taglets_return_real_accept(ValadocContentContentElement * base,ValadocContentContentVisitor * visitor)182 valadoc_taglets_return_real_accept (ValadocContentContentElement* base,
183                                     ValadocContentContentVisitor* visitor)
184 {
185 	ValadocTagletsReturn * self;
186 	self = (ValadocTagletsReturn*) base;
187 	g_return_if_fail (visitor != NULL);
188 	valadoc_content_content_visitor_visit_taglet (visitor, (ValadocContentTaglet*) self);
189 }
190 
191 static gpointer
_vala_iterable_ref0(gpointer self)192 _vala_iterable_ref0 (gpointer self)
193 {
194 	return self ? vala_iterable_ref (self) : NULL;
195 }
196 
197 static ValaList*
valadoc_taglets_return_real_get_inheritable_documentation(ValadocContentTaglet * base)198 valadoc_taglets_return_real_get_inheritable_documentation (ValadocContentTaglet* base)
199 {
200 	ValadocTagletsReturn * self;
201 	ValaList* _tmp0_;
202 	ValaList* _tmp1_;
203 	ValaList* _tmp2_;
204 	ValaList* result = NULL;
205 	self = (ValadocTagletsReturn*) base;
206 	_tmp0_ = valadoc_content_block_content_get_content ((ValadocContentBlockContent*) self);
207 	_tmp1_ = _tmp0_;
208 	_tmp2_ = _vala_iterable_ref0 (_tmp1_);
209 	result = _tmp2_;
210 	return result;
211 }
212 
213 static gboolean
valadoc_taglets_return_real_inheritable(ValadocContentTaglet * base,ValadocContentTaglet * taglet)214 valadoc_taglets_return_real_inheritable (ValadocContentTaglet* base,
215                                          ValadocContentTaglet* taglet)
216 {
217 	ValadocTagletsReturn * self;
218 	gboolean result = FALSE;
219 	self = (ValadocTagletsReturn*) base;
220 	g_return_val_if_fail (taglet != NULL, FALSE);
221 	result = VALADOC_TAGLETS_IS_RETURN (taglet);
222 	return result;
223 }
224 
225 static ValadocContentContentElement*
valadoc_taglets_return_real_copy(ValadocContentContentElement * base,ValadocContentContentElement * new_parent)226 valadoc_taglets_return_real_copy (ValadocContentContentElement* base,
227                                   ValadocContentContentElement* new_parent)
228 {
229 	ValadocTagletsReturn * self;
230 	ValadocTagletsReturn* ret = NULL;
231 	ValadocTagletsReturn* _tmp0_;
232 	ValadocTagletsReturn* _tmp1_;
233 	ValadocContentContentElement* result = NULL;
234 	self = (ValadocTagletsReturn*) base;
235 	_tmp0_ = valadoc_taglets_return_new ();
236 	ret = _tmp0_;
237 	_tmp1_ = ret;
238 	valadoc_content_content_element_set_parent ((ValadocContentContentElement*) _tmp1_, new_parent);
239 	{
240 		ValaList* _element_list = NULL;
241 		ValaList* _tmp2_;
242 		ValaList* _tmp3_;
243 		ValaList* _tmp4_;
244 		gint _element_size = 0;
245 		ValaList* _tmp5_;
246 		gint _tmp6_;
247 		gint _tmp7_;
248 		gint _element_index = 0;
249 		_tmp2_ = valadoc_content_block_content_get_content ((ValadocContentBlockContent*) self);
250 		_tmp3_ = _tmp2_;
251 		_tmp4_ = _vala_iterable_ref0 (_tmp3_);
252 		_element_list = _tmp4_;
253 		_tmp5_ = _element_list;
254 		_tmp6_ = vala_collection_get_size ((ValaCollection*) _tmp5_);
255 		_tmp7_ = _tmp6_;
256 		_element_size = _tmp7_;
257 		_element_index = -1;
258 		while (TRUE) {
259 			gint _tmp8_;
260 			gint _tmp9_;
261 			ValadocContentBlock* element = NULL;
262 			ValaList* _tmp10_;
263 			gpointer _tmp11_;
264 			ValadocContentBlock* copy = NULL;
265 			ValadocContentBlock* _tmp12_;
266 			ValadocTagletsReturn* _tmp13_;
267 			ValadocContentContentElement* _tmp14_;
268 			ValadocContentBlock* _tmp15_;
269 			ValadocTagletsReturn* _tmp16_;
270 			ValaList* _tmp17_;
271 			ValaList* _tmp18_;
272 			ValadocContentBlock* _tmp19_;
273 			_element_index = _element_index + 1;
274 			_tmp8_ = _element_index;
275 			_tmp9_ = _element_size;
276 			if (!(_tmp8_ < _tmp9_)) {
277 				break;
278 			}
279 			_tmp10_ = _element_list;
280 			_tmp11_ = vala_list_get (_tmp10_, _element_index);
281 			element = (ValadocContentBlock*) _tmp11_;
282 			_tmp12_ = element;
283 			_tmp13_ = ret;
284 			_tmp14_ = valadoc_content_content_element_copy ((ValadocContentContentElement*) _tmp12_, (ValadocContentContentElement*) _tmp13_);
285 			_tmp15_ = VALADOC_CONTENT_IS_BLOCK (_tmp14_) ? ((ValadocContentBlock*) _tmp14_) : NULL;
286 			if (_tmp15_ == NULL) {
287 				_g_object_unref0 (_tmp14_);
288 			}
289 			copy = _tmp15_;
290 			_tmp16_ = ret;
291 			_tmp17_ = valadoc_content_block_content_get_content ((ValadocContentBlockContent*) _tmp16_);
292 			_tmp18_ = _tmp17_;
293 			_tmp19_ = copy;
294 			vala_collection_add ((ValaCollection*) _tmp18_, _tmp19_);
295 			_g_object_unref0 (copy);
296 			_g_object_unref0 (element);
297 		}
298 		_vala_iterable_unref0 (_element_list);
299 	}
300 	result = (ValadocContentContentElement*) ret;
301 	return result;
302 }
303 
304 ValadocTagletsReturn*
valadoc_taglets_return_construct(GType object_type)305 valadoc_taglets_return_construct (GType object_type)
306 {
307 	ValadocTagletsReturn * self = NULL;
308 	self = (ValadocTagletsReturn*) valadoc_content_block_content_construct (object_type);
309 	return self;
310 }
311 
312 ValadocTagletsReturn*
valadoc_taglets_return_new(void)313 valadoc_taglets_return_new (void)
314 {
315 	return valadoc_taglets_return_construct (VALADOC_TAGLETS_TYPE_RETURN);
316 }
317 
318 static void
valadoc_taglets_return_class_init(ValadocTagletsReturnClass * klass,gpointer klass_data)319 valadoc_taglets_return_class_init (ValadocTagletsReturnClass * klass,
320                                    gpointer klass_data)
321 {
322 	valadoc_taglets_return_parent_class = g_type_class_peek_parent (klass);
323 	((ValadocContentContentElementClass *) klass)->check = (void (*) (ValadocContentContentElement*, ValadocApiTree*, ValadocApiNode*, const gchar*, ValadocErrorReporter*, ValadocSettings*)) valadoc_taglets_return_real_check;
324 	((ValadocContentContentElementClass *) klass)->accept = (void (*) (ValadocContentContentElement*, ValadocContentContentVisitor*)) valadoc_taglets_return_real_accept;
325 	((ValadocContentContentElementClass *) klass)->copy = (ValadocContentContentElement* (*) (ValadocContentContentElement*, ValadocContentContentElement*)) valadoc_taglets_return_real_copy;
326 }
327 
328 static void
valadoc_taglets_return_valadoc_content_taglet_interface_init(ValadocContentTagletIface * iface,gpointer iface_data)329 valadoc_taglets_return_valadoc_content_taglet_interface_init (ValadocContentTagletIface * iface,
330                                                               gpointer iface_data)
331 {
332 	valadoc_taglets_return_valadoc_content_taglet_parent_iface = g_type_interface_peek_parent (iface);
333 	iface->get_parser_rule = (ValadocRule* (*) (ValadocContentTaglet*, ValadocRule*)) valadoc_taglets_return_real_get_parser_rule;
334 	iface->get_inheritable_documentation = (ValaList* (*) (ValadocContentTaglet*)) valadoc_taglets_return_real_get_inheritable_documentation;
335 	iface->inheritable = (gboolean (*) (ValadocContentTaglet*, ValadocContentTaglet*)) valadoc_taglets_return_real_inheritable;
336 }
337 
338 static void
valadoc_taglets_return_valadoc_content_block_interface_init(ValadocContentBlockIface * iface,gpointer iface_data)339 valadoc_taglets_return_valadoc_content_block_interface_init (ValadocContentBlockIface * iface,
340                                                              gpointer iface_data)
341 {
342 	valadoc_taglets_return_valadoc_content_block_parent_iface = g_type_interface_peek_parent (iface);
343 }
344 
345 static void
valadoc_taglets_return_instance_init(ValadocTagletsReturn * self,gpointer klass)346 valadoc_taglets_return_instance_init (ValadocTagletsReturn * self,
347                                       gpointer klass)
348 {
349 }
350 
351 static GType
valadoc_taglets_return_get_type_once(void)352 valadoc_taglets_return_get_type_once (void)
353 {
354 	static const GTypeInfo g_define_type_info = { sizeof (ValadocTagletsReturnClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_taglets_return_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocTagletsReturn), 0, (GInstanceInitFunc) valadoc_taglets_return_instance_init, NULL };
355 	static const GInterfaceInfo valadoc_content_taglet_info = { (GInterfaceInitFunc) valadoc_taglets_return_valadoc_content_taglet_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
356 	static const GInterfaceInfo valadoc_content_block_info = { (GInterfaceInitFunc) valadoc_taglets_return_valadoc_content_block_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
357 	GType valadoc_taglets_return_type_id;
358 	valadoc_taglets_return_type_id = g_type_register_static (VALADOC_CONTENT_TYPE_BLOCK_CONTENT, "ValadocTagletsReturn", &g_define_type_info, 0);
359 	g_type_add_interface_static (valadoc_taglets_return_type_id, VALADOC_CONTENT_TYPE_TAGLET, &valadoc_content_taglet_info);
360 	g_type_add_interface_static (valadoc_taglets_return_type_id, VALADOC_CONTENT_TYPE_BLOCK, &valadoc_content_block_info);
361 	return valadoc_taglets_return_type_id;
362 }
363 
364 GType
valadoc_taglets_return_get_type(void)365 valadoc_taglets_return_get_type (void)
366 {
367 	static volatile gsize valadoc_taglets_return_type_id__volatile = 0;
368 	if (g_once_init_enter (&valadoc_taglets_return_type_id__volatile)) {
369 		GType valadoc_taglets_return_type_id;
370 		valadoc_taglets_return_type_id = valadoc_taglets_return_get_type_once ();
371 		g_once_init_leave (&valadoc_taglets_return_type_id__volatile, valadoc_taglets_return_type_id);
372 	}
373 	return valadoc_taglets_return_type_id__volatile;
374 }
375 
376