source: trunk/abcl/contrib/jss/jtypecase.lisp

Last change on this file was 15146, checked in by Mark Evenson, 5 years ago

JSS read sharp expression bugfixes
(Alan Ruttenberg)

Fix the following in JSS:

1) method call expression lookup java class for jstatic.
2) maybe-class, if it isn't a class, intern in current package vs. jss

Added missing <file:contrib/jss/util.lisp> from the head as of
github.com/alanruttenberg/abcl
with commit 2dab9f16384f279afe0127ef3c540811939c5bcb
<https://github.com/alanruttenberg/abcl/commit/0ce3f7d0e8003d2ca66cf59c4cd5d32a7c8f4f40>.

Untabify all source units for sanity.

Merges <https://github.com/armedbear/abcl/pull/65>.

Via
<https://github.com/armedbear/abcl/pull/65/commits/4461941d335feb298fd246f29967766c213b0e8c>,
<https://github.com/armedbear/abcl/pull/65/commits/3a681f852f0dc0581f8d47393e0d2d5d6e58596f>.

File size: 698 bytes
Line 
1(in-package :jss)
2
3(defvar *jtypecache* (make-hash-table :test 'eq))
4
5(defun jtypep (object type)
6  (declare (optimize (speed 3) (safety 0)))
7  (let ((class (or (gethash type *jtypecache*)
8                   (ignore-errors (setf (gethash type *jtypecache*) (find-java-class type)))))
9        (method (load-time-value (jmethod "java.lang.Class" "isInstance" "java.lang.Object"))))
10    (and class 
11         (jcall method class object))))
12   
13(defmacro jtypecase (keyform &body cases)
14  "JTYPECASE Keyform {(Type Form*)}*
15  Evaluates the Forms in the first clause for which Type names a class that Keyform isInstance of
16  is true."
17  (sys::case-body 'jtypecase keyform cases t 'jtypep nil nil nil))
18
Note: See TracBrowser for help on using the repository browser.