qapi: Generate FOO_str() macro for QAPI enum FOO
The next commit will put it to use. May look pointless now, but we're going to change the FOO_lookup's type, and then it'll help. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1503564371-26090-13-git-send-email-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
1c236ba531
commit
5b5f825d44
1
block.c
1
block.c
@ -42,7 +42,6 @@
|
|||||||
#include "qapi-event.h"
|
#include "qapi-event.h"
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
#include "qemu/id.h"
|
#include "qemu/id.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_BSD
|
#ifdef CONFIG_BSD
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include "qapi/qmp/qbool.h"
|
#include "qapi/qmp/qbool.h"
|
||||||
#include "qapi/qmp/qdict.h"
|
#include "qapi/qmp/qdict.h"
|
||||||
#include "qapi/qmp/qstring.h"
|
#include "qapi/qmp/qstring.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "sysemu/qtest.h"
|
#include "sysemu/qtest.h"
|
||||||
|
|
||||||
typedef struct BDRVBlkdebugState {
|
typedef struct BDRVBlkdebugState {
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "block/thread-pool.h"
|
#include "block/thread-pool.h"
|
||||||
#include "qemu/iov.h"
|
#include "qemu/iov.h"
|
||||||
#include "block/raw-aio.h"
|
#include "block/raw-aio.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "qapi/qmp/qstring.h"
|
#include "qapi/qmp/qstring.h"
|
||||||
|
|
||||||
#if defined(__APPLE__) && (__MACH__)
|
#if defined(__APPLE__) && (__MACH__)
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "block/thread-pool.h"
|
#include "block/thread-pool.h"
|
||||||
#include "qemu/iov.h"
|
#include "qemu/iov.h"
|
||||||
#include "qapi/qmp/qstring.h"
|
#include "qapi/qmp/qstring.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winioctl.h>
|
#include <winioctl.h>
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#include "block/block_int.h"
|
#include "block/block_int.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "qemu/uri.h"
|
#include "qemu/uri.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
#include "qemu/module.h"
|
#include "qemu/module.h"
|
||||||
#include "qemu/bswap.h"
|
#include "qemu/bswap.h"
|
||||||
#include "qemu/bitmap.h"
|
#include "qemu/bitmap.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
#include "qapi/qmp/qbool.h"
|
#include "qapi/qmp/qbool.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "qapi/qmp/types.h"
|
#include "qapi/qmp/types.h"
|
||||||
#include "qapi-event.h"
|
#include "qapi-event.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include "qapi/qmp/qjson.h"
|
#include "qapi/qmp/qjson.h"
|
||||||
#include "qapi/qmp/qlist.h"
|
#include "qapi/qmp/qlist.h"
|
||||||
#include "qapi/qmp/qstring.h"
|
#include "qapi/qmp/qstring.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "qapi-event.h"
|
#include "qapi-event.h"
|
||||||
#include "crypto/hash.h"
|
#include "crypto/hash.h"
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
#include "qapi-visit.h"
|
#include "qapi-visit.h"
|
||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
#include "qapi/qobject-output-visitor.h"
|
#include "qapi/qobject-output-visitor.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
#include "block/block_int.h"
|
#include "block/block_int.h"
|
||||||
#include "qmp-commands.h"
|
#include "qmp-commands.h"
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "qemu/bswap.h"
|
#include "qemu/bswap.h"
|
||||||
|
|
||||||
#include "crypto/block-luks.h"
|
#include "crypto/block-luks.h"
|
||||||
|
@ -1275,6 +1275,9 @@ Example:
|
|||||||
EXAMPLE_QAPI_EVENT__MAX = 1,
|
EXAMPLE_QAPI_EVENT__MAX = 1,
|
||||||
} example_QAPIEvent;
|
} example_QAPIEvent;
|
||||||
|
|
||||||
|
#define example_QAPIEvent_str(val) \
|
||||||
|
qapi_enum_lookup(example_QAPIEvent_lookup, (val))
|
||||||
|
|
||||||
extern const char *const example_QAPIEvent_lookup[];
|
extern const char *const example_QAPIEvent_lookup[];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
1
hmp.c
1
hmp.c
@ -31,7 +31,6 @@
|
|||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
#include "qapi/string-input-visitor.h"
|
#include "qapi/string-input-visitor.h"
|
||||||
#include "qapi/string-output-visitor.h"
|
#include "qapi/string-output-visitor.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "qapi-visit.h"
|
#include "qapi-visit.h"
|
||||||
#include "qom/object_interfaces.h"
|
#include "qom/object_interfaces.h"
|
||||||
#include "ui/console.h"
|
#include "ui/console.h"
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#ifndef QAPI_UTIL_H
|
#ifndef QAPI_UTIL_H
|
||||||
#define QAPI_UTIL_H
|
#define QAPI_UTIL_H
|
||||||
|
|
||||||
|
const char *qapi_enum_lookup(const char *const lookup[], int val);
|
||||||
int qapi_enum_parse(const char * const lookup[], const char *buf,
|
int qapi_enum_parse(const char * const lookup[], const char *buf,
|
||||||
int def, Error **errp);
|
int def, Error **errp);
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "migration.h"
|
#include "migration.h"
|
||||||
#include "migration/global_state.h"
|
#include "migration/global_state.h"
|
||||||
#include "migration/vmstate.h"
|
#include "migration/vmstate.h"
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "migration/vmstate.h"
|
#include "migration/vmstate.h"
|
||||||
#include "block/block.h"
|
#include "block/block.h"
|
||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "qemu/rcu.h"
|
#include "qemu/rcu.h"
|
||||||
#include "block.h"
|
#include "block.h"
|
||||||
#include "postcopy-ram.h"
|
#include "postcopy-ram.h"
|
||||||
|
@ -13,7 +13,13 @@
|
|||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
|
const char *qapi_enum_lookup(const char *const lookup[], int val)
|
||||||
|
{
|
||||||
|
assert(val >= 0);
|
||||||
|
|
||||||
|
return lookup[val];
|
||||||
|
}
|
||||||
|
|
||||||
int qapi_enum_parse(const char * const lookup[], const char *buf,
|
int qapi_enum_parse(const char * const lookup[], const char *buf,
|
||||||
int def, Error **errp)
|
int def, Error **errp)
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
#include "qapi/qmp/qobject.h"
|
#include "qapi/qmp/qobject.h"
|
||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
#include "qemu-version.h"
|
#include "qemu-version.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "qapi-visit.h"
|
#include "qapi-visit.h"
|
||||||
#include "qapi/qobject-output-visitor.h"
|
#include "qapi/qobject-output-visitor.h"
|
||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include "qemu/log.h"
|
#include "qemu/log.h"
|
||||||
#include "qemu/systemd.h"
|
#include "qemu/systemd.h"
|
||||||
#include "block/snapshot.h"
|
#include "block/snapshot.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "qapi/qmp/qstring.h"
|
#include "qapi/qmp/qstring.h"
|
||||||
#include "qom/object_interfaces.h"
|
#include "qom/object_interfaces.h"
|
||||||
#include "io/channel-socket.h"
|
#include "io/channel-socket.h"
|
||||||
|
@ -217,6 +217,7 @@ fdef.write(mcgen('''
|
|||||||
|
|
||||||
fdecl.write(mcgen('''
|
fdecl.write(mcgen('''
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
|
#include "qapi/util.h"
|
||||||
#include "qapi/qmp/qdict.h"
|
#include "qapi/qmp/qdict.h"
|
||||||
#include "%(prefix)sqapi-types.h"
|
#include "%(prefix)sqapi-types.h"
|
||||||
|
|
||||||
|
@ -292,6 +292,10 @@ fdef.write(mcgen('''
|
|||||||
''',
|
''',
|
||||||
prefix=prefix))
|
prefix=prefix))
|
||||||
|
|
||||||
|
fdecl.write(mcgen('''
|
||||||
|
#include "qapi/util.h"
|
||||||
|
'''))
|
||||||
|
|
||||||
schema = QAPISchema(input_file)
|
schema = QAPISchema(input_file)
|
||||||
gen = QAPISchemaGenTypeVisitor()
|
gen = QAPISchemaGenTypeVisitor()
|
||||||
schema.visit(gen)
|
schema.visit(gen)
|
||||||
|
@ -1894,6 +1894,9 @@ typedef enum %(c_name)s {
|
|||||||
|
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
|
|
||||||
|
#define %(c_name)s_str(val) \\
|
||||||
|
qapi_enum_lookup(%(c_name)s_lookup, (val))
|
||||||
|
|
||||||
extern const char *const %(c_name)s_lookup[];
|
extern const char *const %(c_name)s_lookup[];
|
||||||
''',
|
''',
|
||||||
c_name=c_name(name))
|
c_name=c_name(name))
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "test-qapi-types.h"
|
#include "test-qapi-types.h"
|
||||||
|
|
||||||
static void test_qapi_enum_parse(void)
|
static void test_qapi_enum_parse(void)
|
||||||
|
1
tpm.c
1
tpm.c
@ -14,7 +14,6 @@
|
|||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
|
|
||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "sysemu/tpm_backend.h"
|
#include "sysemu/tpm_backend.h"
|
||||||
#include "sysemu/tpm.h"
|
#include "sysemu/tpm.h"
|
||||||
#include "qemu/config-file.h"
|
#include "qemu/config-file.h"
|
||||||
|
@ -82,7 +82,6 @@
|
|||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qapi/qmp/qstring.h"
|
#include "qapi/qmp/qstring.h"
|
||||||
#include "qapi/util.h"
|
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
#include "qemu/option.h"
|
#include "qemu/option.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user