QOM class properties - do we need them?
cover QOM class properties - do we need them?
QOM has the concept of both "object class" properties and "object instance" properties.
The accessor functions installed for the rarely-used class properties still take an Object *, so the *value* of such properties is still per-instance; it's just the *existence* (and type) of the property that is per-class.
Of course, that's also true in practice for the great majority of "instance" properties, because they're created identically and unconditionally for every instance from the per-class instance_init hook.
This also means that the (unused) object_class_property_add_*_ptr() functions don't make a lot of sense, since they require a fixed pointer which means the value of such a property would only be per-class.
Given that, is there really any value to supporting the "class" properties in addition to the "instance" properties? This series is an RFC which removes all support for class properties, changing the few existing users to instance properties instead.
Alternatively, if we *don't* want to remove class properties, should we instead be trying to convert the many, many "instance" properties whose existence is actually per-class to be class properties?
David Gibson (4):
qcrypto: Remove usage of class properties
s390: Don't use class properties
tests: Remove tests for class properties
qom: Abolish class properties
crypto/secret.c | 58 +++++++------- crypto/tlscreds.c | 44 +++++----- crypto/tlscredsanon.c | 16 ++-- crypto/tlscredsx509.c | 26 +++--- include/qom/object.h | 42 ---------- qom/object.c | 195 --------------------------------------------- target-s390x/cpu.c | 1 - target-s390x/cpu_models.c | 47 +++++------ tests/check-qom-proplist.c | 30 +++---- 9 files changed, 106 insertions(+), 353 deletions(-)
Signature · 1 line
2.7.4
RFC 1/4 qcrypto: Remove usage of class properties
qcrypto is one of the few users of QOM class properties, as opposed to instance properties. In anticipation of removing class properties, convert qcrypto to use instance properties instead.
--- crypto/secret.c | 58 +++++++++++++++++++++++++++------------------------ crypto/tlscreds.c | 44 +++++++++++++++++--------------------- crypto/tlscredsanon.c | 16 +++++++++----- crypto/tlscredsx509.c | 26 +++++++++++------------ 4 files changed, 74 insertions(+), 70 deletions(-)
crypto/secret.c +31 -27
@@ -352,6 +352,36 @@ qcrypto_secret_complete(UserCreatable *uc, Error **errp)object_property_set_bool (OBJECT (uc), true,"loaded" , errp); } +static void +qcrypto_secret_instance_init (Object *obj) +{ +object_property_add_bool (obj,"loaded" , + qcrypto_secret_prop_get_loaded, + qcrypto_secret_prop_set_loaded, +NULL ); +object_property_add_enum (obj,"format" , +"QCryptoSecretFormat" , + QCryptoSecretFormat_lookup, + qcrypto_secret_prop_get_format, + qcrypto_secret_prop_set_format, +NULL ); +object_property_add_str (obj,"data" , + qcrypto_secret_prop_get_data, + qcrypto_secret_prop_set_data, +NULL ); +object_property_add_str (obj,"file" , + qcrypto_secret_prop_get_file, + qcrypto_secret_prop_set_file, +NULL ); +object_property_add_str (obj,"keyid" , + qcrypto_secret_prop_get_keyid, + qcrypto_secret_prop_set_keyid, +NULL ); +object_property_add_str (obj,"iv" , + qcrypto_secret_prop_get_iv, + qcrypto_secret_prop_set_iv, +NULL ); +}static void qcrypto_secret_finalize (Object *obj)
@@ -371,33 +401,6 @@ qcrypto_secret_class_init(ObjectClass *oc, void *data)UserCreatableClass *ucc =USER_CREATABLE_CLASS (oc); ucc->complete = qcrypto_secret_complete; - -object_class_property_add_bool (oc,"loaded" , - qcrypto_secret_prop_get_loaded, - qcrypto_secret_prop_set_loaded, -NULL ); -object_class_property_add_enum (oc,"format" , -"QCryptoSecretFormat" , - QCryptoSecretFormat_lookup, - qcrypto_secret_prop_get_format, - qcrypto_secret_prop_set_format, -NULL ); -object_class_property_add_str (oc,"data" , - qcrypto_secret_prop_get_data, - qcrypto_secret_prop_set_data, -NULL ); -object_class_property_add_str (oc,"file" , - qcrypto_secret_prop_get_file, - qcrypto_secret_prop_set_file, -NULL ); -object_class_property_add_str (oc,"keyid" , - qcrypto_secret_prop_get_keyid, - qcrypto_secret_prop_set_keyid, -NULL ); -object_class_property_add_str (oc,"iv" , - qcrypto_secret_prop_get_iv, - qcrypto_secret_prop_set_iv, -NULL ); }
@@ -489,6 +492,7 @@ static const TypeInfo qcrypto_secret_info = { .parent = TYPE_OBJECT, .name = TYPE_QCRYPTO_SECRET, .instance_size = sizeof(QCryptoSecret), + .instance_init = qcrypto_secret_instance_init, .instance_finalize = qcrypto_secret_finalize, .class_size = sizeof(QCryptoSecretClass), .class_init = qcrypto_secret_class_init,
crypto/tlscreds.c +19 -25
61 lines not on this page · raw message
crypto/tlscredsanon.c +11 -5
@@ -173,6 +173,16 @@ qcrypto_tls_creds_anon_complete(UserCreatable *uc, Error **errp)static void +qcrypto_tls_creds_anon_instance_init (Object *obj) +{ +object_property_add_bool (obj,"loaded" , + qcrypto_tls_creds_anon_prop_get_loaded, + qcrypto_tls_creds_anon_prop_set_loaded, +NULL ); +} + + +static void qcrypto_tls_creds_anon_finalize (Object *obj) {QCryptoTLSCredsAnon *creds =QCRYPTO_TLS_CREDS_ANON (obj);
@@ -187,11 +197,6 @@ qcrypto_tls_creds_anon_class_init(ObjectClass *oc, void *data)UserCreatableClass *ucc =USER_CREATABLE_CLASS (oc); ucc->complete = qcrypto_tls_creds_anon_complete; - -object_class_property_add_bool (oc,"loaded" , - qcrypto_tls_creds_anon_prop_get_loaded, - qcrypto_tls_creds_anon_prop_set_loaded, -NULL ); }
@@ -199,6 +204,7 @@ static const TypeInfo qcrypto_tls_creds_anon_info = { .parent = TYPE_QCRYPTO_TLS_CREDS, .name = TYPE_QCRYPTO_TLS_CREDS_ANON, .instance_size = sizeof(QCryptoTLSCredsAnon), + .instance_init = qcrypto_tls_creds_anon_instance_init, .instance_finalize = qcrypto_tls_creds_anon_finalize, .class_size = sizeof(QCryptoTLSCredsAnonClass), .class_init = qcrypto_tls_creds_anon_class_init,
crypto/tlscredsx509.c +13 -13
@@ -810,6 +810,19 @@ qcrypto_tls_creds_x509_init(Object *obj)QCryptoTLSCredsX509 *creds =QCRYPTO_TLS_CREDS_X509 (obj); creds->sanityCheck = true; + +object_property_add_bool (obj,"loaded" , + qcrypto_tls_creds_x509_prop_get_loaded, + qcrypto_tls_creds_x509_prop_set_loaded, +NULL ); +object_property_add_bool (obj,"sanity-check" , + qcrypto_tls_creds_x509_prop_get_sanity, + qcrypto_tls_creds_x509_prop_set_sanity, +NULL ); +object_property_add_str (obj,"passwordid" , + qcrypto_tls_creds_x509_prop_get_passwordid, + qcrypto_tls_creds_x509_prop_set_passwordid, +NULL ); }
@@ -829,19 +842,6 @@ qcrypto_tls_creds_x509_class_init(ObjectClass *oc, void *data)UserCreatableClass *ucc =USER_CREATABLE_CLASS (oc); ucc->complete = qcrypto_tls_creds_x509_complete; - -object_class_property_add_bool (oc,"loaded" , - qcrypto_tls_creds_x509_prop_get_loaded, - qcrypto_tls_creds_x509_prop_set_loaded, -NULL ); -object_class_property_add_bool (oc,"sanity-check" , - qcrypto_tls_creds_x509_prop_get_sanity, - qcrypto_tls_creds_x509_prop_set_sanity, -NULL ); -object_class_property_add_str (oc,"passwordid" , - qcrypto_tls_creds_x509_prop_get_passwordid, - qcrypto_tls_creds_x509_prop_set_passwordid, -NULL ); }
Signature · 1 line
2.7.4
RFC 2/4 s390: Don't use class properties
In reply to David Gibsons390 is one of the very few users of QOM class properties (as opposed to instance properties). In anticipation of removing support for class properties, convert s390 to use instance properties instead.
--- target-s390x/cpu.c | 1 - target-s390x/cpu_models.c | 47 ++++++++++++++++++++++------------------------- 2 files changed, 22 insertions(+), 26 deletions(-)
target-s390x/cpu.c +0 -1
@@ -446,7 +446,6 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)* object_unref(). */ dc->cannot_destroy_with_object_finalize_yet = true; -s390_cpu_model_class_register_props (oc); }static const TypeInfo s390_cpu_type_info = {
target-s390x/cpu_models.c +22 -25
64 lines not on this page · raw message
Signature · 1 line
2.7.4
RFC 3/4 tests: Remove tests for class properties
In reply to David GibsonThere are no-longer any users of QOM class properties (as opposed to instance properties). In anticipation of removing support for them, remove tests for them from the testsuite.
--- tests/check-qom-proplist.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-)
tests/check-qom-proplist.c +10 -20
@@ -124,25 +124,16 @@ static void dummy_init(Object *obj) dummy_get_bv, dummy_set_bv, NULL); -} - - -static void dummy_class_init (ObjectClass *cls,void *data) -{ -object_class_property_add_bool (cls,"bv" , - dummy_get_bv, - dummy_set_bv, -NULL ); -object_class_property_add_str (cls,"sv" , - dummy_get_sv, - dummy_set_sv, -NULL ); -object_class_property_add_enum (cls,"av" , -"DummyAnimal" , - dummy_animal_map, - dummy_get_av, - dummy_set_av, -NULL ); +object_property_add_str (obj,"sv" , + dummy_get_sv, + dummy_set_sv, +NULL ); +object_property_add_enum (obj,"av" , +"DummyAnimal" , + dummy_animal_map, + dummy_get_av, + dummy_set_av, +NULL ); }
@@ -161,7 +152,6 @@ static const TypeInfo dummy_info = { .instance_init = dummy_init, .instance_finalize = dummy_finalize, .class_size = sizeof(DummyObjectClass), - .class_init = dummy_class_init, };
Signature · 1 line
2.7.4
RFC 4/4 qom: Abolish class properties
In reply to David GibsonQOM allows both object class properties as well as object instance properties. object class properties were never much used, and provide no real benefit. Note that it's only the *existence* of such properties that's established on a per-class basis - the way the accessors work, the property's *value* is still per-instance.
Generally it's just as easy to create an instance property for every instance from the (per-class) instance_init hook as it is to create a class property.
Therefore, remove all support for object class properties, simplifying the QOM model a bit.
--- include/qom/object.h | 42 ----------- qom/object.c | 195 --------------------------------------------------- 2 files changed, 237 deletions(-)
include/qom/object.h +0 -42
@@ -941,13 +941,6 @@ ObjectProperty *object_property_add(Object *obj, const char *name,void object_property_del (Object *obj,const char *name,Error **errp); -ObjectProperty *object_class_property_add (ObjectClass *klass,const char *name, -const char *type, -ObjectPropertyAccessor *get, -ObjectPropertyAccessor *set, -ObjectPropertyRelease *release, -void *opaque,Error **errp); -/** * object_property_find: * @obj: the object
@@ -958,8 +951,6 @@ ObjectProperty *object_class_property_add(ObjectClass *klass, const char *name,*/ ObjectProperty *object_property_find (Object *obj,const char *name,Error **errp); -ObjectProperty *object_class_property_find (ObjectClass *klass,const char *name, -Error **errp); typedef struct ObjectPropertyIterator { ObjectClass *nextclass;
@@ -1375,12 +1366,6 @@ void object_property_add_str(Object *obj, const char *name,void (*set)(Object *,const char *,Error **), Error **errp); -void object_class_property_add_str (ObjectClass *klass,const char *name, -char *(*get)(Object *,Error **), -void (*set)(Object *,const char *, -Error **), -Error **errp); -/** * object_property_add_bool: * @obj: the object to add a property to
@@ -1397,11 +1382,6 @@ void object_property_add_bool(Object *obj, const char *name,void (*set)(Object *,bool ,Error **), Error **errp); -void object_class_property_add_bool (ObjectClass *klass,const char *name, -bool (*get)(Object *,Error **), -void (*set)(Object *,bool ,Error **), -Error **errp); -/** * object_property_add_enum: * @obj: the object to add a property to
@@ -1421,13 +1401,6 @@ void object_property_add_enum(Object *obj, const char *name,void (*set)(Object *,int ,Error **), Error **errp); -void object_class_property_add_enum (ObjectClass *klass,const char *name, -const char *typename, -const char *const *strings, -int (*get)(Object *,Error **), -void (*set)(Object *,int ,Error **), -Error **errp); -/** * object_property_add_tm: * @obj: the object to add a property to
@@ -1442,10 +1415,6 @@ void object_property_add_tm(Object *obj, const char *name,void (*get)(Object *,struct tm *,Error **), Error **errp); -void object_class_property_add_tm (ObjectClass *klass,const char *name, -void (*get)(Object *,struct tm *,Error **), -Error **errp); -/** * object_property_add_uint8_ptr: * @obj: the object to add a property to
@@ -1458,8 +1427,6 @@ void object_class_property_add_tm(ObjectClass *klass, const char *name,*/ void object_property_add_uint8_ptr (Object *obj,const char *name,const uint8_t *v,Error **errp); -void object_class_property_add_uint8_ptr (ObjectClass *klass,const char *name, -const uint8_t *v,Error **errp);/** * object_property_add_uint16_ptr:
@@ -1473,8 +1440,6 @@ void object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name,*/ void object_property_add_uint16_ptr (Object *obj,const char *name,const uint16_t *v,Error **errp); -void object_class_property_add_uint16_ptr (ObjectClass *klass,const char *name, -const uint16_t *v,Error **errp);/** * object_property_add_uint32_ptr:
@@ -1488,8 +1453,6 @@ void object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name,*/ void object_property_add_uint32_ptr (Object *obj,const char *name,const uint32_t *v,Error **errp); -void object_class_property_add_uint32_ptr (ObjectClass *klass,const char *name, -const uint32_t *v,Error **errp);/** * object_property_add_uint64_ptr:
@@ -1503,8 +1466,6 @@ void object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,*/ void object_property_add_uint64_ptr (Object *obj,const char *name,const uint64_t *v,Error **Errp); -void object_class_property_add_uint64_ptr (ObjectClass *klass,const char *name, -const uint64_t *v,Error **Errp);/** * object_property_add_alias:
@@ -1556,9 +1517,6 @@ void object_property_add_const_link(Object *obj, const char *name,*/ void object_property_set_description (Object *obj,const char *name,const char *description,Error **errp); -void object_class_property_set_description (ObjectClass *klass,const char *name, -const char *description, -Error **errp);/** * object_child_foreach:
qom/object.c +0 -195
265 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 3 lines · David Gibson
Alternatively, if we *don't* want to remove class properties, should we instead be trying to convert the many, many "instance" properties whose existence is actually per-class to be class properties?
Yes, this was the point of introducing them. :)
Paolo
Quoted 17 lines
David Gibson (4):
qcrypto: Remove usage of class properties
s390: Don't use class properties
tests: Remove tests for class properties
qom: Abolish class propertiescrypto/secret.c | 58 +++++++------- crypto/tlscreds.c | 44 +++++----- crypto/tlscredsanon.c | 16 ++-- crypto/tlscredsx509.c | 26 +++--- include/qom/object.h | 42 ---------- qom/object.c | 195 --------------------------------------------- target-s390x/cpu.c | 1 - target-s390x/cpu_models.c | 47 +++++------ tests/check-qom-proplist.c | 30 +++---- 9 files changed, 106 insertions(+), 353 deletions(-)
Quoted 7 lines · David Gibson
QOM has the concept of both "object class" properties and "object instance" properties.
The accessor functions installed for the rarely-used class properties still take an Object *, so the *value* of such properties is still per-instance; it's just the *existence* (and type) of the property that is per-class.
Yes, of course. This is the whole point of class properties. It avoids allocating the same ObjectProperty struct against every object instance which wastes massive amounts of memory in scenarios where there are lots of instances created.
Quoted 10 lines
Of course, that's also true in practice for the great majority of "instance" properties, because they're created identically and unconditionally for every instance from the per-class
instance_inithook.This also means that the (unused) object_class_property_add_*_ptr() functions don't make a lot of sense, since they require a fixed pointer which means the value of such a property would only be per-class.
Quoted 8 lines
Given that, is there really any value to supporting the "class" properties in addition to the "instance" properties? This series is an RFC which removes all support for class properties, changing the few existing users to instance properties instead.
Alternatively, if we *don't* want to remove class properties, should we instead be trying to convert the many, many "instance" properties whose existence is actually per-class to be class properties?
Practically all instances properties should become class properties as its going to save wasting memory once most are converted.
Regards,
Daniel
Signature · 3 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|
Am 29.09.2016 um 10:14 schrieb Daniel P. Berrange:
Quoted 9 lines · David Gibson
Quoted 7 lines
QOM has the concept of both "object class" properties and "object instance" properties.
The accessor functions installed for the rarely-used class properties still take an Object *, so the *value* of such properties is still per-instance; it's just the *existence* (and type) of the property that is per-class.
Quoted 4 lines
Yes, of course. This is the whole point of class properties. It avoids allocating the same ObjectProperty struct against every object instance which wastes massive amounts of memory in scenarios where there are lots of instances created.
+1
Quoted 15 lines
Quoted 15 lines
Of course, that's also true in practice for the great majority of "instance" properties, because they're created identically and unconditionally for every instance from the per-class
instance_inithook.This also means that the (unused) object_class_property_add_*_ptr() functions don't make a lot of sense, since they require a fixed pointer which means the value of such a property would only be per-class.
Given that, is there really any value to supporting the "class" properties in addition to the "instance" properties? This series is an RFC which removes all support for class properties, changing the few existing users to instance properties instead.
Quoted 6 lines
Quoted 3 lines
Alternatively, if we *don't* want to remove class properties, should we instead be trying to convert the many, many "instance" properties whose existence is actually per-class to be class properties?
Practically all instances properties should become class properties as its going to save wasting memory once most are converted.
Not all, but most. child<> properties were the reason to have properties on the instance.
Regards,
Andreas
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg)
Quoted 36 lines · Andreas Färber
Am 29.09.2016 um 10:14 schrieb Daniel P. Berrange:
Quoted 9 lines · David Gibson
Quoted 7 lines
QOM has the concept of both "object class" properties and "object instance" properties.
The accessor functions installed for the rarely-used class properties still take an Object *, so the *value* of such properties is still per-instance; it's just the *existence* (and type) of the property that is per-class.
Quoted 4 lines
Yes, of course. This is the whole point of class properties. It avoids allocating the same ObjectProperty struct against every object instance which wastes massive amounts of memory in scenarios where there are lots of instances created.
+1
Quoted 19 lines
Quoted 18 lines
Of course, that's also true in practice for the great majority of "instance" properties, because they're created identically and unconditionally for every instance from the per-class
instance_inithook.This also means that the (unused) object_class_property_add_*_ptr() functions don't make a lot of sense, since they require a fixed pointer which means the value of such a property would only be per-class.
Given that, is there really any value to supporting the "class" properties in addition to the "instance" properties? This series is an RFC which removes all support for class properties, changing the few existing users to instance properties instead.
Alternatively, if we *don't* want to remove class properties, should we instead be trying to convert the many, many "instance" properties whose existence is actually per-class to be class properties?
Quoted 5 lines
Quoted 2 lines
Practically all instances properties should become class properties as its going to save wasting memory once most are converted.
Not all, but most. child<> properties were the reason to have properties on the instance.
That's why I said "Practically all", instead of just "all" :-)
Regards,
Daniel
Signature · 3 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|
Am 29.09.2016 um 12:21 schrieb Daniel P. Berrange:
Quoted 9 lines · Andreas Färber
Quoted 6 lines
Am 29.09.2016 um 10:14 schrieb Daniel P. Berrange:
Quoted 2 lines
Practically all instances properties should become class properties as its going to save wasting memory once most are converted.
Not all, but most. child<> properties were the reason to have properties on the instance.
That's why I said "Practically all", instead of just "all" :-)
To me as non-native speaker "practically" is the opposite of "theoretically". :)
Cheers,
Andreas
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg)
Quoted 6 lines · Andreas Färber
Am 29.09.2016 um 12:21 schrieb Daniel P. Berrange:
Quoted 5 lines · Andreas Färber
Quoted 4 lines
Am 29.09.2016 um 10:14 schrieb Daniel P. Berrange:
Quoted 2 lines
Practically all instances properties should become class properties as its going to save wasting memory once most are converted.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Not all, but most. child<> properties were the reason to have properties on the instance.
That's why I said "Practically all", instead of just "all" :-)
To me as non-native speaker "practically" is the opposite of "theoretically". :)
Heh, more English corner cases. "Theoretically" and "in theory" mean the same thing, but "practically" and "in practice" don't. Or.. they do in theory, but not in practice :p. For bonus confusion, saying "practically speaking" would, in this context, mean what you expected, but "practically" on its own doesn't - it means basically the same as "almost" or "nearly".
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Am 29.09.2016 um 12:23 hat Andreas Färber geschrieben:
Quoted 6 lines
Am 29.09.2016 um 12:21 schrieb Daniel P. Berrange:
Quoted 5 lines · Andreas Färber
Quoted 4 lines
Am 29.09.2016 um 10:14 schrieb Daniel P. Berrange:
Quoted 2 lines
Practically all instances properties should become class properties as its going to save wasting memory once most are converted.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Not all, but most. child<> properties were the reason to have properties on the instance.
That's why I said "Practically all", instead of just "all" :-)
To me as non-native speaker "practically" is the opposite of "theoretically". :)
To me it made perfect sense that "pratically all" means "praktisch alle". ;-)
Kevin
Quoted 9 lines · Daniel P. Berrange
Quoted 7 lines · David Gibson
QOM has the concept of both "object class" properties and "object instance" properties.
The accessor functions installed for the rarely-used class properties still take an Object *, so the *value* of such properties is still per-instance; it's just the *existence* (and type) of the property that is per-class.
Quoted 4 lines
Yes, of course. This is the whole point of class properties. It avoids allocating the same ObjectProperty struct against every object instance which wastes massive amounts of memory in scenarios where there are lots of instances created.
Ah, that makes sense.
Quoted 15 lines
Quoted 15 lines
Of course, that's also true in practice for the great majority of "instance" properties, because they're created identically and unconditionally for every instance from the per-class
instance_inithook.This also means that the (unused) object_class_property_add_*_ptr() functions don't make a lot of sense, since they require a fixed pointer which means the value of such a property would only be per-class.
Given that, is there really any value to supporting the "class" properties in addition to the "instance" properties? This series is an RFC which removes all support for class properties, changing the few existing users to instance properties instead.
Quoted 6 lines
Quoted 3 lines
Alternatively, if we *don't* want to remove class properties, should we instead be trying to convert the many, many "instance" properties whose existence is actually per-class to be class properties?
Practically all instances properties should become class properties as its going to save wasting memory once most are converted.
Heh, ok. Well, I'll keep that in mind when I'm adding properties in future. I wonder if there's a way we can better get the word out that this is how properties should usually be done.
That said.. I'm still thinking we should remove object_class_property_add_*_ptr(). Those take an actual pointer to the value, meaning that it can't have different values per-instance. These only create read-only properties, so they're not actually dangerous, but they really don't seem very useful.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 43 lines · David Gibson
Quoted 9 lines · Daniel P. Berrange
Quoted 7 lines · David Gibson
QOM has the concept of both "object class" properties and "object instance" properties.
The accessor functions installed for the rarely-used class properties still take an Object *, so the *value* of such properties is still per-instance; it's just the *existence* (and type) of the property that is per-class.
Quoted 4 lines
Yes, of course. This is the whole point of class properties. It avoids allocating the same ObjectProperty struct against every object instance which wastes massive amounts of memory in scenarios where there are lots of instances created.
Ah, that makes sense.
Quoted 15 lines
Quoted 15 lines
Of course, that's also true in practice for the great majority of "instance" properties, because they're created identically and unconditionally for every instance from the per-class
instance_inithook.This also means that the (unused) object_class_property_add_*_ptr() functions don't make a lot of sense, since they require a fixed pointer which means the value of such a property would only be per-class.
Given that, is there really any value to supporting the "class" properties in addition to the "instance" properties? This series is an RFC which removes all support for class properties, changing the few existing users to instance properties instead.
Quoted 6 lines
Quoted 3 lines
Alternatively, if we *don't* want to remove class properties, should we instead be trying to convert the many, many "instance" properties whose existence is actually per-class to be class properties?
Practically all instances properties should become class properties as its going to save wasting memory once most are converted.
Heh, ok. Well, I'll keep that in mind when I'm adding properties in future. I wonder if there's a way we can better get the word out that this is how properties should usually be done.
Quoted 5 lines
That said.. I'm still thinking we should remove object_class_property_add_*_ptr(). Those take an actual pointer to the value, meaning that it can't have different values per-instance. These only create read-only properties, so they're not actually dangerous, but they really don't seem very useful.
Yeah, that method seems dubious - my mistake in just copying all the existing property methods.
Regards,
Daniel
Signature · 3 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|
Am 29.09.2016 um 02:16 schrieb David Gibson:
Quoted 2 lines
is there really any value to supporting the "class" properties in addition to the "instance" properties?
Yes, it makes enumerating available properties easier by not requiring to instantiate a new instance for printing, e.g., ",help" information.
Regards,
Andreas
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg)
Quoted 7 lines · Andreas Färber
Am 29.09.2016 um 02:16 schrieb David Gibson:
Quoted 2 lines
is there really any value to supporting the "class" properties in addition to the "instance" properties?
Yes, it makes enumerating available properties easier by not requiring to instantiate a new instance for printing, e.g., ",help" information.
A good point. I shall try to be on the lookup for opportunities to change existing properties to class properties.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson