| Allegro CL version 8.2 Unrevised from 8.1 to 8.2. 8.1 version |
Arguments: lisp-name (lisp-class &rest argtypes)
This macro defines a Lisp function that calls a Java constructor. The first argument is the name of the new Lisp function. The second argument is an argument list where the first item is the Lisp name of a class previously defined with def-java-class. The Lisp name is defined as a function of n arguments, where n is the number of argtypes specified. Each argtype is a string or symbol that denotes a Java class. The Lisp class must be defined to represent exactly one Java class. If the Lisp class was defined to represent more than one Java class, an error is signaled when the macro is expanded.
(def-java-class (string-buffer "java.lang.StringBuffer") (application-buffer) () () ((source :initform "Java"))) (def-java-constructor new-string-buffer-int (string-buffer "int"))
This form defines a Lisp function new-string-buffer-int that
calls Java to create an instance of the Java class
java.lang.StringBuffer
, and returns a remote
reference to the instance. The remote reference will be a Lisp
instance of the class string-buffer
.
The constructor is called as an ordinary Lisp function:
(new-string-buffer-int 17)
is an example of such a call.
(def-java-constructor new-string-buffer-str (string-buffer "java.lang.String"))
This form defines another Lisp function (new-string-buffer-str
that calls a different constructor of the
java.lang.StringBuffer
class. The Lisp function
must have a different name because the constructors are ordinary
functions, not generic functions, and thus cannot be overloaded in any
way.
The constructor is also called as an ordinary Lisp function:
(new-string-buffer-str "abc")
See jlinker.htm for more information on the jLinker facility.
Copyright (c) 1998-2016, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.1 page.
Created 2010.1.21.
| Allegro CL version 8.2 Unrevised from 8.1 to 8.2. 8.1 version |