2000-11-03 09:18:09 +01:00
|
|
|
<!-- ##### SECTION Title ##### -->
|
|
|
|
Closures
|
|
|
|
|
|
|
|
<!-- ##### SECTION Short_Description ##### -->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### SECTION Long_Description ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<!-- ##### SECTION See_Also ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
2001-01-31 07:27:41 +01:00
|
|
|
<!-- ##### MACRO G_CLOSURE_NEEDS_MARSHAL ##### -->
|
2000-11-03 09:18:09 +01:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@closure:
|
|
|
|
|
|
|
|
|
2001-11-22 19:54:47 +01:00
|
|
|
<!-- ##### MACRO G_CLOSURE_N_NOTIFIERS ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@cl:
|
|
|
|
|
|
|
|
|
2001-01-31 07:27:41 +01:00
|
|
|
<!-- ##### MACRO G_CCLOSURE_SWAP_DATA ##### -->
|
2000-11-03 09:18:09 +01:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
2001-01-31 07:27:41 +01:00
|
|
|
@cclosure:
|
2000-11-03 09:18:09 +01:00
|
|
|
|
|
|
|
|
2001-01-31 07:27:41 +01:00
|
|
|
<!-- ##### MACRO G_CALLBACK ##### -->
|
2000-11-03 09:18:09 +01:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
2001-01-31 07:27:41 +01:00
|
|
|
@f:
|
2000-11-03 09:18:09 +01:00
|
|
|
|
2001-01-31 07:27:41 +01:00
|
|
|
|
2001-04-03 15:15:41 +02:00
|
|
|
<!-- ##### USER_FUNCTION GCallback ##### -->
|
2000-11-03 09:18:09 +01:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
2001-04-03 15:15:41 +02:00
|
|
|
|
2001-01-31 07:27:41 +01:00
|
|
|
<!-- ##### STRUCT GClosure ##### -->
|
2000-11-03 09:18:09 +01:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
2002-02-24 04:19:45 +01:00
|
|
|
@in_marshal:
|
2002-02-04 19:08:23 +01:00
|
|
|
@is_invalid: Indicates whether the closure has been invalidated by g_closure_invalidate()
|
2000-11-03 09:18:09 +01:00
|
|
|
|
2001-11-22 19:54:47 +01:00
|
|
|
<!-- ##### MACRO G_TYPE_CLOSURE ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-01-31 07:27:41 +01:00
|
|
|
<!-- ##### STRUCT GCClosure ##### -->
|
2000-11-11 01:03:57 +01:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
2001-01-31 07:27:41 +01:00
|
|
|
@closure:
|
|
|
|
@callback:
|
2000-11-11 01:03:57 +01:00
|
|
|
|
2001-01-31 07:27:41 +01:00
|
|
|
<!-- ##### USER_FUNCTION GClosureMarshal ##### -->
|
2000-11-03 09:18:09 +01:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@closure:
|
2001-01-31 07:27:41 +01:00
|
|
|
@return_value:
|
|
|
|
@n_param_values:
|
|
|
|
@param_values:
|
|
|
|
@invocation_hint:
|
|
|
|
@marshal_data:
|
2000-11-03 09:18:09 +01:00
|
|
|
|
|
|
|
|
2001-01-31 07:27:41 +01:00
|
|
|
<!-- ##### USER_FUNCTION GClosureNotify ##### -->
|
2000-11-03 09:18:09 +01:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
2001-01-31 07:27:41 +01:00
|
|
|
@data:
|
|
|
|
@closure:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### STRUCT GClosureNotifyData ##### -->
|
|
|
|
<para>
|
2000-11-03 09:18:09 +01:00
|
|
|
|
2001-01-31 07:27:41 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
@data:
|
|
|
|
@notify:
|
2000-11-03 09:18:09 +01:00
|
|
|
|
|
|
|
<!-- ##### FUNCTION g_cclosure_new ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@callback_func:
|
|
|
|
@user_data:
|
|
|
|
@destroy_data:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION g_cclosure_new_swap ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@callback_func:
|
|
|
|
@user_data:
|
|
|
|
@destroy_data:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION g_cclosure_new_object ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@callback_func:
|
|
|
|
@object:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION g_cclosure_new_object_swap ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@callback_func:
|
|
|
|
@object:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
2001-01-31 07:27:41 +01:00
|
|
|
<!-- ##### FUNCTION g_closure_new_object ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@sizeof_closure:
|
|
|
|
@object:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
2000-11-03 09:18:09 +01:00
|
|
|
<!-- ##### FUNCTION g_closure_ref ##### -->
|
|
|
|
<para>
|
2002-02-04 19:08:23 +01:00
|
|
|
Increment the reference count on a closure to force it staying
|
|
|
|
alive while the caller holds a pointer to it.
|
2000-11-03 09:18:09 +01:00
|
|
|
</para>
|
|
|
|
|
2002-02-04 19:08:23 +01:00
|
|
|
@closure: #GClosure to increment the reference count on
|
|
|
|
@Returns: The @closure passed in, for convenience
|
2000-11-03 09:18:09 +01:00
|
|
|
|
|
|
|
|
2001-08-12 02:56:22 +02:00
|
|
|
<!-- ##### FUNCTION g_closure_sink ##### -->
|
|
|
|
<para>
|
2002-02-04 19:08:23 +01:00
|
|
|
Take over the initial ownership of a closure.
|
|
|
|
When closures are newly created, they get an initial reference count
|
|
|
|
of 1, eventhough no caller has yet invoked g_closure_ref() on the @closure.
|
|
|
|
Code entities that store closures for notification purposes are supposed
|
|
|
|
to call this function, for example like this:
|
Remove references to nonexisting functions
* glib/gmain.c: Remove references to nonexisting functions
g_source_set_callback_closure(), g_source_poll(), g_source_add()
from docs.
* glib/gdir.c (g_dir_open): Typo fix in docs.
* glib/gasyncqueue.c (g_async_queue_lock):
(g_async_queue_unref_and_unlock): Fix markup to avoid erroneous
<link>s in docs.
* glib/gwin32.c: Escape #'s leading to erroneous <link>s in docs.
* glib/gtree.c: Replace some occurances of Gtree by GTree in docs.
* glib/gstring.c (g_string_insert_unichar): Typo fix in docs.
* glib/tmpl/conversions.sgml: Add GIConv.
* glib/tmpl/main.sgml: Fix references to nonexisting functions
g_main_loop_destroy(), g_source_add(), g_source_connect().
* glib/glib-sections.txt: Add GIConv, g_str_has_prefix, g_str_has_suffix.
* glib/tmpl/linked_lists_single.sgml:
* glib/tmpl/linked_lists_double.sgml: GListAllocator doesn't exist.
* glib/glib-docs.sgml: Declare hash entity.
* glib/tmpl/macros.sgml: Escape # in #ifdef to suppress erroneous links.
* gobject/Makefile.am, gobject/gobject-docs.sgml, gobject/tmpl/*:
* glib/Makefile.am, glib/glib-docs.sgml, glib/tmpl/*: Produce XML,
not SGML.
2002-05-27 00:46:28 +02:00
|
|
|
<informalexample><programlisting>
|
2002-02-04 19:08:23 +01:00
|
|
|
static GClosure *notify_closure = NULL;
|
|
|
|
void
|
|
|
|
foo_notify_set_closure (GClosure *closure)
|
|
|
|
{
|
|
|
|
if (notify_closure)
|
|
|
|
g_closure_unref (notify_closure);
|
|
|
|
notify_closure = closure;
|
|
|
|
if (notify_closure)
|
|
|
|
{
|
|
|
|
g_closure_ref (notify_closure);
|
|
|
|
g_closure_sink (notify_closure);
|
|
|
|
}
|
|
|
|
}
|
Remove references to nonexisting functions
* glib/gmain.c: Remove references to nonexisting functions
g_source_set_callback_closure(), g_source_poll(), g_source_add()
from docs.
* glib/gdir.c (g_dir_open): Typo fix in docs.
* glib/gasyncqueue.c (g_async_queue_lock):
(g_async_queue_unref_and_unlock): Fix markup to avoid erroneous
<link>s in docs.
* glib/gwin32.c: Escape #'s leading to erroneous <link>s in docs.
* glib/gtree.c: Replace some occurances of Gtree by GTree in docs.
* glib/gstring.c (g_string_insert_unichar): Typo fix in docs.
* glib/tmpl/conversions.sgml: Add GIConv.
* glib/tmpl/main.sgml: Fix references to nonexisting functions
g_main_loop_destroy(), g_source_add(), g_source_connect().
* glib/glib-sections.txt: Add GIConv, g_str_has_prefix, g_str_has_suffix.
* glib/tmpl/linked_lists_single.sgml:
* glib/tmpl/linked_lists_double.sgml: GListAllocator doesn't exist.
* glib/glib-docs.sgml: Declare hash entity.
* glib/tmpl/macros.sgml: Escape # in #ifdef to suppress erroneous links.
* gobject/Makefile.am, gobject/gobject-docs.sgml, gobject/tmpl/*:
* glib/Makefile.am, glib/glib-docs.sgml, glib/tmpl/*: Produce XML,
not SGML.
2002-05-27 00:46:28 +02:00
|
|
|
</programlisting></informalexample>
|
2002-02-04 19:08:23 +01:00
|
|
|
Because g_closure_sink() may decrement the reference count of a closure
|
|
|
|
(if it hasn't been called on @closure yet) just like g_closure_unref(),
|
|
|
|
g_closure_ref() should be called prior to this function.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@closure: #GClosure to decrement the initial reference count on, if it's
|
|
|
|
still being held
|
2001-08-12 02:56:22 +02:00
|
|
|
|
|
|
|
|
2000-11-03 09:18:09 +01:00
|
|
|
<!-- ##### FUNCTION g_closure_unref ##### -->
|
|
|
|
<para>
|
2002-02-04 19:08:23 +01:00
|
|
|
Decrement the reference count of a closure after it was
|
|
|
|
previously incremented by the same caller. The closure
|
|
|
|
will most likely be destroyed and freed after this function
|
|
|
|
returns.
|
2000-11-03 09:18:09 +01:00
|
|
|
</para>
|
|
|
|
|
2002-02-04 19:08:23 +01:00
|
|
|
@closure: #GClosure to decrement the reference count on
|
2000-11-03 09:18:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION g_closure_invoke ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@closure:
|
|
|
|
@return_value:
|
|
|
|
@n_param_values:
|
|
|
|
@param_values:
|
|
|
|
@invocation_hint:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION g_closure_invalidate ##### -->
|
|
|
|
<para>
|
2002-02-04 19:08:23 +01:00
|
|
|
This function sets a flag on the closure to indicate that it's
|
|
|
|
calling environment has become invalid, and thus causes any future
|
|
|
|
invocations of g_closure_invoke() on this @closure to be ignored.
|
2002-02-04 19:36:33 +01:00
|
|
|
Also, invalidation notifiers installed on the closure will be called
|
|
|
|
at this point, and since invalidation notifiers may unreference
|
|
|
|
the closure, @closure should be considered an invalidated pointer
|
|
|
|
atfer this function, unles g_closure_ref() was called beforehand.
|
2000-11-03 09:18:09 +01:00
|
|
|
</para>
|
|
|
|
|
2002-02-04 19:08:23 +01:00
|
|
|
@closure: GClosure to invalidate
|
2000-11-03 09:18:09 +01:00
|
|
|
|
|
|
|
|
2001-08-12 02:56:22 +02:00
|
|
|
<!-- ##### FUNCTION g_closure_add_finalize_notifier ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@closure:
|
|
|
|
@notify_data:
|
|
|
|
@notify_func:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION g_closure_add_invalidate_notifier ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@closure:
|
|
|
|
@notify_data:
|
|
|
|
@notify_func:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION g_closure_remove_finalize_notifier ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@closure:
|
|
|
|
@notify_data:
|
|
|
|
@notify_func:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION g_closure_remove_invalidate_notifier ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@closure:
|
|
|
|
@notify_data:
|
|
|
|
@notify_func:
|
|
|
|
|
|
|
|
|
2000-11-03 09:18:09 +01:00
|
|
|
<!-- ##### FUNCTION g_closure_new_simple ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@sizeof_closure:
|
|
|
|
@data:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION g_closure_set_marshal ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@closure:
|
|
|
|
@marshal:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION g_closure_add_marshal_guards ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@closure:
|
|
|
|
@pre_marshal_data:
|
|
|
|
@pre_marshal_notify:
|
|
|
|
@post_marshal_data:
|
|
|
|
@post_marshal_notify:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION g_closure_set_meta_marshal ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@closure:
|
|
|
|
@marshal_data:
|
|
|
|
@meta_marshal:
|
|
|
|
|
|
|
|
|
2001-11-22 19:54:47 +01:00
|
|
|
<!-- ##### FUNCTION g_source_set_closure ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@source:
|
|
|
|
@closure:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO G_TYPE_IO_CHANNEL ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO G_TYPE_IO_CONDITION ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
|