18 d.append({'enumtype': e.enumtype})
26 d = {'reply': e.reply}
30 d['stream_msg'] = e.stream_message
32 d['events'] = e.events
37 def walk_defs(s, is_message=False):
43 if b.type == 'Option':
47 d.append([b.fieldtype, b.fieldname, b.limit])
49 d.append([b.fieldtype, b.fieldname])
50 elif b.type == 'Array':
52 d.append([b.fieldtype, b.fieldname,
53 b.length, b.lengthfield])
55 d.append([b.fieldtype, b.fieldname, b.length])
56 elif b.type == 'Union':
59 raise ValueError("Error in processing array type %s" % b)
61 if is_message and t.crc:
63 c['crc'] = "{0:#0{1}x}".format(t.crc, 10)
72 def run(args, filename, s):
75 j['types'] = (walk_defs([o for o in s['types']
76 if o.__class__.__name__ == 'Typedef']))
77 j['messages'] = walk_defs(s['Define'], True)
78 j['unions'] = (walk_defs([o for o in s['types']
79 if o.__class__.__name__ == 'Union']))
80 j['enums'] = (walk_enums([o for o in s['types']
81 if o.__class__.__name__ == 'Enum']))
82 j['services'] = walk_services(s['Service'])
83 j['options'] = s['Option']
84 j['aliases'] = {o.name:o.alias for o in s['types'] if o.__class__.__name__ == 'Using'}
85 j['vl_api_version'] = hex(s['file_crc'])
86 j['imports'] = walk_imports(i for i in s['Import'])
87 return json.dumps(j, indent=4, separators=(',', ': '))