From 468a1bdc6d3bee61f6fec0d8927c834a377cc145 Mon Sep 17 00:00:00 2001 From: godotg Date: Wed, 18 Oct 2023 16:57:43 +0800 Subject: [PATCH] del[lua]: remove unused code --- .../serializer/lua/LuaCharSerializer.java | 42 ------------------- .../main/resources/lua/Buffer/ByteBuffer.lua | 38 ----------------- 2 files changed, 80 deletions(-) delete mode 100644 protocol/src/main/java/com/zfoo/protocol/serializer/lua/LuaCharSerializer.java diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/lua/LuaCharSerializer.java b/protocol/src/main/java/com/zfoo/protocol/serializer/lua/LuaCharSerializer.java deleted file mode 100644 index a73cf0dd0..000000000 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/lua/LuaCharSerializer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2020 The zfoo Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ - -package com.zfoo.protocol.serializer.lua; - -import com.zfoo.protocol.generate.GenerateProtocolFile; -import com.zfoo.protocol.registration.field.IFieldRegistration; -import com.zfoo.protocol.util.StringUtils; - -import java.lang.reflect.Field; - -import static com.zfoo.protocol.util.FileUtils.LS; - -/** - * @author godotg - */ -public class LuaCharSerializer implements ILuaSerializer { - - @Override - public void writeObject(StringBuilder builder, String objectStr, int deep, Field field, IFieldRegistration fieldRegistration) { - GenerateProtocolFile.addTab(builder, deep); - builder.append(StringUtils.format("buffer:writeChar({})", objectStr)).append(LS); - } - - @Override - public String readObject(StringBuilder builder, int deep, Field field, IFieldRegistration fieldRegistration) { - String result = "result" + GenerateProtocolFile.index.getAndIncrement(); - GenerateProtocolFile.addTab(builder, deep); - builder.append(StringUtils.format("local {} = buffer:readChar()", result)).append(LS); - return result; - } -} diff --git a/protocol/src/main/resources/lua/Buffer/ByteBuffer.lua b/protocol/src/main/resources/lua/Buffer/ByteBuffer.lua index e33482209..211f20151 100644 --- a/protocol/src/main/resources/lua/Buffer/ByteBuffer.lua +++ b/protocol/src/main/resources/lua/Buffer/ByteBuffer.lua @@ -408,21 +408,6 @@ function ByteBuffer:readString() return self:readBuffer(length) end ---char -function ByteBuffer:writeChar(charValue) - if charValue == nil or #charValue == 0 then - self:writeString("") - return - end - local str = utf8sub(charValue, 1, 1) - self:writeString(str) - return self -end - -function ByteBuffer:readChar() - return self:readString() -end - --- Write a encoded char array into buf function ByteBuffer:writeBuffer(str) for i = 1, #str do @@ -641,29 +626,6 @@ function ByteBuffer:readDoubleArray() return array end -function ByteBuffer:writeCharArray(array) - if array == null then - self:writeInt(0) - else - self:writeInt(#array); - for index, element in pairs(array) do - self:writeChar(element) - end - end - return self -end - -function ByteBuffer:readCharArray() - local array = {} - local size = self:readInt() - if size > 0 then - for index = 1, size do - table.insert(array, self:readChar()) - end - end - return array -end - function ByteBuffer:writeStringArray(array) if array == null then self:writeInt(0)