Skip to content

Commit

Permalink
ref[lua]: lua protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysunxiao committed Jul 16, 2024
1 parent d6e05d5 commit c3de2d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions protocol/src/main/resources/lua/ByteBuffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,23 @@ function ByteBuffer:getWriteOffset()
return self.writeOffset
end

function ByteBuffer:setWriteOffset(writeOffset)
if writeOffset > #self.buffer + 1 then
error(string.format("writeOffset: %s index out of bounds exception: readerIndex: %s, writerIndex: %s, (expected: 0 <= readerIndex <= writerIndex <= capacity: %s)", writeOffset, self.readOffset, self.writeOffset, #self.buffer))
function ByteBuffer:setWriteOffset(writeIndex)
if writeIndex > #self.buffer + 1 then
error(string.format("writeIndex: %s index out of bounds exception: readOffset: %s, writerOffset: %s, (expected: 0 <= readOffset <= writeOffset <= capacity: %s)", writeIndex, self.readOffset, self.writeOffset, #self.buffer))
end
self.writeOffset = writeOffset
self.writeOffset = writeIndex
return self
end

function ByteBuffer:getReadOffset()
return self.readOffset
end

function ByteBuffer:setReadOffset(readOffset)
if readOffset > self.writeOffset then
error(string.format("readOffset: %s index out of bounds exception: readerIndex: %s, writerIndex: %s, (expected: 0 <= readerIndex <= writerIndex <= capacity: %s)", readOffset, self.readOffset, self.writeOffset, #self.buffer))
function ByteBuffer:setReadOffset(readIndex)
if readIndex > self.writeOffset then
error(string.format("readIndex: %s index out of bounds exception: readOffset: %s, writerIndex: %s, (expected: 0 <= readOffset <= writeOffset <= capacity: %s)", readIndex, self.readOffset, self.writeOffset, #self.buffer))
end
self.readOffset = readOffset
self.readOffset = readIndex
return self
end

Expand Down
16 changes: 8 additions & 8 deletions protocol/src/test/lua/zfoolua/ByteBuffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,23 @@ function ByteBuffer:getWriteOffset()
return self.writeOffset
end

function ByteBuffer:setWriteOffset(writeOffset)
if writeOffset > #self.buffer + 1 then
error(string.format("writeOffset: %s index out of bounds exception: readerIndex: %s, writerIndex: %s, (expected: 0 <= readerIndex <= writerIndex <= capacity: %s)", writeOffset, self.readOffset, self.writeOffset, #self.buffer))
function ByteBuffer:setWriteOffset(writeIndex)
if writeIndex > #self.buffer + 1 then
error(string.format("writeIndex: %s index out of bounds exception: readOffset: %s, writerOffset: %s, (expected: 0 <= readOffset <= writeOffset <= capacity: %s)", writeIndex, self.readOffset, self.writeOffset, #self.buffer))
end
self.writeOffset = writeOffset
self.writeOffset = writeIndex
return self
end

function ByteBuffer:getReadOffset()
return self.readOffset
end

function ByteBuffer:setReadOffset(readOffset)
if readOffset > self.writeOffset then
error(string.format("readOffset: %s index out of bounds exception: readerIndex: %s, writerIndex: %s, (expected: 0 <= readerIndex <= writerIndex <= capacity: %s)", readOffset, self.readOffset, self.writeOffset, #self.buffer))
function ByteBuffer:setReadOffset(readIndex)
if readIndex > self.writeOffset then
error(string.format("readIndex: %s index out of bounds exception: readOffset: %s, writerIndex: %s, (expected: 0 <= readOffset <= writeOffset <= capacity: %s)", readIndex, self.readOffset, self.writeOffset, #self.buffer))
end
self.readOffset = readOffset
self.readOffset = readIndex
return self
end

Expand Down

0 comments on commit c3de2d9

Please sign in to comment.