[cl-opengl-devel] New CFFI features relevant to cl-opengl

Luís Oliveira luismbo at gmail.com
Wed Feb 15 15:10:00 UTC 2006


Hello,

I have added macroexpansion-time translators to CFFI and this is  
quite relevant to cl-opengl. Here's an example:

CFFI> (defctype ensure-float :float)
ENSURE-FLOAT
CFFI> (defmethod expand-to-foreign (value (type (eql 'ensure-float)))
         (if (constantp value)
             (float (eval value))
             `(float ,value)))
; Compiling LAMBDA (.PV-CELL. .NEXT-METHOD-CALL. VALUE TYPE):
; Compiling Top-Level Form:
#<STANDARD-METHOD EXPAND-TO-FOREIGN (T (EQL ENSURE-FLOAT)) {4053169D}>
CFFI> (macroexpand-1 '(defcfun "sqrtf" :float (x ensure-float)))
(PROGN
   NIL
   (DEFUN SQRTF (X)
     (LET ((#:G2792 (FLOAT X)))
       (VALUES (%FOREIGN-FUNCALL "sqrtf" :FLOAT #:G2792 :FLOAT)))))
T
CFFI>


I propose that we use this in cl-opengl and volunteer to do that. :-)

That would mean passing some of the DEFCFUNs in funcs.lisp over to  
the respective <spec-section>.lisp right? Though I see some functions  
that are just (defun foo (...) (%foo ...)) what's up with that?

-- 
Luís Oliveira
http://student.dei.uc.pt/~lmoliv/
Equipa Portuguesa do Translation Project
http://www.iro.umontreal.ca/translation/registry.cgi?team=pt




More information about the cl-opengl-devel mailing list