Re: [Vala] Proposal: CCodeFunc modifier or alike?



On Sat, May 17, 2008 19:54, Yu Feng wrote:
I suggest a new way to specific the way vala mangles the member
functions?

CCodeFunc = cname(paralist);
where cname is the c function's name, and

paralist ::= this | formal param | static members

Several examples to show the flexibility:

class List<weak G> {
      [CCodeFunc this = g_list_insert(this, data)]
      public void insert(G data);
      [CCodeFunc this = g_list_remove(this, data)]
      public void remove(G data);
        [CCodeFunc g_list_free(list)]
      public static void DestroyFunc(List<weak G> list);
}
class List<G> {
      [CCodeFunc this = g_list_insert(this, data)) ]
      public void insert(G #data);
      [CCodeFunc (this = g_list_remove(this, data); G.DestroyFunc(data)) ]
      public void remove(G data);
      [CCodeFunc (g_list_foreach(list, G.DestroyFunc);g_list_free(list))]
        public static void DestroyFunc(List<G> list);
}

It will allow us to pull out a lot of mess from the vala compiler to the
vapi files.

This will also add quite some complexity to the compiler and still have
limits. For example how to handle array length parameters in delegates
with that?

It probably makes sense to allow defining small wrapper methods in a .vala
file to be used in addition to the .vapi file, however, we should use
normal method bodies there, this should reduce the complexity.

Juerg




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]