Changeset 4859


Ignore:
Timestamp:
11/21/03 02:56:15 (18 years ago)
Author:
dmcnaught
Message:

Some convenience functions for doing reflection on Java objects.

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

Legend:

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

    r4753 r4859  
    22;;;
    33;;; Copyright (C) 2003 Peter Graves
    4 ;;; $Id: autoloads.lisp,v 1.64 2003-11-14 17:56:11 piso Exp $
     4;;; $Id: autoloads.lisp,v 1.65 2003-11-21 02:56:15 dmcnaught Exp $
    55;;;
    66;;; This program is free software; you can redistribute it and/or
     
    133133(export 'jregister-handler "JAVA")
    134134(autoload 'jregister-handler "java.lisp")
     135(export 'jclass-name "JAVA")
     136(autoload 'jclass-name "java.lisp")
     137(export 'jobject-class "JAVA")
     138(autoload 'jobject-class "java.lisp")
     139(export 'jclass-constructors "JAVA")
     140(autoload 'jclass-constructors "java.lisp")
     141(export 'jconstructor-params "JAVA")
     142(autoload 'jconstructor-params "java.lisp")
     143(export 'jclass-fields "JAVA")
     144(autoload 'jclass-fields "java.lisp")
     145(export 'jfield-type "JAVA")
     146(autoload 'jfield-type "java.lisp")
     147(export 'jclass-methods "JAVA")
     148(autoload 'jclass-methods "java.lisp")
     149(export 'jinstance-of-p "JAVA")
     150(autoload 'jinstance-of-p "java.lisp")
     151
     152
    135153
    136154;; Profiler.
  • trunk/j/src/org/armedbear/lisp/java.lisp

    r4744 r4859  
    2121(defun jregister-handler (object event handler &key data count)
    2222  (%jregister-handler object event handler data count))
     23
     24(defun jclass-name (class)
     25  "Returns the name of CLASS as a Lisp string"
     26  (jcall (jmethod "java.lang.Class" "getName") class))
     27
     28(defun jobject-class (obj)
     29  "Returns the Java class that OBJ belongs to"
     30  (jcall (jmethod "java.lang.Object" "getClass") obj))
     31
     32(defun jclass-constructors (class)
     33  "Returns a vector of constructors for CLASS"
     34  (jcall (jmethod "java.lang.Class" "getConstructors") class))
     35
     36(defun jconstructor-params (constructor)
     37  "Returns a vector of parameter types (Java classes) for CONSTRUCTOR"
     38  (jcall (jmethod "java.lang.reflect.Constructor" "getParameterTypes") constructor))
     39
     40(defun jclass-fields (class)
     41  "Returns a vector of all accessible fields of CLASS (and its supeorclasses)"
     42  (jcall (jmethod "java.lang.Class" "getFields") class))
     43
     44(defun jfield-type (field)
     45  "Returns the type (Java class) of FIELD"
     46  (jcall (jmethod "java.lang.reflect.Field" "getType") field))
     47
     48(defun jclass-methods (class)
     49  "Return a vector of all accessible methods of CLASS (and its superclasses)"
     50  (jcall (jmethod "java.lang.Class" "getMethods") class))
     51
     52(defun jinstance-of-p (obj class)
     53  "OBJ is an instance of CLASS (or one of its subclasses)"
     54  (jcall (jmethod "java.lang.Class" "isInstance" "java.lang.Object") class obj))
Note: See TracChangeset for help on using the changeset viewer.