1 /* signaturebuilder.c generated by valac, the Vala compiler
2 * generated from signaturebuilder.vala, do not modify */
3
4 /* signaturebuilder.vala
5 *
6 * Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
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 * Didier 'Ptitjes Villevalois <ptitjes@free.fr>
24 */
25
26 #include "valadoc.h"
27 #include <stdlib.h>
28 #include <string.h>
29 #include <glib.h>
30 #include <valagee.h>
31 #include <glib-object.h>
32 #include <gobject/gvaluecollector.h>
33
34 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
35 #define _g_free0(var) (var = (g_free (var), NULL))
36 typedef struct _ValadocApiParamSpecSignatureBuilder ValadocApiParamSpecSignatureBuilder;
37
38 struct _ValadocApiSignatureBuilderPrivate {
39 ValadocContentRun* run;
40 ValadocContentInline* last_appended;
41 };
42
43 struct _ValadocApiParamSpecSignatureBuilder {
44 GParamSpec parent_instance;
45 };
46
47 static gint ValadocApiSignatureBuilder_private_offset;
48 static gpointer valadoc_api_signature_builder_parent_class = NULL;
49
50 G_GNUC_INTERNAL ValadocContentRun* valadoc_content_run_new (ValadocContentRunStyle style);
51 G_GNUC_INTERNAL ValadocContentRun* valadoc_content_run_construct (GType object_type,
52 ValadocContentRunStyle style);
53 static void valadoc_api_signature_builder_append_text (ValadocApiSignatureBuilder* self,
54 const gchar* text);
55 G_GNUC_INTERNAL ValadocContentText* valadoc_content_text_new (const gchar* text);
56 G_GNUC_INTERNAL ValadocContentText* valadoc_content_text_construct (GType object_type,
57 const gchar* text);
58 G_GNUC_INTERNAL ValadocContentSymbolLink* valadoc_content_symbol_link_new (ValadocApiNode* symbol,
59 const gchar* given_symbol_name);
60 G_GNUC_INTERNAL ValadocContentSymbolLink* valadoc_content_symbol_link_construct (GType object_type,
61 ValadocApiNode* symbol,
62 const gchar* given_symbol_name);
63 static void valadoc_api_signature_builder_finalize (ValadocApiSignatureBuilder * obj);
64 static GType valadoc_api_signature_builder_get_type_once (void);
65
66 static inline gpointer
valadoc_api_signature_builder_get_instance_private(ValadocApiSignatureBuilder * self)67 valadoc_api_signature_builder_get_instance_private (ValadocApiSignatureBuilder* self)
68 {
69 return G_STRUCT_MEMBER_P (self, ValadocApiSignatureBuilder_private_offset);
70 }
71
72 /**
73 * Creates a new SignatureBuilder
74 */
75 ValadocApiSignatureBuilder*
valadoc_api_signature_builder_construct(GType object_type)76 valadoc_api_signature_builder_construct (GType object_type)
77 {
78 ValadocApiSignatureBuilder* self = NULL;
79 ValadocContentRun* _tmp0_;
80 self = (ValadocApiSignatureBuilder*) g_type_create_instance (object_type);
81 _tmp0_ = valadoc_content_run_new (VALADOC_CONTENT_RUN_STYLE_NONE);
82 _g_object_unref0 (self->priv->run);
83 self->priv->run = _tmp0_;
84 return self;
85 }
86
87 ValadocApiSignatureBuilder*
valadoc_api_signature_builder_new(void)88 valadoc_api_signature_builder_new (void)
89 {
90 return valadoc_api_signature_builder_construct (VALADOC_API_TYPE_SIGNATURE_BUILDER);
91 }
92
93 static void
valadoc_api_signature_builder_append_text(ValadocApiSignatureBuilder * self,const gchar * text)94 valadoc_api_signature_builder_append_text (ValadocApiSignatureBuilder* self,
95 const gchar* text)
96 {
97 ValadocContentInline* _tmp0_;
98 g_return_if_fail (self != NULL);
99 g_return_if_fail (text != NULL);
100 _tmp0_ = self->priv->last_appended;
101 if (VALADOC_CONTENT_IS_TEXT (_tmp0_)) {
102 ValadocContentInline* _tmp1_;
103 ValadocContentInline* _tmp2_;
104 const gchar* _tmp3_;
105 const gchar* _tmp4_;
106 gchar* _tmp5_;
107 gchar* _tmp6_;
108 _tmp1_ = self->priv->last_appended;
109 _tmp2_ = self->priv->last_appended;
110 _tmp3_ = valadoc_content_text_get_content (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, VALADOC_CONTENT_TYPE_TEXT, ValadocContentText));
111 _tmp4_ = _tmp3_;
112 _tmp5_ = g_strconcat (_tmp4_, text, NULL);
113 _tmp6_ = _tmp5_;
114 valadoc_content_text_set_content (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, VALADOC_CONTENT_TYPE_TEXT, ValadocContentText), _tmp6_);
115 _g_free0 (_tmp6_);
116 } else {
117 ValadocContentRun* _tmp7_;
118 ValaList* _tmp8_;
119 ValaList* _tmp9_;
120 ValadocContentText* _tmp10_;
121 ValadocContentInline* _tmp11_;
122 _tmp7_ = self->priv->run;
123 _tmp8_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) _tmp7_);
124 _tmp9_ = _tmp8_;
125 _tmp10_ = valadoc_content_text_new (text);
126 _g_object_unref0 (self->priv->last_appended);
127 self->priv->last_appended = (ValadocContentInline*) _tmp10_;
128 _tmp11_ = self->priv->last_appended;
129 vala_collection_add ((ValaCollection*) _tmp9_, _tmp11_);
130 }
131 }
132
133 /**
134 * Adds text onto the end of the builder.
135 *
136 * @param text a string
137 * @param spaced add a space at the front of the string if necessary
138 * @return this
139 */
140 ValadocApiSignatureBuilder*
valadoc_api_signature_builder_append(ValadocApiSignatureBuilder * self,const gchar * text,gboolean spaced)141 valadoc_api_signature_builder_append (ValadocApiSignatureBuilder* self,
142 const gchar* text,
143 gboolean spaced)
144 {
145 const gchar* _tmp0_ = NULL;
146 gboolean _tmp1_ = FALSE;
147 ValadocContentInline* _tmp2_;
148 gchar* content = NULL;
149 gchar* _tmp3_;
150 ValadocApiSignatureBuilder* result = NULL;
151 g_return_val_if_fail (self != NULL, NULL);
152 g_return_val_if_fail (text != NULL, NULL);
153 _tmp2_ = self->priv->last_appended;
154 if (_tmp2_ != NULL) {
155 _tmp1_ = spaced;
156 } else {
157 _tmp1_ = FALSE;
158 }
159 if (_tmp1_) {
160 _tmp0_ = " ";
161 } else {
162 _tmp0_ = "";
163 }
164 _tmp3_ = g_strconcat (_tmp0_, text, NULL);
165 content = _tmp3_;
166 valadoc_api_signature_builder_append_text (self, content);
167 result = self;
168 _g_free0 (content);
169 return result;
170 }
171
172 /**
173 * Adds text onto the end of the builder.
174 *
175 * @param text a string
176 * @param spaced add a space at the front of the string if necessary
177 * @return this
178 */
179 ValadocApiSignatureBuilder*
valadoc_api_signature_builder_append_attribute(ValadocApiSignatureBuilder * self,const gchar * text,gboolean spaced)180 valadoc_api_signature_builder_append_attribute (ValadocApiSignatureBuilder* self,
181 const gchar* text,
182 gboolean spaced)
183 {
184 const gchar* _tmp0_ = NULL;
185 gboolean _tmp1_ = FALSE;
186 ValadocContentInline* _tmp2_;
187 gchar* content = NULL;
188 gchar* _tmp3_;
189 ValadocApiSignatureBuilder* result = NULL;
190 g_return_val_if_fail (self != NULL, NULL);
191 g_return_val_if_fail (text != NULL, NULL);
192 _tmp2_ = self->priv->last_appended;
193 if (_tmp2_ != NULL) {
194 _tmp1_ = spaced;
195 } else {
196 _tmp1_ = FALSE;
197 }
198 if (_tmp1_) {
199 _tmp0_ = " ";
200 } else {
201 _tmp0_ = "";
202 }
203 _tmp3_ = g_strconcat (_tmp0_, text, NULL);
204 content = _tmp3_;
205 valadoc_api_signature_builder_append_text (self, content);
206 result = self;
207 _g_free0 (content);
208 return result;
209 }
210
211 /**
212 * Adds highlighted text onto the end of the builder.
213 *
214 * @param text a string
215 * @param spaced add a space at the front of the string if necessary
216 * @return this
217 */
218 ValadocApiSignatureBuilder*
valadoc_api_signature_builder_append_highlighted(ValadocApiSignatureBuilder * self,const gchar * text,gboolean spaced)219 valadoc_api_signature_builder_append_highlighted (ValadocApiSignatureBuilder* self,
220 const gchar* text,
221 gboolean spaced)
222 {
223 const gchar* _tmp0_ = NULL;
224 gboolean _tmp1_ = FALSE;
225 ValadocContentInline* _tmp2_;
226 gchar* content = NULL;
227 gchar* _tmp3_;
228 ValadocContentRun* inner = NULL;
229 ValadocContentRun* _tmp4_;
230 ValaList* _tmp5_;
231 ValaList* _tmp6_;
232 ValadocContentText* _tmp7_;
233 ValadocContentText* _tmp8_;
234 ValadocApiSignatureBuilder* _tmp9_;
235 ValadocApiSignatureBuilder* result = NULL;
236 g_return_val_if_fail (self != NULL, NULL);
237 g_return_val_if_fail (text != NULL, NULL);
238 _tmp2_ = self->priv->last_appended;
239 if (_tmp2_ != NULL) {
240 _tmp1_ = spaced;
241 } else {
242 _tmp1_ = FALSE;
243 }
244 if (_tmp1_) {
245 _tmp0_ = " ";
246 } else {
247 _tmp0_ = "";
248 }
249 _tmp3_ = g_strconcat (_tmp0_, text, NULL);
250 content = _tmp3_;
251 _tmp4_ = valadoc_content_run_new (VALADOC_CONTENT_RUN_STYLE_ITALIC);
252 inner = _tmp4_;
253 _tmp5_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) inner);
254 _tmp6_ = _tmp5_;
255 _tmp7_ = valadoc_content_text_new (content);
256 _tmp8_ = _tmp7_;
257 vala_collection_add ((ValaCollection*) _tmp6_, (ValadocContentInline*) _tmp8_);
258 _g_object_unref0 (_tmp8_);
259 _tmp9_ = valadoc_api_signature_builder_append_content (self, (ValadocContentInline*) inner, spaced);
260 result = _tmp9_;
261 _g_object_unref0 (inner);
262 _g_free0 (content);
263 return result;
264 }
265
266 /**
267 * Adds a Inline onto the end of the builder.
268 *
269 * @param content a content
270 * @param spaced add a space at the front of the inline if necessary
271 * @return this
272 */
273 static gpointer
_g_object_ref0(gpointer self)274 _g_object_ref0 (gpointer self)
275 {
276 return self ? g_object_ref (self) : NULL;
277 }
278
279 ValadocApiSignatureBuilder*
valadoc_api_signature_builder_append_content(ValadocApiSignatureBuilder * self,ValadocContentInline * content,gboolean spaced)280 valadoc_api_signature_builder_append_content (ValadocApiSignatureBuilder* self,
281 ValadocContentInline* content,
282 gboolean spaced)
283 {
284 gboolean _tmp0_ = FALSE;
285 ValadocContentInline* _tmp1_;
286 ValadocContentRun* _tmp2_;
287 ValaList* _tmp3_;
288 ValaList* _tmp4_;
289 ValadocContentInline* _tmp5_;
290 ValadocContentInline* _tmp6_;
291 ValadocApiSignatureBuilder* result = NULL;
292 g_return_val_if_fail (self != NULL, NULL);
293 g_return_val_if_fail (content != NULL, NULL);
294 _tmp1_ = self->priv->last_appended;
295 if (_tmp1_ != NULL) {
296 _tmp0_ = spaced;
297 } else {
298 _tmp0_ = FALSE;
299 }
300 if (_tmp0_) {
301 valadoc_api_signature_builder_append_text (self, " ");
302 }
303 _tmp2_ = self->priv->run;
304 _tmp3_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) _tmp2_);
305 _tmp4_ = _tmp3_;
306 _tmp5_ = _g_object_ref0 (content);
307 _g_object_unref0 (self->priv->last_appended);
308 self->priv->last_appended = _tmp5_;
309 _tmp6_ = self->priv->last_appended;
310 vala_collection_add ((ValaCollection*) _tmp4_, _tmp6_);
311 result = self;
312 return result;
313 }
314
315 /**
316 * Adds a keyword onto the end of the builder.
317 *
318 * @param keyword a keyword
319 * @param spaced add a space at the front of the keyword if necessary
320 * @return this
321 */
322 ValadocApiSignatureBuilder*
valadoc_api_signature_builder_append_keyword(ValadocApiSignatureBuilder * self,const gchar * keyword,gboolean spaced)323 valadoc_api_signature_builder_append_keyword (ValadocApiSignatureBuilder* self,
324 const gchar* keyword,
325 gboolean spaced)
326 {
327 ValadocContentRun* inner = NULL;
328 ValadocContentRun* _tmp0_;
329 ValaList* _tmp1_;
330 ValaList* _tmp2_;
331 ValadocContentText* _tmp3_;
332 ValadocContentText* _tmp4_;
333 ValadocApiSignatureBuilder* _tmp5_;
334 ValadocApiSignatureBuilder* result = NULL;
335 g_return_val_if_fail (self != NULL, NULL);
336 g_return_val_if_fail (keyword != NULL, NULL);
337 _tmp0_ = valadoc_content_run_new (VALADOC_CONTENT_RUN_STYLE_LANG_KEYWORD);
338 inner = _tmp0_;
339 _tmp1_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) inner);
340 _tmp2_ = _tmp1_;
341 _tmp3_ = valadoc_content_text_new (keyword);
342 _tmp4_ = _tmp3_;
343 vala_collection_add ((ValaCollection*) _tmp2_, (ValadocContentInline*) _tmp4_);
344 _g_object_unref0 (_tmp4_);
345 _tmp5_ = valadoc_api_signature_builder_append_content (self, (ValadocContentInline*) inner, spaced);
346 result = _tmp5_;
347 _g_object_unref0 (inner);
348 return result;
349 }
350
351 /**
352 * Adds a symbol onto the end of the builder.
353 *
354 * @param node a node
355 * @param spaced add a space at the front of the node if necessary
356 * @return this
357 */
358 ValadocApiSignatureBuilder*
valadoc_api_signature_builder_append_symbol(ValadocApiSignatureBuilder * self,ValadocApiNode * node,gboolean spaced)359 valadoc_api_signature_builder_append_symbol (ValadocApiSignatureBuilder* self,
360 ValadocApiNode* node,
361 gboolean spaced)
362 {
363 ValadocContentRun* inner = NULL;
364 ValadocContentRun* _tmp0_;
365 ValaList* _tmp1_;
366 ValaList* _tmp2_;
367 const gchar* _tmp3_;
368 const gchar* _tmp4_;
369 ValadocContentSymbolLink* _tmp5_;
370 ValadocContentSymbolLink* _tmp6_;
371 ValadocApiSignatureBuilder* _tmp7_;
372 ValadocApiSignatureBuilder* result = NULL;
373 g_return_val_if_fail (self != NULL, NULL);
374 g_return_val_if_fail (node != NULL, NULL);
375 _tmp0_ = valadoc_content_run_new (VALADOC_CONTENT_RUN_STYLE_BOLD);
376 inner = _tmp0_;
377 _tmp1_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) inner);
378 _tmp2_ = _tmp1_;
379 _tmp3_ = valadoc_api_node_get_name (node);
380 _tmp4_ = _tmp3_;
381 _tmp5_ = valadoc_content_symbol_link_new (node, _tmp4_);
382 _tmp6_ = _tmp5_;
383 vala_collection_add ((ValaCollection*) _tmp2_, (ValadocContentInline*) _tmp6_);
384 _g_object_unref0 (_tmp6_);
385 _tmp7_ = valadoc_api_signature_builder_append_content (self, (ValadocContentInline*) inner, spaced);
386 result = _tmp7_;
387 _g_object_unref0 (inner);
388 return result;
389 }
390
391 /**
392 * Adds a type onto the end of the builder.
393 *
394 * @param node a node
395 * @param spaced add a space at the front of the node if necessary
396 * @return this
397 */
398 ValadocApiSignatureBuilder*
valadoc_api_signature_builder_append_type(ValadocApiSignatureBuilder * self,ValadocApiNode * node,gboolean spaced)399 valadoc_api_signature_builder_append_type (ValadocApiSignatureBuilder* self,
400 ValadocApiNode* node,
401 gboolean spaced)
402 {
403 ValadocContentRunStyle style = 0;
404 gboolean _tmp0_ = FALSE;
405 ValadocContentRun* inner = NULL;
406 ValadocContentRunStyle _tmp3_;
407 ValadocContentRun* _tmp4_;
408 ValaList* _tmp5_;
409 ValaList* _tmp6_;
410 const gchar* _tmp7_;
411 const gchar* _tmp8_;
412 ValadocContentSymbolLink* _tmp9_;
413 ValadocContentSymbolLink* _tmp10_;
414 ValadocApiSignatureBuilder* _tmp11_;
415 ValadocApiSignatureBuilder* result = NULL;
416 g_return_val_if_fail (self != NULL, NULL);
417 g_return_val_if_fail (node != NULL, NULL);
418 style = VALADOC_CONTENT_RUN_STYLE_LANG_TYPE;
419 if (VALADOC_API_IS_TYPESYMBOL (node)) {
420 gboolean _tmp1_;
421 gboolean _tmp2_;
422 _tmp1_ = valadoc_api_typesymbol_get_is_basic_type (G_TYPE_CHECK_INSTANCE_CAST (node, VALADOC_API_TYPE_TYPESYMBOL, ValadocApiTypeSymbol));
423 _tmp2_ = _tmp1_;
424 _tmp0_ = _tmp2_;
425 } else {
426 _tmp0_ = FALSE;
427 }
428 if (_tmp0_) {
429 style = VALADOC_CONTENT_RUN_STYLE_LANG_BASIC_TYPE;
430 }
431 _tmp3_ = style;
432 _tmp4_ = valadoc_content_run_new (_tmp3_);
433 inner = _tmp4_;
434 _tmp5_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) inner);
435 _tmp6_ = _tmp5_;
436 _tmp7_ = valadoc_api_node_get_name (node);
437 _tmp8_ = _tmp7_;
438 _tmp9_ = valadoc_content_symbol_link_new (node, _tmp8_);
439 _tmp10_ = _tmp9_;
440 vala_collection_add ((ValaCollection*) _tmp6_, (ValadocContentInline*) _tmp10_);
441 _g_object_unref0 (_tmp10_);
442 _tmp11_ = valadoc_api_signature_builder_append_content (self, (ValadocContentInline*) inner, spaced);
443 result = _tmp11_;
444 _g_object_unref0 (inner);
445 return result;
446 }
447
448 /**
449 * Adds a type name onto the end of the builder.
450 *
451 * @param name a type name
452 * @param spaced add a space at the front of the type name if necessary
453 * @return this
454 */
455 ValadocApiSignatureBuilder*
valadoc_api_signature_builder_append_type_name(ValadocApiSignatureBuilder * self,const gchar * name,gboolean spaced)456 valadoc_api_signature_builder_append_type_name (ValadocApiSignatureBuilder* self,
457 const gchar* name,
458 gboolean spaced)
459 {
460 ValadocContentRun* inner = NULL;
461 ValadocContentRun* _tmp0_;
462 ValaList* _tmp1_;
463 ValaList* _tmp2_;
464 ValadocContentText* _tmp3_;
465 ValadocContentText* _tmp4_;
466 ValadocApiSignatureBuilder* _tmp5_;
467 ValadocApiSignatureBuilder* result = NULL;
468 g_return_val_if_fail (self != NULL, NULL);
469 g_return_val_if_fail (name != NULL, NULL);
470 _tmp0_ = valadoc_content_run_new (VALADOC_CONTENT_RUN_STYLE_LANG_TYPE);
471 inner = _tmp0_;
472 _tmp1_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) inner);
473 _tmp2_ = _tmp1_;
474 _tmp3_ = valadoc_content_text_new (name);
475 _tmp4_ = _tmp3_;
476 vala_collection_add ((ValaCollection*) _tmp2_, (ValadocContentInline*) _tmp4_);
477 _g_object_unref0 (_tmp4_);
478 _tmp5_ = valadoc_api_signature_builder_append_content (self, (ValadocContentInline*) inner, spaced);
479 result = _tmp5_;
480 _g_object_unref0 (inner);
481 return result;
482 }
483
484 /**
485 * Adds a literal onto the end of the builder.
486 *
487 * @param literal a literal
488 * @param spaced add a space at the front of the literal if necessary
489 * @return this
490 */
491 ValadocApiSignatureBuilder*
valadoc_api_signature_builder_append_literal(ValadocApiSignatureBuilder * self,const gchar * literal,gboolean spaced)492 valadoc_api_signature_builder_append_literal (ValadocApiSignatureBuilder* self,
493 const gchar* literal,
494 gboolean spaced)
495 {
496 ValadocContentRun* inner = NULL;
497 ValadocContentRun* _tmp0_;
498 ValaList* _tmp1_;
499 ValaList* _tmp2_;
500 ValadocContentText* _tmp3_;
501 ValadocContentText* _tmp4_;
502 ValadocApiSignatureBuilder* _tmp5_;
503 ValadocApiSignatureBuilder* result = NULL;
504 g_return_val_if_fail (self != NULL, NULL);
505 g_return_val_if_fail (literal != NULL, NULL);
506 _tmp0_ = valadoc_content_run_new (VALADOC_CONTENT_RUN_STYLE_LANG_LITERAL);
507 inner = _tmp0_;
508 _tmp1_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) inner);
509 _tmp2_ = _tmp1_;
510 _tmp3_ = valadoc_content_text_new (literal);
511 _tmp4_ = _tmp3_;
512 vala_collection_add ((ValaCollection*) _tmp2_, (ValadocContentInline*) _tmp4_);
513 _g_object_unref0 (_tmp4_);
514 _tmp5_ = valadoc_api_signature_builder_append_content (self, (ValadocContentInline*) inner, spaced);
515 result = _tmp5_;
516 _g_object_unref0 (inner);
517 return result;
518 }
519
520 /**
521 * The content
522 */
523 ValadocContentRun*
valadoc_api_signature_builder_get(ValadocApiSignatureBuilder * self)524 valadoc_api_signature_builder_get (ValadocApiSignatureBuilder* self)
525 {
526 ValadocContentRun* _tmp0_;
527 ValadocContentRun* _tmp1_;
528 ValadocContentRun* result = NULL;
529 g_return_val_if_fail (self != NULL, NULL);
530 _tmp0_ = self->priv->run;
531 _tmp1_ = _g_object_ref0 (_tmp0_);
532 result = _tmp1_;
533 return result;
534 }
535
536 static void
valadoc_api_value_signature_builder_init(GValue * value)537 valadoc_api_value_signature_builder_init (GValue* value)
538 {
539 value->data[0].v_pointer = NULL;
540 }
541
542 static void
valadoc_api_value_signature_builder_free_value(GValue * value)543 valadoc_api_value_signature_builder_free_value (GValue* value)
544 {
545 if (value->data[0].v_pointer) {
546 valadoc_api_signature_builder_unref (value->data[0].v_pointer);
547 }
548 }
549
550 static void
valadoc_api_value_signature_builder_copy_value(const GValue * src_value,GValue * dest_value)551 valadoc_api_value_signature_builder_copy_value (const GValue* src_value,
552 GValue* dest_value)
553 {
554 if (src_value->data[0].v_pointer) {
555 dest_value->data[0].v_pointer = valadoc_api_signature_builder_ref (src_value->data[0].v_pointer);
556 } else {
557 dest_value->data[0].v_pointer = NULL;
558 }
559 }
560
561 static gpointer
valadoc_api_value_signature_builder_peek_pointer(const GValue * value)562 valadoc_api_value_signature_builder_peek_pointer (const GValue* value)
563 {
564 return value->data[0].v_pointer;
565 }
566
567 static gchar*
valadoc_api_value_signature_builder_collect_value(GValue * value,guint n_collect_values,GTypeCValue * collect_values,guint collect_flags)568 valadoc_api_value_signature_builder_collect_value (GValue* value,
569 guint n_collect_values,
570 GTypeCValue* collect_values,
571 guint collect_flags)
572 {
573 if (collect_values[0].v_pointer) {
574 ValadocApiSignatureBuilder * object;
575 object = collect_values[0].v_pointer;
576 if (object->parent_instance.g_class == NULL) {
577 return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
578 } else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
579 return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
580 }
581 value->data[0].v_pointer = valadoc_api_signature_builder_ref (object);
582 } else {
583 value->data[0].v_pointer = NULL;
584 }
585 return NULL;
586 }
587
588 static gchar*
valadoc_api_value_signature_builder_lcopy_value(const GValue * value,guint n_collect_values,GTypeCValue * collect_values,guint collect_flags)589 valadoc_api_value_signature_builder_lcopy_value (const GValue* value,
590 guint n_collect_values,
591 GTypeCValue* collect_values,
592 guint collect_flags)
593 {
594 ValadocApiSignatureBuilder ** object_p;
595 object_p = collect_values[0].v_pointer;
596 if (!object_p) {
597 return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
598 }
599 if (!value->data[0].v_pointer) {
600 *object_p = NULL;
601 } else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
602 *object_p = value->data[0].v_pointer;
603 } else {
604 *object_p = valadoc_api_signature_builder_ref (value->data[0].v_pointer);
605 }
606 return NULL;
607 }
608
609 GParamSpec*
valadoc_api_param_spec_signature_builder(const gchar * name,const gchar * nick,const gchar * blurb,GType object_type,GParamFlags flags)610 valadoc_api_param_spec_signature_builder (const gchar* name,
611 const gchar* nick,
612 const gchar* blurb,
613 GType object_type,
614 GParamFlags flags)
615 {
616 ValadocApiParamSpecSignatureBuilder* spec;
617 g_return_val_if_fail (g_type_is_a (object_type, VALADOC_API_TYPE_SIGNATURE_BUILDER), NULL);
618 spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
619 G_PARAM_SPEC (spec)->value_type = object_type;
620 return G_PARAM_SPEC (spec);
621 }
622
623 gpointer
valadoc_api_value_get_signature_builder(const GValue * value)624 valadoc_api_value_get_signature_builder (const GValue* value)
625 {
626 g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_API_TYPE_SIGNATURE_BUILDER), NULL);
627 return value->data[0].v_pointer;
628 }
629
630 void
valadoc_api_value_set_signature_builder(GValue * value,gpointer v_object)631 valadoc_api_value_set_signature_builder (GValue* value,
632 gpointer v_object)
633 {
634 ValadocApiSignatureBuilder * old;
635 g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_API_TYPE_SIGNATURE_BUILDER));
636 old = value->data[0].v_pointer;
637 if (v_object) {
638 g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALADOC_API_TYPE_SIGNATURE_BUILDER));
639 g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
640 value->data[0].v_pointer = v_object;
641 valadoc_api_signature_builder_ref (value->data[0].v_pointer);
642 } else {
643 value->data[0].v_pointer = NULL;
644 }
645 if (old) {
646 valadoc_api_signature_builder_unref (old);
647 }
648 }
649
650 void
valadoc_api_value_take_signature_builder(GValue * value,gpointer v_object)651 valadoc_api_value_take_signature_builder (GValue* value,
652 gpointer v_object)
653 {
654 ValadocApiSignatureBuilder * old;
655 g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_API_TYPE_SIGNATURE_BUILDER));
656 old = value->data[0].v_pointer;
657 if (v_object) {
658 g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALADOC_API_TYPE_SIGNATURE_BUILDER));
659 g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
660 value->data[0].v_pointer = v_object;
661 } else {
662 value->data[0].v_pointer = NULL;
663 }
664 if (old) {
665 valadoc_api_signature_builder_unref (old);
666 }
667 }
668
669 static void
valadoc_api_signature_builder_class_init(ValadocApiSignatureBuilderClass * klass,gpointer klass_data)670 valadoc_api_signature_builder_class_init (ValadocApiSignatureBuilderClass * klass,
671 gpointer klass_data)
672 {
673 valadoc_api_signature_builder_parent_class = g_type_class_peek_parent (klass);
674 ((ValadocApiSignatureBuilderClass *) klass)->finalize = valadoc_api_signature_builder_finalize;
675 g_type_class_adjust_private_offset (klass, &ValadocApiSignatureBuilder_private_offset);
676 }
677
678 static void
valadoc_api_signature_builder_instance_init(ValadocApiSignatureBuilder * self,gpointer klass)679 valadoc_api_signature_builder_instance_init (ValadocApiSignatureBuilder * self,
680 gpointer klass)
681 {
682 self->priv = valadoc_api_signature_builder_get_instance_private (self);
683 self->ref_count = 1;
684 }
685
686 static void
valadoc_api_signature_builder_finalize(ValadocApiSignatureBuilder * obj)687 valadoc_api_signature_builder_finalize (ValadocApiSignatureBuilder * obj)
688 {
689 ValadocApiSignatureBuilder * self;
690 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_API_TYPE_SIGNATURE_BUILDER, ValadocApiSignatureBuilder);
691 g_signal_handlers_destroy (self);
692 _g_object_unref0 (self->priv->run);
693 _g_object_unref0 (self->priv->last_appended);
694 }
695
696 /**
697 * Builds up a signature from the given items.
698 */
699 static GType
valadoc_api_signature_builder_get_type_once(void)700 valadoc_api_signature_builder_get_type_once (void)
701 {
702 static const GTypeValueTable g_define_type_value_table = { valadoc_api_value_signature_builder_init, valadoc_api_value_signature_builder_free_value, valadoc_api_value_signature_builder_copy_value, valadoc_api_value_signature_builder_peek_pointer, "p", valadoc_api_value_signature_builder_collect_value, "p", valadoc_api_value_signature_builder_lcopy_value };
703 static const GTypeInfo g_define_type_info = { sizeof (ValadocApiSignatureBuilderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_api_signature_builder_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocApiSignatureBuilder), 0, (GInstanceInitFunc) valadoc_api_signature_builder_instance_init, &g_define_type_value_table };
704 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) };
705 GType valadoc_api_signature_builder_type_id;
706 valadoc_api_signature_builder_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ValadocApiSignatureBuilder", &g_define_type_info, &g_define_type_fundamental_info, 0);
707 ValadocApiSignatureBuilder_private_offset = g_type_add_instance_private (valadoc_api_signature_builder_type_id, sizeof (ValadocApiSignatureBuilderPrivate));
708 return valadoc_api_signature_builder_type_id;
709 }
710
711 GType
valadoc_api_signature_builder_get_type(void)712 valadoc_api_signature_builder_get_type (void)
713 {
714 static volatile gsize valadoc_api_signature_builder_type_id__volatile = 0;
715 if (g_once_init_enter (&valadoc_api_signature_builder_type_id__volatile)) {
716 GType valadoc_api_signature_builder_type_id;
717 valadoc_api_signature_builder_type_id = valadoc_api_signature_builder_get_type_once ();
718 g_once_init_leave (&valadoc_api_signature_builder_type_id__volatile, valadoc_api_signature_builder_type_id);
719 }
720 return valadoc_api_signature_builder_type_id__volatile;
721 }
722
723 gpointer
valadoc_api_signature_builder_ref(gpointer instance)724 valadoc_api_signature_builder_ref (gpointer instance)
725 {
726 ValadocApiSignatureBuilder * self;
727 self = instance;
728 g_atomic_int_inc (&self->ref_count);
729 return instance;
730 }
731
732 void
valadoc_api_signature_builder_unref(gpointer instance)733 valadoc_api_signature_builder_unref (gpointer instance)
734 {
735 ValadocApiSignatureBuilder * self;
736 self = instance;
737 if (g_atomic_int_dec_and_test (&self->ref_count)) {
738 VALADOC_API_SIGNATURE_BUILDER_GET_CLASS (self)->finalize (self);
739 g_type_free_instance ((GTypeInstance *) self);
740 }
741 }
742
743