source: trunk/j/examples/abcl/javacall_from_lisp/lispfunctions.lisp @ 11383

Last change on this file since 11383 was 11383, checked in by vvoutilainen, 15 years ago

Add copyright/license headers.

File size: 1.5 KB
Line 
1;;; lispfunctions.lisp
2;;;
3;;; Copyright (C) 2008 Ville Voutilainen
4;;;
5;;; This program is free software; you can redistribute it and/or
6;;; modify it under the terms of the GNU General Public License
7;;; as published by the Free Software Foundation; either version 2
8;;; of the License, or (at your option) any later version.
9;;;
10;;; This program is distributed in the hope that it will be useful,
11;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13;;; GNU General Public License for more details.
14;;;
15;;; You should have received a copy of the GNU General Public License
16;;; along with this program; if not, write to the Free Software
17;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19; we need to get the
20; 1) class (Main)
21; 2) classes of the parameters (int)
22; 3) method reference (getting that requires the class
23; of our object and the classes of the parameters
24
25; After that we can invoke the function with jcall,
26; giving the method reference, the object and the parameters.
27; The result is a lisp object (no need to do jobject-lisp-value),
28; unless we invoke the method
29; with jcall-raw.
30(defun void-function (param)
31  (let* ((class (jclass "Main"))
32   (intclass (jclass "int"))
33   (method (jmethod class "addTwoNumbers" intclass intclass))
34   (result (jcall method param 2 4)))
35    (format t "in void-function, result of calling addTwoNumbers(2, 4): ~a~%" result)))
36
Note: See TracBrowser for help on using the repository browser.