On Mon, 21 Oct 2024 at 16:02, Zhao Liu <zhao1....@intel.com> wrote:
>
> On Mon, Oct 21, 2024 at 03:20:39PM +0100, Peter Maydell wrote:
> > What I mean by "the private/public markers are unnecessary" is
> > that they don't tell the reader anything, because all the fields
> > in a QOM device struct are private.
>
> This time I really understand the question of whether it's okay to
> directly access parent_obj/parent_class. :-)
>
> > If you're not in the implementation of that class, then you shouldn't
> > really be directly touching any of the fields in the state struct.
> > (In some places we take a shortcut and do it. But really it's almost
> > never necessary.)
>
> Thank you for your further explanation! I hadn’t noticed that. So, for
> other code (code outside the class/object implementation) to access the
> fields other than parent_obj/parent_class of class/state struct, the
> most ideal way would be to use the set/get property interfaces as
> much as possible instead of accessing them directly, right?

Yes, or whatever APIs (functions etc) are provided for working
with the class. If you have a specific example we could probably
make some more concrete suggestions.

-- PMM

Reply via email to