Add missing code

This commit is contained in:
Andrea Cavalli 2023-04-28 23:45:41 +02:00
parent 0a3021247d
commit 314d255378

View File

@ -577,7 +577,16 @@ public class transform {
}
private static void serializeTdApi(JavaWriter w, String argName, boolean nullCheck) {
//todo:
if (nullCheck) {
w.writeIndent().writeOpenIf("this." + argName + " == null").writeNewLine();
w.writeIndent().writeCall("output.writeBoolean", "false").writeNewLine();
w.writeOpenIfElse(true).writeNewLine();
w.writeIndent().writeCall("output.writeBoolean", "true").writeNewLine();
}
w.writeIndent().writeCall("this." + argName + ".serialize", "output").writeNewLine();
if (nullCheck) {
w.writeCloseBlock(true).writeNewLine();
}
}
private static void serializeNative(JavaWriter w, String argName, String argType) {
@ -585,7 +594,49 @@ public class transform {
}
private static void serializeNative(JavaWriter w, String argName, String argType, boolean nullCheck) {
//todo:
switch (argType) {
case "int":
w.writeIndent().writeCall("output.writeInt", "this." + argName).writeNewLine();
break;
case "byte[]":
case "byte":
if (nullCheck) {
w.writeIndent().writeOpenIf("this." + argName + " == null").writeNewLine();
w.writeIndent().writeCall("output.writeBoolean", "false").writeNewLine();
w.writeOpenIfElse(true).writeNewLine();
w.writeIndent().writeCall("output.writeBoolean", "true").writeNewLine();
}
w.writeIndent().writeCall("output.writeInt", "this." + argName + ".length").writeNewLine();
w.writeIndent().writeCall("output.write", "this." + argName).writeNewLine();
if (nullCheck) {
w.writeCloseBlock(true).writeNewLine();
}
break;
case "long":
w.writeIndent().writeCall("output.writeLong", "this." + argName).writeNewLine();
break;
case "double":
w.writeIndent().writeCall("output.writeDouble", "this." + argName).writeNewLine();
break;
case "boolean":
w.writeIndent().writeCall("output.writeBoolean", "this." + argName).writeNewLine();
break;
case "String":
if (nullCheck) {
w.writeIndent().writeOpenIf("this." + argName + " == null").writeNewLine();
w.writeIndent().writeCall("output.writeBoolean", "false").writeNewLine();
w.writeIndent().writeOpenIfElse(true).writeNewLine();
w.writeIndent().writeCall("output.writeBoolean", "true").writeNewLine();
}
var tmpName = argName.split("[", 2)[0] + "Tmp";
w.writeIndent().writeLocalAssign("byte[]", tmpName, "this." + argName + ".getBytes(StandardCharsets.UTF_8)").writeNewLine();
w.writeIndent().writeCall("output.writeInt", tmpName + ".length").writeNewLine();
w.writeIndent().writeCall("output.write", tmpName).writeNewLine();
if (nullCheck) {
w.writeCloseBlock(true).writeNewLine();
}
break;
}
}
private static void deserializeTdApi(JavaWriter w, String name, String type, Map<String, List<String>> cont, Map<String, TdType> classes) {