[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 7/8] qom: add a object_property_add_enum help
From: |
Andreas Färber |
Subject: |
Re: [Qemu-devel] [PATCH v5 7/8] qom: add a object_property_add_enum helper method |
Date: |
Fri, 19 Jun 2015 18:44:59 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 |
Am 19.06.2015 um 18:38 schrieb Eric Blake:
> On 05/27/2015 09:07 AM, Daniel P. Berrange wrote:
>> A QOM property can be parsed as enum using the visit_type_enum()
>> helper method, but this forces callers to use the more complex
>> generic object_property_add() method when registering it. It
>> also requires that users of that object have access to the
>> string map when they want to read the property value.
>>
>
>> Assuming an object struct of
>>
>> typedef struct {
>> Object parent;
>> MyDevType devtype;
>> ...other fields...
>> } MyDev;
>>
>> The property can then be registered as follows:
>>
>> static int mydev_prop_get_devtype(Object *obj,
>> Error **errp G_GNUC_UNUSED)
>> {
>> MyDev *dev = MYDEV(obj);
>>
>> return dev->devtype;
>> }
>>
>> static void mydev_prop_set_devtype(Object *obj,
>> int value,
>> Error **errp G_GNUC_UNUSED)
>> {
>> MyDev *dev = MYDEV(obj);
>>
>> dev->endpoint = value;
>
> s/endpoint/devtype/
Fixed, and s/parent/parent_obj/ while at it.
Andreas
>
>> Signed-off-by: Daniel P. Berrange <address@hidden>
>> ---
>
--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)
signature.asc
Description: OpenPGP digital signature