Statistics
| Branch: | Revision:

root / scripts / qapi-visit.py @ d131c897

History | View | Annotate | Download (10 kB)

1 06d64c62 Michael Roth
#
2 06d64c62 Michael Roth
# QAPI visitor generator
3 06d64c62 Michael Roth
#
4 06d64c62 Michael Roth
# Copyright IBM, Corp. 2011
5 06d64c62 Michael Roth
#
6 06d64c62 Michael Roth
# Authors:
7 06d64c62 Michael Roth
#  Anthony Liguori <aliguori@us.ibm.com>
8 06d64c62 Michael Roth
#  Michael Roth    <mdroth@linux.vnet.ibm.com>
9 06d64c62 Michael Roth
#
10 06d64c62 Michael Roth
# This work is licensed under the terms of the GNU GPLv2.
11 06d64c62 Michael Roth
# See the COPYING.LIB file in the top-level directory.
12 06d64c62 Michael Roth
13 06d64c62 Michael Roth
from ordereddict import OrderedDict
14 06d64c62 Michael Roth
from qapi import *
15 06d64c62 Michael Roth
import sys
16 06d64c62 Michael Roth
import os
17 06d64c62 Michael Roth
import getopt
18 06d64c62 Michael Roth
import errno
19 06d64c62 Michael Roth
20 d131c897 Kevin Wolf
def generate_visit_struct_fields(field_prefix, members):
21 d131c897 Kevin Wolf
    ret = ''
22 d195325b Paolo Bonzini
23 06d64c62 Michael Roth
    for argname, argentry, optional, structured in parse_args(members):
24 06d64c62 Michael Roth
        if optional:
25 06d64c62 Michael Roth
            ret += mcgen('''
26 d195325b Paolo Bonzini
visit_start_optional(m, obj ? &(*obj)->%(c_prefix)shas_%(c_name)s : NULL, "%(name)s", &err);
27 d195325b Paolo Bonzini
if (obj && (*obj)->%(prefix)shas_%(c_name)s) {
28 06d64c62 Michael Roth
''',
29 06d64c62 Michael Roth
                         c_prefix=c_var(field_prefix), prefix=field_prefix,
30 06d64c62 Michael Roth
                         c_name=c_var(argname), name=argname)
31 06d64c62 Michael Roth
            push_indent()
32 06d64c62 Michael Roth
33 06d64c62 Michael Roth
        if structured:
34 d195325b Paolo Bonzini
            ret += generate_visit_struct_body(field_prefix + argname, argname, argentry)
35 06d64c62 Michael Roth
        else:
36 06d64c62 Michael Roth
            ret += mcgen('''
37 d195325b Paolo Bonzini
visit_type_%(type)s(m, obj ? &(*obj)->%(c_prefix)s%(c_name)s : NULL, "%(name)s", &err);
38 06d64c62 Michael Roth
''',
39 06d64c62 Michael Roth
                         c_prefix=c_var(field_prefix), prefix=field_prefix,
40 06d64c62 Michael Roth
                         type=type_name(argentry), c_name=c_var(argname),
41 06d64c62 Michael Roth
                         name=argname)
42 06d64c62 Michael Roth
43 06d64c62 Michael Roth
        if optional:
44 06d64c62 Michael Roth
            pop_indent()
45 06d64c62 Michael Roth
            ret += mcgen('''
46 06d64c62 Michael Roth
}
47 d195325b Paolo Bonzini
visit_end_optional(m, &err);
48 d195325b Paolo Bonzini
''')
49 d195325b Paolo Bonzini
50 d131c897 Kevin Wolf
    return ret
51 d131c897 Kevin Wolf
52 d131c897 Kevin Wolf
53 d131c897 Kevin Wolf
def generate_visit_struct_body(field_prefix, name, members):
54 d131c897 Kevin Wolf
    ret = mcgen('''
55 d131c897 Kevin Wolf
if (!error_is_set(errp)) {
56 d131c897 Kevin Wolf
''')
57 d131c897 Kevin Wolf
    push_indent()
58 d131c897 Kevin Wolf
59 d131c897 Kevin Wolf
    if len(field_prefix):
60 d131c897 Kevin Wolf
        field_prefix = field_prefix + "."
61 d131c897 Kevin Wolf
        ret += mcgen('''
62 d131c897 Kevin Wolf
Error **errp = &err; /* from outer scope */
63 d131c897 Kevin Wolf
Error *err = NULL;
64 d131c897 Kevin Wolf
visit_start_struct(m, NULL, "", "%(name)s", 0, &err);
65 d131c897 Kevin Wolf
''',
66 d131c897 Kevin Wolf
                name=name)
67 d131c897 Kevin Wolf
    else:
68 d131c897 Kevin Wolf
        ret += mcgen('''
69 d131c897 Kevin Wolf
Error *err = NULL;
70 d131c897 Kevin Wolf
visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err);
71 d131c897 Kevin Wolf
''',
72 d131c897 Kevin Wolf
                name=name)
73 d131c897 Kevin Wolf
74 d195325b Paolo Bonzini
    ret += mcgen('''
75 d131c897 Kevin Wolf
if (!err) {
76 d131c897 Kevin Wolf
    if (!obj || *obj) {
77 d131c897 Kevin Wolf
''')
78 d131c897 Kevin Wolf
    push_indent()
79 d131c897 Kevin Wolf
    push_indent()
80 d195325b Paolo Bonzini
81 d131c897 Kevin Wolf
    ret += generate_visit_struct_fields(field_prefix, members)
82 d131c897 Kevin Wolf
    pop_indent()
83 d131c897 Kevin Wolf
    ret += mcgen('''
84 d195325b Paolo Bonzini
    error_propagate(errp, err);
85 d195325b Paolo Bonzini
    err = NULL;
86 d195325b Paolo Bonzini
}
87 d195325b Paolo Bonzini
''')
88 d195325b Paolo Bonzini
89 d195325b Paolo Bonzini
    pop_indent()
90 d195325b Paolo Bonzini
    pop_indent()
91 d195325b Paolo Bonzini
    ret += mcgen('''
92 d195325b Paolo Bonzini
        /* Always call end_struct if start_struct succeeded.  */
93 d195325b Paolo Bonzini
        visit_end_struct(m, &err);
94 d195325b Paolo Bonzini
    }
95 d195325b Paolo Bonzini
    error_propagate(errp, err);
96 d195325b Paolo Bonzini
}
97 06d64c62 Michael Roth
''')
98 06d64c62 Michael Roth
    return ret
99 06d64c62 Michael Roth
100 06d64c62 Michael Roth
def generate_visit_struct(name, members):
101 06d64c62 Michael Roth
    ret = mcgen('''
102 06d64c62 Michael Roth

103 06d64c62 Michael Roth
void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **errp)
104 06d64c62 Michael Roth
{
105 06d64c62 Michael Roth
''',
106 06d64c62 Michael Roth
                name=name)
107 d195325b Paolo Bonzini
108 06d64c62 Michael Roth
    push_indent()
109 d195325b Paolo Bonzini
    ret += generate_visit_struct_body("", name, members)
110 06d64c62 Michael Roth
    pop_indent()
111 06d64c62 Michael Roth
112 06d64c62 Michael Roth
    ret += mcgen('''
113 06d64c62 Michael Roth
}
114 06d64c62 Michael Roth
''')
115 06d64c62 Michael Roth
    return ret
116 06d64c62 Michael Roth
117 06d64c62 Michael Roth
def generate_visit_list(name, members):
118 06d64c62 Michael Roth
    return mcgen('''
119 06d64c62 Michael Roth

120 06d64c62 Michael Roth
void visit_type_%(name)sList(Visitor *m, %(name)sList ** obj, const char *name, Error **errp)
121 06d64c62 Michael Roth
{
122 3a86a0fa Paolo Bonzini
    GenericList *i, **prev = (GenericList **)obj;
123 d195325b Paolo Bonzini
    Error *err = NULL;
124 06d64c62 Michael Roth

125 d195325b Paolo Bonzini
    if (!error_is_set(errp)) {
126 d195325b Paolo Bonzini
        visit_start_list(m, name, &err);
127 d195325b Paolo Bonzini
        if (!err) {
128 d195325b Paolo Bonzini
            for (; (i = visit_next_list(m, prev, &err)) != NULL; prev = &i) {
129 d195325b Paolo Bonzini
                %(name)sList *native_i = (%(name)sList *)i;
130 d195325b Paolo Bonzini
                visit_type_%(name)s(m, &native_i->value, NULL, &err);
131 d195325b Paolo Bonzini
            }
132 d195325b Paolo Bonzini
            error_propagate(errp, err);
133 d195325b Paolo Bonzini
            err = NULL;
134 d195325b Paolo Bonzini

135 d195325b Paolo Bonzini
            /* Always call end_list if start_list succeeded.  */
136 d195325b Paolo Bonzini
            visit_end_list(m, &err);
137 d195325b Paolo Bonzini
        }
138 d195325b Paolo Bonzini
        error_propagate(errp, err);
139 06d64c62 Michael Roth
    }
140 06d64c62 Michael Roth
}
141 06d64c62 Michael Roth
''',
142 06d64c62 Michael Roth
                name=name)
143 06d64c62 Michael Roth
144 06d64c62 Michael Roth
def generate_visit_enum(name, members):
145 06d64c62 Michael Roth
    return mcgen('''
146 06d64c62 Michael Roth

147 06d64c62 Michael Roth
void visit_type_%(name)s(Visitor *m, %(name)s * obj, const char *name, Error **errp)
148 06d64c62 Michael Roth
{
149 06d64c62 Michael Roth
    visit_type_enum(m, (int *)obj, %(name)s_lookup, "%(name)s", name, errp);
150 06d64c62 Michael Roth
}
151 06d64c62 Michael Roth
''',
152 06d64c62 Michael Roth
                 name=name)
153 06d64c62 Michael Roth
154 06d64c62 Michael Roth
def generate_visit_union(name, members):
155 06d64c62 Michael Roth
    ret = generate_visit_enum('%sKind' % name, members.keys())
156 06d64c62 Michael Roth
157 06d64c62 Michael Roth
    ret += mcgen('''
158 06d64c62 Michael Roth

159 06d64c62 Michael Roth
void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **errp)
160 06d64c62 Michael Roth
{
161 dc8fb6df Paolo Bonzini
    Error *err = NULL;
162 dc8fb6df Paolo Bonzini

163 d195325b Paolo Bonzini
    if (!error_is_set(errp)) {
164 d195325b Paolo Bonzini
        visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err);
165 d195325b Paolo Bonzini
        if (!err) {
166 227ccf6b Stefan Weil
            if (obj && *obj) {
167 d195325b Paolo Bonzini
                visit_type_%(name)sKind(m, &(*obj)->kind, "type", &err);
168 d195325b Paolo Bonzini
                if (!err) {
169 d195325b Paolo Bonzini
                    switch ((*obj)->kind) {
170 06d64c62 Michael Roth
''',
171 06d64c62 Michael Roth
                 name=name)
172 06d64c62 Michael Roth
173 d195325b Paolo Bonzini
    push_indent()
174 d195325b Paolo Bonzini
    push_indent()
175 dc8fb6df Paolo Bonzini
    for key in members:
176 dc8fb6df Paolo Bonzini
        ret += mcgen('''
177 d195325b Paolo Bonzini
            case %(abbrev)s_KIND_%(enum)s:
178 d195325b Paolo Bonzini
                visit_type_%(c_type)s(m, &(*obj)->%(c_name)s, "data", &err);
179 d195325b Paolo Bonzini
                break;
180 dc8fb6df Paolo Bonzini
''',
181 dc8fb6df Paolo Bonzini
                abbrev = de_camel_case(name).upper(),
182 eda50a65 Paolo Bonzini
                enum = c_fun(de_camel_case(key),False).upper(),
183 c664aef5 Michael Roth
                c_type=type_name(members[key]),
184 c9da228b Federico Simoncelli
                c_name=c_fun(key))
185 dc8fb6df Paolo Bonzini
186 dc8fb6df Paolo Bonzini
    ret += mcgen('''
187 d195325b Paolo Bonzini
            default:
188 d195325b Paolo Bonzini
                abort();
189 d195325b Paolo Bonzini
            }
190 d195325b Paolo Bonzini
        }
191 d195325b Paolo Bonzini
        error_propagate(errp, err);
192 d195325b Paolo Bonzini
        err = NULL;
193 d195325b Paolo Bonzini
    }
194 d195325b Paolo Bonzini
''')
195 d195325b Paolo Bonzini
    pop_indent()
196 d195325b Paolo Bonzini
    ret += mcgen('''
197 d195325b Paolo Bonzini
        /* Always call end_struct if start_struct succeeded.  */
198 d195325b Paolo Bonzini
        visit_end_struct(m, &err);
199 dc8fb6df Paolo Bonzini
    }
200 d195325b Paolo Bonzini
    error_propagate(errp, err);
201 d195325b Paolo Bonzini
}
202 d195325b Paolo Bonzini
''')
203 d195325b Paolo Bonzini
204 d195325b Paolo Bonzini
    pop_indent();
205 d195325b Paolo Bonzini
    ret += mcgen('''
206 dc8fb6df Paolo Bonzini
}
207 dc8fb6df Paolo Bonzini
''')
208 dc8fb6df Paolo Bonzini
209 06d64c62 Michael Roth
    return ret
210 06d64c62 Michael Roth
211 7c946bc4 Michael Roth
def generate_declaration(name, members, genlist=True, builtin_type=False):
212 7c946bc4 Michael Roth
    ret = ""
213 7c946bc4 Michael Roth
    if not builtin_type:
214 7c946bc4 Michael Roth
        ret += mcgen('''
215 06d64c62 Michael Roth

216 06d64c62 Michael Roth
void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **errp);
217 06d64c62 Michael Roth
''',
218 7c946bc4 Michael Roth
                    name=name)
219 06d64c62 Michael Roth
220 06d64c62 Michael Roth
    if genlist:
221 06d64c62 Michael Roth
        ret += mcgen('''
222 06d64c62 Michael Roth
void visit_type_%(name)sList(Visitor *m, %(name)sList ** obj, const char *name, Error **errp);
223 06d64c62 Michael Roth
''',
224 06d64c62 Michael Roth
                 name=name)
225 06d64c62 Michael Roth
226 06d64c62 Michael Roth
    return ret
227 06d64c62 Michael Roth
228 b9c4b48d Amos Kong
def generate_enum_declaration(name, members, genlist=True):
229 b9c4b48d Amos Kong
    ret = ""
230 b9c4b48d Amos Kong
    if genlist:
231 b9c4b48d Amos Kong
        ret += mcgen('''
232 b9c4b48d Amos Kong
void visit_type_%(name)sList(Visitor *m, %(name)sList ** obj, const char *name, Error **errp);
233 b9c4b48d Amos Kong
''',
234 b9c4b48d Amos Kong
                     name=name)
235 b9c4b48d Amos Kong
236 b9c4b48d Amos Kong
    return ret
237 b9c4b48d Amos Kong
238 06d64c62 Michael Roth
def generate_decl_enum(name, members, genlist=True):
239 06d64c62 Michael Roth
    return mcgen('''
240 06d64c62 Michael Roth

241 06d64c62 Michael Roth
void visit_type_%(name)s(Visitor *m, %(name)s * obj, const char *name, Error **errp);
242 06d64c62 Michael Roth
''',
243 06d64c62 Michael Roth
                name=name)
244 06d64c62 Michael Roth
245 06d64c62 Michael Roth
try:
246 7c946bc4 Michael Roth
    opts, args = getopt.gnu_getopt(sys.argv[1:], "chbp:o:",
247 7c946bc4 Michael Roth
                                   ["source", "header", "builtins", "prefix=",
248 7c946bc4 Michael Roth
                                    "output-dir="])
249 06d64c62 Michael Roth
except getopt.GetoptError, err:
250 06d64c62 Michael Roth
    print str(err)
251 06d64c62 Michael Roth
    sys.exit(1)
252 06d64c62 Michael Roth
253 06d64c62 Michael Roth
output_dir = ""
254 06d64c62 Michael Roth
prefix = ""
255 06d64c62 Michael Roth
c_file = 'qapi-visit.c'
256 06d64c62 Michael Roth
h_file = 'qapi-visit.h'
257 06d64c62 Michael Roth
258 8d3bc517 Avi Kivity
do_c = False
259 8d3bc517 Avi Kivity
do_h = False
260 7c946bc4 Michael Roth
do_builtins = False
261 8d3bc517 Avi Kivity
262 06d64c62 Michael Roth
for o, a in opts:
263 06d64c62 Michael Roth
    if o in ("-p", "--prefix"):
264 06d64c62 Michael Roth
        prefix = a
265 06d64c62 Michael Roth
    elif o in ("-o", "--output-dir"):
266 06d64c62 Michael Roth
        output_dir = a + "/"
267 8d3bc517 Avi Kivity
    elif o in ("-c", "--source"):
268 8d3bc517 Avi Kivity
        do_c = True
269 19bf7c87 Avi Kivity
    elif o in ("-h", "--header"):
270 19bf7c87 Avi Kivity
        do_h = True
271 7c946bc4 Michael Roth
    elif o in ("-b", "--builtins"):
272 7c946bc4 Michael Roth
        do_builtins = True
273 8d3bc517 Avi Kivity
274 8d3bc517 Avi Kivity
if not do_c and not do_h:
275 8d3bc517 Avi Kivity
    do_c = True
276 8d3bc517 Avi Kivity
    do_h = True
277 06d64c62 Michael Roth
278 06d64c62 Michael Roth
c_file = output_dir + prefix + c_file
279 06d64c62 Michael Roth
h_file = output_dir + prefix + h_file
280 06d64c62 Michael Roth
281 06d64c62 Michael Roth
try:
282 06d64c62 Michael Roth
    os.makedirs(output_dir)
283 06d64c62 Michael Roth
except os.error, e:
284 06d64c62 Michael Roth
    if e.errno != errno.EEXIST:
285 06d64c62 Michael Roth
        raise
286 06d64c62 Michael Roth
287 8d3bc517 Avi Kivity
def maybe_open(really, name, opt):
288 8d3bc517 Avi Kivity
    if really:
289 8d3bc517 Avi Kivity
        return open(name, opt)
290 19bf7c87 Avi Kivity
    else:
291 19bf7c87 Avi Kivity
        import StringIO
292 19bf7c87 Avi Kivity
        return StringIO.StringIO()
293 8d3bc517 Avi Kivity
294 8d3bc517 Avi Kivity
fdef = maybe_open(do_c, c_file, 'w')
295 8d3bc517 Avi Kivity
fdecl = maybe_open(do_h, h_file, 'w')
296 06d64c62 Michael Roth
297 06d64c62 Michael Roth
fdef.write(mcgen('''
298 06d64c62 Michael Roth
/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */
299 06d64c62 Michael Roth

300 06d64c62 Michael Roth
/*
301 06d64c62 Michael Roth
 * schema-defined QAPI visitor functions
302 06d64c62 Michael Roth
 *
303 06d64c62 Michael Roth
 * Copyright IBM, Corp. 2011
304 06d64c62 Michael Roth
 *
305 06d64c62 Michael Roth
 * Authors:
306 06d64c62 Michael Roth
 *  Anthony Liguori   <aliguori@us.ibm.com>
307 06d64c62 Michael Roth
 *
308 06d64c62 Michael Roth
 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
309 06d64c62 Michael Roth
 * See the COPYING.LIB file in the top-level directory.
310 06d64c62 Michael Roth
 *
311 06d64c62 Michael Roth
 */
312 06d64c62 Michael Roth

313 79ee7df8 Paolo Bonzini
#include "qemu-common.h"
314 06d64c62 Michael Roth
#include "%(header)s"
315 06d64c62 Michael Roth
''',
316 06d64c62 Michael Roth
                 header=basename(h_file)))
317 06d64c62 Michael Roth
318 06d64c62 Michael Roth
fdecl.write(mcgen('''
319 06d64c62 Michael Roth
/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */
320 06d64c62 Michael Roth

321 06d64c62 Michael Roth
/*
322 06d64c62 Michael Roth
 * schema-defined QAPI visitor function
323 06d64c62 Michael Roth
 *
324 06d64c62 Michael Roth
 * Copyright IBM, Corp. 2011
325 06d64c62 Michael Roth
 *
326 06d64c62 Michael Roth
 * Authors:
327 06d64c62 Michael Roth
 *  Anthony Liguori   <aliguori@us.ibm.com>
328 06d64c62 Michael Roth
 *
329 06d64c62 Michael Roth
 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
330 06d64c62 Michael Roth
 * See the COPYING.LIB file in the top-level directory.
331 06d64c62 Michael Roth
 *
332 06d64c62 Michael Roth
 */
333 06d64c62 Michael Roth

334 06d64c62 Michael Roth
#ifndef %(guard)s
335 06d64c62 Michael Roth
#define %(guard)s
336 06d64c62 Michael Roth

337 7b1b5d19 Paolo Bonzini
#include "qapi/visitor.h"
338 06d64c62 Michael Roth
#include "%(prefix)sqapi-types.h"
339 7c946bc4 Michael Roth

340 06d64c62 Michael Roth
''',
341 06d64c62 Michael Roth
                  prefix=prefix, guard=guardname(h_file)))
342 06d64c62 Michael Roth
343 06d64c62 Michael Roth
exprs = parse_schema(sys.stdin)
344 06d64c62 Michael Roth
345 7c946bc4 Michael Roth
# to avoid header dependency hell, we always generate declarations
346 7c946bc4 Michael Roth
# for built-in types in our header files and simply guard them
347 7c946bc4 Michael Roth
fdecl.write(guardstart("QAPI_VISIT_BUILTIN_VISITOR_DECL"))
348 7c946bc4 Michael Roth
for typename in builtin_types:
349 7c946bc4 Michael Roth
    fdecl.write(generate_declaration(typename, None, genlist=True,
350 7c946bc4 Michael Roth
                                     builtin_type=True))
351 7c946bc4 Michael Roth
fdecl.write(guardend("QAPI_VISIT_BUILTIN_VISITOR_DECL"))
352 7c946bc4 Michael Roth
353 7c946bc4 Michael Roth
# ...this doesn't work for cases where we link in multiple objects that
354 7c946bc4 Michael Roth
# have the functions defined, so we use -b option to provide control
355 7c946bc4 Michael Roth
# over these cases
356 7c946bc4 Michael Roth
if do_builtins:
357 7c946bc4 Michael Roth
    fdef.write(guardstart("QAPI_VISIT_BUILTIN_VISITOR_DEF"))
358 7c946bc4 Michael Roth
    for typename in builtin_types:
359 7c946bc4 Michael Roth
        fdef.write(generate_visit_list(typename, None))
360 7c946bc4 Michael Roth
    fdef.write(guardend("QAPI_VISIT_BUILTIN_VISITOR_DEF"))
361 7c946bc4 Michael Roth
362 06d64c62 Michael Roth
for expr in exprs:
363 06d64c62 Michael Roth
    if expr.has_key('type'):
364 06d64c62 Michael Roth
        ret = generate_visit_struct(expr['type'], expr['data'])
365 06d64c62 Michael Roth
        ret += generate_visit_list(expr['type'], expr['data'])
366 06d64c62 Michael Roth
        fdef.write(ret)
367 06d64c62 Michael Roth
368 06d64c62 Michael Roth
        ret = generate_declaration(expr['type'], expr['data'])
369 06d64c62 Michael Roth
        fdecl.write(ret)
370 06d64c62 Michael Roth
    elif expr.has_key('union'):
371 06d64c62 Michael Roth
        ret = generate_visit_union(expr['union'], expr['data'])
372 dc8fb6df Paolo Bonzini
        ret += generate_visit_list(expr['union'], expr['data'])
373 06d64c62 Michael Roth
        fdef.write(ret)
374 06d64c62 Michael Roth
375 06d64c62 Michael Roth
        ret = generate_decl_enum('%sKind' % expr['union'], expr['data'].keys())
376 06d64c62 Michael Roth
        ret += generate_declaration(expr['union'], expr['data'])
377 06d64c62 Michael Roth
        fdecl.write(ret)
378 06d64c62 Michael Roth
    elif expr.has_key('enum'):
379 b9c4b48d Amos Kong
        ret = generate_visit_list(expr['enum'], expr['data'])
380 b9c4b48d Amos Kong
        ret += generate_visit_enum(expr['enum'], expr['data'])
381 06d64c62 Michael Roth
        fdef.write(ret)
382 06d64c62 Michael Roth
383 06d64c62 Michael Roth
        ret = generate_decl_enum(expr['enum'], expr['data'])
384 b9c4b48d Amos Kong
        ret += generate_enum_declaration(expr['enum'], expr['data'])
385 06d64c62 Michael Roth
        fdecl.write(ret)
386 06d64c62 Michael Roth
387 06d64c62 Michael Roth
fdecl.write('''
388 06d64c62 Michael Roth
#endif
389 06d64c62 Michael Roth
''')
390 06d64c62 Michael Roth
391 06d64c62 Michael Roth
fdecl.flush()
392 06d64c62 Michael Roth
fdecl.close()
393 06d64c62 Michael Roth
394 06d64c62 Michael Roth
fdef.flush()
395 06d64c62 Michael Roth
fdef.close()