[Kde-bindings] Using generics in Qyoto

Richard Dale rdale at foton.es
Thu Jan 11 11:50:59 UTC 2007

I installed the gmcs mono C# compiler with generics support yesterday, and 
played with it a bit. 

There is no QDBusReply class in the Smoke library as it's template based. For 
QtRuby I wrote a replacement in ruby, and for Qyoto I think we can do the 
same in C# using templates:

class QDBusReply<E> {
    private E m_value;

    public QDBusReply(E foobar) {
        m_value = foobar;
        Console.WriteLine("Constructing an int QDBusReply {0}", foobar);

    public E value() {
        return m_value;


QDBusReply<int> bar = new QDBusReply<int>(13);
Console.WriteLine("QDBusReply.value {0}", bar.value());

So 'bar.value()' has a type of int here.

Where we have ArrayLists at the moment we could use the generic List type 
instead, which would look more like the original C++ api:

List<int> foo = new List<int>();
Console.WriteLine("foo[0]: {0}", foo[0]);

I think we just need to build Qyoto with gmcs instead of mcs, and don't need 
to change anything much so it looks as though it should be easy to switch.

-- Richard

More information about the Kde-bindings mailing list