12 d.append({'enumtype': e.enumtype})
20 d = {'reply': e.reply}
24 d['events'] = e.events
29 def walk_defs(s, is_message=False):
35 if b.type == 'Option':
39 d.append([b.fieldtype, b.fieldname, b.limit])
41 d.append([b.fieldtype, b.fieldname])
42 elif b.type == 'Array':
44 d.append([b.fieldtype, b.fieldname,
45 b.length, b.lengthfield])
47 d.append([b.fieldtype, b.fieldname, b.length])
48 elif b.type == 'Union':
51 raise ValueError("Error in processing array type %s" % b)
53 if is_message and t.crc:
55 c['crc'] = "{0:#0{1}x}".format(t.crc, 10)
68 j['types'] = (walk_defs([o for o in s['types']
69 if o.__class__.__name__ == 'Typedef']))
70 j['messages'] = walk_defs(s['Define'], True)
71 j['unions'] = (walk_defs([o for o in s['types']
72 if o.__class__.__name__ == 'Union']))
73 j['enums'] = (walk_enums([o for o in s['types']
74 if o.__class__.__name__ == 'Enum']))
75 j['services'] = walk_services(s['Service'])
76 j['options'] = s['Option']
77 j['aliases'] = {k: v.alias for k, v in s['Alias'].items()}
78 j['vl_api_version'] = hex(s['file_crc'])
79 return json.dumps(j, indent=4, separators=(',', ': '))