mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
qapi: De-duplicate enum code generation
Duplicated in commit21cd70d
. Yes, we can't import qapi-types, but that's no excuse. Move the helpers from qapi-types.py to qapi.py, and replace the duplicates in qapi-event.py. The generated event enumeration type's lookup table becomes const-correct (see commit2e4450f
), and uses explicit indexes instead of relying on order (see commit912ae9c
). Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1442401589-24189-10-git-send-email-armbru@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
ee44602857
commit
efd2eaa6c2
4 changed files with 64 additions and 122 deletions
|
@ -829,9 +829,9 @@ Example:
|
|||
QDECREF(qmp);
|
||||
}
|
||||
|
||||
const char *example_QAPIEvent_lookup[] = {
|
||||
"MY_EVENT",
|
||||
NULL,
|
||||
const char *const example_QAPIEvent_lookup[] = {
|
||||
[EXAMPLE_QAPI_EVENT_MY_EVENT] = "MY_EVENT",
|
||||
[EXAMPLE_QAPI_EVENT_MAX] = NULL,
|
||||
};
|
||||
$ cat qapi-generated/example-qapi-event.h
|
||||
[Uninteresting stuff omitted...]
|
||||
|
@ -846,10 +846,11 @@ Example:
|
|||
|
||||
void qapi_event_send_my_event(Error **errp);
|
||||
|
||||
extern const char *example_QAPIEvent_lookup[];
|
||||
typedef enum example_QAPIEvent {
|
||||
EXAMPLE_QAPI_EVENT_MY_EVENT = 0,
|
||||
EXAMPLE_QAPI_EVENT_MAX = 1,
|
||||
} example_QAPIEvent;
|
||||
|
||||
extern const char *const example_QAPIEvent_lookup[];
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue