From: Pavel Holejsovsky Date: Tue, 30 Aug 2011 14:20:55 +0000 (+0200) Subject: Make GMainLoop, GMainContext and GSource boxed types X-Git-Tag: 2.29.90~71 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fe4fc3e8b5a5ad8d4113c4df1fe8e0e9f295035e;p=platform%2Fupstream%2Fglib.git Make GMainLoop, GMainContext and GSource boxed types Also add some annotations for better usage of these types in bindings. https://bugzilla.gnome.org/show_bug.cgi?id=657725 --- diff --git a/glib/gmain.c b/glib/gmain.c index a7bcc0f..d8d6292 100644 --- a/glib/gmain.c +++ b/glib/gmain.c @@ -641,7 +641,7 @@ g_main_context_new (void) * specified, and corresponds to the "main" main loop. See also * g_main_context_get_thread_default(). * - * Return value: the global default main context. + * Return value: (transfer none): the global default main context. **/ GMainContext * g_main_context_default (void) @@ -782,8 +782,8 @@ g_main_context_pop_thread_default (GMainContext *context) * non-default context, so it is not safe to assume that this will * always return %NULL if threads are not initialized.) * - * Returns: the thread-default #GMainContext, or %NULL if the - * thread-default context is the global default context. + * Returns: (transfer none): the thread-default #GMainContext, or + * %NULL if the thread-default context is the global default context. * * Since: 2.22 **/ @@ -1085,9 +1085,9 @@ g_source_get_id (GSource *source) * Gets the #GMainContext with which the source is associated. * Calling this function on a destroyed source is an error. * - * Return value: the #GMainContext with which the source is associated, - * or %NULL if the context has not yet been added - * to a source. + * Return value: (transfer none): the #GMainContext with which the + * source is associated, or %NULL if the context has not + * yet been added to a source. **/ GMainContext * g_source_get_context (GSource *source) @@ -1740,7 +1740,7 @@ g_source_unref (GSource *source) * * Finds a #GSource given a pair of context and ID. * - * Return value: the #GSource if found, otherwise, %NULL + * Return value: (transfer none): the #GSource if found, otherwise, %NULL **/ GSource * g_main_context_find_source_by_id (GMainContext *context, @@ -1779,7 +1779,7 @@ g_main_context_find_source_by_id (GMainContext *context, * multiple sources exist with the same source function and user data, * the first one found will be returned. * - * Return value: the source, if one was found, otherwise %NULL + * Return value: (transfer none): the source, if one was found, otherwise %NULL **/ GSource * g_main_context_find_source_by_funcs_user_data (GMainContext *context, @@ -1827,7 +1827,7 @@ g_main_context_find_source_by_funcs_user_data (GMainContext *context, * multiple sources exist with the same user data, the first * one found will be returned. * - * Return value: the source, if one was found, otherwise %NULL + * Return value: (transfer none): the source, if one was found, otherwise %NULL **/ GSource * g_main_context_find_source_by_user_data (GMainContext *context, @@ -2254,7 +2254,7 @@ g_main_depth (void) * * Returns the currently firing source for this thread. * - * Return value: The currently firing source or %NULL. + * Return value: (transfer none): The currently firing source or %NULL. * * Since: 2.12 */ @@ -2807,8 +2807,9 @@ g_main_context_prepare (GMainContext *context, * g_main_context_query: * @context: a #GMainContext * @max_priority: maximum priority source to check - * @timeout_: location to store timeout to be used in polling - * @fds: location to store #GPollFD records that need to be polled. + * @timeout_: (out): location to store timeout to be used in polling + * @fds: (out caller-allocates) (array length=n_fds): location to + * store #GPollFD records that need to be polled. * @n_fds: length of @fds. * * Determines information necessary to poll this main loop. @@ -2877,8 +2878,8 @@ g_main_context_query (GMainContext *context, * g_main_context_check: * @context: a #GMainContext * @max_priority: the maximum numerical priority of sources to check - * @fds: array of #GPollFD's that was passed to the last call to - * g_main_context_query() + * @fds: (array length=n_fds): array of #GPollFD's that was passed to + * the last call to g_main_context_query() * @n_fds: return value of g_main_context_query() * * Passes the results of polling back to the main loop. @@ -3355,7 +3356,7 @@ g_main_loop_is_running (GMainLoop *loop) * * Returns the #GMainContext of @loop. * - * Return value: the #GMainContext of @loop + * Return value: (transfer none): the #GMainContext of @loop **/ GMainContext * g_main_loop_get_context (GMainLoop *loop) @@ -4906,7 +4907,7 @@ g_idle_remove_by_data (gpointer data) /** * g_main_context_invoke: - * @context: a #GMainContext, or %NULL + * @context: (allow-none): a #GMainContext, or %NULL * @function: function to call * @data: data to pass to @function * @@ -4946,7 +4947,7 @@ g_main_context_invoke (GMainContext *context, /** * g_main_context_invoke_full: - * @context: a #GMainContext, or %NULL + * @context: (allow-none): a #GMainContext, or %NULL * @priority: the priority at which to run @function * @function: function to call * @data: data to pass to @function diff --git a/glib/gmain.h b/glib/gmain.h index d31b45f..04d7d71 100644 --- a/glib/gmain.h +++ b/glib/gmain.h @@ -125,7 +125,7 @@ typedef struct _GSourceFuncs GSourceFuncs; /** * GSourceFunc: - * @data: data passed to the function, set when the source was + * @user_data: data passed to the function, set when the source was * created with one of the above functions * * Specifies the type of function passed to g_timeout_add(), @@ -133,20 +133,20 @@ typedef struct _GSourceFuncs GSourceFuncs; * * Returns: %FALSE if the source should be removed */ -typedef gboolean (*GSourceFunc) (gpointer data); +typedef gboolean (*GSourceFunc) (gpointer user_data); /** * GChildWatchFunc: * @pid: the process id of the child process * @status: Status information about the child process, * see waitpid(2) for more information about this field - * @data: user data passed to g_child_watch_add() + * @user_data: user data passed to g_child_watch_add() * * The type of functions to be called when a child exists. */ typedef void (*GChildWatchFunc) (GPid pid, gint status, - gpointer data); + gpointer user_data); struct _GSource { /*< private >*/ diff --git a/gobject/gboxed.c b/gobject/gboxed.c index 944ddc3..93415af 100644 --- a/gobject/gboxed.c +++ b/gobject/gboxed.c @@ -145,6 +145,9 @@ G_DEFINE_BOXED_TYPE (GVariantBuilder, g_variant_builder, g_variant_builder_ref, G_DEFINE_BOXED_TYPE (GError, g_error, g_error_copy, g_error_free) G_DEFINE_BOXED_TYPE (GDateTime, g_date_time, g_date_time_ref, g_date_time_unref); +G_DEFINE_BOXED_TYPE (GMainLoop, g_main_loop, g_main_loop_ref, g_main_loop_unref) +G_DEFINE_BOXED_TYPE (GMainContext, g_main_context, g_main_context_ref, g_main_context_unref) +G_DEFINE_BOXED_TYPE (GSource, g_source, g_source_ref, g_source_unref) /* This one can't use G_DEFINE_BOXED_TYPE (GStrv, g_strv, g_strdupv, g_strfreev) */ GType diff --git a/gobject/glib-types.h b/gobject/glib-types.h index db511e6..a4826ca 100644 --- a/gobject/glib-types.h +++ b/gobject/glib-types.h @@ -182,6 +182,33 @@ typedef gsize GType; */ #define G_TYPE_VARIANT_BUILDER (g_variant_builder_get_type ()) +/** + * G_TYPE_MAIN_LOOP: + * + * The #GType for a boxed type holding a #GMainLoop. + * + * Since: 2.30 + */ +#define G_TYPE_MAIN_LOOP (g_main_loop_get_type ()) + +/** + * G_TYPE_MAIN_CONTEXT: + * + * The #GType for a boxed type holding a #GMainContext. + * + * Since: 2.30 + */ +#define G_TYPE_MAIN_CONTEXT (g_main_context_get_type ()) + +/** + * G_TYPE_SOURCE: + * + * The #GType for a boxed type holding a #GSource. + * + * Since: 2.30 + */ +#define G_TYPE_SOURCE (g_source_get_type ()) + GType g_date_get_type (void) G_GNUC_CONST; GType g_strv_get_type (void) G_GNUC_CONST; GType g_gstring_get_type (void) G_GNUC_CONST; @@ -197,6 +224,9 @@ GType g_date_time_get_type (void) G_GNUC_CONST; GType g_io_channel_get_type (void) G_GNUC_CONST; GType g_io_condition_get_type (void) G_GNUC_CONST; GType g_variant_builder_get_type (void) G_GNUC_CONST; +GType g_main_loop_get_type (void) G_GNUC_CONST; +GType g_main_context_get_type (void) G_GNUC_CONST; +GType g_source_get_type (void) G_GNUC_CONST; #if !defined(G_DISABLE_DEPRECATED) || defined(__GI_SCANNER__) GType g_variant_get_gtype (void) G_GNUC_CONST; diff --git a/gobject/gobject.symbols b/gobject/gobject.symbols index 55494ab..f03f551 100644 --- a/gobject/gobject.symbols +++ b/gobject/gobject.symbols @@ -27,6 +27,9 @@ g_regex_get_type g_match_info_get_type g_variant_builder_get_type g_variant_type_get_gtype +g_main_loop_get_type +g_main_context_get_type +g_source_get_type g_closure_get_type g_value_get_type g_value_array_get_type