Hi,

2009/9/22 Marco Trevisan <[email protected]>:
> Abderrahim Kitouni wrote:
>> did you try to set [CCode (cname=g_new0)] for the constructor? You can
>> make it work somehow with such tricks.
>
> Yes, I tried but it doesn't work since it generates bad c code (with no
> parameters for g_new0) like:
>        _tmp0_ = g_new0 ();
Yes, I forgot to mention that you need to add default arguments to
make it work (IIRC, g_new0 takes a size, so you can make your
constructor

[CCode (cname = "g_new0")]
MyVirtualClass (ulong size = sizeof(int));

or something like this, the problem with this approach is that a user
can break his code (plus it's somewhat ugly)

> This is what I want avoid. I just want to write a VAPI without editing
> the C source code, but creating a new "virtual class" that is a kind of
> wrapper to replace the missing C code.
>
> With Vala 0.7.5 all this was possible, why isn't it any more?
It was a bug :-p

Seriously, I believe this is the intended behaviour, you declared a
*class* not a struct. A compact class' size is not always known, so it
doesn't  always make sense to use g_new, but it may make sense as a
fallback.

I don't know if a struct is what you want or if you need a
constructor. How is this supposed to be used?

Abderrahim
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to