From b1cbc73dbd777b848d1c1855683b2d4566b48e09 Mon Sep 17 00:00:00 2001 From: godotg Date: Mon, 15 Jul 2024 17:41:34 +0800 Subject: [PATCH] ref[TypeScript]: TypeScript protocol --- .../resources/typescript/buffer/ByteBuffer.ts | 24 +++++++++---------- .../typescript/zfoots/buffer/ByteBuffer.ts | 24 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/protocol/src/main/resources/typescript/buffer/ByteBuffer.ts b/protocol/src/main/resources/typescript/buffer/ByteBuffer.ts index 38eac709..5bcd181f 100644 --- a/protocol/src/main/resources/typescript/buffer/ByteBuffer.ts +++ b/protocol/src/main/resources/typescript/buffer/ByteBuffer.ts @@ -88,26 +88,26 @@ class ByteBuffer implements IByteBuffer{ return this.buffer; } - setWriteOffset(writeOffset: number): void { - 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: number): void { + 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; } getWriteOffset(): number { return this.writeOffset; } - setReadOffset(readOffset: number): void { - 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: number): void { + if (readIndex > this.writeOffset) { + throw new Error('readIndex out of bounds exception:readIndex:' + this.readOffset + + ', writeOffset:' + this.writeOffset + + '(expected:0 <= readOffset <= writeOffset <= capacity:' + this.buffer.byteLength + ')'); } - this.readOffset = readOffset; + this.readOffset = readIndex; } getReadOffset(): number { diff --git a/protocol/src/test/typescript/zfoots/buffer/ByteBuffer.ts b/protocol/src/test/typescript/zfoots/buffer/ByteBuffer.ts index 3bee5e71..834fdff9 100644 --- a/protocol/src/test/typescript/zfoots/buffer/ByteBuffer.ts +++ b/protocol/src/test/typescript/zfoots/buffer/ByteBuffer.ts @@ -88,26 +88,26 @@ class ByteBuffer implements IByteBuffer{ return this.buffer; } - setWriteOffset(writeOffset: number): void { - 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: number): void { + 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; } getWriteOffset(): number { return this.writeOffset; } - setReadOffset(readOffset: number): void { - 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: number): void { + if (readIndex > this.writeOffset) { + throw new Error('readIndex out of bounds exception:readIndex:' + this.readOffset + + ', writeOffset:' + this.writeOffset + + '(expected:0 <= readOffset <= writeOffset <= capacity:' + this.buffer.byteLength + ')'); } - this.readOffset = readOffset; + this.readOffset = readIndex; } getReadOffset(): number {