[Vala] Fwd: Replacing "void method ( out Type)" with "Type method()"






Begin forwarded message:

From: pancake <pancake youterm com>
Date: March 12, 2009 9:21:07 AM GMT+01:00
To: Adi Roiban <adi roiban ro>
Subject: Re: [Vala] Replacing "void method ( out Type)" with "Type method()"

An atribute to define a method as the one to get a string representation would be cool.

This is.. In java we have the toString() one, but we can just asign to tostring attribute for a method in a class or just at class level in the vapi file as:

[(CCode tostring="get_text")]

We can the also define default methods for other types like toint="get_size"

What do you think about this?

On Mar 11, 2009, at 10:20 PM, Adi Roiban <adi roiban ro> wrote:

Hi,

I have these 2 examples.

1 - Converting a GLib.Date to GLib.Time

Now we have:
GLib.Date date = GLib.Date();
GLib.Time time;
date.to_time(out time);
time.to_string()

I would like to be able to do: date.to_time.to_string();

2 - Getting a text from Gtk.TexBuffer
Now we have:

Gtk.TextBuffer buf = new Gtk.TextBuffer;
Gtk.Iter star;
Gtk.Iter end;
string text;

buf.get_start_iter(start);
buf.get_end_iter(end);
text = buf.get_text(start,end,true);

I would like to be able to do: text = buf.text;

Right now there is a Gtk.TextBuffe.text property but it's not working:
error: too few arguments to function ‘gtk_text_buffer_get_text'

----------

Now I could rename the Gtk.TextBuffer class in the gtk+ VAPI file and
implement my own Gtk.TextBuffer class inheriting the renamed class.

Is there a way to modify a VAPI file to fix this problem and give us
this syntactic sugaring ?

Maybe there is a way to write small functions inside a VAPI file for
helping VALA with the code generation.

Many thanks!
--
Adi Roiban

_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list


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