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
This commit is contained in:
Pavel Holejsovsky 2011-08-30 16:20:55 +02:00
parent 3354b02ccd
commit fe4fc3e8b5
5 changed files with 58 additions and 21 deletions

View File

@ -641,7 +641,7 @@ g_main_context_new (void)
* specified, and corresponds to the "main" main loop. See also * specified, and corresponds to the "main" main loop. See also
* g_main_context_get_thread_default(). * g_main_context_get_thread_default().
* *
* Return value: the global default main context. * Return value: (transfer none): the global default main context.
**/ **/
GMainContext * GMainContext *
g_main_context_default (void) 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 * non-default context, so it is not safe to assume that this will
* always return %NULL if threads are not initialized.) * always return %NULL if threads are not initialized.)
* *
* Returns: the thread-default #GMainContext, or %NULL if the * Returns: (transfer none): the thread-default #GMainContext, or
* thread-default context is the global default context. * %NULL if the thread-default context is the global default context.
* *
* Since: 2.22 * Since: 2.22
**/ **/
@ -1085,9 +1085,9 @@ g_source_get_id (GSource *source)
* Gets the #GMainContext with which the source is associated. * Gets the #GMainContext with which the source is associated.
* Calling this function on a destroyed source is an error. * Calling this function on a destroyed source is an error.
* *
* Return value: the #GMainContext with which the source is associated, * Return value: (transfer none): the #GMainContext with which the
* or %NULL if the context has not yet been added * source is associated, or %NULL if the context has not
* to a source. * yet been added to a source.
**/ **/
GMainContext * GMainContext *
g_source_get_context (GSource *source) 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. * 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 * GSource *
g_main_context_find_source_by_id (GMainContext *context, 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, * multiple sources exist with the same source function and user data,
* the first one found will be returned. * 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 * GSource *
g_main_context_find_source_by_funcs_user_data (GMainContext *context, 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 * multiple sources exist with the same user data, the first
* one found will be returned. * 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 * GSource *
g_main_context_find_source_by_user_data (GMainContext *context, 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. * 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 * Since: 2.12
*/ */
@ -2807,8 +2807,9 @@ g_main_context_prepare (GMainContext *context,
* g_main_context_query: * g_main_context_query:
* @context: a #GMainContext * @context: a #GMainContext
* @max_priority: maximum priority source to check * @max_priority: maximum priority source to check
* @timeout_: location to store timeout to be used in polling * @timeout_: (out): location to store timeout to be used in polling
* @fds: location to store #GPollFD records that need to be polled. * @fds: (out caller-allocates) (array length=n_fds): location to
* store #GPollFD records that need to be polled.
* @n_fds: length of @fds. * @n_fds: length of @fds.
* *
* Determines information necessary to poll this main loop. * Determines information necessary to poll this main loop.
@ -2877,8 +2878,8 @@ g_main_context_query (GMainContext *context,
* g_main_context_check: * g_main_context_check:
* @context: a #GMainContext * @context: a #GMainContext
* @max_priority: the maximum numerical priority of sources to check * @max_priority: the maximum numerical priority of sources to check
* @fds: array of #GPollFD's that was passed to the last call to * @fds: (array length=n_fds): array of #GPollFD's that was passed to
* g_main_context_query() * the last call to g_main_context_query()
* @n_fds: return value of g_main_context_query() * @n_fds: return value of g_main_context_query()
* *
* Passes the results of polling back to the main loop. * 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. * Returns the #GMainContext of @loop.
* *
* Return value: the #GMainContext of @loop * Return value: (transfer none): the #GMainContext of @loop
**/ **/
GMainContext * GMainContext *
g_main_loop_get_context (GMainLoop *loop) g_main_loop_get_context (GMainLoop *loop)
@ -4906,7 +4907,7 @@ g_idle_remove_by_data (gpointer data)
/** /**
* g_main_context_invoke: * g_main_context_invoke:
* @context: a #GMainContext, or %NULL * @context: (allow-none): a #GMainContext, or %NULL
* @function: function to call * @function: function to call
* @data: data to pass to @function * @data: data to pass to @function
* *
@ -4946,7 +4947,7 @@ g_main_context_invoke (GMainContext *context,
/** /**
* g_main_context_invoke_full: * 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 * @priority: the priority at which to run @function
* @function: function to call * @function: function to call
* @data: data to pass to @function * @data: data to pass to @function

View File

@ -125,7 +125,7 @@ typedef struct _GSourceFuncs GSourceFuncs;
/** /**
* GSourceFunc: * 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 * created with one of the above functions
* *
* Specifies the type of function passed to g_timeout_add(), * 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 * Returns: %FALSE if the source should be removed
*/ */
typedef gboolean (*GSourceFunc) (gpointer data); typedef gboolean (*GSourceFunc) (gpointer user_data);
/** /**
* GChildWatchFunc: * GChildWatchFunc:
* @pid: the process id of the child process * @pid: the process id of the child process
* @status: Status information about the child process, * @status: Status information about the child process,
* see waitpid(2) for more information about this field * 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. * The type of functions to be called when a child exists.
*/ */
typedef void (*GChildWatchFunc) (GPid pid, typedef void (*GChildWatchFunc) (GPid pid,
gint status, gint status,
gpointer data); gpointer user_data);
struct _GSource struct _GSource
{ {
/*< private >*/ /*< private >*/

View File

@ -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 (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 (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) */ /* This one can't use G_DEFINE_BOXED_TYPE (GStrv, g_strv, g_strdupv, g_strfreev) */
GType GType

View File

@ -182,6 +182,33 @@ typedef gsize GType;
*/ */
#define G_TYPE_VARIANT_BUILDER (g_variant_builder_get_type ()) #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_date_get_type (void) G_GNUC_CONST;
GType g_strv_get_type (void) G_GNUC_CONST; GType g_strv_get_type (void) G_GNUC_CONST;
GType g_gstring_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_channel_get_type (void) G_GNUC_CONST;
GType g_io_condition_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_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__) #if !defined(G_DISABLE_DEPRECATED) || defined(__GI_SCANNER__)
GType g_variant_get_gtype (void) G_GNUC_CONST; GType g_variant_get_gtype (void) G_GNUC_CONST;

View File

@ -27,6 +27,9 @@ g_regex_get_type
g_match_info_get_type g_match_info_get_type
g_variant_builder_get_type g_variant_builder_get_type
g_variant_type_get_gtype g_variant_type_get_gtype
g_main_loop_get_type
g_main_context_get_type
g_source_get_type
g_closure_get_type g_closure_get_type
g_value_get_type g_value_get_type
g_value_array_get_type g_value_array_get_type