Changeset 11378


Ignore:
Timestamp:
11/03/08 22:33:06 (13 years ago)
Author:
astalla
Message:

Added CLOS method dispatch on Java classes: a new java:jclass specializer is provided, plus a new JAVA-CLASS metaclass has been introduced to represent all Java classes in the context of CLOS.

Location:
branches/scripting/j/src/org/armedbear/lisp
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/scripting/j/src/org/armedbear/lisp/Autoload.java

    r11369 r11378  
    490490        autoload(PACKAGE_JAVA, "%jnew-proxy", "JProxy");
    491491        autoload(PACKAGE_JAVA, "%jimplement-interface", "JProxy");
     492        autoload(PACKAGE_JAVA, "%find-java-class", "JavaClass");
    492493        autoload(PACKAGE_JAVA, "%jmake-invocation-handler", "JProxy");
    493494        autoload(PACKAGE_JAVA, "%jmake-proxy", "JProxy");
  • branches/scripting/j/src/org/armedbear/lisp/JavaObject.java

    r11297 r11378  
    3838    public LispObject classOf()
    3939    {
    40         return BuiltInClass.JAVA_OBJECT;
     40      if(obj == null) {
     41        return BuiltInClass.JAVA_OBJECT;
     42      } else {
     43        return JavaClass.findJavaClass(obj.getClass());
     44      }
    4145    }
    4246
     
    4751        if (type == BuiltInClass.JAVA_OBJECT)
    4852            return T;
     53        if(type instanceof JavaClass && obj != null) {
     54          return ((JavaClass) type).getJavaClass().isAssignableFrom(obj.getClass()) ? T : NIL;
     55        }
    4956        return super.typep(type);
    5057    }
  • branches/scripting/j/src/org/armedbear/lisp/StandardClass.java

    r11297 r11378  
    108108    addStandardClass(Symbol.BUILT_IN_CLASS, list1(CLASS));
    109109
     110  public static final StandardClass JAVA_CLASS =
     111      addStandardClass(Symbol.JAVA_CLASS, list1(CLASS));
     112 
    110113  public static final StandardClass FORWARD_REFERENCED_CLASS =
    111114    addStandardClass(Symbol.FORWARD_REFERENCED_CLASS, list1(CLASS));
     
    265268    BUILT_IN_CLASS.setCPL(BUILT_IN_CLASS, CLASS, STANDARD_OBJECT,
    266269                          BuiltInClass.CLASS_T);
     270    JAVA_CLASS.setCPL(JAVA_CLASS, CLASS, STANDARD_OBJECT,
     271            BuiltInClass.CLASS_T);
    267272    CELL_ERROR.setCPL(CELL_ERROR, ERROR, SERIOUS_CONDITION, CONDITION,
    268273                      STANDARD_OBJECT, BuiltInClass.CLASS_T);
  • branches/scripting/j/src/org/armedbear/lisp/Symbol.java

    r11297 r11378  
    28752875  public static final Symbol JAVA_OBJECT =
    28762876    PACKAGE_JAVA.addExternalSymbol("JAVA-OBJECT");
     2877  public static final Symbol JAVA_CLASS =
     2878      PACKAGE_JAVA.addExternalSymbol("JAVA-CLASS");
    28772879  public static final Symbol JCALL =
    28782880    PACKAGE_JAVA.addExternalSymbol("JCALL");
  • branches/scripting/j/src/org/armedbear/lisp/clos.lisp

    r11306 r11378  
    897897             (setf object (cadr object)))
    898898           (intern-eql-specializer object)))
     899  ((and (consp specializer)
     900              (eq (car specializer) 'java:jclass))
     901         (let ((class-name (cadr specializer)))
     902           (when (and (consp class-name)
     903                      (eq (car class-name) 'quote))
     904             (setf class-name (cadr class-name)))
     905           (java::%find-java-class class-name)))
    899906        (t
    900907         (error "Unknown specializer: ~S" specializer))))
Note: See TracChangeset for help on using the changeset viewer.