[Vala] Delegating problem



Hmm not 100% sure it vala or my code... but below valacode does not
generate valid C code:


--- The vala code ---------------

public  delegate void test(int a);
public struct Callbacks
{
public int data;
public weak test cb;
Callbacks(int i, weak  test t) { cb = t;  data=i;}
}

public class Test : Object {
Callbacks[] cbs;

construct {    
   cbs=new Callbacks[]
   {
     new Callbacks(100, foo),
     new Callbacks(101, bar)
   };
 }

  void foo(int t)
  {
    stdout.printf("foo\n");
  }
  void bar(int t)
  {
    stdout.printf("bar\n");
  }
}

if I make the callbaks static  it will work but its not a good solution
in my app...

C output fails with:

error: request for member ‘te_target’ in something not a structure or
union reason is this:

--- The generated CCode ------

static void callbacks_init (Callbacks *self, gint i, test t, void*
t_target) {
        test _tmp0;
        memset (self, 0, sizeof (Callbacks));
        (*self).te = (_tmp0 = t, self.te_target = t_target, _tmp0);
        (*self).data = i;
}


it should generate be  (*self).te_target = t_target right?






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]