@@ -13,7 +13,7 @@ var readOffset: int = 0
13
13
func _init ():
14
14
buffer .big_endian = true
15
15
16
- func adjustPadding (predictionLength : int , beforeWriteIndex : int ) -> void :
16
+ func adjustPadding (predictionLength : int , beforeWriteIndex : int ):
17
17
var currentWriteIndex = writeOffset
18
18
var predictionCount = writeIntCount (predictionLength )
19
19
var length = currentWriteIndex - beforeWriteIndex - predictionCount
@@ -24,7 +24,7 @@ func adjustPadding(predictionLength: int, beforeWriteIndex: int) -> void:
24
24
writeInt (length )
25
25
setWriteOffset (currentWriteIndex )
26
26
else :
27
- # get_partial_data of StreamPeerBuffer is deep clone
27
+ # get_partial_data of StreamPeerBuffer is deep clone
28
28
buffer .seek (currentWriteIndex - length )
29
29
var retainedByteBuf = buffer .get_partial_data (length )[1 ]
30
30
setWriteOffset (beforeWriteIndex )
@@ -43,7 +43,7 @@ func compatibleRead(beforeReadIndex: int, length: int) -> bool:
43
43
func getBuffer () -> StreamPeerBuffer :
44
44
return buffer
45
45
46
- func setWriteOffset (writeIndex : int ) -> void :
46
+ func setWriteOffset (writeIndex : int ):
47
47
if (writeIndex > buffer .get_size ()):
48
48
var template = "writeIndex[{} ] out of bounds exception: readOffset: {} , writeOffset: {} (expected: 0 <= readOffset <= writeOffset <= capacity: {} )"
49
49
printerr (template .format ([writeIndex , readOffset , writeOffset , buffer .get_size ()], "{} " ))
@@ -54,7 +54,7 @@ func setWriteOffset(writeIndex: int) -> void:
54
54
func getWriteOffset () -> int :
55
55
return writeOffset
56
56
57
- func setReadOffset (readIndex : int ) -> void :
57
+ func setReadOffset (readIndex : int ):
58
58
if (readIndex > writeOffset ):
59
59
var template = "readIndex[{} ] out of bounds exception: readOffset: {} , writeOffset: {} (expected: 0 <= readOffset <= writeOffset <= capacity: {} )"
60
60
printerr (template .format ([readIndex , readOffset , writeOffset , buffer .size ()], "{} " ))
@@ -71,7 +71,7 @@ func isReadable() -> bool:
71
71
func toBytes () -> PackedByteArray :
72
72
return buffer .data_array .slice (0 , writeOffset )
73
73
74
- func newInstance (protocolId : int ):
74
+ func newInstance (protocolId : int ) -> Object :
75
75
return ProtocolManager .newInstance (protocolId )
76
76
77
77
# -------------------------------------------------write/read-------------------------------------------------
@@ -84,7 +84,7 @@ func writeBytes(value: PackedByteArray):
84
84
func readBytes (length : int ) -> PackedByteArray :
85
85
return buffer .data_array .slice (0 , length )
86
86
87
- func writeBool (value : bool ) -> void :
87
+ func writeBool (value : bool ):
88
88
var byte : int = 1 if value else 0
89
89
buffer .seek (writeOffset )
90
90
buffer .put_8 (byte )
@@ -97,7 +97,7 @@ func readBool() -> bool:
97
97
readOffset += 1
98
98
return byte == 1
99
99
100
- func writeByte (value : int ) -> void :
100
+ func writeByte (value : int ):
101
101
buffer .seek (writeOffset )
102
102
buffer .put_8 (value )
103
103
writeOffset += 1
@@ -109,7 +109,7 @@ func readByte() -> int:
109
109
readOffset += 1
110
110
return value
111
111
112
- func writeShort (value : int ) -> void :
112
+ func writeShort (value : int ):
113
113
buffer .seek (writeOffset )
114
114
buffer .put_16 (value )
115
115
writeOffset += 2
@@ -121,7 +121,7 @@ func readShort() -> int:
121
121
readOffset += 2
122
122
return value
123
123
124
- func writeRawInt (value ) -> void :
124
+ func writeRawInt (value ):
125
125
buffer .seek (writeOffset )
126
126
buffer .put_32 (value )
127
127
writeOffset += 4
@@ -133,7 +133,7 @@ func readRawInt() -> int:
133
133
readOffset += 4
134
134
return value
135
135
136
- func writeInt (value ) -> void :
136
+ func writeInt (value ):
137
137
if ! (minInt <= value && value <= maxInt ):
138
138
printerr ("value must range between minInt:-2147483648 and maxInt:2147483647" )
139
139
return
@@ -158,7 +158,7 @@ func writeIntCount(value: int) -> int:
158
158
func readInt () -> int :
159
159
return readLong ()
160
160
161
- func writeLong (longValue : int ) -> void :
161
+ func writeLong (longValue : int ):
162
162
var value : int = (longValue << 1 ) ^ (longValue >> 63 )
163
163
164
164
if (value >> 7 == 0 ):
@@ -257,7 +257,7 @@ func readLong() -> int:
257
257
return mask ^ - (value & 1 )
258
258
259
259
260
- func writeFloat (value : float ) -> void :
260
+ func writeFloat (value : float ):
261
261
buffer .seek (writeOffset )
262
262
buffer .put_float (value )
263
263
writeOffset += 4
@@ -269,7 +269,7 @@ func readFloat() -> float:
269
269
readOffset += 4
270
270
return value
271
271
272
- func writeDouble (value : float ) -> void :
272
+ func writeDouble (value : float ):
273
273
buffer .seek (writeOffset )
274
274
buffer .put_double (value )
275
275
writeOffset += 8
@@ -282,7 +282,7 @@ func readDouble() -> float:
282
282
return value
283
283
284
284
285
- func writeString (value : String ) -> void :
285
+ func writeString (value : String ):
286
286
if (value == null || value .length () == 0 ):
287
287
writeInt (0 )
288
288
return
@@ -309,7 +309,7 @@ func writePacket(packet, protocolId):
309
309
protocolRegistration .write (self , packet )
310
310
pass
311
311
312
- func readPacket (protocolId ):
312
+ func readPacket (protocolId ) -> Object :
313
313
var protocolRegistration = ProtocolManager .getProtocol (protocolId )
314
314
return protocolRegistration .read (self )
315
315
@@ -356,7 +356,7 @@ func writeShortArray(array):
356
356
writeShort (element )
357
357
pass
358
358
359
- func readShortArray ():
359
+ func readShortArray () -> Array [ int ] :
360
360
var array : Array [int ] = []
361
361
var size = readInt ()
362
362
if (size > 0 ):
@@ -373,7 +373,7 @@ func writeIntArray(array):
373
373
writeInt (element )
374
374
pass
375
375
376
- func readIntArray ():
376
+ func readIntArray () -> Array [ int ] :
377
377
var array : Array [int ] = []
378
378
var size = readInt ()
379
379
if (size > 0 ):
@@ -390,7 +390,7 @@ func writeLongArray(array):
390
390
writeLong (element )
391
391
pass
392
392
393
- func readLongArray ():
393
+ func readLongArray () -> Array [ int ] :
394
394
var array : Array [int ] = []
395
395
var size = readInt ()
396
396
if (size > 0 ):
@@ -407,7 +407,7 @@ func writeFloatArray(array):
407
407
writeFloat (element )
408
408
pass
409
409
410
- func readFloatArray ():
410
+ func readFloatArray () -> Array [ float ] :
411
411
var array : Array [float ] = []
412
412
var size = readInt ()
413
413
if (size > 0 ):
@@ -424,7 +424,7 @@ func writeDoubleArray(array):
424
424
writeDouble (element )
425
425
pass
426
426
427
- func readDoubleArray ():
427
+ func readDoubleArray () -> Array [ float ] :
428
428
var array : Array [float ] = []
429
429
var size = readInt ()
430
430
if (size > 0 ):
@@ -441,7 +441,7 @@ func writeStringArray(array):
441
441
writeString (element )
442
442
pass
443
443
444
- func readStringArray ():
444
+ func readStringArray () -> Array [ String ] :
445
445
var array : Array [String ] = []
446
446
var size = readInt ()
447
447
if (size > 0 ):
@@ -459,7 +459,7 @@ func writePacketArray(array, protocolId):
459
459
protocolRegistration .write (self , element )
460
460
pass
461
461
462
- func readPacketArray (protocolId ):
462
+ func readPacketArray (protocolId ) -> Array :
463
463
var protocolRegistration = ProtocolManager .getProtocol (protocolId )
464
464
var protocol = ProtocolManager .getProtocolClass (protocolId )
465
465
var array = Array ([], typeof (protocol ), StringName ("RefCounted" ), protocol )
@@ -487,7 +487,7 @@ func writeIntIntMap(map):
487
487
writeInt (map [key ])
488
488
pass
489
489
490
- func readIntIntMap ():
490
+ func readIntIntMap () -> Dictionary [ int , int ] :
491
491
var map : Dictionary [int , int ] = {}
492
492
var size = readInt ()
493
493
if (size > 0 ):
@@ -507,7 +507,7 @@ func writeIntLongMap(map):
507
507
writeLong (map [key ])
508
508
pass
509
509
510
- func readIntLongMap ():
510
+ func readIntLongMap () -> Dictionary [ int , int ] :
511
511
var map : Dictionary [int , int ] = {}
512
512
var size = readInt ()
513
513
if (size > 0 ):
@@ -527,7 +527,7 @@ func writeIntStringMap(map):
527
527
writeString (map [key ])
528
528
pass
529
529
530
- func readIntStringMap ():
530
+ func readIntStringMap () -> Dictionary [ int , String ] :
531
531
var map : Dictionary [int , String ] = {}
532
532
var size = readInt ()
533
533
if (size > 0 ):
@@ -548,7 +548,7 @@ func writeIntPacketMap(map, protocolId):
548
548
protocolRegistration .write (self , map [key ])
549
549
pass
550
550
551
- func readIntPacketMap (protocolId ):
551
+ func readIntPacketMap (protocolId ) -> Dictionary :
552
552
var protocolRegistration = ProtocolManager .getProtocol (protocolId )
553
553
var protocol = ProtocolManager .getProtocolClass (protocolId )
554
554
var map = Dictionary ({}, TYPE_INT , "" , null , typeof (protocol ), StringName ("RefCounted" ), protocol )
@@ -570,7 +570,7 @@ func writeLongIntMap(map):
570
570
writeInt (map [key ])
571
571
pass
572
572
573
- func readLongIntMap ():
573
+ func readLongIntMap () -> Dictionary [ int , int ] :
574
574
var map : Dictionary [int , int ] = {}
575
575
var size = readInt ()
576
576
if (size > 0 ):
@@ -590,7 +590,7 @@ func writeLongLongMap(map):
590
590
writeLong (map [key ])
591
591
pass
592
592
593
- func readLongLongMap ():
593
+ func readLongLongMap () -> Dictionary [ int , int ] :
594
594
var map : Dictionary [int , int ] = {}
595
595
var size = readInt ()
596
596
if (size > 0 ):
@@ -610,7 +610,7 @@ func writeLongStringMap(map):
610
610
writeString (map [key ])
611
611
pass
612
612
613
- func readLongStringMap ():
613
+ func readLongStringMap () -> Dictionary [ int , String ] :
614
614
var map : Dictionary [int , String ] = {}
615
615
var size = readInt ()
616
616
if (size > 0 ):
@@ -631,7 +631,7 @@ func writeLongPacketMap(map, protocolId):
631
631
protocolRegistration .write (self , map [key ])
632
632
pass
633
633
634
- func readLongPacketMap (protocolId ):
634
+ func readLongPacketMap (protocolId ) -> Dictionary :
635
635
var protocolRegistration = ProtocolManager .getProtocol (protocolId )
636
636
var protocol = ProtocolManager .getProtocolClass (protocolId )
637
637
var map = Dictionary ({}, TYPE_INT , "" , null , typeof (protocol ), StringName ("RefCounted" ), protocol )
@@ -653,7 +653,7 @@ func writeStringIntMap(map):
653
653
writeInt (map [key ])
654
654
pass
655
655
656
- func readStringIntMap ():
656
+ func readStringIntMap () -> Dictionary [ String , String ] :
657
657
var map : Dictionary [String , String ] = {}
658
658
var size = readInt ()
659
659
if (size > 0 ):
@@ -673,7 +673,7 @@ func writeStringLongMap(map):
673
673
writeLong (map [key ])
674
674
pass
675
675
676
- func readStringLongMap ():
676
+ func readStringLongMap () -> Dictionary [ String , int ] :
677
677
var map : Dictionary [String , int ] = {}
678
678
var size = readInt ()
679
679
if (size > 0 ):
@@ -693,7 +693,7 @@ func writeStringStringMap(map):
693
693
writeString (map [key ])
694
694
pass
695
695
696
- func readStringStringMap ():
696
+ func readStringStringMap () -> Dictionary [ String , String ] :
697
697
var map : Dictionary [String , String ] = {}
698
698
var size = readInt ()
699
699
if (size > 0 ):
@@ -714,7 +714,7 @@ func writeStringPacketMap(map, protocolId):
714
714
protocolRegistration .write (self , map [key ])
715
715
pass
716
716
717
- func readStringPacketMap (protocolId ):
717
+ func readStringPacketMap (protocolId ) -> Dictionary :
718
718
var protocolRegistration = ProtocolManager .getProtocol (protocolId )
719
719
var protocol = ProtocolManager .getProtocolClass (protocolId )
720
720
var map = Dictionary ({}, TYPE_STRING , "" , null , typeof (protocol ), StringName ("RefCounted" ), protocol )
0 commit comments