On 03/29/2018 10:48 AM, Marc-André Lureau wrote:
By moving the common fields to a QObjectCommon, QObject can be a type
which also has a 'base' QObjectCommon field. This allows to write a
generic QOBJECT() macro that will work with any QObject type,
including QObject itself. The container_of() macro ensures that the
object to cast has a QObjectCommon base field, give me some type
safety guarantees. However, for it to work properly, all QObject types
must have 'base' at offset 0 (which is ensured by static checking from
previous patch)

Commit message should mention the rationale you gave in v2 of NOT using a typedef for QObjectCommon (which was intentional so as to minimize the chance that the type gets abused). We could even go so far as to name it QObject_, with trailing underscore, rather than QObjectCommon, to make it obvious it is not for normal use.


Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com>
---


--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Reply via email to