Ignore:
Timestamp:
01/16/17 17:30:17 (10 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>.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.