qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>,
	"Eric Blake" <eblake@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
	"Armbruster, Markus" <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/3] qobject: assume base of a qobject is at offset 0
Date: Wed, 21 Mar 2018 18:43:42 +0100	[thread overview]
Message-ID: <c9897af0-2079-018f-2c05-f95182d69a44@redhat.com> (raw)
In-Reply-To: <CAJ+F1CJAy9jDoF-Q8MpOFkjqy0LGJ9EWC3qvwbkpc=eD7_srwA@mail.gmail.com>

On 21/03/2018 18:23, Marc-André Lureau wrote:
>>
>> Here, QObjectCommon is never used outside of qobject.h; all existing code
>> continues to uwe QObject *.  But the conversion from QString* or QObject *
>> to QObjectCommon * is trivial (&obj->base), and the conversion from
>> QObjectCommon * to the public QObject * is trivial (container_of style
>> cast).  So the QOBJECT() macro becomes comparable to a C++
>> reinterpret_cast<>() that converts any descendent of QObjectCommon into
>> QObject, even if the original type was not QObject; and we never offer a
>> public API to convert anything into or out of QObjectCommon (it only exists
>> as a dummy type to make our other casts easier).
> What is the QOJECT() macro you proposed with that?

#define QOBJECT(x) \
   container_of(&(x)->base, QObject, base)

where the double dereference-and-container_of provides some type safety
(container_of fails if &(x)->base is not a QObjectCommon*).

Paolo

  parent reply	other threads:[~2018-03-21 17:43 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-21 13:40 [Qemu-devel] [PATCH 0/3] RFC: simplify qobject refcount Marc-André Lureau
2018-03-21 13:40 ` [Qemu-devel] [PATCH 1/3] compiler: extend QEMU_GENERIC to handle more arguments Marc-André Lureau
2018-03-21 13:40 ` [Qemu-devel] [PATCH 2/3] qobject: assume base of a qobject is at offset 0 Marc-André Lureau
2018-03-21 14:01   ` Paolo Bonzini
2018-03-21 14:08     ` Marc-André Lureau
2018-03-21 14:19       ` Eric Blake
2018-03-21 14:21         ` Marc-André Lureau
2018-03-21 14:49           ` Paolo Bonzini
2018-03-21 15:29             ` Eric Blake
2018-03-21 15:34               ` Paolo Bonzini
2018-03-21 15:55     ` Marc-André Lureau
2018-03-21 16:00       ` Paolo Bonzini
2018-03-21 16:11         ` Marc-André Lureau
2018-03-21 16:23           ` Paolo Bonzini
2018-03-21 16:59             ` Marc-André Lureau
2018-03-21 17:08               ` Eric Blake
2018-03-21 17:23                 ` Marc-André Lureau
2018-03-21 17:38                   ` Eric Blake
2018-03-21 17:43                   ` Paolo Bonzini [this message]
2018-03-21 14:01   ` Eric Blake
2018-03-21 14:02     ` Paolo Bonzini
2018-03-21 13:40 ` [Qemu-devel] [PATCH 3/3] qobject: replace qobject_incref/QINCREF qobject_decref/QDECREF Marc-André Lureau
2018-03-21 14:28   ` Eric Blake
2018-03-21 14:51     ` Marc-André Lureau
2018-03-21 15:36       ` Eric Blake
2018-03-21 14:09 ` [Qemu-devel] [PATCH 0/3] RFC: simplify qobject refcount Eric Blake
2018-03-21 14:19   ` Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c9897af0-2079-018f-2c05-f95182d69a44@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).