[Kde-bindings] Adding an mf_attribute flag to MethodFlags in smoke.h

Arno Rehn arno at arnorehn.de
Wed Oct 21 16:16:37 UTC 2009


On Wednesday 21 October 2009 18:03:43 Tobias Rautenkranz wrote:
> > If we're at it we could also add sizeof() information for classes (for
> >  dynamic list marshallers)
> 
> If I understand correctly, you need the sizeof to make sure the class is
> stored on the heap by the container.
> 
> e.g. QList<T> stores the objects directly in the array when
> sizeof(T) <= sizeof(void*) and on the heap otherwise.
> 
> template <typename T>
> Q_INLINE_TEMPLATE void QList<T>::node_construct(Node *n, const T &t)
> {
>   if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic)
>     n->v = new T(t); // on the heap
>   else if (QTypeInfo<T>::isComplex)
>     new (n) T(t); // "placement new" -- in place
>   else
>    *reinterpret_cast<T*>(n) = t; // in place (no constructor)
> }
> 
> A "Placement new" constructor is not supported by smoke, but one could
>  still implement the marshaling for large types. (neglecting the third
>  case)
> 
> Thus one could also use a cf_large flag instead of the sizeof?
For the QList marshaller this would suffice, but for more complex stuff like 
QHash and QMap marshallers we need to know the exact size of a type.

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list