1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
3 /* This file gets installed, so we can't assume config.h is available */
8 #include "annotation.h"
10 char backslash_parsing_tester = '\\';
12 G_DEFINE_TYPE (RegressAnnotationObject, regress_annotation_object, G_TYPE_OBJECT);
17 PROP_FUNCTION_PROPERTY,
24 DOC_EMPTY_ARG_PARSING,
29 static guint regress_annotation_object_signals[LAST_SIGNAL] = { 0 };
32 regress_annotation_object_set_property (GObject *object,
39 case PROP_STRING_PROPERTY:
41 case PROP_FUNCTION_PROPERTY:
43 case PROP_TAB_PROPERTY:
46 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
52 regress_annotation_object_get_property (GObject *object,
59 case PROP_STRING_PROPERTY:
61 case PROP_FUNCTION_PROPERTY:
63 case PROP_TAB_PROPERTY:
66 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
72 regress_annotation_object_class_init (RegressAnnotationObjectClass *klass)
74 GObjectClass *gobject_class;
76 gobject_class = G_OBJECT_CLASS (klass);
78 gobject_class->set_property = regress_annotation_object_set_property;
79 gobject_class->get_property = regress_annotation_object_get_property;
82 * RegressAnnotationObject::string-signal:
83 * @regress_annotation: the regress_annotation object
84 * @string: (type utf8): a string
86 * This is a signal which has a broken signal handler,
87 * it says it's pointer but it's actually a string.
90 * Deprecated: 1.2: Use other-signal instead
92 regress_annotation_object_signals[STRING_SIGNAL] =
93 g_signal_new ("string-signal",
94 G_OBJECT_CLASS_TYPE (gobject_class),
98 (GSignalCMarshaller)g_cclosure_marshal_VOID__POINTER,
99 G_TYPE_NONE, 1, G_TYPE_POINTER);
102 * RegressAnnotationObject::list-signal:
103 * @regress_annotation: the regress_annotation object
104 * @list: (type GLib.List) (element-type utf8) (transfer container): a list of strings
106 * This is a signal which takes a list of strings, but it's not
107 * known by GObject as it's only marked as G_TYPE_POINTER
109 regress_annotation_object_signals[LIST_SIGNAL] =
110 g_signal_new ("list-signal",
111 G_OBJECT_CLASS_TYPE (gobject_class),
115 (GSignalCMarshaller)g_cclosure_marshal_VOID__POINTER,
116 G_TYPE_NONE, 1, G_TYPE_POINTER);
119 * RegressAnnotationObject::doc-empty-arg-parsing:
120 * @regress_annotation: the regress_annotation object
123 * This signal tests an empty document argument (@arg1)
125 regress_annotation_object_signals[DOC_EMPTY_ARG_PARSING] =
126 g_signal_new ("doc-empty-arg-parsing",
127 G_OBJECT_CLASS_TYPE (gobject_class),
131 (GSignalCMarshaller)g_cclosure_marshal_VOID__POINTER,
132 G_TYPE_NONE, 1, G_TYPE_POINTER);
135 * RegressAnnotationObject::attribute-signal:
136 * @regress_annotation: the regress_annotation object
137 * @arg1: (attributes some.annotation.foo1=val1): a value
138 * @arg2: (attributes some.annotation.foo2=val2): another value
140 * This signal tests a signal with attributes.
142 * Returns: (attributes some.annotation.foo3=val3): the return value
144 regress_annotation_object_signals[ATTRIBUTE_SIGNAL] =
145 g_signal_new ("attribute-signal",
146 G_OBJECT_CLASS_TYPE (gobject_class),
150 NULL, /* marshaller */
157 * RegressAnnotationObject:string-property:
159 * This is a property which is a string
162 * Deprecated: 1.2: Use better-string-property instead
164 g_object_class_install_property (gobject_class,
165 PROP_STRING_PROPERTY,
166 g_param_spec_string ("string-property",
168 "This property is a string",
170 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
172 * RegressAnnotationObject:function-property: (type RegressAnnotationCallback)
174 g_object_class_install_property (gobject_class,
175 PROP_FUNCTION_PROPERTY,
176 g_param_spec_pointer ("function-property",
178 "This property is a function pointer",
179 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
182 * RegressAnnotationObject:tab-property:
184 * This is a property annotation intentionally indented with a mix
185 * of tabs and strings to test the tab handling capabilities of the scanner.
189 g_object_class_install_property (gobject_class,
191 g_param_spec_string ("tab-property",
193 "This property is a thing",
195 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
199 regress_annotation_object_init (RegressAnnotationObject *object)
205 * regress_annotation_object_method:
206 * @object: a #GObject
208 * Return value: an int
211 regress_annotation_object_method (RegressAnnotationObject *object)
217 * regress_annotation_object_out:
218 * @object: a #GObject
219 * @outarg: (out): This is an argument test
221 * This is a test for out arguments
223 * Return value: an int
226 regress_annotation_object_out (RegressAnnotationObject *object, int *outarg)
233 * regress_annotation_object_in:
234 * @object: a #GObject
235 * @inarg: (in) (transfer none): This is an argument test
237 * This is a test for in arguments
239 * Return value: an int
242 regress_annotation_object_in (RegressAnnotationObject *object, int *inarg)
249 * regress_annotation_object_inout:
250 * @object: a #GObject
251 * @inoutarg: (inout): This is an argument test
253 * This is a test for out arguments
255 * Return value: an int
258 regress_annotation_object_inout (RegressAnnotationObject *object, int *inoutarg)
260 return *inoutarg += 1;
264 * regress_annotation_object_inout2:
265 * @object: a #GObject
266 * @inoutarg: (inout): This is an argument test
268 * This is a second test for out arguments
270 * Return value: an int
273 regress_annotation_object_inout2 (RegressAnnotationObject *object, int *inoutarg)
275 return *inoutarg += 1;
280 * regress_annotation_object_inout3:
281 * @object: a #GObject
282 * @inoutarg: (inout) (allow-none): This is an argument test
284 * This is a 3th test for out arguments
286 * Return value: an int
289 regress_annotation_object_inout3 (RegressAnnotationObject *object, int *inoutarg)
292 return *inoutarg + 1;
297 * regress_annotation_object_calleeowns:
298 * @object: a #GObject
299 * @toown: (out): a #GObject
301 * This is a test for out arguments; GObject defaults to transfer
303 * Return value: an int
306 regress_annotation_object_calleeowns (RegressAnnotationObject *object, GObject **toown)
313 * regress_annotation_object_calleesowns:
314 * @object: a #GObject
315 * @toown1: (out) (transfer full): a #GObject
316 * @toown2: (out) (transfer none): a #GObject
318 * This is a test for out arguments, one transferred, other not
320 * Return value: an int
323 regress_annotation_object_calleesowns (RegressAnnotationObject *object,
332 * regress_annotation_object_get_strings:
333 * @object: a #GObject
335 * This is a test for returning a list of strings, where
336 * each string needs to be freed.
338 * Return value: (element-type utf8) (transfer full): list of strings
341 regress_annotation_object_get_strings (RegressAnnotationObject *object)
344 list = g_list_prepend (list, g_strdup ("regress_annotation"));
345 list = g_list_prepend (list, g_strdup ("bar"));
350 * regress_annotation_object_get_hash:
351 * @object: a #GObject
353 * This is a test for returning a hash table mapping strings to
356 * Return value: (element-type utf8 GObject) (transfer full): hash table
359 regress_annotation_object_get_hash (RegressAnnotationObject *object)
361 GHashTable *hash = g_hash_table_new_full (g_str_hash, g_str_equal,
362 g_free, g_object_unref);
363 g_hash_table_insert (hash, g_strdup ("one"), g_object_ref (object));
364 g_hash_table_insert (hash, g_strdup ("two"), g_object_ref (object));
369 * regress_annotation_object_with_voidp:
370 * @data: Opaque pointer handle
373 regress_annotation_object_with_voidp (RegressAnnotationObject *object, void *data)
379 * regress_annotation_object_get_objects:
380 * @object: a #GObject
382 * This is a test for returning a list of objects.
383 * The list itself should be freed, but not the internal objects,
384 * intentionally similar example to gtk_container_get_children
386 * Return value: (element-type RegressAnnotationObject) (transfer container): list of objects
389 regress_annotation_object_get_objects (RegressAnnotationObject *object)
392 list = g_slist_prepend (list, object);
397 * regress_annotation_object_create_object:
398 * @object: a #GObject
400 * Test returning a caller-owned object
402 * Return value: (transfer full): The object
405 regress_annotation_object_create_object (RegressAnnotationObject *object)
407 return G_OBJECT (g_object_ref (object));
411 * regress_annotation_object_use_buffer:
412 * @object: a #GObject
416 regress_annotation_object_use_buffer (RegressAnnotationObject *object,
423 * regress_annotation_object_compute_sum:
424 * @object: a #GObject
425 * @nums: (array): Sequence of numbers
427 * Test taking a zero-terminated array
430 regress_annotation_object_compute_sum (RegressAnnotationObject *object,
437 * regress_annotation_object_compute_sum_n:
438 * @object: a #GObject
439 * @nums: (array length=n_nums zero-terminated=0): Sequence of
440 * numbers that are zero-terminated
441 * @n_nums: Length of number array
443 * Test taking an array with length parameter
446 regress_annotation_object_compute_sum_n(RegressAnnotationObject *object,
454 * regress_annotation_object_compute_sum_nz:
455 * @object: a #RegressAnnotationObject
456 * @nums: (array length=n_nums zero-terminated): Sequence of numbers that
457 * are zero-terminated
458 * @n_nums: Length of number array
460 * Test taking a zero-terminated array with length parameter
463 regress_annotation_object_compute_sum_nz(RegressAnnotationObject *object,
471 * regress_annotation_object_parse_args:
472 * @object: a #RegressAnnotationObject
473 * @argc: (inout): Length of the argument vector
474 * @argv: (inout) (array length=argc zero-terminated=1): Argument vector
476 * Test taking a zero-terminated array with length parameter
479 regress_annotation_object_parse_args(RegressAnnotationObject *object,
487 * regress_annotation_object_string_out:
488 * @object: a #RegressAnnotationObject
489 * @str_out: (out) (transfer full): string return value
491 * Test returning a string as an out parameter
493 * Returns: some boolean
496 regress_annotation_object_string_out(RegressAnnotationObject *object,
503 * regress_annotation_object_foreach:
504 * @object: a #RegressAnnotationObject
505 * @func: (scope call): Callback to invoke
506 * @user_data: Callback user data
508 * Test taking a call-scoped callback
511 regress_annotation_object_foreach (RegressAnnotationObject *object,
512 RegressAnnotationForeachFunc func,
519 * regress_annotation_object_set_data:
520 * @object: a #RegressAnnotationObject
521 * @data: (array length=length): The data
522 * @length: Length of the data
524 * Test taking a guchar * with a length.
527 regress_annotation_object_set_data (RegressAnnotationObject *object,
535 * regress_annotation_object_set_data2:
536 * @object: a #RegressAnnotationObject
537 * @data: (array length=length) (element-type gint8): The data
538 * @length: Length of the data
540 * Test taking a gchar * with a length.
543 regress_annotation_object_set_data2 (RegressAnnotationObject *object,
551 * regress_annotation_object_set_data3:
552 * @object: a #RegressAnnotationObject
553 * @data: (array length=length) (element-type guint8): The data
554 * @length: Length of the data
556 * Test taking a gchar * with a length, overriding the array element
560 regress_annotation_object_set_data3 (RegressAnnotationObject *object,
568 * regress_annotation_object_allow_none:
569 * @object: a #GObject
570 * @somearg: (allow-none):
572 * Returns: (transfer none): %NULL always
575 regress_annotation_object_allow_none (RegressAnnotationObject *object, const gchar *somearg)
581 * regress_annotation_object_notrans:
582 * @object: a #GObject
584 * Returns: (transfer none): An object, not referenced
588 regress_annotation_object_notrans (RegressAnnotationObject *object)
594 * regress_annotation_object_do_not_use:
595 * @object: a #GObject
597 * Returns: (transfer none): %NULL always
598 * Deprecated: 0.12: Use regress_annotation_object_create_object() instead.
601 regress_annotation_object_do_not_use (RegressAnnotationObject *object)
607 * regress_annotation_object_watch: (skip)
608 * @object: A #RegressAnnotationObject
609 * @func: The callback
610 * @user_data: The callback data
612 * This is here just for the sake of being overriden by its
613 * regress_annotation_object_watch_full().
616 regress_annotation_object_watch (RegressAnnotationObject *object,
617 RegressAnnotationForeachFunc func,
623 * regress_annotation_object_watch_full: (rename-to regress_annotation_object_watch)
624 * @object: A #RegressAnnotationObject
625 * @func: The callback
626 * @user_data: The callback data
627 * @destroy: Destroy notification
629 * Test overriding via the "Rename To" annotation.
632 regress_annotation_object_watch_full (RegressAnnotationObject *object,
633 RegressAnnotationForeachFunc func,
635 GDestroyNotify destroy)
640 * regress_annotation_object_hidden_self:
641 * @object: (type RegressAnnotationObject): A #RegressAnnotationObject
644 regress_annotation_object_hidden_self (gpointer object)
649 * regress_annotation_init:
650 * @argc: (inout): The number of args.
651 * @argv: (inout) (array length=argc): The arguments.
654 regress_annotation_init (int *argc, char ***argv)
660 * regress_annotation_return_array:
661 * @length: (out): Number of return values
663 * Return value: (transfer full) (array length=length): The return value
666 regress_annotation_return_array (int *length)
672 * regress_annotation_string_zero_terminated:
674 * Return value: (transfer full) (array zero-terminated=1): The return value
677 regress_annotation_string_zero_terminated (void)
683 * regress_annotation_string_zero_terminated_out:
684 * @out: (array zero-terminated=1) (inout):
687 regress_annotation_string_zero_terminated_out (char ***out)
692 * regress_annotation_versioned:
697 regress_annotation_versioned (void)
702 * regress_annotation_string_array_length:
704 * @properties: (array length=n_properties) (element-type utf8):
707 regress_annotation_string_array_length (guint n_properties, const gchar * const properties[])
712 * regress_annotation_object_extra_annos: (attributes org.foobar=testvalue)
715 regress_annotation_object_extra_annos (RegressAnnotationObject *object)
720 * regress_annotation_custom_destroy:
721 * @callback: (destroy destroy) (closure data): Destroy notification
723 * Test messing up the heuristic of closure/destroy-notification
724 * detection, and fixing it via annotations.
727 regress_annotation_custom_destroy (RegressAnnotationCallback callback,
728 RegressAnnotationNotifyFunc destroy,
734 * regress_annotation_get_source_file:
736 * Return value: (type filename) (transfer full): Source file
739 regress_annotation_get_source_file (void)
745 * regress_annotation_set_source_file:
746 * @fname: (type filename): Source file
750 regress_annotation_set_source_file (const char *fname)
755 * regress_annotation_ptr_array:
756 * @array: (element-type GObject.Value): the array
759 regress_annotation_ptr_array (GPtrArray *array)
764 * regress_annotation_attribute_func:
765 * @object: A #RegressAnnotationObject.
766 * @data: (attributes some.annotation=value another.annotation=blahvalue): Some data.
768 * Returns: (attributes some.other.annotation=value2 yet.another.annotation=another_value): The return value.
771 regress_annotation_attribute_func (RegressAnnotationObject *object,
778 * regress_annotation_invalid_regress_annotation:
779 * @foo: some text (e.g. example) or else
782 regress_annotation_invalid_regress_annotation (int foo)
788 char backslash_parsing_tester_2 = '\\';
792 * regress_annotation_test_parsing_bug630862:
794 * See https://bugzilla.gnome.org/show_bug.cgi?id=630862
796 * Returns: (transfer none): An object, note the colon:in here
799 regress_annotation_test_parsing_bug630862 (void)
806 * regress_annotation_space_after_comment_bug631690:
808 * Explicitly test having a space after the ** here.
811 regress_annotation_space_after_comment_bug631690 (void)
816 * regress_annotation_return_filename:
818 * Returns: (type filename): An annotated filename
821 regress_annotation_return_filename (void)
823 return g_strdup ("a utf-8 filename");
827 * regress_annotation_transfer_floating:
828 * @object: (in) (transfer floating): an object
830 * Returns: (transfer floating): A floating object
833 regress_annotation_transfer_floating (GObject *object)