3 public enum ParameterEnum
{ FOO
, BAR
}
5 public static delegate
void Maman
.VoidCallback ();
7 public static delegate
int Maman
.ActionCallback ();
9 public delegate
void Maman
.InstanceCallback (int i
);
10 public delegate Maman
.SelfCallback Maman
.SelfCallback (Maman
.SelfCallback scb
);
12 public delegate ParameterEnum Maman
.EnumDelegate (ParameterEnum pe
);
14 struct Maman
.DelegateStruct
{
15 public VoidCallback
callback;
18 interface Maman
.Foo
: Object
{
19 public abstract void foo_method (int i
);
22 class Maman
.Bar
: Object
, Foo
{
23 const DelegateStruct const_delegate_struct
= { do_void_action
};
28 static void do_void_action () {
32 static int do_action () {
36 void do_instance_action (int i
) {
42 static void call_instance_delegate (InstanceCallback instance_cb
) {
46 void assign_instance_delegate (out InstanceCallback instance_cb
) {
47 instance_cb
= foo_method
;
50 static void test_function_pointers () {
51 stdout
.printf ("testing function pointers:");
52 var table
= new HashTable
<string, Bar
>.full (str_hash
, str_equal
, g_free
, Object
.unref
);
55 table
.insert ("foo", new
Bar ());
58 var bar
= table
.lookup ("foo");
59 stdout
.printf (" 3\n");
62 public void foo_method (int i
) {
65 static void test_delegates_interface_method () {
66 // http://bugzilla.gnome.org/show_bug.cgi?id=518109
68 call_instance_delegate (bar
.foo_method
);
71 public static int main () {
72 stdout
.printf ("Delegate Test: 1");
74 VoidCallback void_cb
= do_void_action
;
80 ActionCallback cb
= do_action
;
82 stdout
.printf (" %d", cb ());
88 InstanceCallback instance_cb
= bar
.do_instance_action
;
89 call_instance_delegate (instance_cb
);
91 bar
.assign_instance_delegate (out instance_cb
);
92 call_instance_delegate (instance_cb
);
94 stdout
.printf (" 7\n");
96 test_function_pointers ();
98 test_delegates_interface_method ();