[Kde-bindings] Qyoto D-Bus

Richard Dale richard.j.dale at gmail.com
Sat Oct 28 22:20:05 UTC 2006


On Saturday 28 October 2006 15:47, Arno Rehn wrote:
> Am Donnerstag, 19. Oktober 2006 13:55 schrieb Richard Dale:
> > We need to be able to marshall the 'QList<QVariant>' that
> > QDbusMessage.Arguments() returns in order to get the QVariant that
> > contains the QStringList with the reply.
>
> Should we write an extra function like "marshall_QVariantList" or does this
> code
>
> #define DEF_VALUELIST_MARSHALLER(ListIdent,ItemList,Item) namespace { char
> ListIdent##STR[] = #Item; };  \
>         Marshall::HandlerFn marshall_##ListIdent =
> marshall_ValueListItem<Item,ItemList,ListIdent##STR>;
>
> DEF_VALUELIST_MARSHALLER( QVariantList, QList<QVariant>, QVariant )
>
> 'redirect' the calls to marshall_ValueListItem? I've never seen such a
> construction before, what does it do?
The code 'Marshall::HandlerFn marshall_##ListIdent' in the #define creates a
function called marshall_QVariantList that can be added to the entries in the
Qt_handlers[] array:

    { "QList<QVariant>", marshall_QVariantList },
    { "QList<QVariant>&", marshall_QVariantList },
    { "QVariantList&", marshall_QVariantList },

So if we can add generic callbacks to create a list in C# and add individual
items to it, it will work for all types and not just lists of QVariants, and
we just need to add extra DEF_VALUELIST_MARSHALLER() #defines.

If we are converting a C++ list to a C# one, this call will create a C#
instance corresponding to the C++ one:

obj = set_obj_info(className, o);

It takes a class name, and so it will work with all classes, not just
QVariants.

In the code for the marshaller, 'ItemSTR' is the name of the class contained
in the list being marshalled - ie "QVariant" for a QVariantList. 'Item' is
the type of the items in the list - ie 'Item*' means 'QVariant*'.

-- Richard



More information about the Kde-bindings mailing list