gclosure.inc 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // included by glib2.pas
  2. { -- typedefs --- }
  3. type
  4. PGClosure = ^TGClosure;
  5. PGClosureNotifyData = ^TGClosureNotifyData;
  6. TGClosureNotify = procedure (data:gpointer; closure:PGClosure); cdecl;
  7. {< private > }
  8. {< private > }
  9. {< private > }
  10. {< private > }
  11. { finalization notifiers }
  12. {< private > }
  13. { invalidation notifiers }
  14. {< private > }
  15. {< private > }
  16. {< protected > }
  17. {< public > }
  18. {< public > }
  19. {< private > }
  20. {out }
  21. {< protected > }
  22. {< private > }
  23. { invariants/constrains:
  24. - ->marshal and ->data are _invalid_ as soon as ->is_invalid==TRUE
  25. - invocation of all inotifiers occours prior to fnotifiers
  26. - order of inotifiers is random
  27. inotifiers may _not_ free/invalidate parameter values (e.g. ->data)
  28. - order of fnotifiers is random
  29. - each notifier may only be removed before or during its invocation
  30. - reference counting may only happen prior to fnotify invocation
  31. (in that sense, fnotifiers are really finalization handlers)
  32. }
  33. TGClosure = record
  34. flag0 : longint;
  35. marshal : procedure (closure:PGClosure; return_value:PGValue; n_param_values:guint; param_values:PGValue; invocation_hint:gpointer;
  36. marshal_data:gpointer); cdecl;
  37. data : gpointer;
  38. notifiers : PGClosureNotifyData;
  39. end;
  40. TGCallBackProcedure = procedure;
  41. TGCallback = procedure (para1: TGCallBackProcedure); cdecl;
  42. TGClosureMarshal = procedure (closure:PGClosure; return_value:PGValue; n_param_values:guint; param_values:PGValue; invocation_hint:gpointer;
  43. marshal_data:gpointer); cdecl;
  44. { --- structures --- }
  45. TGClosureNotifyData = record
  46. data : gpointer;
  47. notify : TGClosureNotify;
  48. end;
  49. { --- defines --- }
  50. function G_CLOSURE_NEEDS_MARSHAL(closure : Pointer) : boolean;
  51. function G_CLOSURE_N_NOTIFIERS(cl : PGClosure) : longint;
  52. function G_CCLOSURE_SWAP_DATA(cclosure : PGClosure) : longint;
  53. function G_CALLBACK(f : pointer) : TGCallback;
  54. const
  55. bm_TGClosure_ref_count = $7FFF;
  56. bp_TGClosure_ref_count = 0;
  57. bm_TGClosure_meta_marshal = $8000;
  58. bp_TGClosure_meta_marshal = 15;
  59. bm_TGClosure_n_guards = $10000;
  60. bp_TGClosure_n_guards = 16;
  61. bm_TGClosure_n_fnotifiers = $60000;
  62. bp_TGClosure_n_fnotifiers = 17;
  63. bm_TGClosure_n_inotifiers = $7F80000;
  64. bp_TGClosure_n_inotifiers = 19;
  65. bm_TGClosure_in_inotify = $8000000;
  66. bp_TGClosure_in_inotify = 27;
  67. bm_TGClosure_floating = $10000000;
  68. bp_TGClosure_floating = 28;
  69. bm_TGClosure_derivative_flag = $20000000;
  70. bp_TGClosure_derivative_flag = 29;
  71. bm_TGClosure_in_marshal = $40000000;
  72. bp_TGClosure_in_marshal = 30;
  73. bm_TGClosure_is_invalid = $80000000;
  74. bp_TGClosure_is_invalid = 31;
  75. function ref_count(var a : TGClosure) : guint;
  76. procedure set_ref_count(var a : TGClosure; __ref_count : guint);
  77. function meta_marshal(a : PGClosure) : guint;
  78. procedure set_meta_marshal(var a : TGClosure; __meta_marshal : guint);
  79. function n_guards(a : PGClosure) : guint;
  80. procedure set_n_guards(var a : TGClosure; __n_guards : guint);
  81. function n_fnotifiers(a : PGClosure) : guint;
  82. procedure set_n_fnotifiers(var a : TGClosure; __n_fnotifiers : guint);
  83. function n_inotifiers(a : PGClosure) : guint;
  84. procedure set_n_inotifiers(var a : TGClosure; __n_inotifiers : guint);
  85. function in_inotify(var a : TGClosure) : guint;
  86. procedure set_in_inotify(var a : TGClosure; __in_inotify : guint);
  87. function floating(var a : TGClosure) : guint;
  88. procedure set_floating(var a : TGClosure; __floating : guint);
  89. function derivative_flag(a : PGClosure) : guint;
  90. procedure set_derivative_flag(var a : TGClosure; __derivative_flag : guint);
  91. function in_marshal(var a : TGClosure) : guint;
  92. procedure set_in_marshal(var a : TGClosure; __in_marshal : guint);
  93. function is_invalid(var a : TGClosure) : guint;
  94. procedure set_is_invalid(var a : TGClosure; __is_invalid : guint);
  95. { closure for C function calls, callback() is the user function }
  96. type
  97. PGCClosure = ^TGCClosure;
  98. TGCClosure = record
  99. closure : TGClosure;
  100. callback : gpointer;
  101. end;
  102. { --- prototypes --- }
  103. function g_cclosure_new(callback_func:TGCallback; user_data:gpointer; destroy_data:TGClosureNotify):PGClosure; cdecl; external gliblib;
  104. function g_cclosure_new_swap(callback_func:TGCallback; user_data:gpointer; destroy_data:TGClosureNotify):PGClosure; cdecl; external gliblib;
  105. function g_signal_type_cclosure_new(itype:GType; struct_offset:guint):PGClosure; cdecl; external gliblib;
  106. { --- prototypes --- }
  107. function g_closure_ref(closure:PGClosure):PGClosure; cdecl; external gliblib;
  108. procedure g_closure_sink(closure:PGClosure); cdecl; external gliblib;
  109. procedure g_closure_unref(closure:PGClosure); cdecl; external gliblib;
  110. { intimidating }
  111. function g_closure_new_simple(sizeof_closure:guint; data:gpointer):PGClosure; cdecl; external gliblib;
  112. procedure g_closure_add_finalize_notifier(closure:PGClosure; notify_data:gpointer; notify_func:TGClosureNotify); cdecl; external gliblib;
  113. procedure g_closure_remove_finalize_notifier(closure:PGClosure; notify_data:gpointer; notify_func:TGClosureNotify); cdecl; external gliblib;
  114. procedure g_closure_add_invalidate_notifier(closure:PGClosure; notify_data:gpointer; notify_func:TGClosureNotify); cdecl; external gliblib;
  115. procedure g_closure_remove_invalidate_notifier(closure:PGClosure; notify_data:gpointer; notify_func:TGClosureNotify); cdecl; external gliblib;
  116. procedure g_closure_add_marshal_guards(closure:PGClosure; pre_marshal_data:gpointer; pre_marshal_notify:TGClosureNotify; post_marshal_data:gpointer; post_marshal_notify:TGClosureNotify); cdecl; external gliblib;
  117. procedure g_closure_set_marshal(closure:PGClosure; marshal:TGClosureMarshal); cdecl; external gliblib;
  118. procedure g_closure_set_meta_marshal(closure:PGClosure; marshal_data:gpointer; meta_marshal:TGClosureMarshal); cdecl; external gliblib;
  119. procedure g_closure_invalidate(closure:PGClosure); cdecl; external gliblib;
  120. {out }
  121. procedure g_closure_invoke(closure:PGClosure; return_value:PGValue; n_param_values:guint; param_values:PGValue; invocation_hint:gpointer); cdecl; external gliblib;
  122. { FIXME:
  123. OK: data_object::destroy -> closure_invalidate();
  124. MIS: closure_invalidate() -> disconnect(closure);
  125. MIS: disconnect(closure) -> (unlink) closure_unref();
  126. OK: closure_finalize() -> g_free (data_string);
  127. random remarks:
  128. - need marshaller repo with decent aliasing to base types
  129. - provide marshaller collection, virtually covering anything out there
  130. }
  131. // included by glib2.pas