ref[cs]: rename get and set method

This commit is contained in:
godotg committed 2024-07-15 16:38:02 +08:00
1 parent 6dae8da747
commit 32b7cec8c8
3 files changed
+17 -12

No files matched your search

@@ -242,7 +242,7 @@ public class CodeGenerateCsharp implements ICodeGenerate {
var fieldRegistrations = registration.getFieldRegistrations(); var fieldRegistrations = registration.getFieldRegistrations();
var csBuilder = new StringBuilder(); var csBuilder = new StringBuilder();
if (registration.isCompatible()) { if (registration.isCompatible()) {
csBuilder.append("int beforeWriteIndex = buffer.WriteOffset();").append(LS); csBuilder.append("int beforeWriteIndex = buffer.GetWriteOffset();").append(LS);
csBuilder.append(StringUtils.format("buffer.WriteInt({});", registration.getPredictionLength())).append(LS); csBuilder.append(StringUtils.format("buffer.WriteInt({});", registration.getPredictionLength())).append(LS);
} else { } else {
csBuilder.append("buffer.WriteInt(-1);").append(LS); csBuilder.append("buffer.WriteInt(-1);").append(LS);
@@ -52,7 +52,7 @@ namespace zfoocs
public void AdjustPadding(int predictionLength, int beforeWriteIndex) { public void AdjustPadding(int predictionLength, int beforeWriteIndex) {
// 因为写入的是可变长的int,如果预留的位置过多,则清除多余的位置 // 因为写入的是可变长的int,如果预留的位置过多,则清除多余的位置
var currentWriteIndex = WriteOffset(); var currentWriteIndex = GetWriteOffset();
var predictionCount = WriteIntCount(predictionLength); var predictionCount = WriteIntCount(predictionLength);
var length = currentWriteIndex - beforeWriteIndex - predictionCount; var length = currentWriteIndex - beforeWriteIndex - predictionCount;
var lengthCount = WriteIntCount(length); var lengthCount = WriteIntCount(length);
@@ -71,11 +71,16 @@ namespace zfoocs
} }
public bool CompatibleRead(int beforeReadIndex, int length) { public bool CompatibleRead(int beforeReadIndex, int length) {
return length != -1 && ReadOffset() < length + beforeReadIndex; return length != -1 && GetReadOffset() < length + beforeReadIndex;
} }
// -------------------------------------------------get/set------------------------------------------------- // -------------------------------------------------get/set-------------------------------------------------
public int WriteOffset() public byte[] GetBuffer()
{
return buffer;
}
public int GetWriteOffset()
{ {
return writeOffset; return writeOffset;
} }
@@ -93,7 +98,7 @@ namespace zfoocs
writeOffset = writeIndex; writeOffset = writeIndex;
} }
public int ReadOffset() public int GetReadOffset()
{ {
return readOffset; return readOffset;
} }
@@ -603,7 +608,7 @@ namespace zfoocs
return Encoding.UTF8.GetString(value, 0, value.Length); return Encoding.UTF8.GetString(value, 0, value.Length);
} }
public void WriteBooleanArray(bool[] array) public void WriteBoolArray(bool[] array)
{ {
if ((array == null) || (array.Length == 0)) if ((array == null) || (array.Length == 0))
{ {
@@ -620,7 +625,7 @@ namespace zfoocs
} }
} }
public bool[] ReadBooleanArray() public bool[] ReadBoolArray()
{ {
int size = ReadInt(); int size = ReadInt();
bool[] array = new bool[size]; bool[] array = new bool[size];
@@ -893,7 +898,7 @@ namespace zfoocs
return array; return array;
} }
public void WriteBooleanList(List<bool> list) public void WriteBoolList(List<bool> list)
{ {
if ((list == null) || (list.Count == 0)) if ((list == null) || (list.Count == 0))
{ {
@@ -910,7 +915,7 @@ namespace zfoocs
} }
} }
public List<bool> ReadBooleanList() public List<bool> ReadBoolList()
{ {
int size = ReadInt(); int size = ReadInt();
List<bool> list = new List<bool>(size); List<bool> list = new List<bool>(size);
@@ -1183,7 +1188,7 @@ namespace zfoocs
return list; return list;
} }
public void WriteBooleanSet(HashSet<bool> set) public void WriteBoolSet(HashSet<bool> set)
{ {
if ((set == null) || (set.Count == 0)) if ((set == null) || (set.Count == 0))
{ {
@@ -1199,7 +1204,7 @@ namespace zfoocs
} }
} }
public HashSet<bool> ReadBooleanSet() public HashSet<bool> ReadBoolSet()
{ {
int size = ReadInt(); int size = ReadInt();
HashSet<bool> set = new HashSet<bool>(); HashSet<bool> set = new HashSet<bool>();
@@ -23,7 +23,7 @@ public class ${protocol_name}Registration : IProtocolRegistration
{ {
return null; return null;
} }
int beforeReadIndex = buffer.ReadOffset(); int beforeReadIndex = buffer.GetReadOffset();
${protocol_name} packet = new ${protocol_name}(); ${protocol_name} packet = new ${protocol_name}();
${protocol_read_deserialization} ${protocol_read_deserialization}
if (length > 0) if (length > 0)