On Sun, Oct 20, 2024 at 12:10:14AM +0800, Zhao Liu wrote: > Hi maintainers and list, > > In the QOM structure, the class and object structs have two members: > parent_class and parent_obj, which are often marked as "< private >" in > the comment. > > I couldn’t find information on why to define ‘private’ and ‘public’, > even in the earliest QOM commits and the patch emails I could find. > > Does ‘private’ refer to the internal implementation code of QOM, or does > it refer to the specific code that defines and implements this object > and its class? > > I understand the original idea of private field indicates it cannot be > accessed directly out of the "private" scope.
I see two scenarios * Devices where the structs are in the include/..../<blah>.h The private/public comments are a message to other code in QEMU about which fields are OK to access directly, and which should not be accessed. * Devices where the structs are in the ../<blah>.c The private/public comments look entirely pointless, as everything is private to the .c file. 99% of the time it seems the "parent" / "parent_obj" fields are the only one marked private. There are a handful of classes where other fields are under the private comment, but not many. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|