Fix parsing for constructors and not objects (#348)

This commit is contained in:
Viktor Oreshkin
2017-10-16 21:15:22 +03:00
committed by Lonami
parent 1b71c6fbf1
commit ee01724cdb
2 changed files with 22 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ import struct
from zlib import crc32
from collections import defaultdict
from .parser import SourceBuilder, TLParser
from .parser import SourceBuilder, TLParser, TLObject
AUTO_GEN_NOTICE = \
'"""File generated by TLObjects\' generator. All changes will be ERASED"""'
@@ -129,6 +129,9 @@ class TLGenerator:
builder.writeln(
'from {}.tl.tlobject import TLObject'.format('.' * depth)
)
builder.writeln(
'from {}.tl import types'.format('.' * depth)
)
# Add the relative imports to the namespaces,
# unless we already are in a namespace.
@@ -638,7 +641,11 @@ class TLGenerator:
else:
# Else it may be a custom type
builder.writeln('{} = reader.tgread_object()'.format(name))
if not arg.skip_constructor_id:
builder.writeln('{} = reader.tgread_object()'.format(name))
else:
builder.writeln('{} = types.{}.from_reader(reader)'.format(
name, TLObject.class_name_for(arg.type)))
# End vector and flag blocks if required (if we opened them before)
if arg.is_vector: