Re: [Vala] embedding c code snippet in vala source.



Man this is a trap. There is no logical relation between failing to
provide examples and the the validaty of a feature.

The consideration about maintenance makes more sense. and I would like
to say again, I agree it is a large patch and I understand any repulsion
toward it: after all it is alien and foreign.

A big patch solving one or two case is useless. 

You've already spend so much commits patching all the mess with
[NoArrayLength] [array_length_pos] [cname] and [FloatingReference].
There is really no point to introduce another mess to replace them and
to kill their descendants. A movement in the opposite direction costs
too much. Let's forget about it.

Regards,

Yu

On Fri, 2008-08-22 at 12:26 +0200, Jürg Billeter wrote:
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]