qapi: Generate QAPIEvent stuff into separate files

Having to include qapi-events.h just for QAPIEvent is suboptimal, but
quite tolerable now.  It'll become problematic when we have events
conditional on the target, because then qapi-events.h won't be usable
from target-independent code anymore.  Avoid that by generating it
into separate files.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20190214152251.2073-6-armbru@redhat.com>
This commit is contained in:
Markus Armbruster 2019-02-14 16:22:38 +01:00
parent c2e196a9b4
commit 5d75648b56
9 changed files with 60 additions and 29 deletions

View file

@ -1381,11 +1381,15 @@ qapi_event_send_EVENT().
The following files are created:
$(prefix)qapi-events.h - Function prototypes for each event type, plus an
enumeration of all event names
$(prefix)qapi-events.h - Function prototypes for each event type
$(prefix)qapi-events.c - Implementation of functions to send an event
$(prefix)qapi-emit-events.h - Enumeration of all event names, and
common event code declarations
$(prefix)qapi-emit-events.c - Common event code definitions
Example:
$ cat qapi-generated/example-qapi-events.h
@ -1397,21 +1401,8 @@ Example:
#include "qapi/util.h"
#include "example-qapi-types.h"
void qapi_event_send_my_event(void);
typedef enum example_QAPIEvent {
EXAMPLE_QAPI_EVENT_MY_EVENT,
EXAMPLE_QAPI_EVENT__MAX,
} example_QAPIEvent;
#define example_QAPIEvent_str(val) \
qapi_enum_lookup(&example_QAPIEvent_lookup, (val))
extern const QEnumLookup example_QAPIEvent_lookup;
void example_qapi_event_emit(example_QAPIEvent event, QDict *qdict);
#endif /* EXAMPLE_QAPI_EVENTS_H */
$ cat qapi-generated/example-qapi-events.c
[Uninteresting stuff omitted...]
@ -1427,6 +1418,31 @@ Example:
qobject_unref(qmp);
}
[Uninteresting stuff omitted...]
$ cat qapi-generated/example-qapi-emit-events.h
[Uninteresting stuff omitted...]
#ifndef EXAMPLE_QAPI_EMIT_EVENTS_H
#define EXAMPLE_QAPI_EMIT_EVENTS_H
#include "qapi/util.h"
typedef enum example_QAPIEvent {
EXAMPLE_QAPI_EVENT_MY_EVENT,
EXAMPLE_QAPI_EVENT__MAX,
} example_QAPIEvent;
#define example_QAPIEvent_str(val) \
qapi_enum_lookup(&example_QAPIEvent_lookup, (val))
extern const QEnumLookup example_QAPIEvent_lookup;
void example_qapi_event_emit(example_QAPIEvent event, QDict *qdict);
#endif /* EXAMPLE_QAPI_EMIT_EVENTS_H */
$ cat qapi-generated/example-qapi-emit-events.c
[Uninteresting stuff omitted...]
const QEnumLookup example_QAPIEvent_lookup = {
.array = (const char *const[]) {
[EXAMPLE_QAPI_EVENT_MY_EVENT] = "MY_EVENT",