Am 07.08.2013 05:36, schrieb Alexey Kardashevskiy: > This what I would suggest: > > #define OBJECT_GET_PARENT_CLASS(obj, name) \ > object_class_get_parent(OBJECT_GET_CLASS(ObjectClass, (obj), (name))) > > @name here is just to make sure we are at the right level of the class > hierarchy. > > And use it like this: > > static void xics_kvm_cpu_setup(XICSState *icp, PowerPCCPU *cpu) > { > XICSStateClass *xsc = XICS_COMMON_CLASS( > OBJECT_GET_PARENT_CLASS(OBJECT(icp), TYPE_KVM_XICS)); > ... > > Here both source and destination classes are checked, everyone must be happy > :)
In addition to what Peter has explained, I recommend against using my macro inline, just like we don't use OBJECT_CHECK() inline. Doing so keeps the uses of TYPE_KVM_XICS together and lets us exchange the implementation more easily should the need arise. Btw COMMON_XICS_CLASS() would be a more specific name. (Yes, ARM GIC is a counter-example.) Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg