On Fri, 2008-08-22 at 05:49 -0400, Yu Feng wrote:
> Just a scratch of idea:
> 
> class array<T> {
>    [CCode (snippet = "int i; while(((T)this)[i]) i++; return i;")]
>    public int get_length();

This won't work (arrays may contain null/0 entries), and it would be
slow.

>    [CCode (snippet = "gpointer * rt; while((T)(this)[i]) i++; result.length = 
> i; rt = g_new0(T, i); for(i=0; i<result.length; i++) rt[i] = this[i]); return 
> rt;")]
>    public array duplicate();

This would at least break memory management, and it looks like a strange
combination of C and Vala syntax, not easy to understand.

>    [CCode (snippet = "return this[id];")]
>    public T element(int id);

Might work if we treated the element method specially, doesn't sound
that straight forward to me.

>    [CCode (snippet = "g_free(this);")]
>    public void free();

We don't want free functions in the bindings API, we already have
`delete' to free memory if you use raw pointers.

Jürg

_______________________________________________
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to