/[cffi-objects]/test.lisp
ViewVC logotype

Contents of /test.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Thu Feb 9 15:53:55 2012 UTC (2 years, 2 months ago) by rklochkov
File size: 700 byte(s)
Initial release
1 (defpackage cffi-objects.test
2 (:use cl cffi-objects))
3 (in-package cffi-objects.test)
4
5 (defcallback test-double :double ((x :double))
6 (+ x 2))
7
8 (defun call-test-double ()
9 (= 4 (foreign-funcall-pointer (callback test-double) () :double 2 :double)))
10
11 (defcstruct* tstruct
12 (a :int)
13 (b :int))
14
15 (defcallback test-struct :int ((x :pointer))
16 (setf (mem-aref x :int 0) 10)
17 (mem-aref x :int 1))
18
19 (defun call-test-struct ()
20 (let ((s (make-instance 'tstruct)))
21 (setf (a s) 1 (b s) 2)
22 (prog1
23 (foreign-funcall-pointer
24 (callback test-struct) () (struct tstruct :out t) s :int)
25 (assert (= (a s) 10)))))
26
27 (assert (call-test-double))
28
29 (assert (= (call-test-struct) 2))
30

  ViewVC Help
Powered by ViewVC 1.1.5