mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-14 08:26:45 +00:00
ref[kotlin]: rename writeBoolean/readBoolean/writeOffset/readOffset to writeBool/readBool/getWriteOffset/getReadOffset
This commit is contained in:
@@ -292,7 +292,7 @@ public class CodeGenerateKotlin implements ICodeGenerate {
|
||||
var fieldRegistrations = registration.getFieldRegistrations();
|
||||
var ktBuilder = new StringBuilder();
|
||||
if (registration.isCompatible()) {
|
||||
ktBuilder.append("val beforeWriteIndex = buffer.writeOffset()").append(LS);
|
||||
ktBuilder.append("val beforeWriteIndex = buffer.getWriteOffset()").append(LS);
|
||||
ktBuilder.append(StringUtils.format("buffer.writeInt({})", registration.getPredictionLength())).append(LS);
|
||||
} else {
|
||||
ktBuilder.append("buffer.writeInt(-1)").append(LS);
|
||||
|
||||
@@ -29,7 +29,11 @@ class ByteBuffer {
|
||||
}
|
||||
|
||||
// -------------------------------------------------get/set-------------------------------------------------
|
||||
fun writeOffset(): Int {
|
||||
fun getBuffer(): ByteArray {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
fun getWriteOffset(): Int {
|
||||
return writeOffset
|
||||
}
|
||||
|
||||
@@ -43,7 +47,7 @@ class ByteBuffer {
|
||||
writeOffset = writeIndex
|
||||
}
|
||||
|
||||
fun readOffset(): Int {
|
||||
fun getReadOffset(): Int {
|
||||
return readOffset
|
||||
}
|
||||
|
||||
@@ -350,7 +354,7 @@ class ByteBuffer {
|
||||
return String(bytes)
|
||||
}
|
||||
|
||||
fun writeBooleanArray(array: Array<Boolean>) {
|
||||
fun writeBoolArray(array: Array<Boolean>) {
|
||||
if (array.size == 0) {
|
||||
writeInt(0)
|
||||
} else {
|
||||
@@ -362,7 +366,7 @@ class ByteBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
fun readBooleanArray(): Array<Boolean> {
|
||||
fun readBoolArray(): Array<Boolean> {
|
||||
val size = readInt()
|
||||
val array = Array<Boolean>(size) { init -> false }
|
||||
if (size > 0) {
|
||||
@@ -534,7 +538,7 @@ class ByteBuffer {
|
||||
return array
|
||||
}
|
||||
|
||||
fun writeBooleanList(list: List<Boolean>) {
|
||||
fun writeBoolList(list: List<Boolean>) {
|
||||
if (list.isEmpty()) {
|
||||
writeInt(0)
|
||||
} else {
|
||||
@@ -545,7 +549,7 @@ class ByteBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
fun readBooleanList(): List<Boolean> {
|
||||
fun readBoolList(): List<Boolean> {
|
||||
val size = readInt()
|
||||
val list: MutableList<Boolean> = ArrayList()
|
||||
if (size > 0) {
|
||||
@@ -734,7 +738,7 @@ class ByteBuffer {
|
||||
return list
|
||||
}
|
||||
|
||||
fun writeBooleanSet(set: Set<Boolean>) {
|
||||
fun writeBoolSet(set: Set<Boolean>) {
|
||||
if (set.isEmpty()) {
|
||||
writeInt(0)
|
||||
} else {
|
||||
@@ -745,7 +749,7 @@ class ByteBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
fun readBooleanSet(): Set<Boolean> {
|
||||
fun readBoolSet(): Set<Boolean> {
|
||||
val size = readInt()
|
||||
val set: MutableSet<Boolean> = HashSet()
|
||||
if (size > 0) {
|
||||
|
||||
@@ -18,7 +18,7 @@ class ${protocol_name}Registration : IProtocolRegistration {
|
||||
if (length == 0) {
|
||||
return packet
|
||||
}
|
||||
val beforeReadIndex = buffer.readOffset()
|
||||
val beforeReadIndex = buffer.getReadOffset()
|
||||
${protocol_read_deserialization}
|
||||
if (length > 0) {
|
||||
buffer.setReadOffset(beforeReadIndex + length)
|
||||
|
||||
@@ -163,7 +163,7 @@ fun compatibleTest() {
|
||||
|
||||
var equal = 0
|
||||
var notEqual = 0
|
||||
for (i in 0 until buffer.writeOffset()) {
|
||||
for (i in 0 until buffer.getWriteOffset()) {
|
||||
val a = buffer.readByte()
|
||||
val b = newBuffer.readByte()
|
||||
if (a == b) {
|
||||
|
||||
@@ -29,7 +29,11 @@ class ByteBuffer {
|
||||
}
|
||||
|
||||
// -------------------------------------------------get/set-------------------------------------------------
|
||||
fun writeOffset(): Int {
|
||||
fun getBuffer(): ByteArray {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
fun getWriteOffset(): Int {
|
||||
return writeOffset
|
||||
}
|
||||
|
||||
@@ -43,7 +47,7 @@ class ByteBuffer {
|
||||
writeOffset = writeIndex
|
||||
}
|
||||
|
||||
fun readOffset(): Int {
|
||||
fun getReadOffset(): Int {
|
||||
return readOffset
|
||||
}
|
||||
|
||||
@@ -350,7 +354,7 @@ class ByteBuffer {
|
||||
return String(bytes)
|
||||
}
|
||||
|
||||
fun writeBooleanArray(array: Array<Boolean>) {
|
||||
fun writeBoolArray(array: Array<Boolean>) {
|
||||
if (array.size == 0) {
|
||||
writeInt(0)
|
||||
} else {
|
||||
@@ -362,7 +366,7 @@ class ByteBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
fun readBooleanArray(): Array<Boolean> {
|
||||
fun readBoolArray(): Array<Boolean> {
|
||||
val size = readInt()
|
||||
val array = Array<Boolean>(size) { init -> false }
|
||||
if (size > 0) {
|
||||
@@ -534,7 +538,7 @@ class ByteBuffer {
|
||||
return array
|
||||
}
|
||||
|
||||
fun writeBooleanList(list: List<Boolean>) {
|
||||
fun writeBoolList(list: List<Boolean>) {
|
||||
if (list.isEmpty()) {
|
||||
writeInt(0)
|
||||
} else {
|
||||
@@ -545,7 +549,7 @@ class ByteBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
fun readBooleanList(): List<Boolean> {
|
||||
fun readBoolList(): List<Boolean> {
|
||||
val size = readInt()
|
||||
val list: MutableList<Boolean> = ArrayList()
|
||||
if (size > 0) {
|
||||
@@ -734,7 +738,7 @@ class ByteBuffer {
|
||||
return list
|
||||
}
|
||||
|
||||
fun writeBooleanSet(set: Set<Boolean>) {
|
||||
fun writeBoolSet(set: Set<Boolean>) {
|
||||
if (set.isEmpty()) {
|
||||
writeInt(0)
|
||||
} else {
|
||||
@@ -745,7 +749,7 @@ class ByteBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
fun readBooleanSet(): Set<Boolean> {
|
||||
fun readBoolSet(): Set<Boolean> {
|
||||
val size = readInt()
|
||||
val set: MutableSet<Boolean> = HashSet()
|
||||
if (size > 0) {
|
||||
|
||||
@@ -72,7 +72,7 @@ class ComplexObjectRegistration : IProtocolRegistration {
|
||||
return
|
||||
}
|
||||
val message = packet as ComplexObject
|
||||
val beforeWriteIndex = buffer.writeOffset()
|
||||
val beforeWriteIndex = buffer.getWriteOffset()
|
||||
buffer.writeInt(36962)
|
||||
buffer.writeByte(message.a)
|
||||
buffer.writeByte(message.aa)
|
||||
@@ -100,8 +100,8 @@ class ComplexObjectRegistration : IProtocolRegistration {
|
||||
buffer.writeDoubleArray(message.ffff)
|
||||
buffer.writeBool(message.g)
|
||||
buffer.writeBool(message.gg)
|
||||
buffer.writeBooleanArray(message.ggg)
|
||||
buffer.writeBooleanArray(message.gggg)
|
||||
buffer.writeBoolArray(message.ggg)
|
||||
buffer.writeBoolArray(message.gggg)
|
||||
buffer.writeString(message.jj)
|
||||
buffer.writeStringArray(message.jjj)
|
||||
buffer.writePacket(message.kk, 102)
|
||||
@@ -188,7 +188,7 @@ class ComplexObjectRegistration : IProtocolRegistration {
|
||||
if (length == 0) {
|
||||
return packet
|
||||
}
|
||||
val beforeReadIndex = buffer.readOffset()
|
||||
val beforeReadIndex = buffer.getReadOffset()
|
||||
val result0 = buffer.readByte()
|
||||
packet.a = result0
|
||||
val result1 = buffer.readByte()
|
||||
@@ -241,9 +241,9 @@ class ComplexObjectRegistration : IProtocolRegistration {
|
||||
packet.g = result24
|
||||
val result25 = buffer.readBool()
|
||||
packet.gg = result25
|
||||
val array26 = buffer.readBooleanArray()
|
||||
val array26 = buffer.readBoolArray()
|
||||
packet.ggg = array26
|
||||
val array27 = buffer.readBooleanArray()
|
||||
val array27 = buffer.readBoolArray()
|
||||
packet.gggg = array27
|
||||
val result28 = buffer.readString()
|
||||
packet.jj = result28
|
||||
|
||||
@@ -27,7 +27,7 @@ class EmptyObjectRegistration : IProtocolRegistration {
|
||||
if (length == 0) {
|
||||
return packet
|
||||
}
|
||||
val beforeReadIndex = buffer.readOffset()
|
||||
val beforeReadIndex = buffer.getReadOffset()
|
||||
|
||||
if (length > 0) {
|
||||
buffer.setReadOffset(beforeReadIndex + length)
|
||||
|
||||
@@ -40,7 +40,7 @@ class NormalObjectRegistration : IProtocolRegistration {
|
||||
return
|
||||
}
|
||||
val message = packet as NormalObject
|
||||
val beforeWriteIndex = buffer.writeOffset()
|
||||
val beforeWriteIndex = buffer.getWriteOffset()
|
||||
buffer.writeInt(857)
|
||||
buffer.writeByte(message.a)
|
||||
buffer.writeByteArray(message.aaa)
|
||||
@@ -71,7 +71,7 @@ class NormalObjectRegistration : IProtocolRegistration {
|
||||
if (length == 0) {
|
||||
return packet
|
||||
}
|
||||
val beforeReadIndex = buffer.readOffset()
|
||||
val beforeReadIndex = buffer.getReadOffset()
|
||||
val result0 = buffer.readByte()
|
||||
packet.a = result0
|
||||
val array1 = buffer.readByteArray()
|
||||
|
||||
@@ -22,7 +22,7 @@ class ObjectARegistration : IProtocolRegistration {
|
||||
return
|
||||
}
|
||||
val message = packet as ObjectA
|
||||
val beforeWriteIndex = buffer.writeOffset()
|
||||
val beforeWriteIndex = buffer.getWriteOffset()
|
||||
buffer.writeInt(201)
|
||||
buffer.writeInt(message.a)
|
||||
buffer.writeIntStringMap(message.m)
|
||||
@@ -37,7 +37,7 @@ class ObjectARegistration : IProtocolRegistration {
|
||||
if (length == 0) {
|
||||
return packet
|
||||
}
|
||||
val beforeReadIndex = buffer.readOffset()
|
||||
val beforeReadIndex = buffer.getReadOffset()
|
||||
val result0 = buffer.readInt()
|
||||
packet.a = result0
|
||||
val map1 = buffer.readIntStringMap()
|
||||
|
||||
@@ -19,7 +19,7 @@ class ObjectBRegistration : IProtocolRegistration {
|
||||
return
|
||||
}
|
||||
val message = packet as ObjectB
|
||||
val beforeWriteIndex = buffer.writeOffset()
|
||||
val beforeWriteIndex = buffer.getWriteOffset()
|
||||
buffer.writeInt(4)
|
||||
buffer.writeBool(message.flag)
|
||||
buffer.writeInt(message.innerCompatibleValue)
|
||||
@@ -32,7 +32,7 @@ class ObjectBRegistration : IProtocolRegistration {
|
||||
if (length == 0) {
|
||||
return packet
|
||||
}
|
||||
val beforeReadIndex = buffer.readOffset()
|
||||
val beforeReadIndex = buffer.getReadOffset()
|
||||
val result0 = buffer.readBool()
|
||||
packet.flag = result0
|
||||
if (buffer.compatibleRead(beforeReadIndex, length)) {
|
||||
|
||||
@@ -30,7 +30,7 @@ class SimpleObjectRegistration : IProtocolRegistration {
|
||||
if (length == 0) {
|
||||
return packet
|
||||
}
|
||||
val beforeReadIndex = buffer.readOffset()
|
||||
val beforeReadIndex = buffer.getReadOffset()
|
||||
val result0 = buffer.readInt()
|
||||
packet.c = result0
|
||||
val result1 = buffer.readBool()
|
||||
|
||||
Reference in New Issue
Block a user