Changeset 5239


Ignore:
Timestamp:
12/21/03 14:05:49 (17 years ago)
Author:
asimon
Message:

JNEW-ARRAY-FROM-ARRAY
java-extensions module

File:
1 edited

Legend:

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

    r5238 r5239  
    22;;;
    33;;; Copyright (C) 2003 Peter Graves
    4 ;;; $Id: java.lisp,v 1.10 2003-12-20 22:40:02 asimon Exp $
     4;;; $Id: java.lisp,v 1.11 2003-12-21 14:05:49 asimon Exp $
    55;;;
    66;;; This program is free software; you can redistribute it and/or
     
    6767  (apply #'jarray-set java-array new-value indices))
    6868
     69(defun jnew-array-from-array (element-type array)
     70  "Returns a new Java array with base type ELEMENT-TYPE (a string or a class-ref)
     71   initialized from ARRAY"
     72  (flet
     73    ((row-major-to-index (dimensions n)
     74                         (loop for dims on dimensions
     75                           for dim = (car dims)
     76                           with indices
     77                           do
     78                           (multiple-value-bind (m r) (floor n (apply #'* (cdr dims)))
     79                             (push m indices)
     80                             (setq n r))
     81                           finally (return (nreverse indices)))))
     82    (let* ((dimensions (array-dimensions array))
     83           (jarray (apply #'jnew-array element-type dimensions)))
     84      (dotimes (i (array-total-size array) jarray)
     85  #+maybe_one_day
     86  (setf (apply #'jarray-ref jarray (row-major-to-index dimensions i)) (row-major-aref array i))
     87  (apply #'(setf jarray-ref) (row-major-aref array i) jarray (row-major-to-index dimensions i))))))
     88
    6989(defun jclass-constructors (class)
    7090  "Returns a vector of constructors for CLASS"
     
    115135  "MEMBER is a static member of its declaring class"
    116136  (jstatic (jmethod "java.lang.reflect.Modifier" "isStatic" "int")
    117     "java.lang.reflect.Modifier"
    118     (jcall (jmethod "java.lang.reflect.Member" "getModifiers") member)))
     137           "java.lang.reflect.Modifier"
     138           (jcall (jmethod "java.lang.reflect.Member" "getModifiers") member)))
    119139
    120140(defun jmember-public-p (member)
    121141  "MEMBER is a public member of its declaring class"
    122142  (jstatic (jmethod "java.lang.reflect.Modifier" "isPublic" "int")
    123     "java.lang.reflect.Modifier"
    124     (jcall (jmethod "java.lang.reflect.Member" "getModifiers") member)))
     143           "java.lang.reflect.Modifier"
     144           (jcall (jmethod "java.lang.reflect.Member" "getModifiers") member)))
     145
     146(provide :java-extensions)
Note: See TracChangeset for help on using the changeset viewer.