From b71fddc378e68a377ab35e5daeb1ffe81f5b99e8 Mon Sep 17 00:00:00 2001 From: zgy-ian Date: Mon, 27 Sep 2021 11:25:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9generate=5Fplugin?= =?UTF-8?q?=E4=B8=ADjava=E4=BB=A3=E7=A0=81string=E8=BF=87=E9=95=BF?= =?UTF-8?q?=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zgy-ian --- ":wq\357\274\232wq" | 13 +++++++++++ ts2panda/scripts/generate_plugin.py | 35 ++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 ":wq\357\274\232wq" diff --git "a/:wq\357\274\232wq" "b/:wq\357\274\232wq" new file mode 100644 index 0000000000..f8a8446c0d --- /dev/null +++ "b/:wq\357\274\232wq" @@ -0,0 +1,13 @@ +修改generate_plugin中java代码string过长的优化 + +Signed-off-by: zgy-ian + +# Please enter the commit message for your changes. Lines starting +# with '#' will be ignored, and an empty message aborts the commit. +# +# On branch master +# Your branch is up to date with 'origin/master'. +# +# Changes to be committed: +# modified: ts2panda/scripts/generate_plugin.py +# diff --git a/ts2panda/scripts/generate_plugin.py b/ts2panda/scripts/generate_plugin.py index 306e9696d2..5c2f360f6f 100755 --- a/ts2panda/scripts/generate_plugin.py +++ b/ts2panda/scripts/generate_plugin.py @@ -108,13 +108,38 @@ def gen_java_method(input_arguments): % os.linesep) output.write(" return%s" % os.linesep) lines = input_src.readlines() - for line in lines[:-1]: + # seperate_lines into blocks + single_block_len = 1024 + total_len = len(lines) + for index, line in enumerate(lines): + block_index = index // single_block_len line = line.strip(os.linesep) line = line.replace("\"", "\\\"") - output.write(" \"%s\\n\" +%s" % (line, os.linesep)) - - last_line = lines[-1].replace("\"", "\\\"").strip(os.linesep) - output.write(" \"%s\";%s" % (last_line, os.linesep)) + # generate getJsCode%s + if (index % single_block_len == 0): + output.write(" private static String getJsCode%s(){%s" + % (block_index, os.linesep)) + output.write(" return%s" % os.linesep) + if (index % single_block_len == single_block_len-1 or index == total_len - 1): + output.write(" \"%s\";%s" % (line, os.linesep)) + output.write(" }%s" % os.linesep) + else: + output.write(" \"%s\\n\" +%s" % (line, os.linesep)) + block_num = (total_len//single_block_len) + 1 + if total_len % single_block_len == 0: + block_num = total_len // single_block_len + # generate getJsCode + output.write( + " public static String getJsCode(){%s" % os.linesep) + output.write(" return %s" % os.linesep) + # let getJsCode call getJsCode%s + for index in range(block_num): + if (index != block_num - 1): + output.write(" getJsCode%() +%s" % + (index, os.linesep)) + else: + output.write(" getJsCode%s() ;%s" % + (index, os.linesep)) output.write(" }%s" % os.linesep) output.write("%s" % os.linesep) -- Gitee From 89aeb15b4bffd09772ffa0c72dc8bb777033bc4b Mon Sep 17 00:00:00 2001 From: zgy-ian Date: Mon, 27 Sep 2021 03:33:13 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20:wq?= =?UTF-8?q?=EF=BC=9Awq?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ":wq\357\274\232wq" | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 ":wq\357\274\232wq" diff --git "a/:wq\357\274\232wq" "b/:wq\357\274\232wq" deleted file mode 100644 index f8a8446c0d..0000000000 --- "a/:wq\357\274\232wq" +++ /dev/null @@ -1,13 +0,0 @@ -修改generate_plugin中java代码string过长的优化 - -Signed-off-by: zgy-ian - -# Please enter the commit message for your changes. Lines starting -# with '#' will be ignored, and an empty message aborts the commit. -# -# On branch master -# Your branch is up to date with 'origin/master'. -# -# Changes to be committed: -# modified: ts2panda/scripts/generate_plugin.py -# -- Gitee