[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 12/46] qapi: Track location that created an i
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v5 12/46] qapi: Track location that created an implicit type |
Date: |
Mon, 28 Sep 2015 22:03:41 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 09/28/2015 06:56 AM, Markus Armbruster wrote:
> Eric Blake <address@hidden> writes:
>
>> A future patch will enable error detection in the various
>> QapiSchema check() methods. But since all errors have to
>> have an associated 'info' location, we need a location to
>> be associated with all implicit types. Easiest is to reuse
>> the location of the enclosing entity that includes the
>> dictionary defining the implicit type.
>>
>> While at it, we were always passing None as the location of
>> array types, making that parameter useless; sharing the
>> location (if any) of the underlying element type makes sense.
>
> The parameter is useless only because all array types are implicit.
> Once we change that, it won't be anymore.
I guess it depends whether I pass in the existing info when creating the
array or determine the info when resolving the string name of the array
element during check() (it will ultimately be the same info either way,
it's just a question of which approach looks cleaner for getting the
information set).
>> @@ -917,6 +917,7 @@ class QAPISchemaArrayType(QAPISchemaType):
>> def check(self, schema):
>> self.element_type = schema.lookup_type(self._element_type_name)
>> assert self.element_type
>> + self._info = self.element_type._info
>>
>> def json_type(self):
>> return 'array'
>
> Implicit array type's info is the element type's info. Okay.
>
>> @@ -928,6 +929,7 @@ class QAPISchemaArrayType(QAPISchemaType):
>> class QAPISchemaObjectType(QAPISchemaType):
>> def __init__(self, name, info, base, local_members, variants):
>> QAPISchemaType.__init__(self, name, info)
>> + assert info or name == ':empty'
>
> I think what we really want to assert is "we got info unless this is a
> built-in entity", in QAPISchemaEntity.__init__().
To do that, arrays would have to pass info in to __init__() rather than
deferring to check() as I did above.
>
> Built-in entities are exactly the types defined by
> QAPISchema._def_predefineds(), currently the built-in types and
> ':empty'.
I'm still wondering how best to test that, but agree that hoisting the
assert into QAPISchemaEntity instead of just in QAPISchemaObjectType
would be nice. Maybe some sort of boolean switch, initially off, then
turned on after _def_predefineds() is called, and assuming that no types
other than predefineds are initialized prior to that point.
>
> Missing: implicit enum types' info.
I'll add it; should be the info of the containing union type that caused
the implicit enum.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v5 09/46] qapi: Use consistent generated code patterns, (continued)
- [Qemu-devel] [PATCH v5 10/46] qapi: Merge generation of per-member visits, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 11/46] qapi: Don't use info as witness of implicit object type, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 12/46] qapi: Track location that created an implicit type, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 14/46] qapi: Detect collisions in C member names, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 16/46] qapi: Detect base class loops, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 15/46] qapi: Defer duplicate member checks to schema check(), Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 13/46] qapi: Track owner of each object member, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 17/46] qapi: Provide nicer array names in introspection, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 18/46] qapi-introspect: Guarantee particular sorting, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 20/46] qapi: Fix alternates that accept 'number' but not 'int', Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 21/46] qmp: Fix reference-counting of qnull on empty output visit, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 19/46] qapi: Simplify visiting of alternate types, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 22/46] qapi: Don't abuse stack to track qmp-output root, Eric Blake, 2015/09/21