Fix for callbacks under windows from Andrew Lyon.
[cl-glfw.git] / lib / glfw-macros.lisp
blob66811b335dde1d8e4e1306bfd3f509bb076b991d
1 (in-package #:cl-glfw)
3 (defmacro defcfun+doc ((c-name lisp-name) return-type (&body args) docstring)
4 `(progn
5 (defcfun (,c-name ,lisp-name) ,return-type ,@args)
6 (setf (documentation #',lisp-name 'function) ,docstring)))
8 (defmacro defcfun+out+doc ((c-name lisp-name) return-type (&body args) docstring)
9 (let ((internal-name (intern (format nil "%~a" lisp-name)))
10 (in-arg-names (mapcar #'second (remove-if-not #'(lambda (arg)
11 (eql (car arg) :in))
12 args)))
13 (out-args (mapcar #'cdr (remove-if-not #'(lambda (arg)
14 (eql (car arg) :out))
15 args))))
16 `(progn
17 (defcfun (,c-name ,internal-name) ,return-type
18 ,@(mapcar #'(lambda (arg)
19 (if (eql (car arg) :out)
20 (list (second arg) :pointer)
21 (cdr arg)))
22 args))
23 (defun ,lisp-name ,in-arg-names
24 ,docstring
25 (with-foreign-objects ,out-args
26 (,internal-name ,@(mapcar #'second args))
27 (list ,@(mapcar #'(lambda (arg)
28 `(mem-ref ,(first arg) ',(second arg)))
29 out-args)))))))