adding the possibility of adding constructors to vapi struct
Hello, I'm creating the sfml vapi and I see that it's not possible to create a builder of a structure in a vapi.
[CCode (cname = "sfVideoMode", destroy_function = "")]
[SimpleType]
public struct VideoMode{
public VideoMode(uint x, uint y){
width = x;
height = y;
}
uint width;
uint height;
...
}
vala code:
var window = new RenderWindow ({200, 200}, "SFML works!");
// instead of
var window = new RenderWindow (VideoMode(200, 200), "SFML works!");
it's possible to make a static function, but that would make:
var window = new RenderWindow (VideoMode.VideoMode(200, 200), "SFML works!");
I imagine that the addition must be difficult because the vapi don't know the private attributes, but shouldn't it at least be able to modify the public attributes? Edit: all attributes in a struct are public
SFML uses a lot of structures, at least twenty or so, which doesn't help readability. Then the addition could help other binding for libC which implements few functions.
Else If it's too difficult, it would be possible to make a vapi function call another vapi function, as I could make VideoMode() call VideoMode.VideoMode() like this:
[SimpleType]
public struct VideoMode{
[CCode (cname = "my_static_constructor_VIDEOMODE")]
public static VideoMode VideoMode(int x, int y){
return {x, y};
}
[CCode (cname = "my_static_constructor_VIDEOMODE")]
public VideoMode(int x, int y);
...
}
so that it generates the static function and can use it.