This commit is contained in:
Viktor Oreshkin 2017-12-27 13:44:22 +00:00 committed by GitHub
commit e48d42ef2c

View File

@ -694,21 +694,17 @@ class TLGenerator:
will be written will be written
""" """
if tlobject.result.startswith('Vector<'): if tlobject.result.startswith('Vector<'):
# Vector results are a bit special since they can also be composed # Check if Vector contents are boxed or not
# of integer values and such; however, the result of requests is # We're implying that constructor names always
# not parsed as arguments are and it's a bit harder to tell which # start with lowecase and types start with uppercase
# is which. match = re.match(r'Vector<([\w\d]+)>', tlobject.result)
if tlobject.result == 'Vector<int>': if match and match.group(1).lower():
inner_type = match.group(1)
# not boxed
builder.writeln('reader.read_int() # Vector id') builder.writeln('reader.read_int() # Vector id')
builder.writeln('count = reader.read_int()') builder.writeln('count = reader.read_int()')
builder.writeln( builder.writeln(
'self.result = [reader.read_int() for _ in range(count)]' 'self.result = [reader.read_{}() for _ in range(count)]'.format(inner_type)
)
elif tlobject.result == 'Vector<long>':
builder.writeln('reader.read_int() # Vector id')
builder.writeln('count = reader.read_long()')
builder.writeln(
'self.result = [reader.read_long() for _ in range(count)]'
) )
else: else:
builder.writeln('self.result = reader.tgread_vector()') builder.writeln('self.result = reader.tgread_vector()')