qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/3] qom-qobject: introduce object_property_{g,


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 1/3] qom-qobject: introduce object_property_{g, s}et_ptr
Date: Tue, 21 Feb 2017 17:23:24 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0


On 21/02/2017 16:57, Eric Blake wrote:
>> +    /* You can retrieve a covariant (superclass) type... */
>> +    ret = OBJECT_PROPERTY_GET_PTR(OBJECT(dobj), "qv",
>> +                                  UserDefZero, &local_err);
>> +    g_assert(!local_err);
>> +
>> +    g_assert_cmpint(ret->integer, ==, 0);
>> +    qapi_free_UserDefZero(ret);
> 
> You coded a non-strict visitor above to allow this to happen, but is it
> really what we want?  It basically means we are grabbing the property
> fields we care about, while ignoring the rest of the property.  I guess
> it may be okay.

The tests were very useful to write, because I had hardly gotten any of
the corner cases right. :)  I think these semantics make the most sense.

Yeah, it uses non-strict mode but this test provides a reason (namely,
covariant return types) why non-strict mode is useful.  It makes
backwards-compatibility easier.

>> +
>> +    /* Test that the property has not been modified at all */
>> +    ret = OBJECT_PROPERTY_GET_PTR(OBJECT(dobj), "qv",
>> +                                  UserDefZero, &local_err);
>> +    g_assert(!local_err);
>> +
>> +    g_assert_cmpint(ret->integer, ==, 0);
>> +    qapi_free_UserDefZero(ret);
>> +}
>> +
>> +++ b/tests/qapi-schema/qapi-schema-test.json
>> @@ -91,6 +91,14 @@
>>              '*enum1': 'EnumOne' } }   # intentional forward reference
>>  
>>  ##
>> +# @UserDefOneMore:
>> +# for testing nested structs
> Is nested the right word here?

Just copied from UserDefOne. :)  I'll change both to "derived".

Paolo

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]