Re: [Vala] embedding c code snippet in vala source.
- From: Jürg Billeter <j bitron ch>
- To: Yu Feng <rainwoodman gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] embedding c code snippet in vala source.
- Date: Fri, 22 Aug 2008 12:26:10 +0200
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]