blob: 7c383c27472de0273fda3cc113fb0f3f2f05d732 [file] [log] [blame]
Ole Troan9d420872017-10-12 13:06:35 +02001# C generation
2import datetime
3import os
Nirmoy Dasc9f40222018-06-28 10:18:43 +02004import time
Ole Troan33a58172019-09-04 09:12:29 +02005import sys
6from io import StringIO
Ole Troan9d420872017-10-12 13:06:35 +02007
Ole Troan413f4a52018-11-28 11:36:05 +01008datestring = datetime.datetime.utcfromtimestamp(
9 int(os.environ.get('SOURCE_DATE_EPOCH', time.time())))
Ole Troan9d420872017-10-12 13:06:35 +020010input_filename = 'inputfil'
11top_boilerplate = '''\
12/*
13 * VLIB API definitions {datestring}
14 * Input file: {input_filename}
15 * Automatically generated: please edit the input file NOT this file!
16 */
17
Ole Troan288e0932019-05-29 12:30:05 +020018#include <stdbool.h>
Ole Troan9d420872017-10-12 13:06:35 +020019#if defined(vl_msg_id)||defined(vl_union_id) \\
20 || defined(vl_printfun) ||defined(vl_endianfun) \\
21 || defined(vl_api_version)||defined(vl_typedefs) \\
22 || defined(vl_msg_name)||defined(vl_msg_name_crc_list) \\
23 || defined(vl_api_version_tuple)
24/* ok, something was selected */
25#else
26#warning no content included from {input_filename}
27#endif
28
29#define VL_API_PACKED(x) x __attribute__ ((packed))
30'''
31
32bottom_boilerplate = '''\
33/****** API CRC (whole file) *****/
34
35#ifdef vl_api_version
36vl_api_version({input_filename}, {file_crc:#08x})
37
38#endif
39'''
40
41
42def msg_ids(s):
43 output = '''\
44
45/****** Message ID / handler enum ******/
46
47#ifdef vl_msg_id
48'''
49
Ole Troan2c2feab2018-04-24 00:02:37 -040050 for t in s['Define']:
Ole Troan9d420872017-10-12 13:06:35 +020051 output += "vl_msg_id(VL_API_%s, vl_api_%s_t_handler)\n" % \
52 (t.name.upper(), t.name)
53 output += "#endif"
54
55 return output
56
57
58def msg_names(s):
59 output = '''\
60
61/****** Message names ******/
62
63#ifdef vl_msg_name
64'''
65
Ole Troan2c2feab2018-04-24 00:02:37 -040066 for t in s['Define']:
Ole Troan9d420872017-10-12 13:06:35 +020067 dont_trace = 0 if t.dont_trace else 1
68 output += "vl_msg_name(vl_api_%s_t, %d)\n" % (t.name, dont_trace)
69 output += "#endif"
70
71 return output
72
73
74def msg_name_crc_list(s, suffix):
75 output = '''\
76
77/****** Message name, crc list ******/
78
79#ifdef vl_msg_name_crc_list
80'''
81 output += "#define foreach_vl_msg_name_crc_%s " % suffix
82
Ole Troan2c2feab2018-04-24 00:02:37 -040083 for t in s['Define']:
Ole Troan9d420872017-10-12 13:06:35 +020084 output += "\\\n_(VL_API_%s, %s, %08x) " % \
85 (t.name.upper(), t.name, t.crc)
86 output += "\n#endif"
87
88 return output
89
90
Ole Troan413f4a52018-11-28 11:36:05 +010091def api2c(fieldtype):
92 mappingtable = {'string': 'vl_api_string_t', }
93 if fieldtype in mappingtable:
94 return mappingtable[fieldtype]
95 return fieldtype
96
97
Ole Troan75761b92019-09-11 17:49:08 +020098def typedefs(objs, filename):
Ole Troan9d420872017-10-12 13:06:35 +020099 name = filename.replace('.', '_')
100 output = '''\
101
102
103/****** Typedefs ******/
104
105#ifdef vl_typedefs
Ole Troan33a58172019-09-04 09:12:29 +0200106#ifndef included_{module}_typedef
107#define included_{module}_typedef
Ole Troan9d420872017-10-12 13:06:35 +0200108'''
109 output = output.format(module=name)
Ole Troan53fffa12018-11-13 12:36:56 +0100110
Ole Troan2c2feab2018-04-24 00:02:37 -0400111 for o in objs:
112 tname = o.__class__.__name__
Ole Troan75761b92019-09-11 17:49:08 +0200113 if tname == 'Using':
114 if 'length' in o.alias:
115 output += 'typedef %s vl_api_%s_t[%s];\n' % (o.alias['type'], o.name, o.alias['length'])
116 else:
117 output += 'typedef %s vl_api_%s_t;\n' % (o.alias['type'], o.name)
118 elif tname == 'Enum':
Andrew Yourtchenko5c4b9f12019-03-19 14:52:29 +0100119 if o.enumtype == 'u32':
120 output += "typedef enum {\n"
121 else:
122 output += "typedef enum __attribute__((__packed__)) {\n"
123
Ole Troan2c2feab2018-04-24 00:02:37 -0400124 for b in o.block:
125 output += " %s = %s,\n" % (b[0], b[1])
126 output += '} vl_api_%s_t;\n' % o.name
Andrew Yourtchenko5c4b9f12019-03-19 14:52:29 +0100127 if o.enumtype != 'u32':
128 size1 = 'sizeof(vl_api_%s_t)' % o.name
129 size2 = 'sizeof(%s)' % o.enumtype
130 err_str = 'size of API enum %s is wrong' % o.name
Ole Troan33a58172019-09-04 09:12:29 +0200131 output += ('STATIC_ASSERT(%s == %s, "%s");\n'
132 % (size1, size2, err_str))
Ole Troan2c2feab2018-04-24 00:02:37 -0400133 else:
134 if tname == 'Union':
135 output += "typedef VL_API_PACKED(union _vl_api_%s {\n" % o.name
Ole Troan9d420872017-10-12 13:06:35 +0200136 else:
Ole Troan33a58172019-09-04 09:12:29 +0200137 output += ("typedef VL_API_PACKED(struct _vl_api_%s {\n"
138 % o.name)
Ole Troan2c2feab2018-04-24 00:02:37 -0400139 for b in o.block:
Ole Troan33a58172019-09-04 09:12:29 +0200140 if b.type == 'Option':
141 continue
Ole Troan2c2feab2018-04-24 00:02:37 -0400142 if b.type == 'Field':
Ole Troan33a58172019-09-04 09:12:29 +0200143 output += " %s %s;\n" % (api2c(b.fieldtype),
144 b.fieldname)
Ole Troan2c2feab2018-04-24 00:02:37 -0400145 elif b.type == 'Array':
146 if b.lengthfield:
Ole Troan33a58172019-09-04 09:12:29 +0200147 output += " %s %s[0];\n" % (api2c(b.fieldtype),
148 b.fieldname)
Ole Troan2c2feab2018-04-24 00:02:37 -0400149 else:
Ole Troane5ff5a32019-08-23 22:55:18 +0200150 # Fixed length strings decay to nul terminated u8
151 if b.fieldtype == 'string':
152 if b.modern_vla:
Ole Troan33a58172019-09-04 09:12:29 +0200153 output += (' {} {};\n'
154 .format(api2c(b.fieldtype),
155 b.fieldname))
Ole Troane5ff5a32019-08-23 22:55:18 +0200156 else:
Ole Troan33a58172019-09-04 09:12:29 +0200157 output += (' u8 {}[{}];\n'
158 .format(b.fieldname, b.length))
Ole Troane5ff5a32019-08-23 22:55:18 +0200159 else:
Ole Troan33a58172019-09-04 09:12:29 +0200160 output += (" %s %s[%s];\n" %
161 (api2c(b.fieldtype), b.fieldname,
162 b.length))
Ole Troan2c2feab2018-04-24 00:02:37 -0400163 else:
Ole Troan33a58172019-09-04 09:12:29 +0200164 raise ValueError("Error in processing type {} for {}"
165 .format(b, o.name))
Ole Troan9d420872017-10-12 13:06:35 +0200166
Ole Troan2c2feab2018-04-24 00:02:37 -0400167 output += '}) vl_api_%s_t;\n' % o.name
Ole Troan9d420872017-10-12 13:06:35 +0200168
169 output += "\n#endif"
170 output += "\n#endif\n\n"
171
172 return output
173
174
175format_strings = {'u8': '%u',
Ole Troan33a58172019-09-04 09:12:29 +0200176 'bool': '%u',
Ole Troan9d420872017-10-12 13:06:35 +0200177 'i8': '%d',
178 'u16': '%u',
179 'i16': '%d',
180 'u32': '%u',
181 'i32': '%ld',
182 'u64': '%llu',
183 'i64': '%llu',
Ole Troan33a58172019-09-04 09:12:29 +0200184 'f64': '%.2f'}
185
186noprint_fields = {'_vl_msg_id': None,
187 'client_index': None,
188 'context': None}
Ole Troan9d420872017-10-12 13:06:35 +0200189
190
Ole Troan33a58172019-09-04 09:12:29 +0200191class Printfun():
192 _dispatch = {}
193
194 def __init__(self, stream):
195 self.stream = stream
196
197 def print_string(self, o, stream):
198 write = stream.write
199 if o.modern_vla:
200 write(' if (vl_api_string_len(&a->{f}) > 0) {{\n'
201 .format(f=o.fieldname))
202 write(' s = format(s, "\\n%U{f}: %.*s", '
203 'format_white_space, indent, '
204 'vl_api_string_len(&a->{f}) - 1, '
205 'vl_api_from_api_string(&a->{f}));\n'.format(f=o.fieldname))
206 write(' } else {\n')
207 write(' s = format(s, "\\n%U{f}:", '
208 'format_white_space, indent);\n'.format(f=o.fieldname))
209 write(' }\n')
210 else:
211 write(' s = format(s, "\\n%U{f}: %s", '
212 'format_white_space, indent, a->{f});\n'
213 .format(f=o.fieldname))
214
215 def print_field(self, o, stream):
216 write = stream.write
217 if o.fieldname in noprint_fields:
218 return
219 if o.fieldtype in format_strings:
220 f = format_strings[o.fieldtype]
221 write(' s = format(s, "\\n%U{n}: {f}", '
222 'format_white_space, indent, a->{n});\n'
223 .format(n=o.fieldname, f=f))
224 else:
225 write(' s = format(s, "\\n%U{n}: %U", '
226 'format_white_space, indent, '
227 'format_{t}, &a->{n}, indent);\n'
228 .format(n=o.fieldname, t=o.fieldtype))
229
230 _dispatch['Field'] = print_field
231
232 def print_array(self, o, stream):
233 write = stream.write
234
235 forloop = '''\
236 for (i = 0; i < {lfield}; i++) {{
237 s = format(s, "\\n%U{n}: %U",
238 format_white_space, indent, format_{t}, &a->{n}[i], indent);
239 }}
240'''
241
242 forloop_format = '''\
243 for (i = 0; i < {lfield}; i++) {{
244 s = format(s, "\\n%U{n}: {t}",
245 format_white_space, indent, a->{n}[i]);
246 }}
247'''
248
249 if o.fieldtype == 'string':
250 return self.print_string(o, stream)
251
252 if o.fieldtype == 'u8':
253 if o.lengthfield:
254 write(' s = format(s, "\\n%U{n}: %U", format_white_space, '
255 'indent, format_hex_bytes, a->{n}, a->{lfield});\n'
256 .format(n=o.fieldname, lfield=o.lengthfield))
257 else:
258 write(' s = format(s, "\\n%U{n}: %U", format_white_space, '
259 'indent, format_hex_bytes, a, {lfield});\n'
260 .format(n=o.fieldname, lfield=o.length))
261 return
262
263 lfield = 'a->' + o.lengthfield if o.lengthfield else o.length
264 if o.fieldtype in format_strings:
265 write(forloop_format.format(lfield=lfield,
266 t=format_strings[o.fieldtype],
267 n=o.fieldname))
268 else:
269 write(forloop.format(lfield=lfield, t=o.fieldtype, n=o.fieldname))
270
271 _dispatch['Array'] = print_array
272
273 def print_alias(self, k, v, stream):
274 write = stream.write
275 if ('length' in v.alias and v.alias['length'] and
276 v.alias['type'] == 'u8'):
277 write(' return format(s, "%U", format_hex_bytes, a, {});\n'
278 .format(v.alias['length']))
279 elif v.alias['type'] in format_strings:
280 write(' return format(s, "{}", *a);\n'
281 .format(format_strings[v.alias['type']]))
282 else:
Ole Troan75761b92019-09-11 17:49:08 +0200283 write(' return format(s, "{} (print not implemented)");\n'
Ole Troan33a58172019-09-04 09:12:29 +0200284 .format(k))
285
286 def print_enum(self, o, stream):
287 write = stream.write
288 write(" switch(*a) {\n")
289 for b in o:
290 write(" case %s:\n" % b[1])
291 write(' return format(s, "{}");\n'.format(b[0]))
292 write(' }\n')
293
294 _dispatch['Enum'] = print_enum
295
296 def print_obj(self, o, stream):
297 write = stream.write
298
299 if o.type in self._dispatch:
300 self._dispatch[o.type](self, o, stream)
301 else:
302 write(' s = format(s, "\\n{} {} {} (print not implemented");\n'
303 .format(o.type, o.fieldtype, o.fieldname))
304
305
306def printfun(objs, stream, modulename):
307 write = stream.write
308
309 h = '''\
Ole Troan9d420872017-10-12 13:06:35 +0200310/****** Print functions *****/
311#ifdef vl_printfun
Ole Troan33a58172019-09-04 09:12:29 +0200312#ifndef included_{module}_printfun
313#define included_{module}_printfun
Ole Troan9d420872017-10-12 13:06:35 +0200314
315#ifdef LP64
316#define _uword_fmt \"%lld\"
317#define _uword_cast (long long)
318#else
319#define _uword_fmt \"%ld\"
320#define _uword_cast long
321#endif
322
323'''
Ole Troan33a58172019-09-04 09:12:29 +0200324
325 signature = '''\
326static inline void *vl_api_{name}_t_print (vl_api_{name}_t *a, void *handle)
327{{
328 u8 *s = 0;
329 u32 indent __attribute__((unused)) = 2;
330 int i __attribute__((unused));
331'''
332
333 h = h.format(module=modulename)
334 write(h)
335
336 pp = Printfun(stream)
337 for t in objs:
338 if t.manual_print:
339 write("/***** manual: vl_api_%s_t_print *****/\n\n" % t.name)
340 continue
341 write(signature.format(name=t.name))
342 write(' /* Message definition: vl_api_{}_t: */\n'.format(t.name))
343 write(" s = format(s, \"vl_api_%s_t:\");\n" % t.name)
344 for o in t.block:
345 pp.print_obj(o, stream)
346 write(' vec_add1(s, 0);\n')
347 write(' vl_print (handle, (char *)s);\n')
348 write(' vec_free (s);\n')
349 write(' return handle;\n')
350 write('}\n\n')
351
352 write("\n#endif")
353 write("\n#endif /* vl_printfun */\n")
354
355 return ''
356
357
Ole Troan75761b92019-09-11 17:49:08 +0200358def printfun_types(objs, stream, modulename):
Ole Troan33a58172019-09-04 09:12:29 +0200359 write = stream.write
360 pp = Printfun(stream)
361
362 h = '''\
363/****** Print functions *****/
364#ifdef vl_printfun
365#ifndef included_{module}_printfun_types
366#define included_{module}_printfun_types
367
368'''
369 h = h.format(module=modulename)
370 write(h)
371
372 signature = '''\
373static inline u8 *format_vl_api_{name}_t (u8 *s, va_list * args)
374{{
375 vl_api_{name}_t *a = va_arg (*args, vl_api_{name}_t *);
376 u32 indent __attribute__((unused)) = va_arg (*args, u32);
377 int i __attribute__((unused));
378 indent += 2;
379'''
380
Ole Troan2c2feab2018-04-24 00:02:37 -0400381 for t in objs:
382 if t.__class__.__name__ == 'Enum':
Ole Troan33a58172019-09-04 09:12:29 +0200383 write(signature.format(name=t.name))
384 pp.print_enum(t.block, stream)
385 write(' return s;\n')
386 write('}\n\n')
Ole Troan2c2feab2018-04-24 00:02:37 -0400387 continue
Ole Troan33a58172019-09-04 09:12:29 +0200388
Ole Troan9d420872017-10-12 13:06:35 +0200389 if t.manual_print:
Ole Troan33a58172019-09-04 09:12:29 +0200390 write("/***** manual: vl_api_%s_t_print *****/\n\n" % t.name)
Ole Troan9d420872017-10-12 13:06:35 +0200391 continue
Ole Troan9d420872017-10-12 13:06:35 +0200392
Ole Troan75761b92019-09-11 17:49:08 +0200393 if t.__class__.__name__ == 'Using':
394 write(signature.format(name=t.name))
395 pp.print_alias(t.name, t, stream)
396 write('}\n\n')
397 continue
398
Ole Troan33a58172019-09-04 09:12:29 +0200399 write(signature.format(name=t.name))
Ole Troan9d420872017-10-12 13:06:35 +0200400 for o in t.block:
Ole Troan33a58172019-09-04 09:12:29 +0200401 pp.print_obj(o, stream)
Ole Troan9d420872017-10-12 13:06:35 +0200402
Ole Troan33a58172019-09-04 09:12:29 +0200403 write(' return s;\n')
404 write('}\n\n')
Ole Troan9d420872017-10-12 13:06:35 +0200405
Ole Troan33a58172019-09-04 09:12:29 +0200406 write("\n#endif")
407 write("\n#endif /* vl_printfun_types */\n")
Ole Troan9d420872017-10-12 13:06:35 +0200408
Ole Troan33a58172019-09-04 09:12:29 +0200409
410def imports(imports):
411 output = '/* Imported API files */\n'
412 output += '#ifndef vl_api_version\n'
413
414 for i in imports:
415 s = i.filename.replace('plugins/', '')
416 output += '#include <{}.h>\n'.format(s)
417 output += '#endif\n'
Ole Troan9d420872017-10-12 13:06:35 +0200418 return output
419
420
421endian_strings = {
422 'u16': 'clib_net_to_host_u16',
423 'u32': 'clib_net_to_host_u32',
424 'u64': 'clib_net_to_host_u64',
425 'i16': 'clib_net_to_host_u16',
426 'i32': 'clib_net_to_host_u32',
427 'i64': 'clib_net_to_host_u64',
Paul Vinciguerra07f87542019-07-30 18:24:41 -0400428 'f64': 'clib_net_to_host_u64',
Ole Troan9d420872017-10-12 13:06:35 +0200429}
430
431
Ole Troan33a58172019-09-04 09:12:29 +0200432def endianfun_array(o):
433 forloop = '''\
434 for (i = 0; i < {length}; i++) {{
435 a->{name}[i] = {format}(a->{name}[i]);
436 }}
437'''
438
439 forloop_format = '''\
440 for (i = 0; i < {length}; i++) {{
441 {type}_endian(&a->{name}[i]);
442 }}
443'''
444
445 output = ''
446 if o.fieldtype == 'u8' or o.fieldtype == 'string':
447 output += ' /* a->{n} = a->{n} (no-op) */\n'.format(n=o.fieldname)
448 else:
449 lfield = 'a->' + o.lengthfield if o.lengthfield else o.length
450 if o.fieldtype in endian_strings:
451 output += (forloop
452 .format(length=lfield,
453 format=endian_strings[o.fieldtype],
454 name=o.fieldname))
455 else:
456 output += (forloop_format
457 .format(length=lfield, type=o.fieldtype,
458 name=o.fieldname))
459 return output
460
461
462def endianfun_obj(o):
463 output = ''
464 if o.type == 'Array':
465 return endianfun_array(o)
466 elif o.type != 'Field':
467 output += (' s = format(s, "\\n{} {} {} (print not implemented");\n'
468 .format(o.type, o.fieldtype, o.fieldname))
469 return output
470 if o.fieldtype in endian_strings:
471 output += (' a->{name} = {format}(a->{name});\n'
472 .format(name=o.fieldname,
473 format=endian_strings[o.fieldtype]))
474 elif o.fieldtype.startswith('vl_api_'):
475 output += (' {type}_endian(&a->{name});\n'
476 .format(type=o.fieldtype, name=o.fieldname))
477 else:
478 output += ' /* a->{n} = a->{n} (no-op) */\n'.format(n=o.fieldname)
479
480 return output
481
482
Ole Troan75761b92019-09-11 17:49:08 +0200483def endianfun(objs, modulename):
Ole Troan9d420872017-10-12 13:06:35 +0200484 output = '''\
485
486/****** Endian swap functions *****/\n\
487#ifdef vl_endianfun
Ole Troan33a58172019-09-04 09:12:29 +0200488#ifndef included_{module}_endianfun
489#define included_{module}_endianfun
Ole Troan9d420872017-10-12 13:06:35 +0200490
491#undef clib_net_to_host_uword
492#ifdef LP64
493#define clib_net_to_host_uword clib_net_to_host_u64
494#else
495#define clib_net_to_host_uword clib_net_to_host_u32
496#endif
497
498'''
Ole Troan33a58172019-09-04 09:12:29 +0200499 output = output.format(module=modulename)
500
501 signature = '''\
502static inline void vl_api_{name}_t_endian (vl_api_{name}_t *a)
503{{
504 int i __attribute__((unused));
505'''
506
Ole Troan2c2feab2018-04-24 00:02:37 -0400507 for t in objs:
508 if t.__class__.__name__ == 'Enum':
Ole Troan33a58172019-09-04 09:12:29 +0200509 output += signature.format(name=t.name)
510 if t.enumtype in endian_strings:
511 output += (' *a = {}(*a);\n'
512 .format(endian_strings[t.enumtype]))
513 else:
514 output += (' /* a->{name} = a->{name} (no-op) */\n'
515 .format(name=t.name))
516
517 output += '}\n\n'
Ole Troan2c2feab2018-04-24 00:02:37 -0400518 continue
Ole Troan33a58172019-09-04 09:12:29 +0200519
Ole Troan9d420872017-10-12 13:06:35 +0200520 if t.manual_endian:
521 output += "/***** manual: vl_api_%s_t_endian *****/\n\n" % t.name
522 continue
Ole Troan33a58172019-09-04 09:12:29 +0200523
Ole Troan75761b92019-09-11 17:49:08 +0200524
525 if t.__class__.__name__ == 'Using':
526 output += signature.format(name=t.name)
527 if ('length' in t.alias and t.alias['length'] and
528 t.alias['type'] == 'u8'):
529 output += (' /* a->{name} = a->{name} (no-op) */\n'
530 .format(name=t.name))
531 elif t.alias['type'] in format_strings:
532 output += (' *a = {}(*a);\n'
533 .format(endian_strings[t.alias['type']]))
534 else:
535 output += ' /* Not Implemented yet {} */'.format(t.name)
536 output += '}\n\n'
537 continue
538
Ole Troan33a58172019-09-04 09:12:29 +0200539 output += signature.format(name=t.name)
Ole Troan9d420872017-10-12 13:06:35 +0200540
541 for o in t.block:
Ole Troan33a58172019-09-04 09:12:29 +0200542 output += endianfun_obj(o)
Ole Troan9d420872017-10-12 13:06:35 +0200543 output += '}\n\n'
Ole Troan33a58172019-09-04 09:12:29 +0200544
545 output += "\n#endif"
Ole Troan9d420872017-10-12 13:06:35 +0200546 output += "\n#endif /* vl_endianfun */\n\n"
547
548 return output
549
550
551def version_tuple(s, module):
552 output = '''\
553/****** Version tuple *****/
554
555#ifdef vl_api_version_tuple
556
557'''
Ole Troan2c2feab2018-04-24 00:02:37 -0400558 if 'version' in s['Option']:
559 v = s['Option']['version']
Ole Troan9d420872017-10-12 13:06:35 +0200560 (major, minor, patch) = v.split('.')
561 output += "vl_api_version_tuple(%s, %s, %s, %s)\n" % \
562 (module, major, minor, patch)
563
564 output += "\n#endif /* vl_api_version_tuple */\n\n"
565
566 return output
567
568
569#
570# Plugin entry point
571#
Ole Troan8dbfb432019-04-24 14:31:18 +0200572def run(input_filename, s):
Ole Troan33a58172019-09-04 09:12:29 +0200573 stream = StringIO()
Ole Troan9d420872017-10-12 13:06:35 +0200574 basename = os.path.basename(input_filename)
575 filename, file_extension = os.path.splitext(basename)
Ole Troan33a58172019-09-04 09:12:29 +0200576 modulename = filename.replace('.', '_')
577
Ole Troan9d420872017-10-12 13:06:35 +0200578 output = top_boilerplate.format(datestring=datestring,
579 input_filename=basename)
Ole Troan33a58172019-09-04 09:12:29 +0200580 output += imports(s['Import'])
Ole Troan9d420872017-10-12 13:06:35 +0200581 output += msg_ids(s)
582 output += msg_names(s)
583 output += msg_name_crc_list(s, filename)
Ole Troan75761b92019-09-11 17:49:08 +0200584 output += typedefs(s['types'] + s['Define'], filename + file_extension)
585 printfun_types(s['types'], stream, modulename)
Ole Troan33a58172019-09-04 09:12:29 +0200586 printfun(s['Define'], stream, modulename)
587 output += stream.getvalue()
Ole Troan75761b92019-09-11 17:49:08 +0200588 output += endianfun(s['types'] + s['Define'], modulename)
Ole Troan9d420872017-10-12 13:06:35 +0200589 output += version_tuple(s, basename)
590 output += bottom_boilerplate.format(input_filename=basename,
Ole Troan8dbfb432019-04-24 14:31:18 +0200591 file_crc=s['file_crc'])
Ole Troan9d420872017-10-12 13:06:35 +0200592
593 return output