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