Added an .empty() function to the objects, fixes to msgs_ack

The .empty() function returns an "empty" instance of the object
(attributes set to None). This is used rather than using reflection.

The msgs_ack handling broke stuff (InvokeWithLayer when there were
updates), so this is now handled; yet there may be a better fix
This commit is contained in:
Lonami
2016-09-26 17:16:15 +02:00
parent ded655911e
commit 77aa37d2ad
4 changed files with 25 additions and 13 deletions

View File

@@ -132,6 +132,17 @@ class TLGenerator:
TLGenerator.write_onsend_code(builder, arg, tlobject.args)
builder.end_block()
# Write the empty() function, which returns an "empty"
# instance, in which all attributes are set to None
builder.writeln('@staticmethod')
builder.writeln('def empty():')
builder.writeln('"""Returns an "empty" instance (all attributes are None)"""')
builder.writeln('return {}({})'.format(
TLGenerator.get_class_name(tlobject),
', '.join('None' for _ in range(len(args)))
))
builder.end_block()
# Write the on_response(self, reader) function
builder.writeln('def on_response(self, reader):')
# Do not read constructor's ID, since that's already been read somewhere else