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

2008-08-22 Thread Sam Liddicott
You can probably simplify it and perhaps make it less offensive by getting rid of the C parsing for symbol names and try another way. For my work on compact classes vmt expressions etc, I implement it as a macro body; if you implement the snippet as a macro body it and pass in the vala paramete

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

2008-08-22 Thread Hans Vercammen
Hi, On Fri, 2008-08-22 at 05:49 -0400, Yu Feng wrote: > Just a scratch of idea: > > class array { >[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,

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

2008-08-22 Thread Sam Liddicott
* Jürg Billeter wrote, On 22/08/08 11:26: > >>[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. > Darn, I'll need them for compact classes... Sam ___

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

2008-08-22 Thread Sam Liddicott
* Alexey Lubimov wrote, On 22/08/08 12:53: > Jürg Billeter пишет: >> On Fri, 2008-08-22 at 06:45 -0400, Yu Feng wrote: >> >>> Man this is a trap. There is no logical relation between failing to >>> provide examples and the the validaty of a feature. >>> >> >> I agree, however, I don't see a

Re: [Vala] Question on Documentation and tutorials.

2008-08-22 Thread Clément DAVID
Hi, You can take a look at samples on the Vala main page : http://live.gnome.org/Vala#head-9c728d151a2a0483d4f3b5837e5b545df9d8499d If you want more informations about gtk and glib ecosystem, look at : http://library.gnome.org/devel/references or with devhelp (which is better) with the right docu

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

2008-08-22 Thread Alexey Lubimov
Jürg Billeter пишет: On Fri, 2008-08-22 at 06:45 -0400, Yu Feng wrote: Man this is a trap. There is no logical relation between failing to provide examples and the the validaty of a feature. I agree, however, I don't see a reason to merge a feature as long as there is no use case for i

[Vala] Question on Documentation and tutorials.

2008-08-22 Thread Ahm ed
Hello, I just wanted to start by saying that I really do appreciate all the work that you do here on vala and I am very excited for the completion of this language and it's tools. As such I am interested in learning vala, however I have had a hard time with the documentation. I have looked through

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

2008-08-22 Thread Jürg Billeter
On Fri, 2008-08-22 at 14:35 +0400, Alexey Lubimov wrote: > Jürg Billeter пишет: > > On Fri, 2008-08-22 at 13:28 +0400, Alexey Lubimov wrote: > >> You can see 15 bugs in vala-0.3.5 sources only... > >> > > > > Most of these look correct from a quick look. The scanner and parser use > > byte off

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

2008-08-22 Thread Jürg Billeter
On Fri, 2008-08-22 at 06:45 -0400, Yu Feng wrote: > Man this is a trap. There is no logical relation between failing to > provide examples and the the validaty of a feature. I agree, however, I don't see a reason to merge a feature as long as there is no use case for it. Cheers, Jürg ___

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

2008-08-22 Thread Alexey Lubimov
Jürg Billeter пишет: On Fri, 2008-08-22 at 13:28 +0400, Alexey Lubimov wrote: Jürg Billeter пишет: Ok, as you agree that the null-terminated arrays should be handled, your g_strv_length example is not a real use case for the snippet support. Can you provide a concrete exam

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

2008-08-22 Thread Yu Feng
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 a

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

2008-08-22 Thread Alexey Lubimov
Jürg Billeter пишет: On Fri, 2008-08-22 at 13:28 +0400, Alexey Lubimov wrote: Jürg Billeter пишет: Ok, as you agree that the null-terminated arrays should be handled, your g_strv_length example is not a real use case for the snippet support. Can you provide a concrete exam

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

2008-08-22 Thread Jürg Billeter
On Fri, 2008-08-22 at 05:49 -0400, Yu Feng wrote: > Just a scratch of idea: > > class array { >[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 = "gpoi

[Vala] Lets talk about some easier stuff before this controversial one.

2008-08-22 Thread Yu Feng
On Fri, 2008-08-22 at 11:54 +0200, Jürg Billeter wrote: > On Fri, 2008-08-22 at 05:24 -0400, Yu Feng wrote: > > On Fri, 2008-08-22 at 11:04 +0200, Jürg Billeter wrote: > > > > Another direction of this patch is to allow small wrapping code in > > > > the .vapi declarations (which might ease the vap

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

2008-08-22 Thread Jürg Billeter
On Fri, 2008-08-22 at 05:24 -0400, Yu Feng wrote: > On Fri, 2008-08-22 at 11:04 +0200, Jürg Billeter wrote: > > > Another direction of this patch is to allow small wrapping code in > > > the .vapi declarations (which might ease the vapi authors's life) > > > > This is the only place where I might

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

2008-08-22 Thread pancake
On Fri, 2008-08-22 at 05:24 -0400, Yu Feng wrote: > > C doesn't support inline assembly code. Some C compilers support inline > > assembly but that's a compiler-specific extension to the C language. > My idea came from some experience with open watcom's asm embedding. They > encouraged people to em

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

2008-08-22 Thread Yu Feng
Just a scratch of idea: class array { [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 with in generics, class array { [CCode (snippet =

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

2008-08-22 Thread Jürg Billeter
On Fri, 2008-08-22 at 13:28 +0400, Alexey Lubimov wrote: > Jürg Billeter пишет: > > Ok, as you agree that the null-terminated arrays should be handled, > your > > g_strv_length example is not a real use case for the snippet support. > > Can you provide a concrete example where you think it makes mo

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

2008-08-22 Thread Alexey Lubimov
Jürg Billeter пишет: On Fri, 2008-08-22 at 05:09 -0400, Yu Feng wrote: On Fri, 2008-08-22 at 10:44 +0200, Jürg Billeter wrote: Maybe I'm just missing an interesting use case, however, I currently fail to see where the snippet approach makes it more comfortable to write or use bindings.

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

2008-08-22 Thread Yu Feng
On Fri, 2008-08-22 at 11:04 +0200, Jürg Billeter wrote: > Hi Yu, > > On Thu, 2008-08-21 at 14:27 -0400, Yu Feng wrote: > > I made a patch that allows embedding c code snippet in vala source. > > > > http://bugzilla.gnome.org/show_bug.cgi?id=548897 > > > > This is quite primitive and more has to

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

2008-08-22 Thread Jürg Billeter
On Fri, 2008-08-22 at 05:09 -0400, Yu Feng wrote: > On Fri, 2008-08-22 at 10:44 +0200, Jürg Billeter wrote: > > Maybe I'm just missing an interesting use case, however, I currently > > fail to see where the snippet approach makes it more comfortable to > > write or use bindings. Can you provide exa

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

2008-08-22 Thread Yu Feng
On Fri, 2008-08-22 at 10:44 +0200, Jürg Billeter wrote: > Hi Yu, > > On Fri, 2008-08-22 at 02:58 -0400, Yu Feng wrote: > > Which do you prefer if you want to split a string? mysplit or split? > > > > [CCode (cname = "g_strmysplit", snippet = "gchar ** rt = > > g_strsplit(this, > > delimiter,

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

2008-08-22 Thread Jürg Billeter
Hi Yu, On Thu, 2008-08-21 at 14:27 -0400, Yu Feng wrote: > I made a patch that allows embedding c code snippet in vala source. > > http://bugzilla.gnome.org/show_bug.cgi?id=548897 > > This is quite primitive and more has to be done, especially to translate > the vala variable names to cnames. >

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

2008-08-22 Thread Jürg Billeter
Hi Yu, On Fri, 2008-08-22 at 02:58 -0400, Yu Feng wrote: > Which do you prefer if you want to split a string? mysplit or split? > > [CCode (cname = "g_strmysplit", snippet = "gchar ** rt = g_strsplit(this, > delimiter, max_tokens); *result_length1 = rt?g_strv_length(rt):0; return > rt;")] >

Re: [Vala] trunk fails compiling .vala files.

2008-08-22 Thread Jürg Billeter
On Thu, 2008-08-21 at 12:11 -0400, Yu Feng wrote: > Dear Juerg, and others, > > A trunk built from a vala 0.3.4 can not compile any program, giving the > following error. You should build trunk with Vala 0.3.5 as it requires some fixes that have been committed only a short time before the 0.3.5 r

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

2008-08-22 Thread Daniel Svensson
On Thu, Aug 21, 2008 at 8:27 PM, Yu Feng <[EMAIL PROTECTED]> wrote: > Dear all, > > I made a patch that allows embedding c code snippet in vala source. > > http://bugzilla.gnome.org/show_bug.cgi?id=548897 Why not just write a .vapi-file for your C-code? It's easy as pie to mix vala with C-code. Ju

Re: [Vala] trunk fails compiling .vala files.

2008-08-22 Thread Clément DAVID
Me too, you can switch to HEAD-1 to get no errors 2008/8/21 Victor Manuel Jáquez Leal <[EMAIL PROTECTED]>: > Me! since yesterday > > On Thu, Aug 21, 2008 at 6:11 PM, Yu Feng <[EMAIL PROTECTED]> wrote: >> Dear Juerg, and others, >> >> A trunk built from a vala 0.3.4 can not compile any program, giv

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

2008-08-22 Thread Yu Feng
Thanks. but cexpression is too long for typing.. Perhaps a reasonable name for a uncommon usage though. I had to make several changes over the entire vala. Perhaps I should separate them into small ones. yu On Fri, 2008-08-22 at 08:18 +0100, Sam Liddicott wrote: > Surely it's OK for VAPI file

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

2008-08-22 Thread Alexey Lubimov
Ali Sabil пишет: On Fri, Aug 22, 2008 at 7:32 AM, Yu Feng <[EMAIL PROTECTED] > wrote: On Thu, 2008-08-21 at 23:18 +0100, Emmanuele Bassi wrote: > On Thu, 2008-08-21 at 14:27 -0400, Yu Feng wrote: > > Dear all, > > > > I made a patch that allows

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

2008-08-22 Thread Sam Liddicott
Surely it's OK for VAPI files whose purpose is to integrate with C anyway; and certainly preferable to having to ship an extra vapi .h file with inline function or macro definitions... I think its great. I prefer the name cexpression to snippet, I use such things in my compac class virtual met

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

2008-08-22 Thread Daniel Lucraft
--- Emmanuele Bassi <[EMAIL PROTECTED]> wrote: > no, please: let's not turn Vala into the new GOB. > this makes the code an > unbearable mess - been there, done that. wow, I'd not seen that project before. I like how one of the GOB examples includes a 'shoot_yourself_in_the_head' function. Says i