<div dir="ltr">Or is it that once the lambda is compiled, it replaces the version with generate-gl-function in it? Does that mean that the wrapper functions are compiled on first call?<br></div><div class="gmail_extra"><br>
<br><div class="gmail_quote">On 16 October 2013 13:42, Chris Bagley <span dir="ltr"><<a href="mailto:chris.bagley@gmail.com" target="_blank">chris.bagley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">It seems to be compiling a new lambda on every call. I'll walk through my logic below:<br><br>So I am looking at how (gen-buffers) is implemented.<br><br>(defun gen-buffers (count)<br> (with-foreign-object (buffer-array '%gl:uint count)<br>
(%gl:gen-buffers count buffer-array)<br> (loop for i below count<br> collecting (mem-aref buffer-array '%gl:uint i))))<br><br>%gl:gen-buffers is deifned as <br>(defglextfun ("glGenBuffers" gen-buffers) :void<br>
(n sizei)<br> (buffers (:pointer uint)))<br><br>which expands to:<br>(progn<br> (declaim (notinline gen-buffers))<br> (defun gen-buffers (n buffers)<br> (generate-gl-function "glgenbuffers" 'gen-buffers ':void<br>
'((n sizei) (buffers (:pointer uint))) n buffers))<br> (setf (get 'gen-buffers 'proc-address-dummy) #'gen-buffers)<br> 'gen-buffers)<br><br>and generate-gl-function<br>(defun generate-gl-function (foreign-name lisp-name result-type body &rest args)<br>
(let ((address (gl-get-proc-address foreign-name))<br> (arg-list (mapcar #'first body)))<br> (when (or (not (pointerp address)) (null-pointer-p address))<br> (error "Couldn't find function ~A" foreign-name))<br>
(compile lisp-name<br> `(lambda ,arg-list<br> (multiple-value-prog1<br> (foreign-funcall-pointer<br> ,address<br> (:library opengl)<br>
,@(loop for i in body<br> collect (second i)<br> collect (first i))<br> ,result-type)<br> #-cl-opengl-no-check-error<br>
(check-error ',lisp-name))))<br> (apply lisp-name args)))<br><br>What is going on here? I don't believe that it is recompiling the wrapper function on every call, but I'm having issues working out how else this works.<br>
Hope someone can help me out here.<br>Cheers <br>Baggers<br><br></div>
</blockquote></div><br></div>