On 11/26/2015 07:51 AM, Markus Armbruster wrote: > Eric Blake <ebl...@redhat.com> 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