From 0b0b337eca4d0433a4688eed36deb8d8cd57e0b0 Mon Sep 17 00:00:00 2001 From: godotg Date: Mon, 15 Jul 2024 17:22:00 +0800 Subject: [PATCH] ref[JS]: js protocol --- protocol/src/main/resources/cpp/ByteBuffer.h | 4 ++-- .../resources/csharp/Buffer/ByteBuffer.cs | 4 ++-- .../ecmascript/buffer/ByteBuffer.mjs | 24 +++++++++---------- .../resources/javascript/buffer/ByteBuffer.js | 4 ++-- .../javascript/zfoojs/buffer/ByteBuffer.js | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/protocol/src/main/resources/cpp/ByteBuffer.h b/protocol/src/main/resources/cpp/ByteBuffer.h index 52d69bb0..c1eae9d1 100644 --- a/protocol/src/main/resources/cpp/ByteBuffer.h +++ b/protocol/src/main/resources/cpp/ByteBuffer.h @@ -123,7 +123,7 @@ namespace zfoo { "writeIndex[" + std::to_string(writeIndex) + "] out of bounds exception: readOffset: " + std::to_string(readOffset) + ", writeOffset: " + std::to_string(writeOffset) + - "(expected: 0 <= readOffset <= writeOffset <= capacity:" + std::to_string(max_capacity); + "(expected: 0 <= readOffset <= writeOffset <= capacity:" + std::to_string(max_capacity) + ")"; throw errorMessage; } writeOffset = writeIndex; @@ -135,7 +135,7 @@ namespace zfoo { "readIndex[" + std::to_string(readIndex) + "] out of bounds exception: readOffset: " + std::to_string(readOffset) + ", writeOffset: " + std::to_string(writeOffset) + - "(expected: 0 <= readOffset <= writeOffset <= capacity:" + std::to_string(max_capacity); + "(expected: 0 <= readOffset <= writeOffset <= capacity:" + std::to_string(max_capacity) + ")"; throw errorMessage; } readOffset = readIndex; diff --git a/protocol/src/main/resources/csharp/Buffer/ByteBuffer.cs b/protocol/src/main/resources/csharp/Buffer/ByteBuffer.cs index a231ada0..f8bc3d1e 100644 --- a/protocol/src/main/resources/csharp/Buffer/ByteBuffer.cs +++ b/protocol/src/main/resources/csharp/Buffer/ByteBuffer.cs @@ -92,7 +92,7 @@ namespace zfoocs throw new Exception("writeIndex[" + writeIndex + "] out of bounds exception: readOffset: " + readOffset + ", writeOffset: " + writeOffset + - "(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.Length); + "(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.Length) + ")"; } writeOffset = writeIndex; } @@ -108,7 +108,7 @@ namespace zfoocs { throw new Exception("readIndex[" + readIndex + "] out of bounds exception: readIndex: " + readOffset + ", writeOffset: " + writeOffset + - "(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.Length); + "(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.Length) + ")"; } readOffset = readIndex; } diff --git a/protocol/src/main/resources/ecmascript/buffer/ByteBuffer.mjs b/protocol/src/main/resources/ecmascript/buffer/ByteBuffer.mjs index 48cd660f..e8f109c7 100644 --- a/protocol/src/main/resources/ecmascript/buffer/ByteBuffer.mjs +++ b/protocol/src/main/resources/ecmascript/buffer/ByteBuffer.mjs @@ -83,26 +83,26 @@ class ByteBuffer { return this.writeOffset; } - setWriteOffset(writeOffset) { - if (writeOffset > this.buffer.byteLength) { - throw new Error('index out of bounds exception: readerIndex: ' + this.readOffset + - ', writerIndex: ' + this.writeOffset + - '(expected: 0 <= readerIndex <= writerIndex <= capacity:' + this.buffer.byteLength); + setWriteOffset(writeIndex) { + if (writeIndex > this.buffer.byteLength) { + throw new Error('writeIndex out of bounds exception: readOffset: ' + this.readOffset + + ', writeOffset: ' + this.writeOffset + + '(expected: 0 <= readOffset <= writeOffset <= capacity:' + this.buffer.byteLength) + ')'; } - this.writeOffset = writeOffset; + this.writeOffset = writeIndex; } getReadOffset() { return this.readOffset; } - setReadOffset(readOffset) { - if (readOffset > this.writeOffset) { - throw new Error('index out of bounds exception: readerIndex: ' + this.readOffset + - ', writerIndex: ' + this.writeOffset + - '(expected: 0 <= readerIndex <= writerIndex <= capacity:' + this.buffer.byteLength); + setReadOffset(readIndex) { + if (readIndex > this.writeOffset) { + throw new Error('readIndex out of bounds exception: readOffset: ' + this.readOffset + + ', writeOffset: ' + this.writeOffset + + '(expected: 0 <= readOffset <= writeOffset <= capacity:' + this.buffer.byteLength) + ")"; } - this.readOffset = readOffset; + this.readOffset = readIndex; } getCapacity() { diff --git a/protocol/src/main/resources/javascript/buffer/ByteBuffer.js b/protocol/src/main/resources/javascript/buffer/ByteBuffer.js index c15b1d39..2ecf9a46 100644 --- a/protocol/src/main/resources/javascript/buffer/ByteBuffer.js +++ b/protocol/src/main/resources/javascript/buffer/ByteBuffer.js @@ -100,7 +100,7 @@ const ByteBuffer = function() { if (writeIndex > this.buffer.byteLength) { throw new Error('writeIndex out of bounds exception: readOffset: ' + this.readOffset + ', writeOffset: ' + this.writeOffset + - '(expected: 0 <= readOffset <= writeOffset <= capacity:' + this.buffer.byteLength); + '(expected: 0 <= readOffset <= writeOffset <= capacity:' + this.buffer.byteLength) + ')'; } this.writeOffset = writeIndex; }; @@ -113,7 +113,7 @@ const ByteBuffer = function() { if (readIndex > this.writeOffset) { throw new Error('readIndex out of bounds exception: readOffset: ' + this.readOffset + ', writeOffset: ' + this.writeOffset + - '(expected: 0 <= readOffset <= writeOffset <= capacity:' + this.buffer.byteLength); + '(expected: 0 <= readOffset <= writeOffset <= capacity:' + this.buffer.byteLength) + ')'; } this.readOffset = readIndex; }; diff --git a/protocol/src/test/javascript/zfoojs/buffer/ByteBuffer.js b/protocol/src/test/javascript/zfoojs/buffer/ByteBuffer.js index c15b1d39..2ecf9a46 100644 --- a/protocol/src/test/javascript/zfoojs/buffer/ByteBuffer.js +++ b/protocol/src/test/javascript/zfoojs/buffer/ByteBuffer.js @@ -100,7 +100,7 @@ const ByteBuffer = function() { if (writeIndex > this.buffer.byteLength) { throw new Error('writeIndex out of bounds exception: readOffset: ' + this.readOffset + ', writeOffset: ' + this.writeOffset + - '(expected: 0 <= readOffset <= writeOffset <= capacity:' + this.buffer.byteLength); + '(expected: 0 <= readOffset <= writeOffset <= capacity:' + this.buffer.byteLength) + ')'; } this.writeOffset = writeIndex; }; @@ -113,7 +113,7 @@ const ByteBuffer = function() { if (readIndex > this.writeOffset) { throw new Error('readIndex out of bounds exception: readOffset: ' + this.readOffset + ', writeOffset: ' + this.writeOffset + - '(expected: 0 <= readOffset <= writeOffset <= capacity:' + this.buffer.byteLength); + '(expected: 0 <= readOffset <= writeOffset <= capacity:' + this.buffer.byteLength) + ')'; } this.readOffset = readIndex; };