source: trunk/abcl/examples/lisp-to-java/lispfunctions.lisp

Last change on this file was 11384, checked in by vvoutilainen, 6 years ago

Add Id tags and thus keyword properties.

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