added repo.or.cz incantation
[rclg.git] / clsr / gcc-xml-ffi / test / gcc-xml-test.cl
blob0e01b5157eb84cb2c5d356c784de7c570a7257fe
2 (in-package :gcc-xml-test)
4 (defun eval-decls (s)
5 (loop for d = (read s nil)
6 while d do
7 (format t "~A~%" d)
8 (eval d)))
10 (defparameter *library-path*
11 (asdf:component-pathname
12 (asdf:find-component
13 (asdf:find-system "gcc-xml-ffi-test")
14 "libraries")))
16 (defun uffi-load-library (lib)
17 (unless (uffi:load-foreign-library
18 (uffi:find-foreign-library
19 lib
20 (list (pathname-directory *load-truename*)
21 (print (merge-pathnames
22 (make-pathname :directory (list :relative "libffitest" ".libs"))
23 *library-path*
25 (print (merge-pathnames
26 (make-pathname :directory (list :relative "lib" "ffitest"))
27 *library-path*
28 )))
29 :types '("so" "dylib"))
30 :supporting-libraries '("c")
31 :module lib
32 :force-load t)
33 (error "Unable to load ffitest library")))
35 (eval-when (:compile-toplevel :load-toplevel :execute)
36 (defparameter *ffitest-loaded* nil)
38 (when *load-truename*
39 (uffi-load-library "libffitest"))
40 (let ((decls))
41 (with-open-file (defout "decls.lisp" :direction :output :if-exists :supersede)
42 (setf decls (parse-gcc-xml-file "test/ffitest.xml"))
43 (write-uffi-declarations decls defout))
44 (with-open-file (defin "decls.lisp" :direction :input)
45 (let ((*package* (find-package :gcc-xml-test)))
46 (eval-decls defin)))
47 (setf *ffitest-loaded* t)
48 decls))
50 (defun do-test2 ()
51 (let ((x (uffi::convert-to-foreign-string "evenboguser")))
52 (let ((foreign-string-y (|foo_function| x)))
53 (let ((y (uffi::convert-from-foreign-string foreign-string-y)))
54 (print y))
55 (uffi:free-foreign-object foreign-string-y))
56 (uffi:free-foreign-object x)))
58 (defun do-uffi-test-2 ()
59 (when *load-truename*
60 (uffi-load-library "libffitest"))
61 (let ((decls))
62 (with-open-file (defout "decls.lisp" :direction :output :if-exists :supersede)
63 (setf decls (parse-gcc-xml-file "test/ffitest2.xml"))
64 (write-uffi-declarations decls defout)
66 ; (defpackage #:opengl (:use #:cl))
67 ; (let ((*package* (find-package :opengl)))
68 (let ((*package* (find-package :gcc-xml-test)))
69 (with-open-file (defin "decls.lisp" :direction :input)
70 (eval-decls defin))
72 decls))