Skip to content

Commit 252dc31

Browse files
Markus Armbrusterebblake
Markus Armbruster
authored andcommitted
qapi: Generate separate .h, .c for each module
Our qapi-schema.json is composed of modules connected by include directives, but the generated code is monolithic all the same: one qapi-types.h with all the types, one qapi-visit.h with all the visitors, and so forth. These monolithic headers get included all over the place. In my "build everything" tree, adding a QAPI type recompiles about 4800 out of 5100 objects. We wouldn't write such monolithic headers by hand. It stands to reason that we shouldn't generate them, either. Split up generated qapi-types.h to mirror the schema's modular structure: one header per module. Name the main module's header qapi-types.h, and sub-module D/B.json's header D/qapi-types-B.h. Mirror the schema's includes in the headers, so that qapi-types.h gets you everything exactly as before. If you need less, you can include one or more of the sub-module headers. To be exploited shortly. Split up qapi-types.c, qapi-visit.h, qapi-visit.c, qmp-commands.h, qmp-commands.c, qapi-event.h, qapi-event.c the same way. qmp-introspect.h, qmp-introspect.c and qapi.texi remain monolithic. The split of qmp-commands.c duplicates static helper function qmp_marshal_output_str() in qapi-commands-char.c and qapi-commands-misc.c. This happens when commands returning the same type occur in multiple modules. Not worth avoiding. Since I'm going to rename qapi-event.[ch] to qapi-events.[ch], and qmp-commands.[ch] to qapi-commands.[ch], name the shards that way already, to reduce churn. This requires temporary hacks in commands.py and events.py. Similarly, c_name() must temporarily be taught to munge '/' in common.py. They'll go away with the rename. Signed-off-by: Markus Armbruster <[email protected]> Message-Id: <[email protected]> Reviewed-by: Eric Blake <[email protected]> [eblake: declare a dummy variable in each .c file, to shut up OSX toolchain warnings about empty .o files, including hacking c_name()] Signed-off-by: Eric Blake <[email protected]>
1 parent 3da7a41 commit 252dc31

File tree

6 files changed

+310
-22
lines changed

6 files changed

+310
-22
lines changed

.gitignore

+60
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,67 @@
3131
/qapi-gen-timestamp
3232
/qapi-builtin-types.[ch]
3333
/qapi-builtin-visit.[ch]
34+
/qapi/qapi-commands-block-core.[ch]
35+
/qapi/qapi-commands-block.[ch]
36+
/qapi/qapi-commands-char.[ch]
37+
/qapi/qapi-commands-common.[ch]
38+
/qapi/qapi-commands-crypto.[ch]
39+
/qapi/qapi-commands-introspect.[ch]
40+
/qapi/qapi-commands-migration.[ch]
41+
/qapi/qapi-commands-net.[ch]
42+
/qapi/qapi-commands-rocker.[ch]
43+
/qapi/qapi-commands-run-state.[ch]
44+
/qapi/qapi-commands-sockets.[ch]
45+
/qapi/qapi-commands-tpm.[ch]
46+
/qapi/qapi-commands-trace.[ch]
47+
/qapi/qapi-commands-transaction.[ch]
48+
/qapi/qapi-commands-ui.[ch]
49+
/qapi/qapi-events-block-core.[ch]
50+
/qapi/qapi-events-block.[ch]
51+
/qapi/qapi-events-char.[ch]
52+
/qapi/qapi-events-common.[ch]
53+
/qapi/qapi-events-crypto.[ch]
54+
/qapi/qapi-events-introspect.[ch]
55+
/qapi/qapi-events-migration.[ch]
56+
/qapi/qapi-events-net.[ch]
57+
/qapi/qapi-events-rocker.[ch]
58+
/qapi/qapi-events-run-state.[ch]
59+
/qapi/qapi-events-sockets.[ch]
60+
/qapi/qapi-events-tpm.[ch]
61+
/qapi/qapi-events-trace.[ch]
62+
/qapi/qapi-events-transaction.[ch]
63+
/qapi/qapi-events-ui.[ch]
64+
/qapi/qapi-types-block-core.[ch]
65+
/qapi/qapi-types-block.[ch]
66+
/qapi/qapi-types-char.[ch]
67+
/qapi/qapi-types-common.[ch]
68+
/qapi/qapi-types-crypto.[ch]
69+
/qapi/qapi-types-introspect.[ch]
70+
/qapi/qapi-types-migration.[ch]
71+
/qapi/qapi-types-net.[ch]
72+
/qapi/qapi-types-rocker.[ch]
73+
/qapi/qapi-types-run-state.[ch]
74+
/qapi/qapi-types-sockets.[ch]
75+
/qapi/qapi-types-tpm.[ch]
76+
/qapi/qapi-types-trace.[ch]
77+
/qapi/qapi-types-transaction.[ch]
78+
/qapi/qapi-types-ui.[ch]
3479
/qapi-types.[ch]
80+
/qapi/qapi-visit-block-core.[ch]
81+
/qapi/qapi-visit-block.[ch]
82+
/qapi/qapi-visit-char.[ch]
83+
/qapi/qapi-visit-common.[ch]
84+
/qapi/qapi-visit-crypto.[ch]
85+
/qapi/qapi-visit-introspect.[ch]
86+
/qapi/qapi-visit-migration.[ch]
87+
/qapi/qapi-visit-net.[ch]
88+
/qapi/qapi-visit-rocker.[ch]
89+
/qapi/qapi-visit-run-state.[ch]
90+
/qapi/qapi-visit-sockets.[ch]
91+
/qapi/qapi-visit-tpm.[ch]
92+
/qapi/qapi-visit-trace.[ch]
93+
/qapi/qapi-visit-transaction.[ch]
94+
/qapi/qapi-visit-ui.[ch]
3595
/qapi-visit.[ch]
3696
/qapi-event.[ch]
3797
/qapi-doc.texi

Makefile

+120
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,70 @@ include $(SRC_PATH)/rules.mak
9292
GENERATED_FILES = qemu-version.h config-host.h qemu-options.def
9393
GENERATED_FILES += qapi-builtin-types.h qapi-builtin-types.c
9494
GENERATED_FILES += qapi-types.h qapi-types.c
95+
GENERATED_FILES += qapi/qapi-types-block-core.h qapi/qapi-types-block-core.c
96+
GENERATED_FILES += qapi/qapi-types-block.h qapi/qapi-types-block.c
97+
GENERATED_FILES += qapi/qapi-types-char.h qapi/qapi-types-char.c
98+
GENERATED_FILES += qapi/qapi-types-common.h qapi/qapi-types-common.c
99+
GENERATED_FILES += qapi/qapi-types-crypto.h qapi/qapi-types-crypto.c
100+
GENERATED_FILES += qapi/qapi-types-introspect.h qapi/qapi-types-introspect.c
101+
GENERATED_FILES += qapi/qapi-types-migration.h qapi/qapi-types-migration.c
102+
GENERATED_FILES += qapi/qapi-types-net.h qapi/qapi-types-net.c
103+
GENERATED_FILES += qapi/qapi-types-rocker.h qapi/qapi-types-rocker.c
104+
GENERATED_FILES += qapi/qapi-types-run-state.h qapi/qapi-types-run-state.c
105+
GENERATED_FILES += qapi/qapi-types-sockets.h qapi/qapi-types-sockets.c
106+
GENERATED_FILES += qapi/qapi-types-tpm.h qapi/qapi-types-tpm.c
107+
GENERATED_FILES += qapi/qapi-types-trace.h qapi/qapi-types-trace.c
108+
GENERATED_FILES += qapi/qapi-types-transaction.h qapi/qapi-types-transaction.c
109+
GENERATED_FILES += qapi/qapi-types-ui.h qapi/qapi-types-ui.c
95110
GENERATED_FILES += qapi-builtin-visit.h qapi-builtin-visit.c
96111
GENERATED_FILES += qapi-visit.h qapi-visit.c
112+
GENERATED_FILES += qapi/qapi-visit-block-core.h qapi/qapi-visit-block-core.c
113+
GENERATED_FILES += qapi/qapi-visit-block.h qapi/qapi-visit-block.c
114+
GENERATED_FILES += qapi/qapi-visit-char.h qapi/qapi-visit-char.c
115+
GENERATED_FILES += qapi/qapi-visit-common.h qapi/qapi-visit-common.c
116+
GENERATED_FILES += qapi/qapi-visit-crypto.h qapi/qapi-visit-crypto.c
117+
GENERATED_FILES += qapi/qapi-visit-introspect.h qapi/qapi-visit-introspect.c
118+
GENERATED_FILES += qapi/qapi-visit-migration.h qapi/qapi-visit-migration.c
119+
GENERATED_FILES += qapi/qapi-visit-net.h qapi/qapi-visit-net.c
120+
GENERATED_FILES += qapi/qapi-visit-rocker.h qapi/qapi-visit-rocker.c
121+
GENERATED_FILES += qapi/qapi-visit-run-state.h qapi/qapi-visit-run-state.c
122+
GENERATED_FILES += qapi/qapi-visit-sockets.h qapi/qapi-visit-sockets.c
123+
GENERATED_FILES += qapi/qapi-visit-tpm.h qapi/qapi-visit-tpm.c
124+
GENERATED_FILES += qapi/qapi-visit-trace.h qapi/qapi-visit-trace.c
125+
GENERATED_FILES += qapi/qapi-visit-transaction.h qapi/qapi-visit-transaction.c
126+
GENERATED_FILES += qapi/qapi-visit-ui.h qapi/qapi-visit-ui.c
97127
GENERATED_FILES += qmp-commands.h qmp-commands.c
128+
GENERATED_FILES += qapi/qapi-commands-block-core.h qapi/qapi-commands-block-core.c
129+
GENERATED_FILES += qapi/qapi-commands-block.h qapi/qapi-commands-block.c
130+
GENERATED_FILES += qapi/qapi-commands-char.h qapi/qapi-commands-char.c
131+
GENERATED_FILES += qapi/qapi-commands-common.h qapi/qapi-commands-common.c
132+
GENERATED_FILES += qapi/qapi-commands-crypto.h qapi/qapi-commands-crypto.c
133+
GENERATED_FILES += qapi/qapi-commands-introspect.h qapi/qapi-commands-introspect.c
134+
GENERATED_FILES += qapi/qapi-commands-migration.h qapi/qapi-commands-migration.c
135+
GENERATED_FILES += qapi/qapi-commands-net.h qapi/qapi-commands-net.c
136+
GENERATED_FILES += qapi/qapi-commands-rocker.h qapi/qapi-commands-rocker.c
137+
GENERATED_FILES += qapi/qapi-commands-run-state.h qapi/qapi-commands-run-state.c
138+
GENERATED_FILES += qapi/qapi-commands-sockets.h qapi/qapi-commands-sockets.c
139+
GENERATED_FILES += qapi/qapi-commands-tpm.h qapi/qapi-commands-tpm.c
140+
GENERATED_FILES += qapi/qapi-commands-trace.h qapi/qapi-commands-trace.c
141+
GENERATED_FILES += qapi/qapi-commands-transaction.h qapi/qapi-commands-transaction.c
142+
GENERATED_FILES += qapi/qapi-commands-ui.h qapi/qapi-commands-ui.c
98143
GENERATED_FILES += qapi-event.h qapi-event.c
144+
GENERATED_FILES += qapi/qapi-events-block-core.h qapi/qapi-events-block-core.c
145+
GENERATED_FILES += qapi/qapi-events-block.h qapi/qapi-events-block.c
146+
GENERATED_FILES += qapi/qapi-events-char.h qapi/qapi-events-char.c
147+
GENERATED_FILES += qapi/qapi-events-common.h qapi/qapi-events-common.c
148+
GENERATED_FILES += qapi/qapi-events-crypto.h qapi/qapi-events-crypto.c
149+
GENERATED_FILES += qapi/qapi-events-introspect.h qapi/qapi-events-introspect.c
150+
GENERATED_FILES += qapi/qapi-events-migration.h qapi/qapi-events-migration.c
151+
GENERATED_FILES += qapi/qapi-events-net.h qapi/qapi-events-net.c
152+
GENERATED_FILES += qapi/qapi-events-rocker.h qapi/qapi-events-rocker.c
153+
GENERATED_FILES += qapi/qapi-events-run-state.h qapi/qapi-events-run-state.c
154+
GENERATED_FILES += qapi/qapi-events-sockets.h qapi/qapi-events-sockets.c
155+
GENERATED_FILES += qapi/qapi-events-tpm.h qapi/qapi-events-tpm.c
156+
GENERATED_FILES += qapi/qapi-events-trace.h qapi/qapi-events-trace.c
157+
GENERATED_FILES += qapi/qapi-events-transaction.h qapi/qapi-events-transaction.c
158+
GENERATED_FILES += qapi/qapi-events-ui.h qapi/qapi-events-ui.c
99159
GENERATED_FILES += qmp-introspect.c qmp-introspect.h
100160
GENERATED_FILES += qapi-doc.texi
101161

@@ -524,10 +584,70 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
524584

525585
qapi-builtin-types.c qapi-builtin-types.h \
526586
qapi-types.c qapi-types.h \
587+
qapi/qapi-types-block-core.c qapi/qapi-types-block-core.h \
588+
qapi/qapi-types-block.c qapi/qapi-types-block.h \
589+
qapi/qapi-types-char.c qapi/qapi-types-char.h \
590+
qapi/qapi-types-common.c qapi/qapi-types-common.h \
591+
qapi/qapi-types-crypto.c qapi/qapi-types-crypto.h \
592+
qapi/qapi-types-introspect.c qapi/qapi-types-introspect.h \
593+
qapi/qapi-types-migration.c qapi/qapi-types-migration.h \
594+
qapi/qapi-types-net.c qapi/qapi-types-net.h \
595+
qapi/qapi-types-rocker.c qapi/qapi-types-rocker.h \
596+
qapi/qapi-types-run-state.c qapi/qapi-types-run-state.h \
597+
qapi/qapi-types-sockets.c qapi/qapi-types-sockets.h \
598+
qapi/qapi-types-tpm.c qapi/qapi-types-tpm.h \
599+
qapi/qapi-types-trace.c qapi/qapi-types-trace.h \
600+
qapi/qapi-types-transaction.c qapi/qapi-types-transaction.h \
601+
qapi/qapi-types-ui.c qapi/qapi-types-ui.h \
527602
qapi-builtin-visit.c qapi-builtin-visit.h \
528603
qapi-visit.c qapi-visit.h \
604+
qapi/qapi-visit-block-core.c qapi/qapi-visit-block-core.h \
605+
qapi/qapi-visit-block.c qapi/qapi-visit-block.h \
606+
qapi/qapi-visit-char.c qapi/qapi-visit-char.h \
607+
qapi/qapi-visit-common.c qapi/qapi-visit-common.h \
608+
qapi/qapi-visit-crypto.c qapi/qapi-visit-crypto.h \
609+
qapi/qapi-visit-introspect.c qapi/qapi-visit-introspect.h \
610+
qapi/qapi-visit-migration.c qapi/qapi-visit-migration.h \
611+
qapi/qapi-visit-net.c qapi/qapi-visit-net.h \
612+
qapi/qapi-visit-rocker.c qapi/qapi-visit-rocker.h \
613+
qapi/qapi-visit-run-state.c qapi/qapi-visit-run-state.h \
614+
qapi/qapi-visit-sockets.c qapi/qapi-visit-sockets.h \
615+
qapi/qapi-visit-tpm.c qapi/qapi-visit-tpm.h \
616+
qapi/qapi-visit-trace.c qapi/qapi-visit-trace.h \
617+
qapi/qapi-visit-transaction.c qapi/qapi-visit-transaction.h \
618+
qapi/qapi-visit-ui.c qapi/qapi-visit-ui.h \
529619
qmp-commands.h qmp-commands.c \
620+
qapi/qapi-commands-block-core.c qapi/qapi-commands-block-core.h \
621+
qapi/qapi-commands-block.c qapi/qapi-commands-block.h \
622+
qapi/qapi-commands-char.c qapi/qapi-commands-char.h \
623+
qapi/qapi-commands-common.c qapi/qapi-commands-common.h \
624+
qapi/qapi-commands-crypto.c qapi/qapi-commands-crypto.h \
625+
qapi/qapi-commands-introspect.c qapi/qapi-commands-introspect.h \
626+
qapi/qapi-commands-migration.c qapi/qapi-commands-migration.h \
627+
qapi/qapi-commands-net.c qapi/qapi-commands-net.h \
628+
qapi/qapi-commands-rocker.c qapi/qapi-commands-rocker.h \
629+
qapi/qapi-commands-run-state.c qapi/qapi-commands-run-state.h \
630+
qapi/qapi-commands-sockets.c qapi/qapi-commands-sockets.h \
631+
qapi/qapi-commands-tpm.c qapi/qapi-commands-tpm.h \
632+
qapi/qapi-commands-trace.c qapi/qapi-commands-trace.h \
633+
qapi/qapi-commands-transaction.c qapi/qapi-commands-transaction.h \
634+
qapi/qapi-commands-ui.c qapi/qapi-commands-ui.h \
530635
qapi-event.c qapi-event.h \
636+
qapi/qapi-events-block-core.c qapi/qapi-events-block-core.h \
637+
qapi/qapi-events-block.c qapi/qapi-events-block.h \
638+
qapi/qapi-events-char.c qapi/qapi-events-char.h \
639+
qapi/qapi-events-common.c qapi/qapi-events-common.h \
640+
qapi/qapi-events-crypto.c qapi/qapi-events-crypto.h \
641+
qapi/qapi-events-introspect.c qapi/qapi-events-introspect.h \
642+
qapi/qapi-events-migration.c qapi/qapi-events-migration.h \
643+
qapi/qapi-events-net.c qapi/qapi-events-net.h \
644+
qapi/qapi-events-rocker.c qapi/qapi-events-rocker.h \
645+
qapi/qapi-events-run-state.c qapi/qapi-events-run-state.h \
646+
qapi/qapi-events-sockets.c qapi/qapi-events-sockets.h \
647+
qapi/qapi-events-tpm.c qapi/qapi-events-tpm.h \
648+
qapi/qapi-events-trace.c qapi/qapi-events-trace.h \
649+
qapi/qapi-events-transaction.c qapi/qapi-events-transaction.h \
650+
qapi/qapi-events-ui.c qapi/qapi-events-ui.h \
531651
qmp-introspect.h qmp-introspect.c \
532652
qapi-doc.texi: \
533653
qapi-gen-timestamp ;

Makefile.objs

+64-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,56 @@
33
stub-obj-y = stubs/ crypto/
44
util-obj-y = util/ qobject/ qapi/
55
util-obj-y += qapi-builtin-types.o
6+
util-obj-y += qapi-types.o
7+
util-obj-y += qapi/qapi-types-block-core.o
8+
util-obj-y += qapi/qapi-types-block.o
9+
util-obj-y += qapi/qapi-types-char.o
10+
util-obj-y += qapi/qapi-types-common.o
11+
util-obj-y += qapi/qapi-types-crypto.o
12+
util-obj-y += qapi/qapi-types-introspect.o
13+
util-obj-y += qapi/qapi-types-migration.o
14+
util-obj-y += qapi/qapi-types-net.o
15+
util-obj-y += qapi/qapi-types-rocker.o
16+
util-obj-y += qapi/qapi-types-run-state.o
17+
util-obj-y += qapi/qapi-types-sockets.o
18+
util-obj-y += qapi/qapi-types-tpm.o
19+
util-obj-y += qapi/qapi-types-trace.o
20+
util-obj-y += qapi/qapi-types-transaction.o
21+
util-obj-y += qapi/qapi-types-ui.o
622
util-obj-y += qapi-builtin-visit.o
7-
util-obj-y += qmp-introspect.o qapi-types.o qapi-visit.o qapi-event.o
23+
util-obj-y += qapi-visit.o
24+
util-obj-y += qapi/qapi-visit-block-core.o
25+
util-obj-y += qapi/qapi-visit-block.o
26+
util-obj-y += qapi/qapi-visit-char.o
27+
util-obj-y += qapi/qapi-visit-common.o
28+
util-obj-y += qapi/qapi-visit-crypto.o
29+
util-obj-y += qapi/qapi-visit-introspect.o
30+
util-obj-y += qapi/qapi-visit-migration.o
31+
util-obj-y += qapi/qapi-visit-net.o
32+
util-obj-y += qapi/qapi-visit-rocker.o
33+
util-obj-y += qapi/qapi-visit-run-state.o
34+
util-obj-y += qapi/qapi-visit-sockets.o
35+
util-obj-y += qapi/qapi-visit-tpm.o
36+
util-obj-y += qapi/qapi-visit-trace.o
37+
util-obj-y += qapi/qapi-visit-transaction.o
38+
util-obj-y += qapi/qapi-visit-ui.o
39+
util-obj-y += qapi-event.o
40+
util-obj-y += qapi/qapi-events-block-core.o
41+
util-obj-y += qapi/qapi-events-block.o
42+
util-obj-y += qapi/qapi-events-char.o
43+
util-obj-y += qapi/qapi-events-common.o
44+
util-obj-y += qapi/qapi-events-crypto.o
45+
util-obj-y += qapi/qapi-events-introspect.o
46+
util-obj-y += qapi/qapi-events-migration.o
47+
util-obj-y += qapi/qapi-events-net.o
48+
util-obj-y += qapi/qapi-events-rocker.o
49+
util-obj-y += qapi/qapi-events-run-state.o
50+
util-obj-y += qapi/qapi-events-sockets.o
51+
util-obj-y += qapi/qapi-events-tpm.o
52+
util-obj-y += qapi/qapi-events-trace.o
53+
util-obj-y += qapi/qapi-events-transaction.o
54+
util-obj-y += qapi/qapi-events-ui.o
55+
util-obj-y += qmp-introspect.o
856

957
chardev-obj-y = chardev/
1058

@@ -81,6 +129,21 @@ common-obj-$(CONFIG_FDT) += device_tree.o
81129
# qapi
82130

83131
common-obj-y += qmp-commands.o
132+
common-obj-y += qapi/qapi-commands-block-core.o
133+
common-obj-y += qapi/qapi-commands-block.o
134+
common-obj-y += qapi/qapi-commands-char.o
135+
common-obj-y += qapi/qapi-commands-common.o
136+
common-obj-y += qapi/qapi-commands-crypto.o
137+
common-obj-y += qapi/qapi-commands-introspect.o
138+
common-obj-y += qapi/qapi-commands-migration.o
139+
common-obj-y += qapi/qapi-commands-net.o
140+
common-obj-y += qapi/qapi-commands-rocker.o
141+
common-obj-y += qapi/qapi-commands-run-state.o
142+
common-obj-y += qapi/qapi-commands-sockets.o
143+
common-obj-y += qapi/qapi-commands-tpm.o
144+
common-obj-y += qapi/qapi-commands-trace.o
145+
common-obj-y += qapi/qapi-commands-transaction.o
146+
common-obj-y += qapi/qapi-commands-ui.o
84147
common-obj-y += qmp-introspect.o
85148
common-obj-y += qmp.o hmp.o
86149
endif

scripts/qapi/commands.py

+24-11
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,24 @@ def gen_registry(registry, prefix):
223223
return ret
224224

225225

226-
class QAPISchemaGenCommandVisitor(QAPISchemaMonolithicCVisitor):
226+
class QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor):
227227

228228
def __init__(self, prefix):
229-
QAPISchemaMonolithicCVisitor.__init__(
230-
self, prefix, 'qmp-commands',
229+
QAPISchemaModularCVisitor.__init__(
230+
self, prefix, 'qapi-commands',
231231
' * Schema-defined QAPI/QMP commands', __doc__)
232232
self._regy = ''
233-
self._visited_ret_types = set()
233+
self._visited_ret_types = {}
234+
235+
# Temporary HACK:
236+
def _module_basename(self, what, name):
237+
basename = QAPISchemaModularCVisitor._module_basename(self, what, name)
238+
if name == self._main_module:
239+
return re.sub(r'qapi-commands', 'qmp-commands', basename)
240+
return basename
241+
242+
def _begin_module(self, name):
243+
self._visited_ret_types[self._genc] = set()
234244
self._genc.add(mcgen('''
235245
#include "qemu/osdep.h"
236246
#include "qemu-common.h"
@@ -246,26 +256,29 @@ def __init__(self, prefix):
246256
#include "%(prefix)sqmp-commands.h"
247257
248258
''',
249-
prefix=prefix))
259+
prefix=self._prefix))
250260
self._genh.add(mcgen('''
251261
#include "%(prefix)sqapi-types.h"
252262
#include "qapi/qmp/dispatch.h"
253263
254-
void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds);
255264
''',
256-
prefix=prefix,
257-
c_prefix=c_name(prefix, protect=False)))
265+
prefix=self._prefix))
258266

259267
def visit_end(self):
260-
self._genc.add(gen_registry(self._regy, self._prefix))
268+
(genc, genh) = self._module[self._main_module]
269+
genh.add(mcgen('''
270+
void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds);
271+
''',
272+
c_prefix=c_name(self._prefix, protect=False)))
273+
genc.add(gen_registry(self._regy, self._prefix))
261274

262275
def visit_command(self, name, info, arg_type, ret_type,
263276
gen, success_response, boxed):
264277
if not gen:
265278
return
266279
self._genh.add(gen_command_decl(name, arg_type, boxed, ret_type))
267-
if ret_type and ret_type not in self._visited_ret_types:
268-
self._visited_ret_types.add(ret_type)
280+
if ret_type and ret_type not in self._visited_ret_types[self._genc]:
281+
self._visited_ret_types[self._genc].add(ret_type)
269282
self._genc.add(gen_marshal_output(ret_type))
270283
self._genh.add(gen_marshal_decl(name))
271284
self._genc.add(gen_marshal(name, arg_type, boxed, ret_type))

0 commit comments

Comments
 (0)