Re: [Vala] Starting with Vala, problems with strings
Hi again. I am still having troubles with things that i should easily do in C. Maybe because i have never programmed in C#, or mono or anything like it. In my test code i want to split a math sentence in terms, like the next string example: "(2+a)*d+(a*b-3)-4-q/2" My function split_in_terms, is a very bad implementation (i know) that should split the string into 4 terms, and if not possible, return NULL. For that i have tryed with a List, but when using nth_data it prints this string: "g_list_nth_data", only once. So i think that Lists are not yet fully implemented so i switched to Array. Where now i cant compile it. ERROR:arraylist.c:322:gee_array_list_real_get: assertion failed: (_tmp0) And i dont have any clue where the problem is. Also i dont know when should i use pointers in Vala. I know from C that every object must be defined as a pointer, but the Vala bindings, doesnt defines them as pointer, so, why should i add an * If i dont add it, i cant change the value of the parameter. supouse a function like next: private static void split_in_terms(string strmath, string* term_left, string* term_right) This also gives a lot of warnings for term_left and right. Please note too the casting in: new Array(false, true, (uint)sizeof(string)); Seems like the new array requires an ulong instead of uint which is returned by sizeof. I dont know if this is the correct behavior or not, but it seems strange. private static Array* split_in_terms(string strmath) { int x = 0; int parentesis=0; Array list = new Array(false, true, (uint)sizeof(string)); string str = strmath; StringBuilder term = new StringBuilder(""); int p = 0; stdout.printf("str = %s\n", str); for(weak string s = str; s.get_char()!=0 ; s = s.next_char()) { unichar c = s.get_char(); if ( c == '(') { parentesis++; term.append_unichar(c); } else if ( c == ')') { parentesis--; term.append_unichar(c); } else if ( c == '+') { if ( parentesis == 0) { list.append_val( term.str ); print("%s\n",term.str); term = new StringBuilder(""); p = x+1; if ( str.len() >= p ) list.append_val( "+" ); } } else { term.append_unichar(c); } x++; } list.append_val( term.str ); if (parentesis != 0) { stdout.printf("SintaxERROR: Los parentesis no cierran adecuadamente: %s\n", str); return null; } return &list; } public void calculate () { double mean, max, min; string str = "holaaa+world"; print ("1"); Array* list = split_in_terms( str ); print ("2"); for (int i = 0; i < list->length; i++) stdout.printf ("term%d = %s\n", i, list->index(i)); /*for (int i = 0; i < list->length(); i++) stdout.printf ("term%d = %s\n", i, list->nth_data (i)*/);*/ print ("3"); . Cheers. Diego ___ Vala-list mailing list Vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] [ANNOUNCE] Vala 0.7.1 - Compiler for the GObject type system
2009/4/20 Michael 'Mickey' Lauer : > It was discussed on this very list few days ago. > > http://mail.gnome.org/archives/vala-list/2009-April/msg00097.html /me is guilty of not reading all threads Thanks! -mt ___ Vala-list mailing list Vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] [ANNOUNCE] Vala 0.7.1 - Compiler for the GObject type system
On Monday 20 April 2009 18:54:51 Michael Terry wrote: > 2009/4/20 Jürg Billeter : > > * Introduce new syntax to connect/disconnect signal handlers. > > Can you expound on that? I didn't see anything new in the wiki tutorial. It was discussed on this very list few days ago. http://mail.gnome.org/archives/vala-list/2009-April/msg00097.html :M: ___ Vala-list mailing list Vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] [ANNOUNCE] Vala 0.7.1 - Compiler for the GObject type system
2009/4/20 Jan Niklas Hasse : > How can I let valac 0.7 create a .vapi file (like it is described here: You're trying to create a library used by other Vala code? You probably want the --library argument. -mt ___ Vala-list mailing list Vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] [ANNOUNCE] Vala 0.7.1 - Compiler for the GObject type system
2009/4/20 Jürg Billeter : > * Introduce new syntax to connect/disconnect signal handlers. Can you expound on that? I didn't see anything new in the wiki tutorial. -mt ___ Vala-list mailing list Vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] [ANNOUNCE] Vala 0.7.1 - Compiler for the GObject type system
I've got a question, sorry if it has already been answered or the answer is obvious: How can I let valac 0.7 create a .vapi file (like it is described here: http://live.gnome.org/Vala/Tutorial#head-4b087370837491f65c097e895868d22677bde803 ) ? ___ Vala-list mailing list Vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
[Vala] [ANNOUNCE] Vala 0.7.1 - Compiler for the GObject type system
We are pleased to announce version 0.7.1 of Vala, a compiler for the GObject type system. Vala 0.7.1 is now available for download at: http://download.gnome.org/sources/vala/0.7/ Changes since 0.7.0 * Introduce new syntax to connect/disconnect signal handlers. * Add experimental support for fixed-length arrays. * Update Genie parser (Jamie McCracken). * Updates to the GLib, Cairo, GTK+, GStreamer, and POSIX bindings. * Many bug fixes. Vala is a new programming language that aims to bring modern programming language features to GNOME developers without imposing any additional runtime requirements and without using a different ABI compared to applications and libraries written in C. valac, the Vala compiler, is a self-hosting compiler that translates Vala source code into C source and header files. It uses the GObject type system to create classes and interfaces declared in the Vala source code. The syntax of Vala is similar to C#, modified to better fit the GObject type system. Vala supports modern language features as the following: * Interfaces * Properties * Signals * Foreach * Lambda expressions * Type inference for local variables * Generics * Non-null types * Assisted memory management * Exception handling Vala is designed to allow access to existing C libraries, especially GObject-based libraries, without the need for runtime bindings. All that is needed to use a library with Vala is an API file, containing the class and method declarations in Vala syntax. Vala currently comes with bindings for GLib and GTK+. It's planned to provide generated bindings for the full GNOME Platform at a later stage. Using classes and methods written in Vala from an application written in C is not difficult. The Vala library only has to install the generated header files and C applications may then access the GObject-based API of the Vala library as usual. It should also be easily possible to write a bindings generator for access to Vala libraries from applications written in e.g. C# as the Vala parser is written as a library, so that all compile-time information is available when generating a binding. More information about Vala is available at http://live.gnome.org/Vala The Vala Team Jürg Billeter and Raffaele Sandrini ___ Vala-list mailing list Vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Starting with Vala, problems with strings
On Sun, 2009-04-19 at 23:33 +0200, Frederik wrote: > Diego Jacobi wrote: > > Why isnt string = GString ? > > Also i am courius why is it called StringBuilder? It sound like "not a > > GString". > > In order to resemble C# and Java which both have [s|S]tring and > StringBuilder. > > string = char *(immutable) > StringBuilder = GString(mutable) > ...Although there are a few special functions on string that modify the string in-place. Also GString is not intended for text manipulation. It doesn't know more about utf8 other than append_unichar. > > Regards, > > Frederik > ___ > Vala-list mailing list > Vala-list@gnome.org > http://mail.gnome.org/mailman/listinfo/vala-list ___ Vala-list mailing list Vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list