4 (defun w-i-args-helper (args)
8 (cond ((= 1 (length args
)) 'il
:load-image
)
9 ((= 3 (length args
)) 'il
:load-l
)
10 ((stringp (second args
)) 'il
:load
)
14 (defmacro with-images
((&rest images
) &body body
)
15 "Generates an IL image for each of IMAGES, binding and loading if a parameter is supplied. BODY is executed, and the images are freed thereafter."
17 (count (length images
)))
18 `(cffi:with-foreign-object
(,ids
:uint
,count
)
19 (il:gen-images
,count
,ids
)
21 (let (,@(loop for x in images
22 for
(var . args
) = (if (listp x
) x
(list x
))
24 collect
`(,var
(anaphora:aprog1
(cffi:mem-ref
,ids
:uint
,i
)
25 ,@(w-i-args-helper args
)))))
27 (il:delete-images
,count
,ids
)))))
29 (il:with-images
(urp arp
(exit "/home/julian/exit.pcx")) (format t
"~&~A ~A ~A" urp arp exit
))