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



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




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