Changeset 4968


Ignore:
Timestamp:
12/04/03 16:56:02 (18 years ago)
Author:
piso
Message:

INVOKE-LATER

File:
1 edited

Legend:

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

    r4291 r4968  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: LispAPI.java,v 1.28 2003-10-10 18:55:22 piso Exp $
     5 * $Id: LispAPI.java,v 1.29 2003-12-04 16:56:02 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2323
    2424import java.util.Iterator;
     25import javax.swing.SwingUtilities;
    2526import javax.swing.undo.CompoundEdit;
    2627import org.armedbear.lisp.ConditionThrowable;
    2728import org.armedbear.lisp.Fixnum;
     29import org.armedbear.lisp.Function;
     30import org.armedbear.lisp.GenericFunction;
    2831import org.armedbear.lisp.JavaObject;
    2932import org.armedbear.lisp.Keyword;
     
    3336import org.armedbear.lisp.LispObject;
    3437import org.armedbear.lisp.LispString;
     38import org.armedbear.lisp.LispThread;
    3539import org.armedbear.lisp.Package;
    3640import org.armedbear.lisp.Packages;
     
    4347import org.armedbear.lisp.Symbol;
    4448import org.armedbear.lisp.TypeError;
     49import org.armedbear.lisp.UndefinedFunction;
    4550import org.armedbear.lisp.WrongNumberOfArgumentsException;
    4651
     
    823828    }
    824829
     830    // ### invoke-later
     831    public static final Primitive1 INVOKE_LATER =
     832        new Primitive1("INVOKE-LATER", PACKAGE_J, true)
     833    {
     834        public LispObject execute(LispObject arg) throws ConditionThrowable
     835        {
     836            final LispObject fun;
     837            if (arg instanceof Symbol)
     838                fun = arg.getSymbolFunction();
     839            else
     840                fun = arg;
     841            if (fun instanceof Function || fun instanceof GenericFunction) {
     842                Runnable r = new Runnable() {
     843                    public void run()
     844                    {
     845                        try {
     846                            funcall0(fun, LispThread.currentThread());
     847                        }
     848                        catch (Throwable t) {
     849                            Log.error(t);
     850                        }
     851                    }
     852                };
     853                SwingUtilities.invokeLater(r);
     854                return NIL;
     855            }
     856            throw new ConditionThrowable(new UndefinedFunction(arg));
     857        }
     858    };
     859
    825860    static {
    826861        for (Iterator it = Property.iterator(); it.hasNext();)
Note: See TracChangeset for help on using the changeset viewer.