[cl-opengl-devel] cl-opengl/gl/types.lisp not define new classes

Luís Oliveira luismbo at gmail.com
Thu Nov 27 21:05:12 UTC 2008


Hello.

On Tue, Nov 25, 2008 at 3:16 AM, gusti <ggh.develop at gmail.com> wrote:
> I'm trying to use the cl-opengl packages in my linux with clisp but I found
> that the file cl-opengl/gl/types.lisp doesn't define the new class that must
> do.

Works for me on Linux with CLISP 2.46, latest CFFI and latest
cl-opengl. What version are you using?


> For example, see the command line below:
>   [118]> (cffi:define-foreign-type ensure-integer ()
>     ()
>     (:actual-type :int)
>     (:simple-parser ensure-integer))
>   ENSURE-INTEGER
>
> instead of define a class as for example:
>   [119]> (defclass mi-clase ()  ()  )
>   #<STANDARD-CLASS MI-CLASE>

If you have a look at the macroexpansion you'll see that
DEFINE-FOREIGN-TYPE doesn't indeed define a new class.

[4]> (macroexpand
       '(cffi:define-foreign-type ensure-integer ()
           ()
           (:actual-type :int)
           (:simple-parser ensure-integer)))
(EVAL-WHEN (:COMPILE-TOPLEVEL :LOAD-TOPLEVEL :EXECUTE)
 (DEFCLASS ENSURE-INTEGER (CFFI::ENHANCED-FOREIGN-TYPE) NIL
  (:DEFAULT-INITARGS :ACTUAL-TYPE '(:INT)))
 (CFFI:DEFINE-PARSE-METHOD ENSURE-INTEGER (&REST CFFI::ARGS)
  (APPLY #'MAKE-INSTANCE 'ENSURE-INTEGER CFFI::ARGS))
 'ENSURE-INTEGER) ;
T


You can also confirm that through FIND-CLASS:

[7]> (cffi:define-foreign-type ensure-integer ()
        ()
        (:actual-type :int)
        (:simple-parser ensure-integer))
ENSURE-INTEGER
[8]> (find-class 'ensure-integer)
#<STANDARD-CLASS ENSURE-INTEGER>


> So after that, obviously, the 'defmethod translate-to-foreign' fail, see
> below:
>   [120]> (defmethod translate-to-foreign (value (type ensure-integer))
>     (truncate value))
>
>   *** - FIND-CLASS: ENSURE-INTEGER does not name a class
>   The following restarts are available:
>   ABORT          :R1      ABORT
>   Break 1 [121]>

[9]> (defmethod cffi:translate-to-foreign (value (type ensure-integer))
       (truncate value))
#<STANDARD-METHOD (#<BUILT-IN-CLASS T> #<STANDARD-CLASS ENSURE-INTEGER>)>


> Do you know what is the problem? Can you help me please?

My guess is that you're using a *very* old version of CFFI. Latest is 0.10.3.

HTH.

-- 
Luís Oliveira
http://student.dei.uc.pt/~lmoliv/




More information about the cl-opengl-devel mailing list