[Kde-bindings] Using generics in Qyoto
arno at arnorehn.de
Fri Jan 12 23:40:37 UTC 2007
Am Freitag, 12. Januar 2007 17:16 schrieb Richard Dale:
> On Friday 12 January 2007 15:43, Arno Rehn wrote:
> > Am Donnerstag, 11. Januar 2007 14:30 schrieb Richard Dale:
> > > On Thursday 11 January 2007 13:05, Arno Rehn wrote:
> > > > > 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
> > >
> > > Well I was assuming the marshallers wouldn't need a huge change, but
> > > maybe I'm wrong. But I won't checkin that uses generics until you've
> > > tracked down why your dbus doesn't work anyway.
> > OK, as my dbus is now working, let's come back to generics.
> > I see two possibilities for things like QLists and QPairs etc...
> > We could parse those classes with Kalyptus and work with them like with
> > any other class, when we request an element via QLists.At() it would
> > probably get marshalled the normal way - that would not require a huge
> > change in the marshalling functions - I think we could even just delete
> > the ValueList Marshallers.
> > The other possibility would be to create our own Lists<T>, but it would
> > be quite difficult to marshall from a C++-QList to a C#-List<T>.
> > I would prefer to just parse the Qt stuff with kalyptus and nothing more.
> > We can then add some functions for interopability with C#, e.g. to cast a
> > QList to an ArrayList and vice versa, so it is easier to use other
> > libraries for Mono.
> > Well, that's my opinion.
> > Do you already have some code?
> No, I haven't done anything other than to find out about the List<T> type
> in C#/mono. I was thinking we would:
> Change this C++
> QList<QWidget *> associatedWidgets() const;
> to this C#
> List<QWidget> associatedWidgets();
> I don't think we want a QList type in Qyoto. I'm assuming that the above
> would't be a huge change to the code that currently marshalls from a
> QList<QWidget *> to an ArrayList.
Well, I thought about that and the difficulty is, that we have to create a
List<T> at runtime from C++ where we don't know, what T is. The type of T is
given to us as a string and exactly that is the problem. We can't just create
a List<whatever> with 'new List<Type.GetType("whatever")'. The only
possibility is via Reflection, and that way is, ahm, well, not very nice, I
think. I've already tried it and it works, but as I said, not very nice to
I prefer the native List<T> of Mono, too, and would implement it via
Reflection, if there's no other way.
Here's what I tried: http://phpfi.com/193151
arno at arnorehn.de
More information about the Kde-bindings