Changeset 14947


Ignore:
Timestamp:
01/16/17 17:30:17 (11 months ago)
Author:
mevenson
Message:

JSS syntax for fields (Alan Ruttenberg)

<thing> is either {<lisp expression>} or a class name or abbreviation that find-java-class can use

If <thing> is a lisp expression, then it is evaluated (in the lexical environment) and used as an instance
If <thing> is a class name the result of find-java-class is used and a static field access is done.

<field> is either {<lisp expression} or string

If <field> is a lisp expression it should evaluate to a string that names a field
If <field> is a string (no quotes) it is used as the field name

eg. #"foo.bar.baz" -> (get-java-field (find-java-class 'foo.bar) "baz" t)

#"{foo}.baz" -> (get-java-field (find-java-class foo) "baz" t)

From <https://github.com/armedbear/abcl/pull/25/commits/b94639b21843c439a5bf437661446c0b65a67791>.

Location:
trunk/abcl/contrib/jss
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/contrib/jss/invoke.lisp

    r14940 r14947  
    208208    (unread-char char stream)
    209209    (let ((name (read stream)))
    210       (let ((object-var (gensym))
    211             (args-var (gensym)))
    212         `(lambda (,object-var &rest ,args-var)
    213            (invoke-restargs ,name  ,object-var ,args-var ,(eql arg 0))))))
     210      (if (or (find #\. name) (find #\{ name))
     211    (jss-transform-to-field name)
     212    (let ((object-var (gensym))
     213    (args-var (gensym)))
     214      `(lambda (,object-var &rest ,args-var)
     215         (invoke-restargs ,name  ,object-var ,args-var ,(eql arg 0)))))))
    214216  (set-dispatch-macro-character #\# #\" 'read-invoke))
    215217
  • trunk/abcl/contrib/jss/jss.asd

    r14940 r14947  
    1 ;;;; -*- Mode: LISP -*-
     1(in-package :asdf)
    22(asdf:defsystem :jss
    33  :author "Alan Ruttenberg, Mark Evenson"
     
    1010             (:file "optimize-java-call")
    1111                                     (:file "classpath")
    12                                      (:file "compat")))))
     12             (:file "transform-to-field")
     13                                     (:file "compat")
     14             )))
     15;;  :defsystem-depends-on (:prove-asdf)
     16;;  :in-order-to ((test-op (test-op jss/tests)))
     17  )
     18
     19;; Until prove-asdf works
     20(let ((where (merge-pathnames "jss-tests.lisp" (load-time-value *load-pathname*))))
     21  (defun cl-user::test-jss()
     22    (funcall (intern "QUICKLOAD" 'ql) :prove)
     23    (funcall (intern "RUN" 'prove) where)))
     24
     25;; (asdf:defsystem :jss/tests
     26;;   :depends-on (jss)
     27;;   :components ((:module tests
     28;;    :pathname ""
     29;;    :components ((:test-file "jss-tests"))
     30;;    ))
     31;;   :perform (test-op :after (op c)
     32;;                     (funcall (intern #.(string :run) :prove) c)))
     33
     34
    1335
    1436
Note: See TracChangeset for help on using the changeset viewer.