[Kde-bindings] Using generics in Qyoto

Arno Rehn arno at arnorehn.de
Thu Jan 11 13:05:32 UTC 2007


Am Donnerstag, 11. Januar 2007 12:50 schrieb Richard Dale:
> 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>();
> foo.Add(1);
> 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.

Good idea, but we would have to re-write some major parts of the 
list-marshallers. But that shouldn't be the problem.
Anyway, I first try to get my dbus things to work ;-)

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list