/src/wrappers/gobject/library/g_closure.e
Specman e | 1125 lines | 258 code | 297 blank | 570 comment | 0 complexity | 523f273d8230f92334ce0f58e906588d MD5 | raw file
1indexing 2 description: " Closures - Functions as first-class objects." 3 copyright: "(C) 2006 Paolo Redaelli " 4 license: "LGPL v2 or later" 5 date: "$Date:$" 6 revision: "$Revision:$" 7 8deferred class G_CLOSURE 9 -- A GClosure represents a callback supplied by the programmer. It 10 -- will generally comprise a function of some kind and a marshaller 11 -- used to call it. It is the reponsibility of the marshaller to 12 -- convert the arguments for the invocation from GValues into a 13 -- suitable form, perform the callback on the converted arguments, 14 -- and transform the return value back into a GValue. 15 16 -- In the case of C programs, a closure usually just holds a 17 -- pointer to a function and maybe a data argument, and the 18 -- marshaller converts between GValue and native C types. The 19 -- GObject library provides the GCClosure type for this 20 -- purpose. Bindings for other languages need marshallers which 21 -- convert between GValues and suitable representations in the 22 -- runtime of the language in order to use functions written in 23 -- that languages as callbacks. 24 25 -- Within GObject, closures play an important role in the 26 -- implementation of signals. When a signal is registered, the 27 -- c_marshaller argument to g_signal_new() specifies the default C 28 -- marshaller for any closure which is connected to this 29 -- signal. GObject provides a number of C marshallers for this 30 -- purpose, see the g_cclosure_marshal_*() functions. Additional C 31 -- marshallers can be generated with the glib-genmarshal 32 -- utility. Closures can be explicitly connected to signals with 33 -- g_signal_connect_closure(), but it usually more convenient to 34 -- let GObject create a closure automatically by using one of the 35 -- g_signal_connect_*() functions which take a callback 36 -- function/user data pair. 37 38 -- Using closures has a number of important advantages over a 39 -- simple callback function/data pointer combination: 40 41 -- o Closures allow the callee to get the types of the callback 42 -- parameters, which means that language bindings don't have to 43 -- write individual glue for each callback type. 44 45 -- o The reference counting of GClosure makes it easy to handle 46 -- reentrancy right; if a callback is removed while it is being 47 -- invoked, the closure and it's parameters won't be freed until 48 -- the invocation finishes. 49 50 -- o g_closure_invalidate() and invalidation notifiers allow 51 -- callbacks to be automatically removed when the objects they 52 -- point to go away. 53 54inherit 55 C_STRUCT 56 57feature -- Callback pointer 58 callback_pointer: POINTER is 59 -- The address of the actual Eiffel callback feature 60 -- `function'. Even if the body of this feature is common to 61 -- all heirs it must be nevertheless made deferred. The 62 -- actual body is: 63 64 -- callback_pointer: POINTER is 65 -- do 66 -- Result := get_callback_pointer ($callback) 67 -- ensure Result.is_not_null 68 -- end 69 70 -- But callback coulnd't be declared here because it must 71 -- follow the actual signature of the corresponding C signal 72 -- callback feature. So even this feature must be deferred. 73 deferred 74 end 75 76 object: G_OBJECT 77 78feature -- Creation 79 link_to (an_object: like object) is 80 -- Creates a new closure which invokes 'callback' 81 82 -- TODO: add destroy_notify callback support 83 require valid_object: an_object /= Void 84 do 85 debug 86 print (generating_type) print(".connect (an_object=") print (an_object.to_pointer.to_string) 87 print (" an_object.handle=") print (an_object.handle.to_string) 88 print (") Current=") print (to_pointer.to_string) 89 print (" Current.handle=") print (handle.to_string) 90 print ("%N") 91 end 92 -- Note: the following implementation will make the C 93 -- GClosure to call Eiffel's `callback' feature of 94 -- `Current'. We pass the address of callback and of Current, 95 -- which no destroy_callback since the user_data, which is 96 -- actually a pointer to Current is handled by the Eiffel 97 -- garbage collector. 98 object := an_object 99 handle := g_cclosure_new_swap (callback_pointer, 100 $object, -- as user_data 101 default_pointer -- i.e.: NULL as destroy callback 102 ) 103 -- g_cclosure_new_swap creates a new closure which invokes 104 -- callback_func with user_data with user_data as the first 105 -- parameter. Note: this exchange is necessary to allow us to 106 -- directly call Eiffel features, which *require* the address 107 -- of Current as the first parameter. Paolo 2006-04-12 108 109 -- This is needed to avoid long term GC bugs. The ref is required 110 -- To notify that we have an owned reference to the closure. 111 -- The sink is to remove the default unowned reference 112 -- ** trixx, 20060721 113 ref 114 sink 115 116 -- see also g_cclosure_new that creates a new closure which 117 -- invokes callback_func with user_data with user_data as the 118 -- last parameter. 119 120 -- callback_func : the function to invoke 121 -- user_data : user data to pass to callback_func 122 -- destroy_data : destroy notify to be called when user_data is no longer used 123 -- Returns : a new GCClosure 124 end 125 126 127 -- g_cclosure_new_object () 128 129 -- GClosure* g_cclosure_new_object (callback_func: POINTER, 130 -- an_object: POINTER); 131 132 -- A variant of g_cclosure_new() which uses object as user_data and 133 -- calls g_object_watch_closure() on object and the created 134 -- closure. This function is useful when you have a callback 135 -- closely associated with a GObject, and want the callback to no 136 -- longer run after the object is is freed. 137 138 -- callback_func : the function to invoke object : a GObject 139 -- pointer to pass to callback_func Returns : a new GCClosure 140 141 -- g_cclosure_new_object_swap () 142 143 -- GClosure* g_cclosure_new_object_swap (callback_func: POINTER, 144 -- an_object: POINTER); 145 146 -- A variant of g_cclosure_new_swap() which uses object as 147 -- user_data and calls g_object_watch_closure() on object and the 148 -- created closure. This function is useful when you have a 149 -- callback closely associated with a -- GObject, and want the 150 -- callback to no longer run after the object is is freed. 151 152 -- callback_func : the function to invoke object : a GObject 153 -- pointer to pass to callback_func Returns : a new GCClosure 154 155 -- g_closure_new_object () 156 157 -- GClosure* g_closure_new_object (guint sizeof_closure, an_object: POINTER); 158 159 -- A variant of g_closure_new_simple() which stores object in the data field of the closure and calls 160 -- g_object_watch_closure() on object and the created closure. This function is mainly useful when implementing 161 -- new types of closures. 162 163 -- sizeof_closure : the size of the structure to allocate, must be at least sizeof (GClosure) 164 -- object : a GObject pointer to store in the data field of the newly allocated GClosure 165 -- Returns : a newly allocated GClosure 166 167 -- -------------------------------------------------------------------------------------------------------- 168 169feature -- Reference counting and memory handling 170 ref is 171 local ptr: POINTER 172 do 173 ptr := g_closure_ref (handle) 174 -- g_closure_ref returns the closure passed in, for 175 -- convenience 176 end 177 178 unref is 179 -- Decrements the reference count of a closure after it was 180 -- previously incremented by the same caller. If no other 181 -- callers are using the closure, then the closure will be 182 -- destroyed and freed. 183 do 184 g_closure_unref (handle) 185 end 186 187 sink is 188 -- Takes over the initial ownership of a closure. Each 189 -- closure is initially created in afloating state, which 190 -- means that the initial reference count is not owned by any 191 -- caller. 'sink' checks to see if the object is still 192 -- floating, and if so, unsets the floating state and 193 -- decreases the reference count 194 195 -- TODO: Eiffelize the rest of the documentation of this 196 -- feature which include a C example. Paolo 2006-04-12 197 do 198 g_closure_sink (handle) 199 -- Takes over the initial ownership of a closure. Each 200 -- closure is initially created in afloating state, which 201 -- means that the initial reference count is not owned by 202 -- any caller. g_closure_sink() checks to see if the 203 -- object is still floating, and if so, unsets the 204 -- floating state and decreases the reference count. If 205 -- the closure is not floating, g_closure_sink() does 206 -- nothing. The reason for the existance of the floating 207 -- state -- is to prevent cumbersome code sequences like: 208 209 -- closure = g_cclosure_new (cb_func, cb_data); 210 -- g_source_set_closure (source, closure); 211 -- g_closure_unref (closure); /* XXX GObject doesn't really need this */ 212 213 -- Because g_source_set_closure() (and similar functions) 214 -- take ownership of the initial reference count, if it -- 215 -- is unowned, we instead can write: 216 217 -- g_source_set_closure (source, g_cclosure_new (cb_func, cb_data)); 218 219 -- Generally, this function is used together with 220 -- g_closure_ref(). Ane example of storing a closure for 221 -- later -- notification looks like: 222 223 -- static GClosure *notify_closure = NULL; 224 -- void 225 -- foo_notify_set_closure (a_closure: POINTER) 226 -- { 227 -- if (notify_closure) 228 -- g_closure_unref (notify_closure); 229 -- notify_closure = closure; 230 -- if (notify_closure) 231 -- { 232 -- g_closure_ref (notify_closure); 233 -- g_closure_sink (notify_closure); 234 -- } 235 -- } 236 237 -- Because g_closure_sink() may decrement the reference count of a closure (if it hasn't been called on closure 238 -- yet) just like g_closure_unref(), g_closure_ref() should be called prior to this function. 239 240 -- closure : GClosure to decrement the initial reference count on, if it's still being held 241 end 242 243 dispose is 244 do 245 -- Note: memory handling is done by gobject 246 unref 247 handle:=default_pointer 248 end 249 250feature -- Invoking 251 252 invoke (some_parameters: G_VALUE_ARRAY): G_VALUE is 253 -- Invokes the closure, i.e. executes the callback 254 -- represented by the closure. 255 256 -- Heirs of G_CLOSURE which will implements callback for more 257 -- specific closures. Note: the previous could be wrong. 258 -- Paolo 2006-04-26 259 require valid_parameters: some_parameters /= Void 260 do 261 create Result.make 262 g_closure_invoke (handle, Result.handle, 263 some_parameters.count, some_parameters.to_external, 264 default_pointer -- invocation_hint : a context-dependent invocation hint 265 ) 266 -- closure : a GClosure return_value : a GValue to store the 267 -- return value. May be NULL if the callback of closure 268 -- doesn't return a value. n_param_values : the length of 269 -- the param_values array param_values : an array of GValues 270 -- holding the arguments on which to invoke the callback of 271 -- closure -- 272 273 end 274 275 276-- -------------------------------------------------------------------------------------------------------- 277 278-- g_closure_invalidate () 279 280-- void g_closure_invalidate (a_closure: POINTER); 281 282-- Sets a flag on the closure to indicate that it's calling environment has become invalid, and thus causes any 283-- future invocations of g_closure_invoke() on this closure to be ignored. Also, invalidation notifiers 284-- installed on the closure will be called at this point. Note that unless you are holding a reference to the 285-- closure yourself, the invalidation notifiers may unref the closure and cause it to be destroyed, so if you 286-- need to access the closure after calling g_closure_invalidate(), make sure that you've previously called 287-- g_closure_ref(). 288 289-- Note that g_closure_invalidate() will also be called when the reference count of a closure drops to zero 290-- (unless it has already been invalidated before). 291 292-- closure : GClosure to invalidate 293 294-- -------------------------------------------------------------------------------------------------------- 295 296-- g_closure_add_finalize_notifier () 297 298-- void g_closure_add_finalize_notifier (a_closure: POINTER, notify_data: POINTER, notify_func: POINTER); 299 300-- Registers a finalization notifier which will be called when the reference count of closure goes down to 0. 301-- Multiple finalization notifiers on a single closure are invoked in unspecified order. If a single call to 302-- g_closure_unref() results in the closure being both invalidated and finalized, then the invalidate notifiers 303-- will be run before the finalize notifiers. 304 305-- closure : a GClosure 306-- notify_data : data to pass to notify_func 307-- notify_func : the callback function to register 308 309-- -------------------------------------------------------------------------------------------------------- 310 311-- g_closure_add_invalidate_notifier () 312 313-- void g_closure_add_invalidate_notifier 314-- (a_closure: POINTER, notify_data: POINTER, notify_func: POINTER); 315 316-- Registers an invalidation notifier which will be called when the closure is invalidated with 317-- g_closure_invalidate(). Invalidation notifiers are invoked before finalization notifiers, in an unspecified 318-- order. 319 320-- closure : a GClosure 321-- notify_data : data to pass to notify_func 322-- notify_func : the callback function to register 323 324-- -------------------------------------------------------------------------------------------------------- 325 326-- g_closure_remove_finalize_notifier () 327 328-- void g_closure_remove_finalize_notifier 329-- (a_closure: POINTER, notify_data: POINTER, notify_func: POINTER); 330 331-- Removes a finalization notifier. Notifiers are automatically removed after they are run. 332 333-- closure : a GClosure 334-- notify_data : data which was passed to g_closure_add_finalize_notifier() when registering notify_func 335-- notify_func : the callback function to remove 336 337-- -------------------------------------------------------------------------------------------------------- 338 339-- g_closure_remove_invalidate_notifier () 340 341-- void g_closure_remove_invalidate_notifier 342-- (a_closure: POINTER, notify_data: POINTER, notify_func: POINTER); 343 344-- Removes a invalidation notifier. Notifiers are automatically removed after they are run. 345 346-- closure : a GClosure 347-- notify_data : data which was passed to g_closure_add_invalidate_notifier() when registering notify_func 348-- notify_func : the callback function to remove 349 350-- -------------------------------------------------------------------------------------------------------- 351 352-- g_closure_new_simple () 353 354-- GClosure* g_closure_new_simple (guint sizeof_closure, data: POINTER); 355 356-- Allocates a struct of the given size and initializes the initial part as a GClosure. This function is mainly 357-- useful when implementing new types of closures. 358 359-- typedef struct _MyClosure MyClosure; 360-- struct _MyClosure 361-- { 362-- GClosure closure; 363-- /* extra data goes here */ 364-- }; 365 366 367-- static void 368-- my_closure_finalize (notify_data: POINTER, a_closure: POINTER) 369-- { 370-- MyClosure *my_closure = (MyClosure *)closure; 371 372-- /* free extra data here */ 373-- } 374 375-- MyClosure *my_closure_new (data: POINTER) 376-- { 377-- a_closure: POINTER; 378-- MyClosure *my_closure; 379 380-- closure = g_closure_new_simple (sizeof (MyClosure), data); 381-- my_closure = (MyClosure *) closure; 382 383-- / initialize extra data here */ 384 385-- g_closure_add_finalize_notifier (closure, notify_data, my_closure_finalize); 386-- return my_closure; 387-- } 388 389-- sizeof_closure : the size of the structure to allocate, must be at least sizeof (GClosure) 390-- data : data to store in the data field of the newly allocated GClosure 391-- Returns : a newly allocated GClosure 392 393-- -------------------------------------------------------------------------------------------------------- 394 395-- g_closure_set_marshal () 396 397-- void g_closure_set_marshal (a_closure: POINTER, GClosureMarshal marshal); 398 399-- Sets the marshaller of closure. The marshal_data provides a way for a meta marshaller to provide additional 400-- information to the marshaller. (See g_closure_set_meta_marshal().) For GObject's C predefined marshallers 401-- (the g_cclosure_marshal_*() functions), what it provides is a callback function to use instead of 402-- closure->callback. 403 404-- closure : a GClosure 405-- marshal : a GClosureMarshal function 406 407-- -------------------------------------------------------------------------------------------------------- 408 409-- g_closure_add_marshal_guards () 410 411-- void g_closure_add_marshal_guards (a_closure: POINTER, pre_marshal_data: POINTER, pre_marshal_notify: POINTER, post_marshal_data: POINTER, post_marshal_notify: POINTER); 412 413-- Adds a pair of notifiers which get invoked before and after the closure callback, respectively. This is 414-- typically used to protect the extra arguments for the duration of the callback. See g_object_watch_closure() 415-- for an example of marshal guards. 416 417-- closure : a GClosure 418-- pre_marshal_data : data to pass to pre_marshal_notify 419-- pre_marshal_notify : a function to call before the closure callback 420-- post_marshal_data : data to pass to post_marshal_notify 421-- post_marshal_notify : a function to call after the closure callback 422 423-- -------------------------------------------------------------------------------------------------------- 424 425-- g_closure_set_meta_marshal () 426 427-- void g_closure_set_meta_marshal (a_closure: POINTER, marshal_data: POINTER, GClosureMarshal meta_marshal); 428 429-- Sets the meta marshaller of closure. A meta marshaller wraps closure->marshal and modifies the way it is 430-- called in some fashion. The most common use of this facility is for C callbacks. The same marshallers 431-- (generated by glib-genmarshal) are used everywhere, but the way that we get the callback function differs. 432-- In most cases we want to use closure->callback, but in other cases we want to use use some different 433-- technique to retrieve the callbakc function. 434 435-- For example, class closures for signals (see g_signal_type_cclosure_new()) retrieve the callback function 436-- from a fixed offset in the class structure. The meta marshaller retrieves the right callback and passes it 437-- to the marshaller as the marshal_data argument. 438 439-- closure : a GClosure 440-- marshal_data : context-depend 441-- ent data to pass to meta_marshal 442-- meta_marshal : a GClosureMarshal function 443 444-- -------------------------------------------------------------------------------------------------------- 445 446-- g_source_set_closure () 447 448-- void g_source_set_closure (GSource *source, a_closure: POINTER); 449 450-- Set the callback for a source as a GClosure. 451 452-- If the source is not one of the standard GLib types, the closure_callback and closure_marshal fields of the 453-- GSourceFuncs structure must have been filled in with pointers to appropriate functions. 454 455-- source : the source 456-- closure : a GClosure 457 458-- -------------------------------------------------------------------------------------------------------- 459 460-- G_TYPE_IO_CHANNEL 461 462-- #define G_TYPE_IO_CHANNEL (g_io_channel_get_type ()) 463 464-- The GType for GIOChannel. 465 466-- -------------------------------------------------------------------------------------------------------- 467 468-- G_TYPE_IO_CONDITION 469 470-- #define G_TYPE_IO_CONDITION (g_io_condition_get_type ()) 471 472-- The GType for GIOCondition. 473 474-- -------------------------------------------------------------------------------------------------------- 475 476-- g_cclosure_marshal_VOID__VOID () 477 478-- void g_cclosure_marshal_VOID__VOID (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 479 480-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, gpointer 481-- user_data). 482 483-- closure : the GClosure to which the marshaller belongs 484-- return_value : ignored 485-- n_param_values : 1 486-- param_values : a GValue array holding only the instance 487-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 488-- marshal_data : additional data specified when registering the marshaller 489 490-- -------------------------------------------------------------------------------------------------------- 491 492-- g_cclosure_marshal_VOID__BOOLEAN () 493 494-- void g_cclosure_marshal_VOID__BOOLEAN 495-- (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 496 497-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, gboolean arg1, user_data: POINTER). 498 499-- closure : the GClosure to which the marshaller belongs 500-- return_value : ignored 501-- n_param_values : 2 502-- param_values : a GValue array holding the instance and the gboolean parameter 503-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 504-- marshal_data : additional data specified when registering the marshaller 505 506-- -------------------------------------------------------------------------------------------------------- 507 508-- g_cclosure_marshal_VOID__CHAR () 509 510-- void g_cclosure_marshal_VOID__CHAR (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 511 512-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, gchar arg1, user_data: POINTER). 513 514-- closure : the GClosure to which the marshaller belongs 515-- return_value : ignored 516-- n_param_values : 2 517-- param_values : a GValue array holding the instance and the gchar parameter 518-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 519-- marshal_data : additional data specified when registering the marshaller 520 521-- -------------------------------------------------------------------------------------------------------- 522 523-- g_cclosure_marshal_VOID__UCHAR () 524 525-- void g_cclosure_marshal_VOID__UCHAR (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 526 527-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, guchar arg1, user_data: POINTER). 528 529-- closure : the GClosure to which the marshaller belongs 530-- return_value : ignored 531-- n_param_values : 2 532-- param_values : a GValue array holding the instance and the guchar parameter 533-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 534-- marshal_data : additional data specified when registering the marshaller 535 536-- -------------------------------------------------------------------------------------------------------- 537 538-- g_cclosure_marshal_VOID__INT () 539 540-- void g_cclosure_marshal_VOID__INT (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 541 542-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, gint arg1, user_data: POINTER). 543 544-- closure : the GClosure to which the marshaller belongs 545-- return_value : ignored 546-- n_param_values : 2 547-- param_values : a GValue array holding the instance and the gint parameter 548-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 549-- marshal_data : additional data specified when registering the marshaller 550 551-- -------------------------------------------------------------------------------------------------------- 552 553-- g_cclosure_marshal_VOID__UINT () 554 555-- void g_cclosure_marshal_VOID__UINT (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 556 557-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, guint arg1, user_data: POINTER). 558 559-- closure : the GClosure to which the marshaller belongs 560-- return_value : ignored 561-- n_param_values : 2 562-- param_values : a GValue array holding the instance and the guint parameter 563-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 564-- marshal_data : additional data specified when registering the marshaller 565 566-- -------------------------------------------------------------------------------------------------------- 567 568-- g_cclosure_marshal_VOID__LONG () 569 570-- void g_cclosure_marshal_VOID__LONG (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 571 572-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, glong arg1, user_data: POINTER). 573 574-- closure : the GClosure to which the marshaller belongs 575-- return_value : ignored 576-- n_param_values : 2 577-- param_values : a GValue array holding the instance and the glong parameter 578-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 579-- marshal_data : additional data specified when registering the marshaller 580 581-- -------------------------------------------------------------------------------------------------------- 582 583-- g_cclosure_marshal_VOID__ULONG () 584 585-- void g_cclosure_marshal_VOID__ULONG (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 586 587-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, gulong arg1, user_data: POINTER). 588 589-- closure : the GClosure to which the marshaller belongs 590-- return_value : ignored 591-- n_param_values : 2 592-- param_values : a GValue array holding the instance and the gulong parameter 593-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 594-- marshal_data : additional data specified when registering the marshaller 595 596-- -------------------------------------------------------------------------------------------------------- 597 598-- g_cclosure_marshal_VOID__ENUM () 599 600-- void g_cclosure_marshal_VOID__ENUM (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 601 602-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, gint arg1, user_data: POINTER) where the gint parameter denotes an enumeration type.. 603 604-- closure : the GClosure to which the marshaller belongs 605-- return_value : ignored 606-- n_param_values : 2 607-- param_values : a GValue array holding the instance and the enumeration parameter 608-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 609-- marshal_data : additional data specified when registering the marshaller 610 611-- -------------------------------------------------------------------------------------------------------- 612 613-- g_cclosure_marshal_VOID__FLAGS () 614 615-- void g_cclosure_marshal_VOID__FLAGS (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 616 617-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, gint arg1, user_data: POINTER) where the gint parameter denotes a flags type denotes a flags type. 618 619-- closure : the GClosure to which the marshaller belongs 620-- return_value : ignored 621-- n_param_values : 2 622-- param_values : a GValue array holding the instance and the flags parameter 623-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 624-- marshal_data : additional data specified when registering the marshaller 625 626-- -------------------------------------------------------------------------------------------------------- 627 628-- g_cclosure_marshal_VOID__FLOAT () 629 630-- void g_cclosure_marshal_VOID__FLOAT (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 631 632-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, gfloat arg1, user_data: POINTER). 633 634-- closure : the GClosure to which the marshaller belongs 635-- return_value : ignored 636-- n_param_values : 2 637-- param_values : a GValue array holding the instance and the gfloat parameter 638-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 639-- marshal_data : additional data specified when registering the marshaller 640 641-- -------------------------------------------------------------------------------------------------------- 642 643-- g_cclosure_marshal_VOID__DOUBLE () 644 645-- void g_cclosure_marshal_VOID__DOUBLE (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 646 647-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, gdouble arg1, user_data: POINTER). 648 649-- closure : the GClosure to which the marshaller belongs 650-- return_value : ignored 651-- n_param_values : 2 652-- param_values : a GValue array holding the instance and the gdouble parameter 653-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 654-- marshal_data : additional data specified when registering the marshaller 655 656-- -------------------------------------------------------------------------------------------------------- 657 658-- g_cclosure_marshal_VOID__STRING () 659 660-- void g_cclosure_marshal_VOID__STRING (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 661 662-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, const gchar *arg1, user_data: POINTER). 663 664-- closure : the GClosure to which the marshaller belongs 665-- return_value : ignored 666-- n_param_values : 2 667-- param_values : a GValue array holding the instance and the gchar* parameter 668-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 669-- marshal_data : additional data specified when registering the marshaller 670 671-- -------------------------------------------------------------------------------------------------------- 672 673-- g_cclosure_marshal_VOID__PARAM () 674 675-- void g_cclosure_marshal_VOID__PARAM (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 676 677-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, GParamSpec *arg1, user_data: POINTER). 678 679-- closure : the GClosure to which the marshaller belongs 680-- return_value : ignored 681-- n_param_values : 2 682-- param_values : a GValue array holding the instance and the GParamSpec* parameter 683-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 684-- marshal_data : additional data specified when registering the marshaller 685 686-- -------------------------------------------------------------------------------------------------------- 687 688-- g_cclosure_marshal_VOID__BOXED () 689 690-- void g_cclosure_marshal_VOID__BOXED (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 691 692-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, GBoxed *arg1, user_data: POINTER). 693 694-- closure : the GClosure to which the marshaller belongs 695-- return_value : ignored 696-- n_param_values : 2 697-- param_values : a GValue array holding the instance and the GBoxed* parameter 698-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 699-- marshal_data : additional data specified when registering the marshaller 700 701-- -------------------------------------------------------------------------------------------------------- 702 703-- g_cclosure_marshal_VOID__POINTER () 704 705-- void g_cclosure_marshal_VOID__POINTER 706-- (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 707 708-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, arg: POINTER1, user_data: POINTER). 709 710-- closure : the GClosure to which the marshaller belongs 711-- return_value : ignored 712-- n_param_values : 2 713-- param_values : a GValue array holding the instance and the parameter: POINTER 714-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 715-- marshal_data : additional data specified when registering the marshaller 716 717-- -------------------------------------------------------------------------------------------------------- 718 719-- g_cclosure_marshal_VOID__OBJECT () 720 721-- void g_cclosure_marshal_VOID__OBJECT (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 722 723-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, GOBject *arg1, user_data: POINTER). 724 725-- closure : the GClosure to which the marshaller belongs 726-- return_value : ignored 727-- n_param_values : 2 728-- param_values : a GValue array holding the instance and the GObject* parameter 729-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 730-- marshal_data : additional data specified when registering the marshaller 731 732-- -------------------------------------------------------------------------------------------------------- 733 734-- g_cclosure_marshal_STRING__OBJECT_POINTER () 735 736-- void g_cclosure_marshal_STRING__OBJECT_POINTER 737-- (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 738 739-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, GObject *arg1, arg: POINTER2, user_data: POINTER). 740 741-- closure : the GClosure to which the marshaller belongs 742-- return_value : ignored 743-- n_param_values : 3 744-- param_values : a GValue array holding instance, arg1 and arg2 745-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 746-- marshal_data : additional data specified when registering the marshaller 747 748-- -------------------------------------------------------------------------------------------------------- 749 750-- g_cclosure_marshal_VOID__UINT_POINTER () 751 752-- void g_cclosure_marshal_VOID__UINT_POINTER 753-- (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 754 755-- A marshaller for a GCClosure with a callback of type void (*callback) (instance: POINTER, guint arg1, arg: POINTER2, user_data: POINTER). 756 757-- closure : the GClosure to which the marshaller belongs 758-- return_value : ignored 759-- n_param_values : 3 760-- param_values : a GValue array holding instance, arg1 and arg2 761-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 762-- marshal_data : additional data specified when registering the marshaller 763 764-- -------------------------------------------------------------------------------------------------------- 765 766-- g_cclosure_marshal_BOOLEAN__FLAGS () 767 768-- void g_cclosure_marshal_BOOLEAN__FLAGS 769-- (a_closure: POINTER, GValue *return_value, guint n_param_values, const GValue *param_values, invocation_hint: POINTER, marshal_data: POINTER); 770 771-- A marshaller for a GCClosure with a callback of type gboolean (*callback) (instance: POINTER, gint arg1, user_data: POINTER) where the gint parameter denotes a flags type. 772 773-- closure : the GClosure to which the marshaller belongs 774-- return_value : a GValue which can store the returned gboolean 775-- n_param_values : 2 776-- param_values : a GValue array holding instance and arg1 777-- invocation_hint : the invocation hint given as the the last argument to g_closure_invoke() 778-- marshal_data : additional data specified when registering the marshaller 779 780-- -------------------------------------------------------------------------------------------------------- 781 782-- g_cclosure_marshal_BOOL__FLAGS 783 784-- #define g_cclosure_marshal_BOOL__FLAGS 785 786-- Another name for g_cclosure_marshal_BOOLEAN__FLAGS(). 787feature -- size 788 struct_size: INTEGER is 789 external "C inline use <glib-object.h>" 790 alias "sizeof(GCLosure)" 791 end 792 793feature {} -- Externals 794 795 g_closure_needs_marshal (a_closure: POINTER): INTEGER is 796 -- Returns TRUE if a GClosureMarshal marshaller has not yet been 797 -- set on closure. See g_closure_set_marshal(). 798 external "C macro use <glib-object.h>" 799 alias "G_CLOSURE_NEEDS_MARSHAL (*($a_closure))" 800 end 801 802 g_closure_n_notifiers (a_closure: POINTER): INTEGER is 803 -- Returns the total number of notifiers connected with the 804 -- closure cl. The count includes the meta marshaller, the 805 -- finalize and invalidate notifiers and the marshal 806 -- guards. Note that each guard counts as two notifiers. See 807 -- g_closure_set_meta_marshal, 808 -- g_closure_add_finalize_notifier, 809 -- g_closure_add_invalidate_notifier and 810 -- g_closure_add_marshal_guards. 811 external "C macro use <glib-object.h>" 812 alias "G_CLOSURE_N_NOTIFIERS" 813 end 814 815 g_cclosure_swap_data (a_cclosure: POINTER): INTEGER is 816 -- Returns (a gboolean, i.e. an int) whether the user data of 817 -- the GCClosure should be passed as the first parameter to 818 -- the callback. See g_cclosure_new_swap. 819 820 external "C macro use <glib-object.h>" 821 alias "G_CCLOSURE_SWAP_DATA" 822 end 823 824 -- void (*GCallback) (void); 825 826 -- The type used for callback functions in structure definitions 827 -- and function signatures. This doesn't mean that all callback 828 -- functions must take no parameters and return void. The required 829 -- signature of a callback function is determined by the context in 830 -- which is used (e.g. the signal to which it is connected). Use 831 -- G_CALLBACK() to cast the callback function to a GCallback. 832 833 g_type_closure: INTEGER is 834 -- The GType for GClosure. 835 external "C macro use <glib-object.h>" 836 alias "G_TYPE_CLOSURE" 837 end 838 839 --void (*GClosureMarshal) (GClosure *closure, GValue *return_value, 840 --guint n_param_values, const GValue *param_values, gpointer 841 --invocation_hint, gpointer marshal_data); 842 843 --void (*GClosureNotify) (gpointer data, GClosure *closure); 844 845 g_cclosure_new (callback_func, user_data, destroy_data: POINTER): POINTER is -- GClosure 846 external "C use <glib-object.h>" 847 end 848 849 g_cclosure_new_swap (callback_func, user_data, destroy_data: POINTER): POINTER is -- GClosure 850 external "C use <glib-object.h>" 851 end 852 853 g_cclosure_new_object (callback_func, an_object: POINTER): POINTER is -- GClosure 854 external "C use <glib-object.h>" 855 end 856 857 g_cclosure_new_object_swap (callback_func, an_object: POINTER): POINTER is -- GClosure 858 external "C use <glib-object.h>" 859 end 860 861 g_closure_new_object (sizeof_closure: INTEGER; an_object: POINTER): POINTER is -- GClosure 862 -- Note: sizeof_closure is a guint/NATURAL 863 external "C use <glib-object.h>" 864 end 865 866 g_closure_ref (a_closure: POINTER): POINTER is -- GClosure 867 external "C use <glib-object.h>" 868 end 869 870 g_closure_sink (a_closure: POINTER) is 871 external "C use <glib-object.h>" 872 end 873 874 g_closure_unref (a_closure: POINTER) is 875 external "C use <glib-object.h>" 876 end 877 878 g_closure_invoke (a_closure, a_return_value: POINTER; n_param_values: INTEGER; const_gvalue_param_values, invocation_hint: POINTER) is 879 -- Note: n_param_values is guint, i.e. a NATURAL 880 external "C use <glib-object.h>" 881 end 882 883 g_closure_invalidate (a_closure: POINTER) is 884 external "C use <glib-object.h>" 885 end 886 887 g_closure_add_finalize_notifier (a_closure, notify_data, notify_func: POINTER) is 888 external "C use <glib-object.h>" 889 end 890 891 g_closure_add_invalidate_notifier (a_closure, notify_data, notify_func: POINTER) is 892 external "C use <glib-object.h>" 893 end 894 895 g_closure_remove_finalize_notifier (a_closure, notify_data, notify_func: POINTER) is 896 external "C use <glib-object.h>" 897 end 898 899 g_closure_remove_invalidate_notifier (a_closure, notify_data, notify_func: POINTER) is 900 external "C use <glib-object.h>" 901 end 902 903 g_closure_new_simple (sizeof_closure: INTEGER; data: POINTER): POINTER is -- GClosure 904 -- Note sizeof_closure is a guint/NATURAL 905 external "C use <glib-object.h>" 906 end 907 908 g_closure_set_marshal (a_closure, a_marshal: POINTER) is 909 external "C use <glib-object.h>" 910 end 911 912 g_closure_add_marshal_guards (a_closure, pre_marshal_data, pre_marshal_notify, post_marshal_data, post_marshal_notify: POINTER) is 913 external "C use <glib-object.h>" 914 end 915 916 g_closure_set_meta_marshal (a_closure, marshal_data, meta_marshal: POINTER) is 917 external "C use <glib-object.h>" 918 end 919 920 g_source_set_closure (a_gsource, a_closure: POINTER) is 921 external "C use <glib-object.h>" 922 end 923 924 g_type_io_channel is 925 external "C macro use <glib-object.h>" 926 alias "G_TYPE_IO_CHANNEL" 927 end 928 929 g_type_io_condition is 930 external "C macro use <glib-object.h>" 931 alias "G_TYPE_IO_CONDITION" 932 end 933 934 935 g_cclosure_marshal_void__void (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 936 const_gvalue_param_values, invocation_hint, marshal_data: POINTER) is 937 -- Note: n_param_values is a guint/NATURAL 938 external "C use <glib-object.h>" 939 alias "g_cclosure_marshal_VOID__VOID" 940 end 941 942 g_cclosure_marshal_void__boolean (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 943 const_gvalue_param_values, invocation_hint, marshal_data: POINTER) is 944 -- Note: n_param_values is a guint/NATURAL 945 external "C use <glib-object.h>" 946 alias "g_cclosure_marshal_VOID__BOOLEAN" 947 end 948 949 g_cclosure_marshal_void__char (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 950 const_gvalue_param_values, invocation_hint, marshal_data: POINTER) is 951 -- Note: n_param_values is a guint/NATURAL 952 external "C use <glib-object.h>" 953 alias "g_cclosure_marshal_VOID__CHAR" 954 end 955 956 g_cclosure_marshal_void__uchar (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 957 const_gvalue_param_values, invocation_hint, marshal_data: POINTER) is 958 external "C use <glib-object.h>" 959 alias "g_cclosure_marshal_VOID__UCHAR" 960 end 961 962 g_cclosure_marshal_void__int (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 963 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 964 external "C use <glib-object.h>" 965 alias "g_cclosure_marshal_VOID__INT" 966 end 967 968 g_cclosure_marshal_void__uint (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 969 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 970 external "C use <glib-object.h>" 971 alias "g_cclosure_marshal_VOID__UINT" 972 end 973 974 g_cclosure_marshal_void__long (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 975 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 976 external "C use <glib-object.h>" 977 alias "g_cclosure_marshal_VOID__LONG" 978 end 979 980 g_cclosure_marshal_void__ulong (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 981 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 982 external "C use <glib-object.h>" 983 alias "g_cclosure_marshal_VOID__ULONG" 984 end 985 986 g_cclosure_marshal_void__enum (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 987 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 988 external "C use <glib-object.h>" 989 alias "g_cclosure_marshal_VOID__ENUM" 990 end 991 992 g_cclosure_marshal_void__flags (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 993 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 994 external "C use <glib-object.h>" 995 alias "g_cclosure_marshal_VOID__FLAGS" 996 end 997 998 g_cclosure_marshal_void__float (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 999 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 1000 external "C use <glib-object.h>" 1001 alias "g_cclosure_marshal_VOID__FLOAT" 1002 end 1003 1004 g_cclosure_marshal_void__double (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 1005 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 1006 external "C use <glib-object.h>" 1007 alias "g_cclosure_marshal_VOID__DOUBLE" 1008 end 1009 1010 g_cclosure_marshal_void__string (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 1011 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 1012 external "C use <glib-object.h>" 1013 alias "g_cclosure_marshal_VOID__STRING" 1014 end 1015 1016 g_cclosure_marshal_void__param (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 1017 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 1018 external "C use <glib-object.h>" 1019 alias "g_cclosure_marshal_VOID__PARAM" 1020 end 1021 1022 g_cclosure_marshal_void__boxed (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 1023 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 1024 external "C use <glib-object.h>" 1025 alias "g_cclosure_marshal_VOID__BOXED" 1026 end 1027 1028 g_cclosure_marshal_void__pointer (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 1029 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 1030 external "C use <glib-object.h>" 1031 alias "g_cclosure_marshal_VOID__POINTER" 1032 end 1033 1034 g_cclosure_marshal_void__object (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 1035 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 1036 external "C use <glib-object.h>" 1037 alias "g_cclosure_marshal_VOID__OBJECT" 1038 end 1039 1040 g_cclosure_marshal_string__object_pointer (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 1041 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 1042 external "C use <glib-object.h>" 1043 alias "g_cclosure_marshal_STRING__OBJECT_POINTER" 1044 end 1045 1046 g_cclosure_marshal_void__uint_pointer (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 1047 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 1048 external "C use <glib-object.h>" 1049 alias "g_cclosure_marshal_VOID__UINT_POINTER" 1050 end 1051 1052 g_cclosure_marshal_boolean__flags (a_closure, a_return_value: POINTER; n_param_values: INTEGER; 1053 const_gvalueparam_values, invocation_hint, marshal_data: POINTER) is 1054 external "C use <glib-object.h>" 1055 alias "g_cclosure_marshal_BOOLEAN__FLAGS" 1056 end 1057 1058 1059feature {}-- GClosure struct 1060 -- typedef struct { volatile guint in_marshal : 1; volatile guint 1061 -- is_invalid : 1; } GClosure; 1062 1063 -- A GClosure represents a callback supplied by the programmer. 1064 1065 -- volatile guint in_marshal : 1; Indicates whether the closure is 1066 -- currently being invoked with g_closure_invoke() 1067 1068 -- volatile guint is_invalid : 1; Indicates whether the closure has 1069 -- been invalidated by g_closure_invalidate() 1070 1071 get_gstruct_in_marshal (a_gclosure: POINTER): INTEGER is 1072 external "C struct get in_marshal use <glib-object.h>" 1073 end 1074 1075 get_gstruct_is_invalid (a_gclosure: POINTER): INTEGER is 1076 external "C struct get is_invalid use <glib-object.h>" 1077 end 1078 1079feature -- GCClosure struct 1080 -- typedef struct { GClosure closure; callback: POINTER; } 1081 -- GCClosure; 1082 1083 -- A GCClosure is a specialization of GClosure for C function 1084 -- callbacks. 1085 1086 -- GClosure closure; the GClosure 1087 -- callback: POINTER; the callback function 1088 1089 -- GClosureMarshal () 1090 1091 -- void (*GClosureMarshal) (a_closure: POINTER, GValue 1092 -- *return_value, guint n_param_values, const GValue 1093 -- *param_values, invocation_hint: POINTER, marshal_data: 1094 -- POINTER); 1095 1096 -- The type used for marshaller functions. 1097 1098 -- closure : the GClosure to which the marshaller belongs 1099 1100 -- return_value : a GValue to store the return value. May be NULL 1101 -- if the callback of closure doesn't return -- a value. 1102 1103 -- n_param_values : the length of the param_values array 1104 1105 -- param_values : an array of GValues holding the arguments on 1106 -- which to invoke the callback of closure 1107 1108 -- invocation_hint : the invocation hint given as the the last 1109 -- argument to g_closure_invoke() 1110 1111 -- marshal_data : additional data specified when registering the 1112 -- marshaller, see g_closure_set_marshal() and 1113 -- g_closure_set_meta_marshal() 1114 1115 -- GClosureNotify () 1116 1117 -- void (*GClosureNotify) (data: POINTER, a_closure: POINTER); 1118 1119 -- The type used for the various notification callbacks which can be registered on closures. 1120 1121 -- data : data specified when registering the notification 1122 -- callback 1123 1124 -- closure : the GClosure on which the notification is emitted 1125end