[Kde-bindings] Support specific instantiations of template classes in Smoke

Arno Rehn arno at arnorehn.de
Thu Jun 24 15:03:27 UTC 2010


On Thursday 24 June 2010 02:34:14 Chris Burel wrote:
> Richard and I were discussing this today, that it'd be great if Smoke
> could wrap instantiations of template classes.  It came up because
> QPolygon inherits from QVector<QPoint>, but because QVector<QPoint>'s
> methods are not available in Smoke, a significant portion of the
> QPolygon API is unavailable to language bindings.  I tried placing
> "QVector<QPoint>" (the XML-encoded version of QVector<QPoint>)
> in the classes section of smokeconfig.xml for qtcore smoke, but the
> resulting smokedata.cpp only had an entry in the inheritanceList for
> "QVector", and no entry in the classList.  It'd be really great to get
> that to work.
I don't know if this is really the right approach. At least in languages where 
it is possible I would implement QPolygon as a subclass of the language-
specific 'List' class. If you map QVector to the native List class in the 
bindings, then it would feel strange to suddenly have to deal with the 
original QVector API on QPolygon.

In C# I did this for the KUrl::List class. In c++, it inherits from 
QList<KUrl>, and in C# we inherit from System.Collections.Generic.List<KUrl>. 
The additional methods are then implemented in native C# or with native C 
calls and some manual marshalling.

It's definitely more work to implement, but results in a much nicer API, in my 
opionon.

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list