[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] 答复: Re: [PATCH v4 4/5] backends: add description for enum
From: |
Lin Ma |
Subject: |
[Qemu-devel] 答复: Re: [PATCH v4 4/5] backends: add description for enum class properties |
Date: |
Mon, 07 Nov 2016 08:54:54 -0700 |
>>> Markus Armbruster <address@hidden> 2016/11/4 星期五 上午 3:58 >>>
>Lin Ma <address@hidden> writes:
>
>> Signed-off-by: Lin Ma <address@hidden>
>> ---
>> backends/hostmem.c | 4 ++++
>> crypto/secret.c | 4 ++++
>> crypto/tlscreds.c | 4 ++++
>> net/filter.c | 4 ++++
>> 4 files changed, 16 insertions(+)
>>
>> diff --git a/backends/hostmem.c b/backends/hostmem.c
>> index 4256d24..25f303d 100644
>> --- a/backends/hostmem.c
>> +++ b/backends/hostmem.c
>> @@ -377,6 +377,10 @@ host_memory_backend_class_init(ObjectClass *oc, void
>> *data)
>> HostMemPolicy_lookup,
>> host_memory_backend_get_policy,
>> host_memory_backend_set_policy, &error_abort);
>> + object_class_property_set_description(oc, "policy",
>> + "Data
>> format: one of "
>> +
>> HostMemPolicy_value_str,
>> +
>> &error_abort);
>> }
>>
>> static const TypeInfo host_memory_backend_info = {
>> diff --git a/crypto/secret.c b/crypto/secret.c
>> index 285ab7a..71d06e3 100644
>> --- a/crypto/secret.c
>> +++ b/crypto/secret.c
>> @@ -382,6 +382,10 @@ qcrypto_secret_class_init(ObjectClass *oc, void *data)
>>
>> qcrypto_secret_prop_get_format,
>>
>> qcrypto_secret_prop_set_format,
>> NULL);
>> + object_class_property_set_description(oc, "format",
>> +
>> "Data format: one of "
>> +
>> QCryptoSecretFormat_value_str,
>> +
>> &error_abort);
>> object_class_property_add_str(oc, "data",
>>
>> qcrypto_secret_prop_get_data,
>>
>> qcrypto_secret_prop_set_data,
>> diff --git a/crypto/tlscreds.c b/crypto/tlscreds.c
>> index a896553..d3af38a 100644
>> --- a/crypto/tlscreds.c
>> +++ b/crypto/tlscreds.c
>> @@ -237,6 +237,10 @@ qcrypto_tls_creds_class_init(ObjectClass *oc, void
>> *data)
>>
>> qcrypto_tls_creds_prop_get_endpoint,
>>
>> qcrypto_tls_creds_prop_set_endpoint,
>> NULL);
>> + object_class_property_set_description(oc, "endpoint",
>> +
>> "Data format: one of "
>> +
>> QCryptoTLSCredsEndpoint_value_str,
>> +
>> &error_abort);
>> object_class_property_add_str(oc, "priority",
>>
>> qcrypto_tls_creds_prop_get_priority,
>>
>> qcrypto_tls_creds_prop_set_priority,
>> diff --git a/net/filter.c b/net/filter.c
>> index 1dfd2ca..205fb49 100644
>> --- a/net/filter.c
>> +++ b/net/filter.c
>> @@ -182,6 +182,10 @@ static void netfilter_init(Object *obj)
>>
>> NetFilterDirection_lookup,
>>
>> netfilter_get_direction, netfilter_set_direction,
>> NULL);
>> + object_property_set_description(obj, "queue",
>> + "Data
>> format: one of "
>> +
>> NetFilterDirection_value_str,
>> +
>> &error_abort);
>> object_property_add_str(obj, "status",
>> netfilter_get_status,
>> netfilter_set_status,
>> NULL);
>
>After each
>
> object_class_property_add_enum(OC, PROP_NAME", ENUM_NAME, ...);
>
>you add
>
> object_class_property_set_description(OC, PROP_NAME,
>
> "Data format: one of "
>
> ENUM_NAME_value_str,
>
> &error_abort);
>
>Whenever somebody adds another object_class_property_add_enum(), he
>should also add an object_class_property_set_description(). Easily
>forgotten.
>
>Why not do it in object_class_property_add_enum() automatically?
>We got strings[] there...
Because in the help output, I'd like to treat the output as two part:
enum type name + description of enum type name.
So I didn't add it in object_class_property_add_enum().
Yes, it is easy to forget calling object_class_property_set_description().
But is it really better that combine it into object_class_property_add_enum()?
Thanks,
Lin