Changeset 10180


Ignore:
Timestamp:
10/22/05 14:11:08 (16 years ago)
Author:
piso
Message:

typeOf(), classOf(), typep()

File:
1 edited

Legend:

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

    r7936 r10180  
    22 * JavaObject.java
    33 *
    4  * Copyright (C) 2002-2004 Peter Graves
    5  * $Id: JavaObject.java,v 1.17 2004-10-09 13:28:18 piso Exp $
     4 * Copyright (C) 2002-2005 Peter Graves
     5 * $Id: JavaObject.java,v 1.18 2005-10-22 14:11:08 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2222package org.armedbear.lisp;
    2323
    24 public class JavaObject extends LispObject
     24public final class JavaObject extends LispObject
    2525{
    2626    private final Object obj;
     
    2929    {
    3030        this.obj = obj;
     31    }
     32
     33    public LispObject typeOf()
     34    {
     35        return Symbol.JAVA_OBJECT;
     36    }
     37
     38    public LispObject classOf()
     39    {
     40        return BuiltInClass.JAVA_OBJECT;
     41    }
     42
     43    public LispObject typep(LispObject type) throws ConditionThrowable
     44    {
     45        if (type == Symbol.JAVA_OBJECT)
     46            return T;
     47        if (type == BuiltInClass.JAVA_OBJECT)
     48            return T;
     49        return super.typep(type);
    3150    }
    3251
     
    4665    }
    4766
    48     public static final Object getObject(LispObject o) throws ConditionThrowable
     67    public static final Object getObject(LispObject o)
     68        throws ConditionThrowable
    4969    {
    5070        try {
     
    5272        }
    5373        catch (ClassCastException e) {
    54             signal (new TypeError(o, "Java object"));
     74            signalTypeError(o, Symbol.JAVA_OBJECT);
    5575            // Not reached.
    5676            return null;
     
    81101        if (obj instanceof ConditionThrowable)
    82102            return obj.toString();
    83         StringBuffer sb = new StringBuffer("JAVAOBJECT ");
     103        FastStringBuffer sb = new FastStringBuffer("JAVAOBJECT ");
    84104        sb.append(obj == null ? "null" : obj.getClass().getName());
    85105        return unreadableString(sb.toString());
Note: See TracChangeset for help on using the changeset viewer.