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)
64 def run(args, filename, s):
67 j['types'] = (walk_defs([o for o in s['types']
68 if o.__class__.__name__ == 'Typedef']))
69 j['messages'] = walk_defs(s['Define'], True)
70 j['unions'] = (walk_defs([o for o in s['types']
71 if o.__class__.__name__ == 'Union']))
72 j['enums'] = (walk_enums([o for o in s['types']
73 if o.__class__.__name__ == 'Enum']))
74 j['services'] = walk_services(s['Service'])
75 j['options'] = s['Option']
76 j['aliases'] = {o.name:o.alias for o in s['types'] if o.__class__.__name__ == 'Using'}
77 j['vl_api_version'] = hex(s['file_crc'])
78 return json.dumps(j, indent=4, separators=(',', ': '))