Changeset 13368 for trunk/abcl/src/org


Ignore:
Timestamp:
06/29/11 22:04:37 (10 years ago)
Author:
astalla
Message:

Better separation between java-collections and the Java FFI. java-collections should be easily moved to contrib now.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/java-collections.lisp

    r12928 r13368  
    44
    55(in-package :java)
     6
     7(let* ((jclass (jclass "java.util.List"))
     8       (class (%find-java-class jclass)))
     9  (if class
     10      (error "java.util.List is already registered as a Lisp class; since JAVA-CLASSes can't be redefined, I can't inject SEQUENCE in its class precedence list. Ensure that you require :java-collections before specializing any method on java.util.List and in general before using java.util.List as a CLOS class.")
     11      ;;The code below is adapted from ensure-java-class in java.lisp
     12      (%register-java-class
     13       jclass (mop::ensure-class
     14               (make-symbol (jclass-name jclass))
     15               :metaclass (find-class 'java-class)
     16               :direct-superclasses
     17               (let ((supers
     18                      (mapcar #'ensure-java-class
     19                              (delete nil
     20                                      (concatenate 'list
     21                                                   (list (jclass-superclass jclass))
     22                                                   (jclass-interfaces jclass))))))
     23                 (append supers (list (find-class 'sequence)) (jclass-additional-superclasses jclass)))
     24               :java-class jclass))))
    625
    726(defmethod print-object ((coll (jclass "java.util.Collection")) stream)
     
    116135  (error "iterator-copy not supported for Java iterators."))
    117136
    118 ;;However, it makes sense to have some sequence functions available for Sets
     137;;It makes sense to have some sequence functions available for Sets
    119138;;(java.util.Set) too, even if they're not sequences.
    120139(defun jset-add (set item)
  • trunk/abcl/src/org/armedbear/lisp/java.lisp

    r13366 r13368  
    432432    (when (jclass-interface-p jclass)
    433433      (push (find-class 'java-object) supers))
    434     (when (jequal jclass (jclass "java.util.List"))
    435       (push (find-class 'sequence) supers))
    436434    supers))
    437435
Note: See TracChangeset for help on using the changeset viewer.