Generate CONSTRUCTOR_ID and write it upon serializing

This commit is contained in:
Lonami Exo 2018-07-23 22:55:09 +02:00
parent 16ab4e3863
commit 4e8cc8181c
1 changed files with 2 additions and 0 deletions

View File

@ -75,6 +75,7 @@ public class Generator {
writer.write(extendsName); writer.write(extendsName);
} }
writer.write(" {\n"); writer.write(" {\n");
writer.write("public static final int CONSTRUCTOR_ID = " + object.code + ";\n");
for (int i = 0; i < object.args.size(); ++i) { for (int i = 0; i < object.args.size(); ++i) {
final TLArg arg = object.args.get(i); final TLArg arg = object.args.get(i);
@ -148,6 +149,7 @@ public class Generator {
private static void writeSerialize(final Writer writer, final TLObject object) throws IOException { private static void writeSerialize(final Writer writer, final TLObject object) throws IOException {
writer.write("public void serialize(final BinaryWriter writer) {\n"); writer.write("public void serialize(final BinaryWriter writer) {\n");
writer.write("writer.write(CONSTRUCTOR_ID);\n");
for (final TLArg arg : object.args) { for (final TLArg arg : object.args) {
if (!arg.genericDefinition && arg.flags) { if (!arg.genericDefinition && arg.flags) {
writer.write("int "); writer.write("int ");