Changeset 4050


Ignore:
Timestamp:
09/25/03 15:36:14 (20 years ago)
Author:
piso
Message:

FINISH-OUTPUT, FORCE-OUTPUT

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/Primitives.java

    r4045 r4050  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Primitives.java,v 1.436 2003-09-25 00:40:16 piso Exp $
     5 * $Id: Primitives.java,v 1.437 2003-09-25 15:36:14 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    34693469    // ### finish-output
    34703470    // finish-output &optional output-stream => nil
    3471     private static final Primitive FINISH_OUTPUT =
    3472         new Primitive("finish-output") {
     3471    private static final Primitive FINISH_OUTPUT = new Primitive("finish-output") {
    34733472        public LispObject execute(LispObject[] args) throws ConditionThrowable
    34743473        {
    34753474            if (args.length > 1)
    34763475                throw new ConditionThrowable(new WrongNumberOfArgumentsException(this));
    3477             CharacterOutputStream out = null;
    3478             if (args.length == 0)
    3479                 out = getStandardOutput();
    3480             else {
    3481                 LispObject streamArg = args[0];
    3482                 if (streamArg instanceof CharacterOutputStream)
    3483                     out = (CharacterOutputStream) streamArg;
    3484                 else if (streamArg instanceof TwoWayStream)
    3485                     out = ((TwoWayStream)streamArg).getOutputStream();
    3486                 else if (streamArg == T || streamArg == NIL)
    3487                     out = getStandardOutput();
    3488                 else
    3489                     throw new ConditionThrowable(new TypeError(args[1], "character output stream"));
    3490             }
    3491             out.finishOutput();
    3492             return NIL;
    3493         }
    3494     };
     3476            return flushOutput(args);
     3477        }
     3478    };
     3479
     3480    // ### force-output
     3481    // force-output &optional output-stream => nil
     3482    private static final Primitive FORCE_OUTPUT = new Primitive("force-output") {
     3483        public LispObject execute(LispObject[] args) throws ConditionThrowable
     3484        {
     3485            if (args.length > 1)
     3486                throw new ConditionThrowable(new WrongNumberOfArgumentsException(this));
     3487            return flushOutput(args);
     3488        }
     3489    };
     3490
     3491    private static final LispObject flushOutput(LispObject[] args)
     3492        throws ConditionThrowable
     3493    {
     3494        CharacterOutputStream out = null;
     3495        if (args.length == 0)
     3496            out = getStandardOutput();
     3497        else {
     3498            LispObject streamArg = args[0];
     3499            if (streamArg == T)
     3500                streamArg = _TERMINAL_IO_.symbolValue();
     3501            else if (streamArg == NIL)
     3502                streamArg = _STANDARD_OUTPUT_.symbolValue();
     3503            if (streamArg instanceof CharacterOutputStream)
     3504                out = (CharacterOutputStream) streamArg;
     3505            else if (streamArg instanceof TwoWayStream)
     3506                out = ((TwoWayStream)streamArg).getOutputStream();
     3507            else
     3508                throw new ConditionThrowable(new TypeError(args[1], "character output stream"));
     3509        }
     3510        out.flushOutput();
     3511        return NIL;
     3512    }
    34953513
    34963514    // ### close
Note: See TracChangeset for help on using the changeset viewer.