summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/gtk2/src/glib/gclosure.inc
blob: f251f0cc286792232544f1e7cc3107e845158ca1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// included by glib2.pas

{$IFDEF read_forward_definitions}
{$ENDIF read_forward_definitions}

//------------------------------------------------------------------------------

{$IFDEF read_interface_types}
   PGClosure = ^TGClosure;
   PGClosureNotifyData = ^TGClosureNotifyData;
   TGClosureNotify = procedure (data:gpointer; closure:PGClosure); cdecl;

   TGClosure = record
        flag0 : longint;
        marshal : procedure (closure:PGClosure; return_value:PGValue; n_param_values:guint; param_values:PGValue; invocation_hint:gpointer;
                      marshal_data:gpointer); cdecl;
        data : gpointer;
        notifiers : PGClosureNotifyData;
     end;

   PGCClosure = ^TGCClosure;
   TGCClosure = record
        closure : TGClosure;
        callback : gpointer;
     end;

   TGCallBackProcedure = procedure; 
   TGCallback = procedure (para1: TGCallBackProcedure); cdecl;

   TGClosureMarshal = procedure (closure:PGClosure; return_value:PGValue; n_param_values:guint; param_values:PGValue; invocation_hint:gpointer;
                 marshal_data:gpointer); cdecl;
{ --- structures ---  }
   TGClosureNotifyData = record
        data : gpointer;
        notify : TGClosureNotify;
     end;

{$ENDIF read_interface_types}

//------------------------------------------------------------------------------

{$IFDEF read_interface_rest}
{ --- defines ---  }

function G_CLOSURE_NEEDS_MARSHAL(closure : Pointer) : boolean;
function G_CLOSURE_N_NOTIFIERS(cl : PGClosure) : longint;
function G_CCLOSURE_SWAP_DATA(cclosure : PGClosure) : longint;
function G_CALLBACK(f : pointer) : TGCallback;

const
   bm_TGClosure_ref_count = $7FFF;
   bp_TGClosure_ref_count = 0;
   bm_TGClosure_meta_marshal = $8000;
   bp_TGClosure_meta_marshal = 15;
   bm_TGClosure_n_guards = $10000;
   bp_TGClosure_n_guards = 16;
   bm_TGClosure_n_fnotifiers = $60000;
   bp_TGClosure_n_fnotifiers = 17;
   bm_TGClosure_n_inotifiers = $7F80000;
   bp_TGClosure_n_inotifiers = 19;
   bm_TGClosure_in_inotify = $8000000;
   bp_TGClosure_in_inotify = 27;
   bm_TGClosure_floating = $10000000;
   bp_TGClosure_floating = 28;
   bm_TGClosure_derivative_flag = $20000000;
   bp_TGClosure_derivative_flag = 29;
   bm_TGClosure_in_marshal = $40000000;
   bp_TGClosure_in_marshal = 30;
   bm_TGClosure_is_invalid = $80000000;
   bp_TGClosure_is_invalid = 31;

function ref_count(var a : TGClosure) : guint;
procedure set_ref_count(var a : TGClosure; __ref_count : guint);
function meta_marshal(a : PGClosure) : guint;
procedure set_meta_marshal(var a : TGClosure; __meta_marshal : guint);
function n_guards(a : PGClosure) : guint;
procedure set_n_guards(var a : TGClosure; __n_guards : guint);
function n_fnotifiers(a : PGClosure) : guint;
procedure set_n_fnotifiers(var a : TGClosure; __n_fnotifiers : guint);
function n_inotifiers(a : PGClosure) : guint;
procedure set_n_inotifiers(var a : TGClosure; __n_inotifiers : guint);
function in_inotify(var a : TGClosure) : guint;
procedure set_in_inotify(var a : TGClosure; __in_inotify : guint);
function floating(var a : TGClosure) : guint;
procedure set_floating(var a : TGClosure; __floating : guint);
function derivative_flag(a : PGClosure) : guint;
procedure set_derivative_flag(var a : TGClosure; __derivative_flag : guint);
function in_marshal(var a : TGClosure) : guint;
procedure set_in_marshal(var a : TGClosure; __in_marshal : guint);
function is_invalid(var a : TGClosure) : guint;
procedure set_is_invalid(var a : TGClosure; __is_invalid : guint);


{ closure for C function calls, callback() is the user function }

{ --- prototypes ---  }

function g_cclosure_new(callback_func:TGCallback; user_data:gpointer; destroy_data:TGClosureNotify):PGClosure; cdecl; external gliblib;
function g_cclosure_new_swap(callback_func:TGCallback; user_data:gpointer; destroy_data:TGClosureNotify):PGClosure; cdecl; external gliblib;
function g_signal_type_cclosure_new(itype:GType; struct_offset:guint):PGClosure; cdecl; external gliblib;
{ --- prototypes ---  }
function g_closure_ref(closure:PGClosure):PGClosure; cdecl; external gliblib;
procedure g_closure_sink(closure:PGClosure); cdecl; external gliblib;
procedure g_closure_unref(closure:PGClosure); cdecl; external gliblib;
{ intimidating  }
function g_closure_new_simple(sizeof_closure:guint; data:gpointer):PGClosure; cdecl; external gliblib;
procedure g_closure_add_finalize_notifier(closure:PGClosure; notify_data:gpointer; notify_func:TGClosureNotify); cdecl; external gliblib;
procedure g_closure_remove_finalize_notifier(closure:PGClosure; notify_data:gpointer; notify_func:TGClosureNotify); cdecl; external gliblib;
procedure g_closure_add_invalidate_notifier(closure:PGClosure; notify_data:gpointer; notify_func:TGClosureNotify); cdecl; external gliblib;
procedure g_closure_remove_invalidate_notifier(closure:PGClosure; notify_data:gpointer; notify_func:TGClosureNotify); cdecl; external gliblib;
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;
procedure g_closure_set_marshal(closure:PGClosure; marshal:TGClosureMarshal); cdecl; external gliblib;
procedure g_closure_set_meta_marshal(closure:PGClosure; marshal_data:gpointer; meta_marshal:TGClosureMarshal); cdecl; external gliblib;
procedure g_closure_invalidate(closure:PGClosure); cdecl; external gliblib;
{out }
procedure g_closure_invoke(closure:PGClosure; return_value:PGValue; n_param_values:guint; param_values:PGValue; invocation_hint:gpointer); cdecl; external gliblib;

{ FIXME:
   OK:  data_object::destroy            -> closure_invalidate();
   MIS: closure_invalidate()            -> disconnect(closure);
   MIS: disconnect(closure)             -> (unlink) closure_unref();
   OK:  closure_finalize()              -> g_free (data_string);

   random remarks:
   - need marshaller repo with decent aliasing to base types
   - provide marshaller collection, virtually covering anything out there
 }
{$ENDIF read_interface_rest}

// included by glib2.pas