On 10/08/2015 08:09 AM, Daniel P. Berrange wrote: > When there are many instances of a given class, registering > properties against the instance is wasteful of resources. The > majority of objects have a statically defined list of possible > properties, so most of the properties are easily registerable > against the class. Only those properties which are conditionally > registered at runtime need be recorded against the klass. > > Registering properties against classes also makes it possible > to provide static introspection of QOM - currently introspection > is only possible after creating an instance of a class, which > severely limits its usefulness. > > This impl only supports simple scalar properties. It does not > attempt to allow child object / link object properties against > the class. There are ways to support those too, but it would > make this patch more complicated, so it is left as an exercise > for the future. > > There is no equivalent to object_property_del provided, since > classes must be immutable once they are defined. > > Signed-off-by: Daniel P. Berrange <berra...@redhat.com> > --- > include/qom/object.h | 47 +++++++++- > qom/object.c | 242 > ++++++++++++++++++++++++++++++++++++++++++++++++--- > 2 files changed, 275 insertions(+), 14 deletions(-) > > @@ -898,10 +903,11 @@ object_property_add(Object *obj, const char *name, > const char *type, > return ret; > } > > - if (g_hash_table_contains(obj->properties, name)) { > + > + if (object_property_find(obj, name, NULL) != NULL) { > error_setg(errp, "attempt to add duplicate property '%s'" > - " to object (type '%s')", name, > - object_get_typename(obj)); > + " to object (type '%s')", name, > + object_get_typename(obj));
Ah, the indentation hunk I noticed in 4/5. Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature