Changeset 15359
- Timestamp:
- 07/30/20 14:09:13 (3 years ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/BasicVector_ByteBuffer.java
r15350 r15359 88 88 elements = buffer; 89 89 this.directAllocation = directAllocation; 90 capacity = buffer.limit();90 capacity = ((java.nio.Buffer)buffer).limit(); 91 91 } 92 92 … … 156 156 return (((int)elements.get(index) & 0xff)); // XXX Hmmm 157 157 } catch (IndexOutOfBoundsException e) { 158 badIndex(index, elements.limit());158 badIndex(index, ((java.nio.Buffer)elements).limit()); 159 159 // Not reached. 160 160 return 0; … … 167 167 return coerceFromJavaByte(elements.get(index)); 168 168 } catch (IndexOutOfBoundsException e) { 169 badIndex(index, elements.limit());169 badIndex(index, ((java.nio.Buffer)elements).limit()); 170 170 return NIL; // Not reached. 171 171 } … … 195 195 BasicVector_ByteBuffer v = new BasicVector_ByteBuffer(end - start, directAllocation); 196 196 ByteBuffer view = elements.asReadOnlyBuffer(); 197 view.position(start);198 view.limit(end);197 ((java.nio.Buffer)view).position(start); 198 ((java.nio.Buffer)view).limit(end); 199 199 try { 200 200 v.elements.put(view); … … 231 231 // this strategy will work out⊠232 232 if (n < length()) { 233 elements.limit(n);233 ((java.nio.Buffer)elements).limit(n); 234 234 capacity = n; 235 235 return; -
trunk/abcl/src/org/armedbear/lisp/BasicVector_CharBuffer.java
r15305 r15359 77 77 elements = buffer.asCharBuffer(); 78 78 this.directAllocation = directAllocation; 79 capacity = buffer.limit();79 capacity = ((java.nio.Buffer)buffer).limit(); 80 80 } 81 81 … … 83 83 elements = buffer; 84 84 this.directAllocation = directAllocation; 85 capacity = buffer.limit();85 capacity = ((java.nio.Buffer)buffer).limit(); 86 86 } 87 87 … … 152 152 return elements.get(index); 153 153 } catch (ArrayIndexOutOfBoundsException e) { 154 badIndex(index, elements.limit()); // FIXME should implement method for length() contract154 badIndex(index, ((java.nio.Buffer)elements).limit()); // FIXME should implement method for length() contract 155 155 // Not reached. 156 156 return 0; … … 164 164 return Fixnum.getInstance(elements.get(index)); 165 165 } catch (IndexOutOfBoundsException e) { 166 badIndex(index, elements.limit()); // FIXME limit() --> capacity?166 badIndex(index, ((java.nio.Buffer)elements).limit()); // FIXME limit() --> capacity? 167 167 return NIL; // Not reached. 168 168 } … … 231 231 // Not totally sure that this strategy will work out⊠232 232 if (n < length()) { 233 elements.limit(n);233 ((java.nio.Buffer)elements).limit(n); 234 234 capacity = n; 235 235 return; -
trunk/abcl/src/org/armedbear/lisp/BasicVector_IntBuffer.java
r15337 r15359 80 80 this.directAllocation = directAllocation; 81 81 elements = buffer.asIntBuffer(); 82 capacity = buffer.limit();82 capacity = ((java.nio.Buffer)buffer).limit(); 83 83 } 84 84 … … 86 86 this.directAllocation = directAllocation; 87 87 elements = buffer; 88 capacity = buffer.limit();88 capacity = ((java.nio.Buffer)buffer).limit(); 89 89 } 90 90 … … 155 155 return number(((long)elements.get(index)) & 0xffffffffL).intValue(); 156 156 } catch (IndexOutOfBoundsException e) { 157 badIndex(index, elements.limit());157 badIndex(index, ((java.nio.Buffer)elements).limit()); 158 158 return -1; // Not reached. 159 159 } … … 165 165 return ((long)elements.get(index)) & 0xffffffffL; 166 166 } catch (IndexOutOfBoundsException e) { 167 badIndex(index, elements.limit());167 badIndex(index, ((java.nio.Buffer)elements).limit()); 168 168 return -1; // Not reached. 169 169 } … … 175 175 return number(((long)elements.get(index)) & 0xffffffffL); 176 176 } catch (IndexOutOfBoundsException e) { 177 badIndex(index, elements.limit());177 badIndex(index, ((java.nio.Buffer)elements).limit()); 178 178 return NIL; // Not reached. 179 179 } … … 229 229 // shouldn't touch, so use the java.nio.Buffer limit pointer. 230 230 // Not totally sure that this strategy will work out⊠231 elements.limit(n);231 ((java.nio.Buffer)elements).limit(n); 232 232 capacity = n; 233 233 return; -
trunk/abcl/src/org/armedbear/lisp/ComplexArray_ByteBuffer.java
r15350 r15359 250 250 } 251 251 if (data != null) { 252 for (int i = data.limit(); i-- > 0;)252 for (int i = ((java.nio.Buffer)data).limit(); i-- > 0;) 253 253 data.put(i, (byte) n); // FIXME Faster!! 254 254 } else { … … 279 279 // FIXME move me to someplace more general 280 280 public static void fill(ByteBuffer buffer, byte value) { 281 for (int i = 0; i < buffer.limit(); i++) {281 for (int i = 0; i < ((java.nio.Buffer)buffer).limit(); i++) { 282 282 buffer.put(value); 283 283 } -
trunk/abcl/src/org/armedbear/lisp/ComplexArray_IntBuffer.java
r15351 r15359 240 240 } 241 241 if (data != null) { 242 for (int i = data.limit(); i-- > 0;) {242 for (int i = ((java.nio.Buffer)data).limit(); i-- > 0;) { 243 243 data.put(i, (int) (obj.longValue() & 0xffffffffL));; 244 244 } -
trunk/abcl/src/org/armedbear/lisp/ComplexVector_ByteBuffer.java
r15350 r15359 192 192 return coerceFromJavaByte(elements.get(index)); 193 193 } catch (ArrayIndexOutOfBoundsException e) { 194 badIndex(index, elements.limit());194 badIndex(index, ((java.nio.Buffer)elements).limit()); 195 195 return NIL; // Not reached. 196 196 } … … 229 229 elements.put(index, coerceToJavaByte(newValue)); 230 230 } catch (IndexOutOfBoundsException e) { 231 badIndex(index, elements.limit());231 badIndex(index, ((java.nio.Buffer)elements).limit()); 232 232 } 233 233 } else { … … 273 273 // use the limit marker to denote the length 274 274 if (n < length()) { 275 elements.limit(n);275 ((java.nio.Buffer)elements).limit(n); 276 276 this.capacity = n; 277 277 return; 278 278 } 279 if (n == elements.limit()) {279 if (n == ((java.nio.Buffer)elements).limit()) { 280 280 return; 281 281 } -
trunk/abcl/src/org/armedbear/lisp/ComplexVector_IntBuffer.java
r15351 r15359 185 185 return number(((long)elements.get(index)) & 0xffffffffL); 186 186 } catch (IndexOutOfBoundsException e) { 187 badIndex(index, elements.limit());187 badIndex(index, ((java.nio.Buffer)elements).limit()); 188 188 return NIL; // Not reached. 189 189 } … … 207 207 elements.put(index, (int)(newValue.longValue() & 0xffffffffL)); 208 208 } catch (IndexOutOfBoundsException e) { 209 badIndex(index, elements.limit());209 badIndex(index, ((java.nio.Buffer)elements).limit()); 210 210 } 211 211 } else { … … 253 253 // use the limit marker to denote the length 254 254 if (n < length()) { 255 elements.limit(n);255 ((java.nio.Buffer)elements).limit(n); 256 256 this.capacity = n; 257 257 return; 258 258 } 259 if (n == elements.limit()) {259 if (n == ((java.nio.Buffer)elements).limit()) { 260 260 return; 261 261 } -
trunk/abcl/src/org/armedbear/lisp/util/DecodingReader.java
r12902 r15359 85 85 this.ce = cs.newEncoder(); 86 86 bbuf = ByteBuffer.allocate(size); 87 bbuf.flip(); // mark the buffer as 'needs refill'87 ((java.nio.Buffer)bbuf).flip(); // mark the buffer as 'needs refill' 88 88 } 89 89 … … 174 174 ce.encode(CharBuffer.wrap(cbuf, off, len)); 175 175 176 if (tb.limit() > bbuf.position()) {176 if (tb.limit() > ((java.nio.Buffer)bbuf).position()) { 177 177 // unread bbuf into the pushback input stream 178 178 // in order to free up space for the content of 'tb' 179 for (int i = bbuf.limit(); i-- > bbuf.position(); )179 for (int i = ((java.nio.Buffer)bbuf).limit(); i-- > ((java.nio.Buffer)bbuf).position(); ) 180 180 stream.unread(bbuf.get(i)); 181 181 182 bbuf.clear();182 ((java.nio.Buffer)bbuf).clear(); 183 183 ce.encode(CharBuffer.wrap(cbuf, off, len), bbuf, true); 184 bbuf.flip();184 ((java.nio.Buffer)bbuf).flip(); 185 185 } else { 186 186 // Don't unread bbuf, since tb will fit in front of the 187 187 // existing data 188 int j = bbuf.position() - 1;189 for (int i = tb.limit(); i-- > 0; j--) // two-counter loop188 int j = ((java.nio.Buffer)bbuf).position() - 1; 189 for (int i = ((java.nio.Buffer)tb).limit(); i-- > 0; j--) // two-counter loop 190 190 bbuf.put(j, tb.get(i)); 191 191 192 bbuf.position(j+1);192 ((java.nio.Buffer)bbuf).position(j+1); 193 193 } 194 194 } … … 215 215 216 216 if (c < 0) { 217 bbuf.flip(); // prepare bbuf for reading217 ((java.nio.Buffer)bbuf).flip(); // prepare bbuf for reading 218 218 return false; 219 219 } 220 220 221 221 bbuf.put(by, 0, c); 222 bbuf.flip();222 ((java.nio.Buffer)bbuf).flip(); 223 223 } 224 224 return true; -
trunk/abcl/src/org/armedbear/lisp/util/RandomAccessCharacterFile.java
r14863 r15359 18 18 * You should have received a copy of the GNU General Public License 19 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, . 21 21 * 22 22 * As a special exception, the copyright holders of this library give you … … 297 297 298 298 // there is no readable data available in the buffers. 299 bbuf.flip();299 ((java.nio.Buffer)bbuf).flip(); 300 300 301 301 // there is no write pending data in the buffers. … … 361 361 if (bbufIsDirty) { 362 362 flushBbuf(false); 363 bbuf.clear();363 ((java.nio.Buffer)bbuf).clear(); 364 364 bbufIsReadable = false; 365 365 } else { 366 int bbufEnd = bbufIsReadable ? bbuf.limit() : bbuf.position(); 366 int bbufEnd = bbufIsReadable 367 ? ((java.nio.Buffer)bbuf).limit() 368 : ((java.nio.Buffer)bbuf).position(); 367 369 fcn.position(bbufpos + bbufEnd); 368 bbufpos += bbuf.position();370 bbufpos += ((java.nio.Buffer)bbuf).position(); 369 371 if (bbufIsReadable) { 370 372 bbuf.compact(); 371 373 bbufIsReadable = false; 372 } else //must discard the junk bytes after bbuf.position()373 bbuf.clear();374 } else //must discard the junk bytes after ((java.nio.Buffer)bbuf).position() 375 ((java.nio.Buffer)bbuf).clear(); 374 376 } 375 377 376 378 bufReady = (fcn.read(bbuf) != -1); 377 bbuf.flip();379 ((java.nio.Buffer)bbuf).flip(); 378 380 bbufIsReadable = true; 379 381 } … … 434 436 if (CoderResult.OVERFLOW == r || bbuf.remaining() == 0) { 435 437 flushBbuf(false); 436 bbuf.clear();438 ((java.nio.Buffer)bbuf).clear(); 437 439 bbufIsReadable = false; 438 440 } 439 441 if (r.isUnmappable()) { 440 throw new RACFUnmappableCharacterException( cbuf.position(),441 cbuf.charAt( cbuf.position()),442 throw new RACFUnmappableCharacterException(((java.nio.Buffer)cbuf).position(), 443 cbuf.charAt(((java.nio.Buffer)cbuf).position()), 442 444 cset.name()); 443 445 } … … 445 447 // We don't really expect Malformed, but not handling it 446 448 // will cause an infinite loop if we don't... 447 throw new RACFMalformedInputException( cbuf.position(),448 cbuf.charAt( cbuf.position()),449 throw new RACFMalformedInputException(((java.nio.Buffer)cbuf).position(), 450 cbuf.charAt(((java.nio.Buffer)cbuf).position()), 449 451 cset.name()); 450 452 } … … 452 454 // before bbuf is filled. 453 455 } 454 if ( bbuf.position() > 0 && bbufIsDirty && flush) {456 if (((java.nio.Buffer)bbuf).position() > 0 && bbufIsDirty && flush) { 455 457 flushBbuf(false); 456 458 } … … 460 462 flushBbuf(true); 461 463 long bbufend = bbufpos // in case bbuf is readable, its contents is valid 462 + (bbufIsReadable ? bbuf.limit() : bbuf.position()); // beyond position() 464 + (bbufIsReadable 465 ? ((java.nio.Buffer)bbuf).limit() 466 : ((java.nio.Buffer)bbuf).position()); // beyond position() 463 467 if (newPosition >= bbufpos && newPosition < bbufend) { 464 468 // near seek. within existing data of bbuf. 465 469 if (!bbufIsReadable) { //rewinding. keep tail buffered. 466 bbuf.limit(bbuf.position());470 ((java.nio.Buffer)bbuf).limit(((java.nio.Buffer)bbuf).position()); 467 471 bbufIsReadable = true; 468 472 } 469 bbuf.position((int)(newPosition - bbufpos));473 ((java.nio.Buffer)bbuf).position((int)(newPosition - bbufpos)); 470 474 } else { 471 475 fcn.position(newPosition); 472 476 // far seek; discard the buffer (it's already cleared) 473 bbuf.clear();474 bbuf.flip(); // "there is no useful data on this buffer yet."477 ((java.nio.Buffer)bbuf).clear(); 478 ((java.nio.Buffer)bbuf).flip(); // "there is no useful data on this buffer yet." 475 479 bbufIsReadable = true; 476 480 bbufpos = newPosition; … … 479 483 480 484 public final long position() throws IOException { 481 return bbufpos + bbuf.position(); // the logical position within the file.485 return bbufpos + ((java.nio.Buffer)bbuf).position(); // the logical position within the file. 482 486 } 483 487 … … 499 503 if (commitOnly) { 500 504 ByteBuffer dup = bbuf.duplicate(); 501 dup.flip();505 ((java.nio.Buffer)dup).flip(); 502 506 fcn.write(dup); 503 507 //ideally, should restore fcn.position(). but don't for performance. … … 508 512 509 513 if (bbufIsDirty) { 510 bbuf.flip();514 ((java.nio.Buffer)bbuf).flip(); 511 515 fcn.write(bbuf); 512 516 } 513 517 514 bbufpos += bbuf.position();515 bbuf.clear();516 bbuf.flip(); // there's no useable data in this buffer518 bbufpos += ((java.nio.Buffer)bbuf).position(); 519 ((java.nio.Buffer)bbuf).clear(); 520 ((java.nio.Buffer)bbuf).flip(); // there's no useable data in this buffer 517 521 bbufIsDirty = false; 518 522 bbufIsReadable = true; … … 557 561 shortByteBuf = ByteBuffer.allocate((int)cenc.maxBytesPerChar()); 558 562 } 559 singleCharBuf.clear();563 ((java.nio.Buffer)singleCharBuf).clear(); 560 564 singleCharBuf.append(c); 561 singleCharBuf.flip();562 shortByteBuf.clear();565 ((java.nio.Buffer)singleCharBuf).flip(); 566 ((java.nio.Buffer)shortByteBuf).clear(); 563 567 cenc.encode(singleCharBuf, shortByteBuf, false); 564 int n = shortByteBuf.position();568 int n = ((java.nio.Buffer)shortByteBuf).position(); 565 569 long pos = position() - n; 566 570 position(pos); … … 577 581 if (bbuf.remaining() == 0) { 578 582 flushBbuf(false); 579 bbuf.clear();583 ((java.nio.Buffer)bbuf).clear(); 580 584 bbufIsReadable = false; 581 585 }
Note: See TracChangeset
for help on using the changeset viewer.