72 #else[rw] |
69 #else[rw] |
73 super(bb, mark, pos, lim, cap, addr); |
70 super(bb, mark, pos, lim, cap, addr); |
74 #end[rw] |
71 #end[rw] |
75 } |
72 } |
76 |
73 |
|
74 @Override |
|
75 Object base() { |
|
76 return bb.hb; |
|
77 } |
|
78 |
77 public $Type$Buffer slice() { |
79 public $Type$Buffer slice() { |
78 int pos = this.position(); |
80 int pos = this.position(); |
79 int lim = this.limit(); |
81 int lim = this.limit(); |
80 assert (pos <= lim); |
82 assert (pos <= lim); |
81 int rem = (pos <= lim ? lim - pos : 0); |
83 int rem = (pos <= lim ? lim - pos : 0); |
115 protected long byteOffset(long i) { |
117 protected long byteOffset(long i) { |
116 return (i << $LG_BYTES_PER_VALUE$) + address; |
118 return (i << $LG_BYTES_PER_VALUE$) + address; |
117 } |
119 } |
118 |
120 |
119 public $type$ get() { |
121 public $type$ get() { |
120 $memtype$ x = unsafe.get$Memtype$Unaligned(bb.hb, byteOffset(nextGetIndex()), |
122 $memtype$ x = UNSAFE.get$Memtype$Unaligned(bb.hb, byteOffset(nextGetIndex()), |
121 {#if[boB]?true:false}); |
123 {#if[boB]?true:false}); |
122 return $fromBits$(x); |
124 return $fromBits$(x); |
123 } |
125 } |
124 |
126 |
125 public $type$ get(int i) { |
127 public $type$ get(int i) { |
126 $memtype$ x = unsafe.get$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)), |
128 $memtype$ x = UNSAFE.get$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)), |
127 {#if[boB]?true:false}); |
129 {#if[boB]?true:false}); |
128 return $fromBits$(x); |
130 return $fromBits$(x); |
129 } |
131 } |
130 |
132 |
131 #if[streamableType] |
133 #if[streamableType] |
132 $type$ getUnchecked(int i) { |
134 $type$ getUnchecked(int i) { |
133 $memtype$ x = unsafe.get$Memtype$Unaligned(bb.hb, byteOffset(i), |
135 $memtype$ x = UNSAFE.get$Memtype$Unaligned(bb.hb, byteOffset(i), |
134 {#if[boB]?true:false}); |
136 {#if[boB]?true:false}); |
135 return $fromBits$(x); |
137 return $fromBits$(x); |
136 } |
138 } |
137 #end[streamableType] |
139 #end[streamableType] |
138 |
140 |
139 #end[rw] |
141 #end[rw] |
140 |
142 |
141 public $Type$Buffer put($type$ x) { |
143 public $Type$Buffer put($type$ x) { |
142 #if[rw] |
144 #if[rw] |
143 $memtype$ y = $toBits$(x); |
145 $memtype$ y = $toBits$(x); |
144 unsafe.put$Memtype$Unaligned(bb.hb, byteOffset(nextPutIndex()), y, |
146 UNSAFE.put$Memtype$Unaligned(bb.hb, byteOffset(nextPutIndex()), y, |
145 {#if[boB]?true:false}); |
147 {#if[boB]?true:false}); |
146 return this; |
148 return this; |
147 #else[rw] |
149 #else[rw] |
148 throw new ReadOnlyBufferException(); |
150 throw new ReadOnlyBufferException(); |
149 #end[rw] |
151 #end[rw] |
150 } |
152 } |
151 |
153 |
152 public $Type$Buffer put(int i, $type$ x) { |
154 public $Type$Buffer put(int i, $type$ x) { |
153 #if[rw] |
155 #if[rw] |
154 $memtype$ y = $toBits$(x); |
156 $memtype$ y = $toBits$(x); |
155 unsafe.put$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)), y, |
157 UNSAFE.put$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)), y, |
156 {#if[boB]?true:false}); |
158 {#if[boB]?true:false}); |
157 return this; |
159 return this; |
158 #else[rw] |
160 #else[rw] |
159 throw new ReadOnlyBufferException(); |
161 throw new ReadOnlyBufferException(); |
160 #end[rw] |
162 #end[rw] |