This patch series provides infrastructure and documentation for marking QOM struct fields as private to the class implementation.
Patch 1 is the implementation (which is a trivial five lines!) and documentation of the code pattern that it's intended to be used with. Patch 2 is an example of its use in the ARM GIC classes. This patch depends on Andreas' "A9MPCore+A15MPCore QOM'ification" v2 patchset, really just because there aren't any examples in the tree at the moment of devices which I understand and which use the "include file with device struct which is included by both implementation and object users" pattern. A .h file which uses this pattern ends up with half a dozen extra lines of boilerplate, which is slightly sad but not too awful. It would be pretty easy to autogenerate (along with the type macros themselves) if we decided to do that in future, though. I'm not hugely attached to either the "__private" or IMPLEMENTING_FOO naming conventions, so feel free to bikeshed them. (I am aware that the former is treading on the implementation reserved namespace...) Incidentally, I think I would be in favour of (as a coding style issue) having exactly one class per .h file, which the gic doesn't currently do (it puts both TYPE_ARM_GIC_COMMON and TYPE_ARM_GIC in one file). Peter Maydell (2): Provide infrastructure for marking private QOM struct fields arm_gic: Use new __private macro to mark private fields hw/intc/arm_gic.c | 3 +++ hw/intc/arm_gic_common.c | 2 ++ hw/intc/arm_gic_kvm.c | 2 ++ hw/intc/armv7m_nvic.c | 2 ++ include/hw/intc/arm_gic.h | 64 ++++++++++++++++++++++++++++----------------- include/qemu/compiler.h | 10 +++++++ include/qom/object.h | 47 +++++++++++++++++++++++++++++++++ 7 files changed, 106 insertions(+), 24 deletions(-) -- 1.7.9.5