[Vala] How should an array be dynamically allocated?

2010-09-23 Thread Charles Hixson

This is what I attempted:
/**convert a string (of the form output by to_string) into the 
fields

*of the current instance*/
voidstr2bib(string str)
{inti=count(str, @"$gs");
stringsflds[]=newstring [i];
sflds=str.split(@"$gs");
}
/**returns the number of times delim occurs within str*/
intcount (string str, string delim)
{inti, res;
for(i = 0, res = 0;i <= str.length - delim.length;i++)
{if(str[i: i + delim.length] == delim)res++;}
returnres;
}

The Vala compiler likes it, but c doesn't (array size missing, 
incompatible types when assigning to type 'char*[1]' from type 'char**', 
etc.)



___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] [Genie] is this a bug ?

2010-09-23 Thread Jiří Zárevúcky
Nicolas píše v Čt 23. 09. 2010 v 12:03 +0200:
> Hi,
> 
> I'm developping a program and i made a mistake in my code, i think i 
> found a bug.
> If i call my gtk window class "test" and in this class i create a gtk 
> button named "test", vala does not report an error, only gcc.
> 

That is a really unusual case. The problem is that since C macros are
text based only, one of them is taking your variable as an argument
instead of the type. That can be worked around by using "struct _Klass"
instead of simply "Klass" in Vala generated macros.

It's not a big issue, but you can report it as a bug if you wish. It's
not Genie specific, so component should be "codegen". You can quote my
first paragraph there. However, keep in mind that due to some specifics
of the translation, you can still easily cause GCC to fail without Vala
noticing if you want to, and there is no easy way to fix that.



signature.asc
Description: Toto je digitálně  podepsaná část  zprávy
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] [Genie] is this a bug ?

2010-09-23 Thread Nicolas

Hi,

I'm developping a program and i made a mistake in my code, i think i 
found a bug.
If i call my gtk window class "test" and in this class i create a gtk 
button named "test", vala does not report an error, only gcc.


Test program:

[indent=4]

// Build with valac --pkg gtk+-2.0 yourfile.gs

uses
Gtk

class test : Window

init
title = "Test Window"
default_height = 250
default_width = 250
window_position = WindowPosition.CENTER
destroy.connect(Gtk.main_quit)
var test = new Button()
add(test)

init
Gtk.init (ref args)
var testing = new test()
testing.show_all()
Gtk.main()

Is this a bug ?
Nicolas.
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list