Changes between Version 1 and Version 2 of ImplementingJavaInterfaces


Ignore:
Timestamp:
01/26/11 10:01:35 (11 years ago)
Author:
Mark Evenson
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ImplementingJavaInterfaces

    v1 v2  
    1 To implement Java interfaces in Lisp, we define our API via the generic function JAVA:JMAKE-PROXY as follows:
     1To implement Java interfaces in Lisp, the simplest function is
     2
     3{{{
     4(defun jinterface-implementation (interface &rest method-names-and-defs)
     5  "Creates and returns an implementation of a Java interface with
     6   methods calling Lisp closures as given in METHOD-NAMES-AND-DEFS.
     7
     8   INTERFACE is either a Java interface or a string naming one.
     9
     10   METHOD-NAMES-AND-DEFS is an alternating list of method names
     11   (strings) and method definitions (closures).
     12
     13   For missing methods, a dummy implementation is provided that
     14   returns nothing or null depending on whether the return type is
     15   void or not. This is for convenience only, and a warning is issued
     16   for each undefined method."
     17[…]
     18}}}
     19
     20Thus, for the Java interface compiled into a Java class, and on the current classspath (see [wiki: JAVA:ADD-TO-CLASSPATH] see the BankAccount example in the 'java-interfaces'.
     21
     22
     23
     24A more full featured API can be found via the generic function JAVA:JMAKE-PROXY as follows:
    225
    326{{{
     
    1134  overloaded methods are merged, so you have to manually discriminate them if you want to.
    1235  The remaining arguments are java-objects wrapping the method's parameters."
    13  […]
     36[…]
    1437}}}
    1538