From 0fbeb92e2529e175b2bc5a0758408c40fa4a8265 Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Thu, 20 Aug 2020 14:02:59 +0200 Subject: [PATCH] Java 8 support --- __main__.py | 4 ++-- code_writer.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/__main__.py b/__main__.py index 3639ccb..0598114 100644 --- a/__main__.py +++ b/__main__.py @@ -109,7 +109,7 @@ def deserialize_native(output: CodeWriter, arg_name, arg_type, null_check: bool tmp_name = arg_name.split("[")[0] + "Tmp" output.indent() - output.local_assign(tmp_name, f"new byte[input.readInt()]") + output.local_assign("byte[]", tmp_name, f"new byte[input.readInt()]") output.newline() output.indent() @@ -217,7 +217,7 @@ def serialize_native(output: CodeWriter, arg_type: str, arg_name: str, null_chec output.indent() tmp_name = arg_name.split("[")[0] + "Tmp" - output.local_assign(tmp_name, f"this.{arg_name}.getBytes(StandardCharsets.UTF_8)") + output.local_assign("byte[]", tmp_name, f"this.{arg_name}.getBytes(StandardCharsets.UTF_8)") output.newline() output.indent() output.call("output.writeInt", f"{tmp_name}.length") diff --git a/code_writer.py b/code_writer.py index ab3d08f..97b000c 100644 --- a/code_writer.py +++ b/code_writer.py @@ -57,8 +57,8 @@ class CodeWriter: self.fd.write("} else {") self.indent_depth += 1 - def local_assign(self, name: str, value: str): - self.fd.write("var " + name + " = " + value + ";") + def local_assign(self, object_type: str, name: str, value: str): + self.fd.write(object_type + " " + name + " = " + value + ";") def open_for(self, start: str, cond: str, stmt: str): self.indent_depth += 1