3 public static delegate
void Maman
.VoidCallback ();
5 public static delegate
int Maman
.ActionCallback ();
7 public delegate
void Maman
.InstanceCallback (int i
);
9 struct Maman
.DelegateStruct
{
10 public VoidCallback
callback;
13 interface Maman
.Foo
: Object
{
14 public abstract void foo_method (int i
);
17 class Maman
.Bar
: Object
, Foo
{
18 const DelegateStruct const_delegate_struct
= { do_void_action
};
23 static void do_void_action () {
27 static int do_action () {
31 void do_instance_action (int i
) {
37 static void call_instance_delegate (InstanceCallback instance_cb
) {
41 static void test_function_pointers () {
42 stdout
.printf ("testing function pointers:");
43 var table
= new HashTable
<string, Bar
>.full (str_hash
, str_equal
, g_free
, Object
.unref
);
46 table
.insert ("foo", new
Bar ());
49 var bar
= table
.lookup ("foo");
50 stdout
.printf (" 3\n");
53 public void foo_method (int i
) {
56 static void test_delegates_interface_method () {
57 // http://bugzilla.gnome.org/show_bug.cgi?id=518109
59 call_instance_delegate (bar
.foo_method
);
62 static int main (string[] args
) {
63 stdout
.printf ("Delegate Test: 1");
65 VoidCallback void_cb
= do_void_action
;
71 ActionCallback cb
= do_action
;
73 stdout
.printf (" %d", cb ());
79 InstanceCallback instance_cb
= bar
.do_instance_action
;
80 call_instance_delegate (instance_cb
);
82 stdout
.printf (" 7\n");
84 test_function_pointers ();
86 test_delegates_interface_method ();