From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2OcF-0000Pv-6J for qemu-devel@nongnu.org; Thu, 25 Jul 2013 12:42:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2OcC-00022O-BM for qemu-devel@nongnu.org; Thu, 25 Jul 2013 12:42:11 -0400 Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:1d0::1]:58941 helo=mnementh.archaic.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2OcC-00021s-5K for qemu-devel@nongnu.org; Thu, 25 Jul 2013 12:42:08 -0400 From: Peter Maydell Date: Thu, 25 Jul 2013 17:42:01 +0100 Message-Id: <1374770523-6570-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [RFC 0/2] Allow QOM struct fields to be marked as private List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexander Graf , Anthony Liguori , =?UTF-8?q?Andreas=20F=C3=A4rber?= , patches@linaro.org 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