feat[typescript]: syntax formatting of TypeScript

This commit is contained in:
godotg committed 2023-12-12 12:47:40 +08:00
1 parent 76a384f77e
commit 53c55efe25
4 files changed
+303 -184

No files matched your search

@@ -87,7 +87,7 @@ public abstract class GenerateTsUtils {
} }
public static void createProtocolManager(List<IProtocolRegistration> protocolList) throws IOException { public static void createProtocolManager(List<IProtocolRegistration> protocolList) throws IOException {
var list = List.of("typescript/buffer/ByteBuffer.ts", "typescript/buffer/Long.ts", "typescript/buffer/Longbits.ts"); var list = List.of("typescript/IByteBuffer.ts", "typescript/buffer/ByteBuffer.ts", "typescript/buffer/Long.ts", "typescript/buffer/Longbits.ts");
for (var fileName : list) { for (var fileName : list) {
var fileInputStream = ClassUtils.getFileFromClassPath(fileName); var fileInputStream = ClassUtils.getFileFromClassPath(fileName);
var createFile = new File(StringUtils.format("{}/{}", protocolOutputPath, StringUtils.substringAfterFirst(fileName, "typescript/"))); var createFile = new File(StringUtils.format("{}/{}", protocolOutputPath, StringUtils.substringAfterFirst(fileName, "typescript/")));
@@ -105,7 +105,6 @@ public abstract class GenerateTsUtils {
var path = GenerateProtocolPath.protocolAbsolutePath(protocolId, CodeLanguage.TypeScript); var path = GenerateProtocolPath.protocolAbsolutePath(protocolId, CodeLanguage.TypeScript);
importBuilder.append(StringUtils.format("import {} from './{}';", protocolName, path)).append(LS); importBuilder.append(StringUtils.format("import {} from './{}';", protocolName, path)).append(LS);
initProtocolBuilder.append(StringUtils.format("protocols.set({}, {});", protocolId, protocolName)).append(LS); initProtocolBuilder.append(StringUtils.format("protocols.set({}, {});", protocolId, protocolName)).append(LS);
} }
protocolManagerTemplate = StringUtils.format(protocolManagerTemplate, importBuilder.toString().trim(), initProtocolBuilder.toString().trim()); protocolManagerTemplate = StringUtils.format(protocolManagerTemplate, importBuilder.toString().trim(), initProtocolBuilder.toString().trim());
@@ -138,11 +137,19 @@ public abstract class GenerateTsUtils {
private static String importSubProtocol(ProtocolRegistration registration) { private static String importSubProtocol(ProtocolRegistration registration) {
var protocolId = registration.getId(); var protocolId = registration.getId();
var subProtocols = ProtocolAnalysis.getFirstSubProtocolIds(protocolId); var subProtocols = ProtocolAnalysis.getFirstSubProtocolIds(protocolId);
// import IByteBuffer first
if (CollectionUtils.isEmpty(subProtocols)) {
return StringUtils.EMPTY;
}
var importBuilder = new StringBuilder(); var importBuilder = new StringBuilder();
var protocolPath = GenerateProtocolPath.getProtocolPath(protocolId);
if (StringUtils.isEmpty(protocolPath) ) {
importBuilder.append(StringUtils.format("import IByteBuffer from './IByteBuffer';")).append(LS);
} else {
var splits = protocolPath.split(StringUtils.PERIOD_REGEX);
importBuilder.append(StringUtils.format("import IByteBuffer from '{}IByteBuffer';", "../".repeat(splits.length))).append(LS);
}
if (CollectionUtils.isEmpty(subProtocols)) {
return importBuilder.toString();
}
// import other sub protocols
for (var subProtocolId : subProtocols) { for (var subProtocolId : subProtocols) {
var protocolClassName = EnhanceObjectProtocolSerializer.getProtocolClassSimpleName(subProtocolId); var protocolClassName = EnhanceObjectProtocolSerializer.getProtocolClassSimpleName(subProtocolId);
var path = GenerateProtocolPath.getRelativePath(protocolId, subProtocolId); var path = GenerateProtocolPath.getRelativePath(protocolId, subProtocolId);
@@ -0,0 +1,117 @@
interface IByteBuffer {
adjustPadding(predictionLength: number, beforeWriteIndex: number): void
compatibleRead(beforeReadIndex: number, length: number): boolean
setWriteOffset(writeOffset: number): void
getWriteOffset(): number
setReadOffset(readOffset: number): void
getReadOffset(): number
getCapacity(): number
ensureCapacity(minCapacity: number): void
isReadable(): boolean
writeBytes(byteArray: ArrayBuffer): void
toBytes(): ArrayBuffer
writeBoolean(value: boolean): void
readBoolean(): boolean
writeByte(value: number): void
readByte(): number
writeShort(value: number): void
readShort(): number
writeRawInt(value: number): void
readRawInt(): number
writeInt(value: number): void
writeIntCount(value: number): number
readInt(): number
writeLong(value: number): void
readLong(): number
writeFloat(value: number): void
readFloat(): number
writeDouble(value: number): void
readDouble(): number
writeString(value: string): void
readString(): string
writePacket(packet: any, protocolId: number): void
readPacket(protocolId: number): any
writeBooleanArray(array: Array<boolean> | null): void
readBooleanArray(): boolean[]
writeByteArray(array: Array<number> | null): void
readByteArray(): number[]
writeShortArray(array: Array<number> | null): void
readShortArray(): number[]
writeIntArray(array: Array<number> | null): void
readIntArray(): number[]
writeLongArray(array: Array<number> | null): void
readLongArray(): number[]
writeFloatArray(array: Array<number> | null): void
readFloatArray(): number[]
writeDoubleArray(array: Array<number> | null): void
readDoubleArray(): number[]
writeStringArray(array: Array<string> | null): void
readStringArray(): string[]
writePacketArray(array: Array<any> | null, protocolId: number): void
readPacketArray(protocolId: number): any
// ---------------------------------------------list-------------------------------------------
writeBooleanList(list: Array<boolean> | null): void
readBooleanList(): boolean[]
writeByteList(list: Array<number> | null): void
readByteList(): number[]
writeShortList(list: Array<number> | null): void
readShortList(): number[]
writeIntList(list: Array<number> | null): void
readIntList(): number[]
writeLongList(list: Array<number> | null): void
readLongList(): number[]
writeFloatList(list: Array<number> | null): void
readFloatList(): number[]
writeDoubleList(list: Array<number> | null): void
readDoubleList(): number[]
writeStringList(list: Array<string> | null): void
readStringList(): string[]
writePacketList(list: Array<any> | null, protocolId: number): void
readPacketList(protocolId: number): any[]
// ---------------------------------------------set-------------------------------------------
writeBooleanSet(set: Set<boolean> | null): void
readBooleanSet(): Set<boolean>
writeByteSet(set: Set<number> | null): void
readByteSet(): Set<number>
writeShortSet(set: Set<number> | null): void
readShortSet(): Set<number>
writeIntSet(set: Set<number> | null): void
readIntSet(): Set<number>
writeLongSet(set: Set<number> | null): void
readLongSet(): Set<number>
writeFloatSet(set: Set<number> | null): void
readFloatSet(): Set<number>
writeDoubleSet(set: Set<number> | null): void
readDoubleSet(): Set<number>
writeStringSet(set: Set<string> | null): void
readStringSet(): Set<string>
writePacketSet(set: Set<any> | null, protocolId: number): void
readPacketSet(protocolId: number): Set<any>
// ---------------------------------------------map-------------------------------------------
writeIntIntMap(map: Map<number, number> | null): void
readIntIntMap(): Map<number, number>
writeIntLongMap(map: Map<number, number> | null): void
readIntLongMap(): Map<number, number>
writeIntStringMap(map: Map<number, string> | null): void
readIntStringMap(): Map<number, string>
writeIntPacketMap(map: Map<number, any> | null, protocolId: number): void
readIntPacketMap(protocolId: number): Map<number, any>
writeLongIntMap(map: Map<number, number> | null): void
readLongIntMap(): Map<number, number>
writeLongLongMap(map: Map<number, number> | null): void
readLongLongMap(): Map<number, number>
writeLongStringMap(map: Map<number, string> | null): void
readLongStringMap(): Map<number, string>
writeLongPacketMap(map: Map<number, any> | null, protocolId: number): any
readLongPacketMap(protocolId: number): Map<number, any>
writeStringIntMap(map: Map<string, number> | null): void
readStringIntMap(): Map<string, number>
writeStringLongMap(map: Map<string, number> | null): void
readStringLongMap(): Map<string, number>
writeStringStringMap(map: Map<string, string> | null): void
readStringStringMap(): Map<string, string>
writeStringPacketMap(map: Map<string, any> | null, protocolId: number): void
readStringPacketMap(protocolId: number): Map<string, any>
}
export default IByteBuffer;
@@ -10,7 +10,7 @@ class {} {
return {}.PROTOCOL_ID; return {}.PROTOCOL_ID;
} }
static write(buffer: any, packet: {} | null) { static write(buffer: IByteBuffer, packet: {} | null) {
if (packet === null) { if (packet === null) {
buffer.writeInt(0); buffer.writeInt(0);
return; return;
@@ -18,7 +18,7 @@ class {} {
{} {}
} }
static read(buffer: any): {} | null { static read(buffer: IByteBuffer): {} | null {
const length = buffer.readInt(); const length = buffer.readInt();
if (length === 0) { if (length === 0) {
return null; return null;
@@ -1,3 +1,4 @@
import IByteBuffer from "../IByteBuffer";
import ProtocolManager from "../ProtocolManager"; import ProtocolManager from "../ProtocolManager";
import {writeInt64, readInt64} from "./Longbits"; import {writeInt64, readInt64} from "./Longbits";
@@ -44,7 +45,7 @@ function decodeZigzagInt(n: number) {
} }
class ByteBuffer { class ByteBuffer implements IByteBuffer{
writeOffset: number; writeOffset: number;
readOffset: number; readOffset: number;
buffer: ArrayBuffer; buffer: ArrayBuffer;
@@ -388,21 +389,15 @@ class ByteBuffer {
return value; return value;
} }
writePacketFlag(value: any): boolean { writePacket(packet: any, protocolId: number): void {
const flag = (value === null) || (value === undefined);
this.writeBoolean(!flag);
return flag;
};
writePacket(packet: any, protocolId: number) {
const protocolRegistration = ProtocolManager.getProtocol(protocolId); const protocolRegistration = ProtocolManager.getProtocol(protocolId);
protocolRegistration.write(this, packet); protocolRegistration.write(this, packet);
}; }
readPacket(protocolId: number): any { readPacket(protocolId: number): any {
const protocolRegistration = ProtocolManager.getProtocol(protocolId); const protocolRegistration = ProtocolManager.getProtocol(protocolId);
return protocolRegistration.read(this); return protocolRegistration.read(this);
}; }
writeBooleanArray(array: Array<boolean> | null) { writeBooleanArray(array: Array<boolean> | null) {
if (array === null) { if (array === null) {
@@ -413,9 +408,9 @@ class ByteBuffer {
this.writeBoolean(element); this.writeBoolean(element);
}); });
} }
}; }
readBooleanArray(): any { readBooleanArray(): Array<boolean> {
const array: boolean[] = []; const array: boolean[] = [];
const length = this.readInt(); const length = this.readInt();
if (length > 0) { if (length > 0) {
@@ -424,9 +419,9 @@ class ByteBuffer {
} }
} }
return array; return array;
}; }
writeByteArray(array: Array<number> | null) { writeByteArray(array: Array<number> | null): void {
if (array === null) { if (array === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -435,9 +430,9 @@ class ByteBuffer {
this.writeByte(element); this.writeByte(element);
}); });
} }
}; }
readByteArray(): any { readByteArray(): Array<number> {
const array: number[] = []; const array: number[] = [];
const length = this.readInt(); const length = this.readInt();
if (length > 0) { if (length > 0) {
@@ -446,9 +441,9 @@ class ByteBuffer {
} }
} }
return array; return array;
}; }
writeShortArray(array: Array<number> | null) { writeShortArray(array: Array<number> | null): void {
if (array === null) { if (array === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -457,9 +452,9 @@ class ByteBuffer {
this.writeShort(element); this.writeShort(element);
}); });
} }
}; }
readShortArray(): any { readShortArray(): number[] {
const array: number[] = []; const array: number[] = [];
const length = this.readInt(); const length = this.readInt();
if (length > 0) { if (length > 0) {
@@ -468,9 +463,9 @@ class ByteBuffer {
} }
} }
return array; return array;
}; }
writeIntArray(array: Array<number> | null) { writeIntArray(array: Array<number> | null): void {
if (array === null) { if (array === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -479,9 +474,9 @@ class ByteBuffer {
this.writeInt(element); this.writeInt(element);
}); });
} }
}; }
readIntArray(): any { readIntArray(): number[] {
const array: number[] = []; const array: number[] = [];
const length = this.readInt(); const length = this.readInt();
if (length > 0) { if (length > 0) {
@@ -490,9 +485,9 @@ class ByteBuffer {
} }
} }
return array; return array;
}; }
writeLongArray(array: Array<number> | null) { writeLongArray(array: Array<number> | null): void {
if (array === null) { if (array === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -501,9 +496,9 @@ class ByteBuffer {
this.writeLong(element); this.writeLong(element);
}); });
} }
}; }
readLongArray(): any { readLongArray(): number[] {
const array: number[] = []; const array: number[] = [];
const length = this.readInt(); const length = this.readInt();
if (length > 0) { if (length > 0) {
@@ -512,9 +507,9 @@ class ByteBuffer {
} }
} }
return array; return array;
}; }
writeFloatArray(array: Array<number> | null) { writeFloatArray(array: Array<number> | null): void {
if (array === null) { if (array === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -523,9 +518,9 @@ class ByteBuffer {
this.writeFloat(element); this.writeFloat(element);
}); });
} }
}; }
readFloatArray(): any { readFloatArray(): number[] {
const array: number[] = []; const array: number[] = [];
const length = this.readInt(); const length = this.readInt();
if (length > 0) { if (length > 0) {
@@ -534,9 +529,9 @@ class ByteBuffer {
} }
} }
return array; return array;
}; }
writeDoubleArray(array: Array<number> | null) { writeDoubleArray(array: Array<number> | null): void {
if (array === null) { if (array === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -545,9 +540,9 @@ class ByteBuffer {
this.writeDouble(element); this.writeDouble(element);
}); });
} }
}; }
readDoubleArray(): any { readDoubleArray(): number[] {
const array: number[] = []; const array: number[] = [];
const length = this.readInt(); const length = this.readInt();
if (length > 0) { if (length > 0) {
@@ -556,9 +551,9 @@ class ByteBuffer {
} }
} }
return array; return array;
}; }
writeStringArray(array: Array<string> | null) { writeStringArray(array: Array<string> | null): void {
if (array === null) { if (array === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -567,9 +562,9 @@ class ByteBuffer {
this.writeString(element); this.writeString(element);
}); });
} }
}; }
readStringArray(): any { readStringArray(): string[] {
const array: string[] = []; const array: string[] = [];
const length = this.readInt(); const length = this.readInt();
if (length > 0) { if (length > 0) {
@@ -578,9 +573,9 @@ class ByteBuffer {
} }
} }
return array; return array;
}; }
writePacketArray(array: Array<any> | null, protocolId: number) { writePacketArray(array: Array<any> | null, protocolId: number): void {
if (array === null) { if (array === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -590,9 +585,9 @@ class ByteBuffer {
protocolRegistration.write(this, element); protocolRegistration.write(this, element);
}); });
} }
}; }
readPacketArray(protocolId: number): any { readPacketArray(protocolId: number): any[] {
const array: any[] = []; const array: any[] = [];
const length = this.readInt(); const length = this.readInt();
if (length > 0) { if (length > 0) {
@@ -602,83 +597,83 @@ class ByteBuffer {
} }
} }
return array; return array;
}; }
// ---------------------------------------------list------------------------------------------- // ---------------------------------------------list-------------------------------------------
writeBooleanList(list: any) { writeBooleanList(list: Array<boolean> | null): void {
this.writeBooleanArray(list); this.writeBooleanArray(list);
}; }
readBooleanList(): any { readBooleanList(): boolean[] {
return this.readBooleanArray(); return this.readBooleanArray();
}; }
writeByteList(list: any) { writeByteList(list: Array<number> | null): void {
this.writeByteArray(list); this.writeByteArray(list);
}; }
readByteList(): any { readByteList(): number[] {
return this.readByteArray(); return this.readByteArray();
}; }
writeShortList(list: any) { writeShortList(list: Array<number> | null): void {
this.writeShortArray(list); this.writeShortArray(list);
}; }
readShortList(): any { readShortList(): number[] {
return this.readShortArray(); return this.readShortArray();
}; }
writeIntList(list: any) { writeIntList(list: Array<number> | null): void {
this.writeIntArray(list); this.writeIntArray(list);
}; }
readIntList(): any { readIntList(): number[] {
return this.readIntArray(); return this.readIntArray();
}; }
writeLongList(list: any) { writeLongList(list: Array<number> | null): void {
this.writeLongArray(list); this.writeLongArray(list);
}; }
readLongList(): any { readLongList(): number[] {
return this.readLongArray(); return this.readLongArray();
}; }
writeFloatList(list: any) { writeFloatList(list: Array<number> | null): void {
this.writeFloatArray(list); this.writeFloatArray(list);
}; }
readFloatList(): any { readFloatList(): number[] {
return this.readFloatArray(); return this.readFloatArray();
}; }
writeDoubleList(list: any) { writeDoubleList(list: Array<number> | null): void {
this.writeDoubleArray(list); this.writeDoubleArray(list);
}; }
readDoubleList(): any { readDoubleList(): number[] {
return this.readDoubleArray(); return this.readDoubleArray();
}; }
writeStringList(list: any) { writeStringList(list: Array<string> | null): void {
this.writeStringArray(list); this.writeStringArray(list);
}; }
readStringList(): any { readStringList(): string[] {
return this.readStringArray(); return this.readStringArray();
}; }
writePacketList(list: any, protocolId: number) { writePacketList(list: Array<any> | null, protocolId: number): void {
this.writePacketArray(list, protocolId); this.writePacketArray(list, protocolId);
}; }
readPacketList(protocolId: number): any { readPacketList(protocolId: number): any[] {
return this.readPacketArray(protocolId); return this.readPacketArray(protocolId);
}; }
// ---------------------------------------------set------------------------------------------- // ---------------------------------------------set-------------------------------------------
writeBooleanSet(set: Set<boolean> | null) { writeBooleanSet(set: Set<boolean> | null): void {
if (set === null) { if (set === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -687,13 +682,13 @@ class ByteBuffer {
this.writeBoolean(element); this.writeBoolean(element);
}); });
} }
}; }
readBooleanSet(): any { readBooleanSet(): Set<boolean> {
return new Set(this.readBooleanArray()); return new Set(this.readBooleanArray());
}; }
writeByteSet(set: Set<number> | null) { writeByteSet(set: Set<number> | null): void {
if (set === null) { if (set === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -702,13 +697,13 @@ class ByteBuffer {
this.writeByte(element); this.writeByte(element);
}); });
} }
}; }
readByteSet(): any { readByteSet(): Set<number> {
return new Set(this.readByteArray()); return new Set(this.readByteArray());
}; }
writeShortSet(set: Set<number> | null) { writeShortSet(set: Set<number> | null): void {
if (set === null) { if (set === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -717,13 +712,13 @@ class ByteBuffer {
this.writeShort(element); this.writeShort(element);
}); });
} }
}; }
readShortSet(): any { readShortSet(): Set<number> {
return new Set(this.readShortArray()); return new Set(this.readShortArray());
}; }
writeIntSet(set: Set<number> | null) { writeIntSet(set: Set<number> | null): void {
if (set === null) { if (set === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -732,13 +727,13 @@ class ByteBuffer {
this.writeInt(element); this.writeInt(element);
}); });
} }
}; }
readIntSet(): any { readIntSet(): Set<number> {
return new Set(this.readIntArray()); return new Set(this.readIntArray());
}; }
writeLongSet(set: Set<number> | null) { writeLongSet(set: Set<number> | null): void {
if (set === null) { if (set === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -747,13 +742,13 @@ class ByteBuffer {
this.writeLong(element); this.writeLong(element);
}); });
} }
}; }
readLongSet(): any { readLongSet(): Set<number> {
return new Set(this.readLongArray()); return new Set(this.readLongArray());
}; }
writeFloatSet(set: Set<number> | null) { writeFloatSet(set: Set<number> | null): void {
if (set === null) { if (set === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -762,13 +757,13 @@ class ByteBuffer {
this.writeFloat(element); this.writeFloat(element);
}); });
} }
}; }
readFloatSet(): any { readFloatSet(): Set<number> {
return new Set(this.readFloatArray()); return new Set(this.readFloatArray());
}; }
writeDoubleSet(set: Set<number> | null) { writeDoubleSet(set: Set<number> | null): void {
if (set === null) { if (set === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -777,13 +772,13 @@ class ByteBuffer {
this.writeDouble(element); this.writeDouble(element);
}); });
} }
}; }
readDoubleSet(): any { readDoubleSet(): Set<number> {
return new Set(this.readDoubleArray()); return new Set(this.readDoubleArray());
}; }
writeStringSet(set: Set<string> | null) { writeStringSet(set: Set<string> | null): void {
if (set === null) { if (set === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -792,13 +787,13 @@ class ByteBuffer {
this.writeString(element); this.writeString(element);
}); });
} }
}; }
readStringSet(): any { readStringSet(): Set<string> {
return new Set(this.readStringArray()); return new Set(this.readStringArray());
}; }
writePacketSet(set: Set<any> | null, protocolId: number) { writePacketSet(set: Set<any> | null, protocolId: number): void {
if (set === null) { if (set === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -808,14 +803,14 @@ class ByteBuffer {
protocolRegistration.write(this, element); protocolRegistration.write(this, element);
}); });
} }
}; }
readPacketSet(protocolId: number): any { readPacketSet(protocolId: number): Set<any> {
return new Set(this.readPacketArray(protocolId)); return new Set(this.readPacketArray(protocolId));
}; }
// ---------------------------------------------map------------------------------------------- // ---------------------------------------------map-------------------------------------------
writeIntIntMap(map: Map<number, number> | null) { writeIntIntMap(map: Map<number, number> | null): void {
if (map === null) { if (map === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -825,10 +820,10 @@ class ByteBuffer {
this.writeInt(value); this.writeInt(value);
}); });
} }
}; }
readIntIntMap(): any { readIntIntMap(): Map<number, number> {
const map = new Map(); const map = new Map<number, number>();
const size = this.readInt(); const size = this.readInt();
if (size > 0) { if (size > 0) {
for (let index = 0; index < size; index++) { for (let index = 0; index < size; index++) {
@@ -838,9 +833,9 @@ class ByteBuffer {
} }
} }
return map; return map;
}; }
writeIntLongMap(map: Map<number, number> | null) { writeIntLongMap(map: Map<number, number> | null): void {
if (map === null) { if (map === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -850,10 +845,10 @@ class ByteBuffer {
this.writeLong(value); this.writeLong(value);
}); });
} }
}; }
readIntLongMap(): any { readIntLongMap(): Map<number, number> {
const map = new Map(); const map = new Map<number, number>();
const size = this.readInt(); const size = this.readInt();
if (size > 0) { if (size > 0) {
for (let index = 0; index < size; index++) { for (let index = 0; index < size; index++) {
@@ -863,9 +858,9 @@ class ByteBuffer {
} }
} }
return map; return map;
}; }
writeIntStringMap(map: Map<number, string> | null) { writeIntStringMap(map: Map<number, string> | null): void {
if (map === null) { if (map === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -875,10 +870,10 @@ class ByteBuffer {
this.writeString(value); this.writeString(value);
}); });
} }
}; }
readIntStringMap(): any { readIntStringMap(): Map<number, string> {
const map = new Map(); const map = new Map<number, string>();
const size = this.readInt(); const size = this.readInt();
if (size > 0) { if (size > 0) {
for (let index = 0; index < size; index++) { for (let index = 0; index < size; index++) {
@@ -888,9 +883,9 @@ class ByteBuffer {
} }
} }
return map; return map;
}; }
writeIntPacketMap(map: Map<number, any> | null, protocolId: number) { writeIntPacketMap(map: Map<number, any> | null, protocolId: number): void {
if (map === null) { if (map === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -901,10 +896,10 @@ class ByteBuffer {
protocolRegistration.write(this, value); protocolRegistration.write(this, value);
}); });
} }
}; }
readIntPacketMap(protocolId: number): any { readIntPacketMap(protocolId: number): Map<number, any> {
const map = new Map(); const map = new Map<number, any>();
const size = this.readInt(); const size = this.readInt();
if (size > 0) { if (size > 0) {
const protocolRegistration = ProtocolManager.getProtocol(protocolId); const protocolRegistration = ProtocolManager.getProtocol(protocolId);
@@ -915,9 +910,9 @@ class ByteBuffer {
} }
} }
return map; return map;
}; }
writeLongIntMap(map: Map<number, number> | null) { writeLongIntMap(map: Map<number, number> | null): void {
if (map === null) { if (map === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -927,10 +922,10 @@ class ByteBuffer {
this.writeInt(value); this.writeInt(value);
}); });
} }
}; }
readLongIntMap(): any { readLongIntMap(): Map<number, number> {
const map = new Map(); const map = new Map<number, number>();
const size = this.readInt(); const size = this.readInt();
if (size > 0) { if (size > 0) {
for (let index = 0; index < size; index++) { for (let index = 0; index < size; index++) {
@@ -940,9 +935,9 @@ class ByteBuffer {
} }
} }
return map; return map;
}; }
writeLongLongMap(map: Map<number, number> | null) { writeLongLongMap(map: Map<number, number> | null): void {
if (map === null) { if (map === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -952,10 +947,10 @@ class ByteBuffer {
this.writeLong(value); this.writeLong(value);
}); });
} }
}; }
readLongLongMap(): any { readLongLongMap(): Map<number, number> {
const map = new Map(); const map = new Map<number, number>();
const size = this.readInt(); const size = this.readInt();
if (size > 0) { if (size > 0) {
for (let index = 0; index < size; index++) { for (let index = 0; index < size; index++) {
@@ -965,9 +960,9 @@ class ByteBuffer {
} }
} }
return map; return map;
}; }
writeLongStringMap(map: Map<number, string> | null) { writeLongStringMap(map: Map<number, string> | null): void {
if (map === null) { if (map === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -977,10 +972,10 @@ class ByteBuffer {
this.writeString(value); this.writeString(value);
}); });
} }
}; }
readLongStringMap(): any { readLongStringMap(): Map<number, string> {
const map = new Map(); const map = new Map<number, string>();
const size = this.readInt(); const size = this.readInt();
if (size > 0) { if (size > 0) {
for (let index = 0; index < size; index++) { for (let index = 0; index < size; index++) {
@@ -990,7 +985,7 @@ class ByteBuffer {
} }
} }
return map; return map;
}; }
writeLongPacketMap(map: Map<number, any> | null, protocolId: number): any { writeLongPacketMap(map: Map<number, any> | null, protocolId: number): any {
if (map === null) { if (map === null) {
@@ -1003,10 +998,10 @@ class ByteBuffer {
protocolRegistration.write(this, value); protocolRegistration.write(this, value);
}); });
} }
}; }
readLongPacketMap(protocolId: number): any { readLongPacketMap(protocolId: number): Map<number, any> {
const map = new Map(); const map = new Map<number, any>();
const size = this.readInt(); const size = this.readInt();
if (size > 0) { if (size > 0) {
const protocolRegistration = ProtocolManager.getProtocol(protocolId); const protocolRegistration = ProtocolManager.getProtocol(protocolId);
@@ -1017,9 +1012,9 @@ class ByteBuffer {
} }
} }
return map; return map;
}; }
writeStringIntMap(map: Map<string, number> | null) { writeStringIntMap(map: Map<string, number> | null): void {
if (map === null) { if (map === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -1029,10 +1024,10 @@ class ByteBuffer {
this.writeInt(value); this.writeInt(value);
}); });
} }
}; }
readStringIntMap(): any { readStringIntMap(): Map<string, number> {
const map = new Map(); const map = new Map<string, number>();
const size = this.readInt(); const size = this.readInt();
if (size > 0) { if (size > 0) {
for (let index = 0; index < size; index++) { for (let index = 0; index < size; index++) {
@@ -1042,9 +1037,9 @@ class ByteBuffer {
} }
} }
return map; return map;
}; }
writeStringLongMap(map: Map<string, number> | null) { writeStringLongMap(map: Map<string, number> | null): void {
if (map === null) { if (map === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -1054,10 +1049,10 @@ class ByteBuffer {
this.writeLong(value); this.writeLong(value);
}); });
} }
}; }
readStringLongMap(): any { readStringLongMap(): Map<string, number> {
const map = new Map(); const map = new Map<string, number>();
const size = this.readInt(); const size = this.readInt();
if (size > 0) { if (size > 0) {
for (let index = 0; index < size; index++) { for (let index = 0; index < size; index++) {
@@ -1067,9 +1062,9 @@ class ByteBuffer {
} }
} }
return map; return map;
}; }
writeStringStringMap(map: Map<string, string> | null) { writeStringStringMap(map: Map<string, string> | null): void {
if (map === null) { if (map === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -1079,10 +1074,10 @@ class ByteBuffer {
this.writeString(value); this.writeString(value);
}); });
} }
}; }
readStringStringMap(): any { readStringStringMap(): Map<string, string> {
const map = new Map(); const map = new Map<string, string>();
const size = this.readInt(); const size = this.readInt();
if (size > 0) { if (size > 0) {
for (let index = 0; index < size; index++) { for (let index = 0; index < size; index++) {
@@ -1092,9 +1087,9 @@ class ByteBuffer {
} }
} }
return map; return map;
}; }
writeStringPacketMap(map: Map<string, any> | null, protocolId: number) { writeStringPacketMap(map: Map<string, any> | null, protocolId: number): void {
if (map === null) { if (map === null) {
this.writeInt(0); this.writeInt(0);
} else { } else {
@@ -1105,10 +1100,10 @@ class ByteBuffer {
protocolRegistration.write(this, value); protocolRegistration.write(this, value);
}); });
} }
}; }
readStringPacketMap(protocolId: number): any { readStringPacketMap(protocolId: number): Map<string, any> {
const map = new Map(); const map = new Map<string, any>();
const size = this.readInt(); const size = this.readInt();
if (size > 0) { if (size > 0) {
const protocolRegistration = ProtocolManager.getProtocol(protocolId); const protocolRegistration = ProtocolManager.getProtocol(protocolId);
@@ -1119,7 +1114,7 @@ class ByteBuffer {
} }
} }
return map; return map;
}; }
} }
export default ByteBuffer; export default ByteBuffer;