[Vala] Creating constructors on binded classes
- From: "Alberto Ruiz" <aruiz gnome org>
- To: Vala paldo org
- Subject: [Vala] Creating constructors on binded classes
- Date: Sat, 15 Sep 2007 07:29:32 +0100
I have the following class from clutter:
[CCode (copy_function = "clutter_knot_copy", cheader_filename = "clutter/clutter.h")]
public class Knot : GLib.Boxed {
public int x;
public int y;
public weak Clutter.Knot copy ();
public bool equal (Clutter.Knot knot_b);
public static GLib.Type get_type ();
}
I don't really know why is it a class, since the structure
Obviously, in Vala, we want something more natural and comfortable than:
var knot = new Knot();
knot.x = 1;
knot.y = 2;
Since usually, you have collections of several knots, in C you see the use of this class as:
Knot[] knots = {{1, 2}, {3, 4}, {5, 6} ...}
I would like to, at least, provide a simple constructor:
var knots = new Knot[] { new Knot(1, 2), new Knot(3, 4), ...}
The problem here is that if I create a new function, I need to copy paste the whole class, hide it in metadata, paste it on
clutter-0.4-custom.vala and implement the new constructor. I don't quite like this idea, is it possible to just add the constructor in the custom file without getting the error that Knot is already defined?
Something like:
namespace Clutter
{
class Knot {
public Knot (int x, int y)
{
this.x = x;
this.y = y;
}
}
}
Thanks,
--
Un saludo,
Alberto Ruiz
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]