qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] a QOM Coding Conventions question


From: Peter Crosthwaite
Subject: Re: [Qemu-devel] a QOM Coding Conventions question
Date: Sun, 15 Dec 2013 09:06:30 +1000

On Sat, Dec 14, 2013 at 6:26 AM, Antony Pavlov <address@hidden> 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.

Regards,
Peter

>
> --
> Best regards,
>   Antony Pavlov
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]