From: Antony Pavlov <antonynpavlov@gmail.com>
To: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Andreas Färber" <afaerber@suse.de>,
"QEMU Developers" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] a QOM Coding Conventions question
Date: Sun, 15 Dec 2013 15:17:09 +0400 [thread overview]
Message-ID: <20131215151709.be54fbe34245cae757ba0279@gmail.com> (raw)
In-Reply-To: <CAEgOgz607jpoNJ1QTQTjaePw+-9+joa1LJE7Ta56GsT+--f0hQ@mail.gmail.com>
On Sun, 15 Dec 2013 09:06:30 +1000
Peter Crosthwaite <peter.crosthwaite@xilinx.com> wrote:
> On Sat, Dec 14, 2013 at 6:26 AM, Antony Pavlov <antonynpavlov@gmail.com> wrote:
> > Hi, Andreas!
> >
> > Here is a quote from http://wiki.qemu.org/QOMConventions
> >
> >> a FooClass structure definition containing at least the parent class field:
> >>
> >> typedef struct {
> >> /*< private >*/
> >> MyParentClass parent_class;
> >> /*< public >*/
> >>
> >> [any fields you need]
> >> } FooClass;
> >
> > What do the "< private >" and "< public >" comments exactly mean here?
>
> Private means inaccessible to everybody, including the implementation
> of class being instantiated. No one should ever dereference a private
> variable, they should be managed by QOM indirectly via casts if
> needed. Public means that at least someone can access it. Note that
> public does not declare a free-for-all. QOM class variables may be
> "public" in the sense that the class implementation may access them.
> Container devices however still can not, and they are private from
> that point of view.
>
> For example, a timer peripheral may have a "public" ptimer, in the
> sense that the timer class derefences and modifies the timer for its
> implmentation. An embedding SoC device however can NOT use this
> despite being public, its private to the timer implementation. So in
> short:
>
> < /* private */ > - owned by the QOM framwork - do no dereference ever
> from anywhere.
> < /* public */> - owned by the class implementation - do not
> dereference from containers.
>
> There is also automated documentation generation using this.
>
It's a exhaustive comment! Thanks!
Can we add a comment like this to http://wiki.qemu.org/QOMConventions?
IMHO this public/private QOM convention is a bit confusing. I can remember
about "public/private/protected" in C++/Java. Here is a quote
from http://en.wikipedia.org/?title=C%2B%2B
A public member of the class is accessible to any function.
A private member is accessible only to functions that are
members of that class and to functions and classes explicitly
granted access permission by the class ("friends").
So if you use FooClass' point of view (C++/Java habit) then
"private" and "protect" confuse you.
Can we use more detailed comments? E.g.
typedef struct {
/*< QOM service fields >*/
MyParentClass parent_class;
/*< class private fields >*/
[any fields you need]
} FooClass;
--
Best regards,
Antony Pavlov
next prev parent reply other threads:[~2013-12-15 11:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-13 20:26 [Qemu-devel] a QOM Coding Conventions question Antony Pavlov
2013-12-14 23:06 ` Peter Crosthwaite
2013-12-14 23:42 ` Peter Maydell
2013-12-14 23:51 ` Peter Crosthwaite
2013-12-15 9:02 ` Pantelis Koukousoulas
2013-12-16 12:48 ` Peter Crosthwaite
2013-12-16 13:26 ` Andreas Färber
2013-12-15 11:17 ` Antony Pavlov [this message]
2013-12-16 14:17 ` Andreas Färber
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=20131215151709.be54fbe34245cae757ba0279@gmail.com \
--to=antonynpavlov@gmail.com \
--cc=afaerber@suse.de \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--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).