[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v13 03/14] qapi: Convert QType into QAPI built-i
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v13 03/14] qapi: Convert QType into QAPI built-in enum type |
Date: |
Thu, 26 Nov 2015 22:09:29 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 11/26/2015 07:51 AM, Markus Armbruster wrote:
> Eric Blake <address@hidden> writes:
>
>> What's more meta than using qapi to define qapi? :)
>>
>> Convert QType into a full-fledged[*] builtin qapi enum type, so
>> that a subsequent patch can then use it as the discriminator
>> type of qapi alternate types. Fortunately, the judicious use of
>> 'prefix' in the qapi definition avoids churn to the spelling of
>> the enum constants.
>>
>> #include <stddef.h>
>> #include <assert.h>
>> +#include "qapi-types.h"
>
> Needed for QType. Risk for circular inclusion. We're currently fine,
> because generated qapi-types.h includes only "qemu/typedefs.h" (visible
> below). Should we add a comment to qapi-types.py?
How about this:
@@ -323,6 +319,7 @@ fdef.write(mcgen('''
''',
prefix=prefix))
+# To avoid circular headers, use only typedefs.h here, not qobject.h
fdecl.write(mcgen('''
#include <stdbool.h>
#include <stdint.h>
-#include "qapi/qmp/qobject.h"
+#include "qemu/typedefs.h"
'''))
schema = QAPISchema(input_file)
>> def visit_enum_type(self, name, info, values, prefix):
>> - self._fwdecl += gen_enum(name, values, prefix)
>> - self._fwdefn += gen_enum_lookup(name, values, prefix)
>> + # Special case for our lone builtin enum type
>> + # TODO use something cleaner than existence of info
>> + if not info:
>> + self._btin += gen_enum(name, values, prefix)
>> + if do_builtins:
>> + self.defn += gen_enum_lookup(name, values, prefix)
>> + else:
>> + self._fwdecl += gen_enum(name, values, prefix)
>> + self._fwdefn += gen_enum_lookup(name, values, prefix)
>
> Odd: gen_enum_lookup() goes into .defn for built-ins, but ._fwdefn for
> user-defineds. Makes me suspect it ._fwdefn isn't needed anymore. A
> quick test compile is happy with .defn for both.
>
> If we want to keep ._fwdefn for some reason, we should use for built-ins
> as well.
We need it for gen_alternate_qtypes(). But that disappears in 4/14, so
I'll add a patch to clean it up.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v13 00/14] qapi member collision (post-introspection cleanups, subset D), Eric Blake, 2015/11/20
- [Qemu-devel] [PATCH v13 05/14] qapi: Inline _make_implicit_tag(), Eric Blake, 2015/11/20
- [Qemu-devel] [PATCH v13 03/14] qapi: Convert QType into QAPI built-in enum type, Eric Blake, 2015/11/20
- [Qemu-devel] [PATCH v13 07/14] qapi: Simplify visits of optional fields, Eric Blake, 2015/11/20
- [Qemu-devel] [PATCH v13 08/14] qapi: Shorter visits of optional fields, Eric Blake, 2015/11/20
- [Qemu-devel] [PATCH v13 10/14] qapi: Track enum values by QAPISchemaMember, not string, Eric Blake, 2015/11/20
- [Qemu-devel] [PATCH v13 11/14] qapi: Populate info['name'] for each entity, Eric Blake, 2015/11/20
- [Qemu-devel] [PATCH v13 09/14] qapi: Prepare new QAPISchemaMember base class, Eric Blake, 2015/11/20
- [Qemu-devel] [PATCH v13 14/14] qapi: Detect base class loops, Eric Blake, 2015/11/20
- [Qemu-devel] [PATCH v13 04/14] qapi: Simplify visiting of alternate types, Eric Blake, 2015/11/20
- [Qemu-devel] [PATCH v13 12/14] qapi: Enforce (or whitelist) case conventions on qapi members, Eric Blake, 2015/11/20