Changeset 13102


Ignore:
Timestamp:
12/25/10 11:03:50 (13 years ago)
Author:
ehuelsmann
Message:

Add more type-conversion helpers to java.lisp.

File:
1 edited

Legend:

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

    r12994 r13102  
    219219      i (1+ i)))
    220220    jarray))
     221
     222(defun list-from-jarray (jarray)
     223  "Returns a list with the elements of `jarray`."
     224  (loop for i from 0 below (jarray-length jarray)
     225        collect (jarray-ref jarray i)))
     226
     227(defun vector-from-jarray (jarray)
     228  "Returns a vector with the elements of `jarray`."
     229  (loop with vec = (make-array (jarray-length jarray))
     230        for i from 0 below (jarray-length jarray)
     231        do (setf (aref vec i) (jarray-ref jarray i))
     232        finally (return vec)))
     233
     234(defun list-from-jenumeration (jenumeration)
     235  "Returns a list with the elements returned by successive `nextElement`
     236calls on the java.util.Enumeration `jenumeration`."
     237  (loop while (jcall jenumeration
     238                     (jmethod "java.util.Enumeration" "hasMoreElements"))
     239        collect (jcall jenumeration
     240                       (jmethod "java.util.Enumeration" "nextElement"))))
    221241
    222242(defun jclass-constructors (class)
Note: See TracChangeset for help on using the changeset viewer.