diff options
author | Giovanni Campagna <gcampagna@src.gnome.org> | 2012-08-28 03:38:46 +0200 |
---|---|---|
committer | Giovanni Campagna <gcampagna@src.gnome.org> | 2012-10-28 18:48:52 +0100 |
commit | ce4a25dc640bdb02ff30fc233abb1c468721cbbd (patch) | |
tree | b32c10fcbbe3f514b0e33e9117034975ca62d272 /tests/doctool/doc-examples-obj.c | |
parent | 7fc2e9db63370c1a0a09a1557d85d400b106d7f7 (diff) | |
download | gobject-introspection-ce4a25dc640bdb02ff30fc233abb1c468721cbbd.tar.gz |
Expand on the documentation tests
Add tests for complex function signatures (including arrays and
callbacks), for enumerations and for static methods.
Add JS reference files.
https://bugzilla.gnome.org/show_bug.cgi?id=683046
Diffstat (limited to 'tests/doctool/doc-examples-obj.c')
-rw-r--r-- | tests/doctool/doc-examples-obj.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/doctool/doc-examples-obj.c b/tests/doctool/doc-examples-obj.c index 44360d9d..992e7151 100644 --- a/tests/doctool/doc-examples-obj.c +++ b/tests/doctool/doc-examples-obj.c @@ -125,3 +125,68 @@ doc_examples_obj_method (DocExamplesObj *self, gint first_arg, gfloat second_arg { return FALSE; } + +/** + * doc_examples_obj_static_method: + * @out_arg: (out) (allow-none): a pointer to int, or %NULL to ignore + * + * This is an example of a function with an out argument + * and a return value. + * + * Returns: %TRUE if @out_arg is valid, %FALSE otherwise + */ +gboolean +doc_examples_obj_static_method (gint *out_arg) +{ + if (out_arg) + *out_arg = 42; + + return TRUE; +} + +/** + * doc_examples_array_function: + * @out_len: (out): the length of the returned array + * + * This function returns an array with an explicit length, + * and the length should be invisible in most introspected bindings. + * + * Returns: (array length=out_len) (transfer full): an array of numbers. + */ +gint * +doc_examples_array_function (gint *out_len) +{ + gint *array; + int i, n = 3; + + array = g_new(int, n); + for (i = 0; i < n; i++) + array[i] = i; + + *out_len = n; + return array; +} + +/** + * doc_examples_callback_function: + * @callback: Just Call Me Maybe + * @user_data: your stuff + * @destroy_notify: how to get rid of @user_data + * + * This is a function that takes a callback. Different languages + * will expose this in different ways (e.g. Python keeps the + * @user_data parameter, while JS doesn't) + */ +void +doc_examples_callback_function (DocExamplesCallback callback, + gpointer user_data, + GDestroyNotify destroy_notify) +{ + gchar *result; + + result = callback (42, 17); + g_free (result); + + if (user_data && destroy_notify) + destroy_notify (user_data); +} |