Changeset 3906


Ignore:
Timestamp:
09/19/03 17:42:09 (20 years ago)
Author:
piso
Message:

Conditions.

Location:
trunk/j/src/org/armedbear/j
Files:
3 edited

Legend:

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

    r3805 r3906  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: JLisp.java,v 1.12 2003-09-16 00:45:48 piso Exp $
     5 * $Id: JLisp.java,v 1.13 2003-09-19 17:42:09 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2626import java.net.ServerSocket;
    2727import java.net.Socket;
     28import org.armedbear.lisp.ConditionThrowable;
    2829import org.armedbear.lisp.Interpreter;
    29 import org.armedbear.lisp.Condition;
    3030
    3131public final class JLisp extends LispShell
     
    194194    }
    195195
    196     public static void runStartupScript(File file) throws Condition
     196    public static void runStartupScript(File file) throws ConditionThrowable
    197197    {
    198198        if (!Editor.isLispInitialized()) {
     
    216216    }
    217217
    218     public static void runLispCommand(String command) throws Condition
     218    public static void runLispCommand(String command) throws ConditionThrowable
    219219    {
    220220        if (!Editor.isLispInitialized()) {
  • trunk/j/src/org/armedbear/j/JVar.java

    r2672 r3906  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: JVar.java,v 1.1 2003-06-30 19:09:20 piso Exp $
     5 * $Id: JVar.java,v 1.2 2003-09-19 17:42:09 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2323
    2424import java.util.ArrayList;
     25import org.armedbear.lisp.ConditionThrowable;
    2526import org.armedbear.lisp.LispError;
    2627import org.armedbear.lisp.LispObject;
     
    5556    }
    5657
    57     public static JVar getJVar(Symbol symbol) throws LispError
     58    public static JVar getJVar(Symbol symbol) throws ConditionThrowable
    5859    {
    5960        LispObject obj = get(symbol, J_VARIABLE_VALUE, null);
    6061        if (!(obj instanceof JVar))
    61             throw new LispError(String.valueOf(symbol) +
    62                                 " is not defined as an editor variable");
     62            throw new ConditionThrowable(new LispError(String.valueOf(symbol) +
     63                                                       " is not defined as an editor variable"));
    6364        return (JVar) obj;
    6465    }
  • trunk/j/src/org/armedbear/j/LispAPI.java

    r3794 r3906  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: LispAPI.java,v 1.25 2003-09-15 16:18:13 piso Exp $
     5 * $Id: LispAPI.java,v 1.26 2003-09-19 17:42:09 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2424import java.util.Iterator;
    2525import javax.swing.undo.CompoundEdit;
     26import org.armedbear.lisp.ConditionThrowable;
    2627import org.armedbear.lisp.Fixnum;
    2728import org.armedbear.lisp.JavaObject;
     
    6061
    6162    public static final Editor checkEditor(LispObject obj)
    62         throws LispError
     63        throws ConditionThrowable
    6364    {
    6465        if (obj == null)
     
    6869        }
    6970        catch (ClassCastException e) {
    70             throw new TypeError(obj, "editor");
     71            throw new ConditionThrowable(new TypeError(obj, "editor"));
    7172        }
    7273    }
    7374
    7475    public static final Buffer checkBuffer(LispObject obj)
    75         throws LispError
     76        throws ConditionThrowable
    7677    {
    7778        if (obj == null)
     
    8182        }
    8283        catch (ClassCastException e) {
    83             throw new TypeError(obj, "buffer");
     84            throw new ConditionThrowable(new TypeError(obj, "buffer"));
    8485        }
    8586    }
    8687
    8788    public static final Position checkMarker(LispObject obj)
    88         throws LispError
     89        throws ConditionThrowable
    8990    {
    9091        if (obj == null)
     
    9495        }
    9596        catch (ClassCastException e) {
    96             throw new TypeError(obj, "marker");
     97            throw new ConditionThrowable(new TypeError(obj, "marker"));
    9798        }
    9899    }
    99100
    100101    public static final Line checkLine(LispObject obj)
    101         throws LispError
     102        throws ConditionThrowable
    102103    {
    103104        if (obj == null)
     
    107108        }
    108109        catch (ClassCastException e) {
    109             throw new TypeError(obj, "line");
     110            throw new ConditionThrowable(new TypeError(obj, "line"));
    110111        }
    111112    }
     
    129130                       "Makes EDITOR the current editor.")
    130131    {
    131         public LispObject execute(LispObject arg) throws LispError
     132        public LispObject execute(LispObject arg) throws ConditionThrowable
    132133        {
    133134            Editor.setCurrentEditor(checkEditor(arg));
     
    158159    private static final Primitive1 BUFFER =
    159160        new Primitive1("buffer", PACKAGE_J, true) {
    160         public LispObject execute(LispObject arg) throws LispError
     161        public LispObject execute(LispObject arg) throws ConditionThrowable
    161162        {
    162163            return new JavaObject(checkEditor(arg).getBuffer());
     
    167168    private static final Primitive1 BUFFER_PATHNAME =
    168169        new Primitive1("buffer-pathname", PACKAGE_J, true) {
    169         public LispObject execute(LispObject arg) throws LispError
     170        public LispObject execute(LispObject arg) throws ConditionThrowable
    170171        {
    171172            File file = checkBuffer(arg).getFile();
     
    182183    private static final Primitive BUFFER_STRING =
    183184        new Primitive("buffer-string", PACKAGE_J, true) {
    184         public LispObject execute() throws LispError
     185        public LispObject execute() throws ConditionThrowable
    185186        {
    186187            return new LispString(Editor.currentBuffer().getText());
    187188        }
    188         public LispObject execute(LispObject arg) throws LispError
     189        public LispObject execute(LispObject arg) throws ConditionThrowable
    189190        {
    190191            return new LispString(checkBuffer(arg).getText());
     
    195196    private static final Primitive1 COPY_MARK =
    196197        new Primitive1("copy-marker", PACKAGE_J, true) {
    197         public LispObject execute(LispObject arg) throws LispError
     198        public LispObject execute(LispObject arg) throws ConditionThrowable
    198199        {
    199200            try {
     
    201202            }
    202203            catch (Exception e) {
    203                 throw new TypeError(arg, "marker");
     204                throw new ConditionThrowable(new TypeError(arg, "marker"));
    204205            }
    205206        }
     
    210211    private static final Primitive GOTO_CHAR =
    211212        new Primitive("goto-char", PACKAGE_J, true) {
    212         public LispObject execute(LispObject arg) throws LispError
     213        public LispObject execute(LispObject arg) throws ConditionThrowable
    213214        {
    214215            // Move dot to position.
     
    218219        }
    219220        public LispObject execute(LispObject first, LispObject second)
    220             throws LispError
     221            throws ConditionThrowable
    221222        {
    222223            Log.debug("goto-char two argument case");
     
    268269        new Primitive1("make-marker", PACKAGE_J, true) {
    269270        public LispObject execute(LispObject first, LispObject second)
    270             throws LispError
     271            throws ConditionThrowable
    271272        {
    272273            Line line = checkLine(first);
     
    279280    private static final Primitive1 MARKER_LINE =
    280281        new Primitive1("marker-line", PACKAGE_J, true) {
    281         public LispObject execute(LispObject arg) throws LispError
     282        public LispObject execute(LispObject arg) throws ConditionThrowable
    282283        {
    283284            return new JavaObject(checkMarker(arg).getLine());
     
    288289    private static final Primitive1 MARKER_CHARPOS =
    289290        new Primitive1("marker-charpos", PACKAGE_J, true) {
    290         public LispObject execute(LispObject arg) throws LispError
     291        public LispObject execute(LispObject arg) throws ConditionThrowable
    291292        {
    292293            return number(checkMarker(arg).getOffset());
     
    310311    private static final Primitive1 LINE_NEXT =
    311312        new Primitive1("line-next", PACKAGE_J, true) {
    312         public LispObject execute(LispObject arg) throws LispError
     313        public LispObject execute(LispObject arg) throws ConditionThrowable
    313314        {
    314315            Line next = checkLine(arg).next();
     
    320321    private static final Primitive1 LINE_PREVIOUS =
    321322        new Primitive1("line-previous", PACKAGE_J, true) {
    322         public LispObject execute(LispObject arg) throws LispError
     323        public LispObject execute(LispObject arg) throws ConditionThrowable
    323324        {
    324325            Line prev = checkLine(arg).previous();
     
    330331    private static final Primitive1 LINE_CHARS =
    331332        new Primitive1("line-chars", PACKAGE_J, true) {
    332         public LispObject execute(LispObject arg) throws LispError
     333        public LispObject execute(LispObject arg) throws ConditionThrowable
    333334        {
    334335            String s = checkLine(arg).getText();
     
    340341    private static final Primitive1 LINE_FLAGS =
    341342        new Primitive1("line-flags", PACKAGE_J, true) {
    342         public LispObject execute(LispObject arg) throws LispError
     343        public LispObject execute(LispObject arg) throws ConditionThrowable
    343344        {
    344345            return number(checkLine(arg).flags());
     
    350351    private static final Primitive1 CHAR_AFTER =
    351352        new Primitive1("char-after", PACKAGE_J, true) {
    352         public LispObject execute(LispObject arg) throws LispError
     353        public LispObject execute(LispObject arg) throws ConditionThrowable
    353354        {
    354355            return LispCharacter.getInstance(checkMarker(arg).getChar());
     
    360361    private static final Primitive1 CHAR_BEFORE =
    361362        new Primitive1("char-before", PACKAGE_J, true) {
    362         public LispObject execute(LispObject arg) throws LispError
     363        public LispObject execute(LispObject arg) throws ConditionThrowable
    363364        {
    364365            Position pos = checkMarker(arg).copy();
     
    371372    private static final Primitive FORWARD_CHAR =
    372373        new Primitive("forward-char", PACKAGE_J, true) {
    373         public LispObject execute() throws LispError
     374        public LispObject execute() throws ConditionThrowable
    374375        {
    375376            return forwardChar(1);
    376377        }
    377         public LispObject execute(LispObject arg) throws LispError
     378        public LispObject execute(LispObject arg) throws ConditionThrowable
    378379        {
    379380            return forwardChar(Fixnum.getValue(arg));
     
    385386    private static final Primitive BACKWARD_CHAR =
    386387        new Primitive("backward-char", PACKAGE_J, true) {
    387         public LispObject execute() throws LispError
     388        public LispObject execute() throws ConditionThrowable
    388389        {
    389390            return forwardChar(-1);
    390391        }
    391         public LispObject execute(LispObject arg) throws LispError
     392        public LispObject execute(LispObject arg) throws ConditionThrowable
    392393        {
    393394            return forwardChar(-Fixnum.getValue(arg));
     
    395396    };
    396397
    397     private static final LispObject forwardChar(int n) throws LispError
     398    private static final LispObject forwardChar(int n) throws ConditionThrowable
    398399    {
    399400        if (n != 0) {
     
    405406                    while (n-- > 0) {
    406407                        if (!pos.next())
    407                             throw new LispError("reached end of buffer");
     408                            throw new ConditionThrowable(new LispError("reached end of buffer"));
    408409                    }
    409410                } else {
     
    411412                    while (n++ < 0) {
    412413                        if (!pos.prev())
    413                             throw new LispError("reached beginning of buffer");
     414                            throw new ConditionThrowable(new LispError("reached beginning of buffer"));
    414415                    }
    415416                }
     
    423424    private static final Primitive BEGINNING_OF_LINE =
    424425        new Primitive("beginning-of-line", PACKAGE_J, true) {
    425         public LispObject execute() throws LispError
     426        public LispObject execute() throws ConditionThrowable
    426427        {
    427428            Editor.currentEditor().bol();
    428429            return NIL;
    429430        }
    430         public LispObject execute(LispObject arg) throws LispError
     431        public LispObject execute(LispObject arg) throws ConditionThrowable
    431432        {
    432433            int n = (arg != NIL) ? Fixnum.getValue(arg) : 1;
     
    452453    private static final Primitive END_OF_LINE =
    453454        new Primitive("end-of-line", PACKAGE_J, true) {
    454         public LispObject execute() throws LispError
     455        public LispObject execute() throws ConditionThrowable
    455456        {
    456457            Editor.currentEditor().eol();
    457458            return NIL;
    458459        }
    459         public LispObject execute(LispObject arg) throws LispError
     460        public LispObject execute(LispObject arg) throws ConditionThrowable
    460461        {
    461462            int n = (arg != NIL) ? Fixnum.getValue(arg) : 1;
     
    492493        new Primitive3("%variable-value", PACKAGE_J, false) {
    493494        public LispObject execute(LispObject first, LispObject second,
    494             LispObject third) throws LispError
     495            LispObject third) throws ConditionThrowable
    495496        {
    496497            Symbol symbol = checkSymbol(first);
     
    502503            if (kind == KEYWORD_CURRENT) {
    503504                if (where != NIL)
    504                     throw new LispError("bad argument " + where);
     505                    throw new ConditionThrowable(new LispError("bad argument " + where));
    505506                final Buffer buffer = editor.getBuffer();
    506507                if (property.isBooleanProperty())
     
    541542                return new LispString(buffer.getStringProperty(property));
    542543            }
    543             throw new LispError("bad keyword argument: " + kind);
     544            throw new ConditionThrowable(new LispError("bad keyword argument: " + kind));
    544545        }
    545546    };
     
    549550    private static final Primitive _SET_VARIABLE_VALUE =
    550551        new Primitive("%set-variable-value", PACKAGE_J, false) {
    551         public LispObject execute(LispObject[] args) throws LispError
     552        public LispObject execute(LispObject[] args) throws ConditionThrowable
    552553        {
    553554            if (args.length != 4)
    554                 throw new WrongNumberOfArgumentsException(this);
     555                throw new ConditionThrowable(new WrongNumberOfArgumentsException(this));
    555556            Symbol symbol = checkSymbol(args[0]);
    556557            JVar jvar = JVar.getJVar(symbol);
     
    610611                return newValue;
    611612            }
    612             throw new LispError("bad keyword argument: " + kind);
     613            throw new ConditionThrowable(new LispError("bad keyword argument: " + kind));
    613614        }
    614615    };
     
    638639        new Primitive2("global-map-key", PACKAGE_J, true) {
    639640        public LispObject execute(LispObject first, LispObject second)
    640       throws LispError
     641      throws ConditionThrowable
    641642        {
    642643            String keyText = LispString.getValue(first);
     
    657658        new Primitive1("global-unmap-key", PACKAGE_J, true) {
    658659        public LispObject execute(LispObject arg)
    659       throws LispError
     660      throws ConditionThrowable
    660661        {
    661662            String keyText = LispString.getValue(arg);
     
    669670        public LispObject execute(LispObject first, LispObject second,
    670671                                  LispObject third)
    671       throws LispError
     672      throws ConditionThrowable
    672673        {
    673674            String keyText = LispString.getValue(first);
     
    683684            Mode mode = Editor.getModeList().getModeFromModeName(modeName);
    684685            if (mode == null)
    685                 throw new LispError("unknown mode \"".concat(modeName).concat("\""));
     686                throw new ConditionThrowable(new LispError("unknown mode \"".concat(modeName).concat("\"")));
    686687            return mode.getKeyMap().mapKey(keyText, command) ? T : NIL;
    687688        }
     
    692693        new Primitive2("unmap-key-for-mode", PACKAGE_J, true) {
    693694        public LispObject execute(LispObject first, LispObject second)
    694       throws LispError
     695      throws ConditionThrowable
    695696        {
    696697            String keyText = LispString.getValue(first);
     
    698699            Mode mode = Editor.getModeList().getModeFromModeName(modeName);
    699700            if (mode == null)
    700                 throw new LispError("unknown mode \"".concat(modeName).concat("\""));
     701                throw new ConditionThrowable(new LispError("unknown mode \"".concat(modeName).concat("\"")));
    701702            return mode.getKeyMap().unmapKey(keyText) ? T : NIL;
    702703        }
     
    707708        new Primitive2("%set-global-property", PACKAGE_J, false) {
    708709        public LispObject execute(LispObject first, LispObject second)
    709       throws LispError
     710      throws ConditionThrowable
    710711        {
    711712            String key = LispString.getValue(first);
     
    723724    private static final Primitive INSERT =
    724725        new Primitive("insert", PACKAGE_J, true) {
    725         public LispObject execute(LispObject[] args) throws LispError
     726        public LispObject execute(LispObject[] args) throws ConditionThrowable
    726727        {
    727728            if (args.length == 0)
     
    739740                        editor.insertString(((LispString)obj).getValue());
    740741                    } else
    741                         throw new TypeError(obj, "character or string");
     742                        throw new ConditionThrowable(new TypeError(obj, "character or string"));
    742743                }
    743744                return NIL;
     
    759760    private static final Primitive1 END_COMPOUND_EDIT =
    760761        new Primitive1("end-compound-edit", PACKAGE_J, false) {
    761         public LispObject execute(LispObject arg) throws LispError
     762        public LispObject execute(LispObject arg) throws ConditionThrowable
    762763        {
    763764            try {
     
    768769            }
    769770            catch (ClassCastException e) {
    770                 throw new TypeError(arg, "compound edit");
     771                throw new ConditionThrowable(new TypeError(arg, "compound edit"));
    771772            }
    772773        }
Note: See TracChangeset for help on using the changeset viewer.