@@ -11,7 +11,7 @@ import Flags._
11
11
* @param from The first index where defined data are found
12
12
* @param to The first index where new data can be written
13
13
*/
14
- class PickleBuffer (data : Array [Byte ], from : Int , to : Int ) {
14
+ abstract class PickleBuffer (data : Array [Byte ], from : Int , to : Int ) {
15
15
16
16
var bytes = data
17
17
var readIndex = from
@@ -24,13 +24,13 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
24
24
bytes = bytes1
25
25
}
26
26
27
- def ensureCapacity (capacity : Int ) =
27
+ final def ensureCapacity (capacity : Int ) =
28
28
while (bytes.length < writeIndex + capacity) dble()
29
29
30
30
// -- Basic output routines --------------------------------------------
31
31
32
32
/** Write a byte of data */
33
- def writeByte (b : Int ) {
33
+ final def writeByte (b : Int ) {
34
34
if (writeIndex == bytes.length) dble()
35
35
bytes(writeIndex) = b.toByte
36
36
writeIndex += 1
@@ -39,7 +39,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
39
39
/** Write a natural number in big endian format, base 128.
40
40
* All but the last digits have bit 0x80 set.
41
41
*/
42
- def writeNat (x : Int ) =
42
+ final def writeNat (x : Int ) =
43
43
writeLongNat(x.toLong & 0x00000000FFFFFFFFL)
44
44
45
45
/**
@@ -49,7 +49,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
49
49
* if the long value is in the range Int.MIN_VALUE to
50
50
* Int.MAX_VALUE.
51
51
*/
52
- def writeLongNat (x : Long ) {
52
+ final def writeLongNat (x : Long ) {
53
53
def writeNatPrefix (x : Long ) {
54
54
val y = x >>> 7
55
55
if (y != 0L ) writeNatPrefix(y)
@@ -66,7 +66,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
66
66
* @param pos ...
67
67
* @param x ...
68
68
*/
69
- def patchNat (pos : Int , x : Int ) {
69
+ final def patchNat (pos : Int , x : Int ) {
70
70
def patchNatPrefix (x : Int ) {
71
71
writeByte(0 )
72
72
Array .copy(bytes, pos, bytes, pos+ 1 , writeIndex - (pos+ 1 ))
@@ -83,7 +83,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
83
83
*
84
84
* @param x The long number to be written.
85
85
*/
86
- def writeLong (x : Long ) {
86
+ final def writeLong (x : Long ) {
87
87
val y = x >> 8
88
88
val z = x & 0xff
89
89
if (- y != (z >> 7 )) writeLong(y)
@@ -93,18 +93,18 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
93
93
// -- Basic input routines --------------------------------------------
94
94
95
95
/** Peek at the current byte without moving the read index */
96
- def peekByte (): Int = bytes(readIndex)
96
+ final def peekByte (): Int = bytes(readIndex)
97
97
98
98
/** Read a byte */
99
- def readByte (): Int = {
99
+ final def readByte (): Int = {
100
100
val x = bytes(readIndex); readIndex += 1 ; x
101
101
}
102
102
103
103
/** Read a natural number in big endian format, base 128.
104
104
* All but the last digits have bit 0x80 set.*/
105
- def readNat (): Int = readLongNat().toInt
105
+ final def readNat (): Int = readLongNat().toInt
106
106
107
- def readLongNat (): Long = {
107
+ final def readLongNat (): Long = {
108
108
var b = 0L
109
109
var x = 0L
110
110
do {
@@ -115,7 +115,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
115
115
}
116
116
117
117
/** Read a long number in signed big endian format, base 256. */
118
- def readLong (len : Int ): Long = {
118
+ final def readLong (len : Int ): Long = {
119
119
var x = 0L
120
120
var i = 0
121
121
while (i < len) {
@@ -129,8 +129,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
129
129
/** Returns the buffer as a sequence of (Int, Array[Byte]) representing
130
130
* (tag, data) of the individual entries. Saves and restores buffer state.
131
131
*/
132
-
133
- def toIndexedSeq : IndexedSeq [(Int , Array [Byte ])] = {
132
+ final def toIndexedSeq : IndexedSeq [(Int , Array [Byte ])] = {
134
133
val saved = readIndex
135
134
readIndex = 0
136
135
readNat() ; readNat() // discarding version
@@ -157,14 +156,14 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
157
156
* @param op ...
158
157
* @return ...
159
158
*/
160
- def until [T ](end : Int , op : () => T ): List [T ] =
159
+ final def until [T ](end : Int , op : () => T ): List [T ] =
161
160
if (readIndex == end) List () else op() :: until(end, op);
162
161
163
162
/** Perform operation <code>op</code> the number of
164
163
* times specified. Concatenate the results into a list.
165
164
*/
166
- def times [T ](n : Int , op : ()=> T ): List [T ] =
165
+ final def times [T ](n : Int , op : ()=> T ): List [T ] =
167
166
if (n == 0 ) List () else op() :: times(n- 1 , op)
168
167
169
- def unpickleScalaFlags (sflags : Long ): FlagSet = ???
168
+ final def unpickleScalaFlags (sflags : Long ): FlagSet = ???
170
169
}
0 commit comments