Changeset 4116
- Timestamp:
- 09/28/03 20:17:06 (19 years ago)
- Location:
- trunk/j/src/org/armedbear/lisp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/lisp/Lisp.java
r4095 r4116 3 3 * 4 4 * Copyright (C) 2002-2003 Peter Graves 5 * $Id: Lisp.java,v 1.15 5 2003-09-28 14:14:04piso Exp $5 * $Id: Lisp.java,v 1.156 2003-09-28 20:13:26 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 763 763 } 764 764 765 public static final CharacterInputStream check InputStream(LispObject obj)765 public static final CharacterInputStream checkCharacterInputStream(LispObject obj) 766 766 throws ConditionThrowable 767 767 { … … 770 770 if (obj instanceof CharacterInputStream) 771 771 return (CharacterInputStream) obj; 772 if (obj instanceof TwoWayStream) 773 return ((TwoWayStream)obj).getInputStream(); 774 throw new ConditionThrowable(new TypeError(obj, "input stream")); 775 } 776 777 public static final CharacterOutputStream checkOutputStream(LispObject obj) 772 if (obj instanceof TwoWayStream) { 773 LispInputStream in = ((TwoWayStream)obj).getInputStream(); 774 if (in instanceof CharacterInputStream) 775 return (CharacterInputStream) in; 776 } 777 throw new ConditionThrowable(new TypeError(obj, "character input stream")); 778 } 779 780 public static final CharacterOutputStream checkCharacterOutputStream(LispObject obj) 778 781 throws ConditionThrowable 779 782 { … … 782 785 if (obj instanceof CharacterOutputStream) 783 786 return (CharacterOutputStream) obj; 784 if (obj instanceof TwoWayStream) 785 return ((TwoWayStream)obj).getOutputStream(); 787 if (obj instanceof TwoWayStream) { 788 LispOutputStream out = ((TwoWayStream)obj).getOutputStream(); 789 if (out instanceof CharacterOutputStream) 790 return (CharacterOutputStream) out; 791 } 786 792 throw new ConditionThrowable(new TypeError(obj, "output stream")); 787 793 } … … 791 797 { 792 798 if (obj == T) 793 return check InputStream(_TERMINAL_IO_.symbolValue());799 return checkCharacterInputStream(_TERMINAL_IO_.symbolValue()); 794 800 if (obj == NIL) 795 return check InputStream(_STANDARD_INPUT_.symbolValue());801 return checkCharacterInputStream(_STANDARD_INPUT_.symbolValue()); 796 802 if (obj instanceof CharacterInputStream) 797 803 return (CharacterInputStream) obj; 798 if (obj instanceof TwoWayStream) 799 return ((TwoWayStream)obj).getInputStream(); 804 if (obj instanceof TwoWayStream) { 805 LispInputStream in = ((TwoWayStream)obj).getInputStream(); 806 if (in instanceof CharacterInputStream) 807 return (CharacterInputStream) in; 808 } 800 809 throw new ConditionThrowable(new TypeError(obj, "character input stream")); 801 810 } … … 805 814 { 806 815 if (obj == T) 807 return check OutputStream(_TERMINAL_IO_.symbolValue());816 return checkCharacterOutputStream(_TERMINAL_IO_.symbolValue()); 808 817 if (obj == NIL) 809 return check OutputStream(_STANDARD_OUTPUT_.symbolValue());818 return checkCharacterOutputStream(_STANDARD_OUTPUT_.symbolValue()); 810 819 if (obj instanceof CharacterOutputStream) 811 820 return (CharacterOutputStream) obj; 812 if (obj instanceof TwoWayStream) 813 return ((TwoWayStream)obj).getOutputStream(); 821 if (obj instanceof TwoWayStream) { 822 LispOutputStream out = ((TwoWayStream)obj).getOutputStream(); 823 if (out instanceof CharacterOutputStream) 824 return (CharacterOutputStream) out; 825 } 814 826 throw new ConditionThrowable(new TypeError(obj, "character output stream")); 815 827 } … … 1044 1056 public static final CharacterOutputStream getStandardOutput() throws ConditionThrowable 1045 1057 { 1046 return check OutputStream(_STANDARD_OUTPUT_.symbolValueNoThrow());1058 return checkCharacterOutputStream(_STANDARD_OUTPUT_.symbolValueNoThrow()); 1047 1059 } 1048 1060 -
trunk/j/src/org/armedbear/lisp/Primitives.java
r4103 r4116 3 3 * 4 4 * Copyright (C) 2002-2003 Peter Graves 5 * $Id: Primitives.java,v 1.45 0 2003-09-28 16:25:31piso Exp $5 * $Id: Primitives.java,v 1.451 2003-09-28 20:14:12 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 619 619 final CharacterOutputStream out; 620 620 if (args.length == 1) 621 out = check OutputStream(_STANDARD_OUTPUT_.symbolValue());621 out = checkCharacterOutputStream(_STANDARD_OUTPUT_.symbolValue()); 622 622 else 623 623 out = outSynonymOf(args[1]); … … 647 647 { 648 648 CharacterOutputStream out = 649 check OutputStream(_STANDARD_OUTPUT_.symbolValue());649 checkCharacterOutputStream(_STANDARD_OUTPUT_.symbolValue()); 650 650 out.prin1(arg); 651 651 return arg; … … 676 676 { 677 677 CharacterOutputStream out = 678 check OutputStream(_STANDARD_OUTPUT_.symbolValue());678 checkCharacterOutputStream(_STANDARD_OUTPUT_.symbolValue()); 679 679 out.terpri(); 680 680 out.prin1(arg); … … 702 702 final CharacterOutputStream out; 703 703 if (args.length == 0) 704 out = check OutputStream(_STANDARD_OUTPUT_.symbolValue());704 out = checkCharacterOutputStream(_STANDARD_OUTPUT_.symbolValue()); 705 705 else 706 706 out = outSynonymOf(args[0]); … … 718 718 CharacterOutputStream out; 719 719 if (args.length == 0) 720 out = check OutputStream(_STANDARD_OUTPUT_.symbolValue());720 out = checkCharacterOutputStream(_STANDARD_OUTPUT_.symbolValue()); 721 721 else 722 722 out = outSynonymOf(args[0]); … … 1129 1129 String s = _format(_args); 1130 1130 if (destination == T) { 1131 check OutputStream(_STANDARD_OUTPUT_.symbolValue()).writeString(s);1131 checkCharacterOutputStream(_STANDARD_OUTPUT_.symbolValue()).writeString(s); 1132 1132 return NIL; 1133 1133 } … … 1139 1139 } 1140 1140 if (destination instanceof TwoWayStream) { 1141 ((TwoWayStream)destination).getOutputStream().writeString(s); 1142 return NIL; 1141 LispOutputStream out = ((TwoWayStream)destination).getOutputStream(); 1142 if (out instanceof CharacterOutputStream) { 1143 ((CharacterOutputStream)out).writeString(s); 1144 return NIL; 1145 } 1146 throw new ConditionThrowable(new TypeError(destination, "character output stream")); 1143 1147 } 1144 1148 // Destination can also be a string with a fill pointer. … … 3301 3305 final CharacterOutputStream out; 3302 3306 if (args.length == 1) 3303 out = check OutputStream(_STANDARD_OUTPUT_.symbolValue());3307 out = checkCharacterOutputStream(_STANDARD_OUTPUT_.symbolValue()); 3304 3308 else 3305 3309 out = outSynonymOf(args[1]); … … 3366 3370 final CharacterOutputStream out; 3367 3371 if (args.length == 0) 3368 out = check OutputStream(_STANDARD_OUTPUT_.symbolValue());3372 out = checkCharacterOutputStream(_STANDARD_OUTPUT_.symbolValue()); 3369 3373 else 3370 3374 out = outSynonymOf(args[0]); … … 3382 3386 final CharacterInputStream in; 3383 3387 if (args.length == 0) 3384 in = check InputStream(_STANDARD_INPUT_.symbolValue());3388 in = checkCharacterInputStream(_STANDARD_INPUT_.symbolValue()); 3385 3389 else 3386 3390 in = inSynonymOf(args[0]); … … 3516 3520 if (length > 4) 3517 3521 throw new ConditionThrowable(new WrongNumberOfArgumentsException(this)); 3518 CharacterInputStream stream ;3522 CharacterInputStream stream = null; 3519 3523 if (length == 0) 3520 3524 stream = getStandardInput(); 3521 3525 else if (args[0] instanceof CharacterInputStream) 3522 3526 stream = (CharacterInputStream) args[0]; 3523 else if (args[0] instanceof TwoWayStream) 3524 stream = ((TwoWayStream)args[0]).getInputStream(); 3525 else 3526 throw new ConditionThrowable(new TypeError(args[0], "input stream")); 3527 else if (args[0] instanceof TwoWayStream) { 3528 LispInputStream in = ((TwoWayStream)args[0]).getInputStream(); 3529 if (in instanceof CharacterInputStream) 3530 stream = (CharacterInputStream) in; 3531 } 3532 if (stream == null) 3533 throw new ConditionThrowable(new TypeError(args[0], "character input stream")); 3527 3534 boolean eofError = length > 1 ? (args[1] != NIL) : true; 3528 3535 LispObject eofValue = length > 2 ? args[2] : NIL; … … 3725 3732 throw new ConditionThrowable(new WrongNumberOfArgumentsException(this)); 3726 3733 CharacterInputStream stream = 3727 length > 0 ? check InputStream(args[0]) : getStandardInput();3734 length > 0 ? checkCharacterInputStream(args[0]) : getStandardInput(); 3728 3735 boolean eofError = length > 1 ? (args[1] != NIL) : true; 3729 3736 LispObject eofValue = length > 2 ? args[2] : NIL; … … 3742 3749 throw new ConditionThrowable(new WrongNumberOfArgumentsException(this)); 3743 3750 CharacterInputStream stream = 3744 length > 0 ? check InputStream(args[0]) : getStandardInput();3751 length > 0 ? checkCharacterInputStream(args[0]) : getStandardInput(); 3745 3752 boolean eofError = length > 1 ? (args[1] != NIL) : true; 3746 3753 LispObject eofValue = length > 2 ? args[2] : NIL; … … 3759 3766 throw new ConditionThrowable(new WrongNumberOfArgumentsException(this)); 3760 3767 CharacterInputStream stream = 3761 length > 1 ? check InputStream(args[1]) : getStandardInput();3768 length > 1 ? checkCharacterInputStream(args[1]) : getStandardInput(); 3762 3769 return stream.unreadChar(checkCharacter(args[0])); 3763 3770 } -
trunk/j/src/org/armedbear/lisp/TwoWayStream.java
r3887 r4116 3 3 * 4 4 * Copyright (C) 2003 Peter Graves 5 * $Id: TwoWayStream.java,v 1. 5 2003-09-19 12:32:14piso Exp $5 * $Id: TwoWayStream.java,v 1.6 2003-09-28 20:17:06 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 24 24 public final class TwoWayStream extends LispStream 25 25 { 26 private final CharacterInputStream in;27 private final CharacterOutputStream out;26 private final LispInputStream in; 27 private final LispOutputStream out; 28 28 29 public TwoWayStream( CharacterInputStream in, CharacterOutputStream out)29 public TwoWayStream(LispInputStream in, LispOutputStream out) 30 30 { 31 31 this.in = in; … … 33 33 } 34 34 35 public CharacterInputStream getInputStream()35 public LispInputStream getInputStream() 36 36 { 37 37 return in; 38 38 } 39 39 40 public CharacterOutputStream getOutputStream()40 public LispOutputStream getOutputStream() 41 41 { 42 42 return out; … … 69 69 throws ConditionThrowable 70 70 { 71 if (!(first instanceof CharacterInputStream))71 if (!(first instanceof LispInputStream)) 72 72 throw new ConditionThrowable(new TypeError(first, "input stream")); 73 if (!(second instanceof CharacterOutputStream))73 if (!(second instanceof LispOutputStream)) 74 74 throw new ConditionThrowable(new TypeError(second, "output stream")); 75 return new TwoWayStream(( CharacterInputStream) first,76 (CharacterOutputStream) second);75 return new TwoWayStream((LispInputStream) first, 76 (LispOutputStream) second); 77 77 } 78 78 };
Note: See TracChangeset
for help on using the changeset viewer.