Re: [Vala] embedding c code snippet in vala source.
- From: Hans Vercammen <hveso3 gmail com>
- 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 18:56:56 +0200
Hi,
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();
[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();
[CCode (snippet = "return this[id];")]
public T element(int id);
[CCode (snippet = "g_free(this);")]
public void free();
}
It looks to me like you are requesting some sort of compile-time
templates, which is certainly not the way vala or C does it. Although I
like the abstract meta-programming features of C++, I think it's way out
of scope to get something like this into vala. As I understand it, vala
is a very thin lean machine between C and C++ targeting Glib and GObject
which allows you to incorporate other libraries (or external exotic
functions) without too much fuss. For compile-time templates or
embedding other languages, you will need a much bigger compiler beastie
to support this properly.
Regards,
Hans
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]