[Vala] add methods to a compact class from outside the main definition in a VAPI file



Hi all:

I'm working on the XCB VAPI files, and I have a problem. XCB is subdivided in several parts: the core X protocol, utility functions and extensions.

The core protocol creates a compact class, Connection, which represents a xcb_connection_t structure, and all the functions for the XCB core protocol are inside as methods of the Connection compact class.

Now I'm starting to implement several extensions and utility functions, like ICCCM and Composite. The problem is that they are a collection of functions that receives a xcb_connection_t structure as first parameter, just like the core protocol ones. That means that they are like methods of the Connection class. The problem is that they belongs to a different library, which can be compiled or not in a project, so I think that I should not add these extension methods inside the Connection class.

So the question is: is possible to create a VAPI file that depends of another, and which adds methods to a class defined in that VAPI file?

If it is not possible, is there a way of doing an "alias" of a compact class? This is: for the ICCCM methods, define an Icccm compact class with a constructor that receives a Connection object, and what it does is to create an alias of that Connection object under the type Icccm, so all the ICCCM methods whould be inside that compact class.

(I tried to do that with:

    [Compact]
[CCode (cname = "xcb_connection_t", cprefix = "xcb_icccm_", ref_function = "", unref_function = "")]
    public class Icccm {
        [CCode (cname = "xcb_connect")]
        public Icccm (Connection conn) {
            this = conn;
        }
    }

but returned an error)

Thanks.

--
Nos leemos
                         RASTER    (Linux user #228804)
raster rastersoft com              http://www.rastersoft.com



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