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