1 (defpackage #:cl-glfw-types
3 (:shadow
#:boolean
#:byte
#:float
#:char
#:string
)
4 (:export
#:enum
#:boolean
#:bitfield
#:byte
#:short
#:int
#:sizei
#:ubyte
#:ushort
#:uint
5 #:float
#:clampf
#:double
#:clampd
#:void
#:uint64
#:int64
11 (in-package #:cl-glfw-types
)
13 (defctype enum
:uint32
)
14 (defctype boolean
:uint8
)
15 (defctype bitfield
:uint32
)
17 (defctype short
:int16
)
19 (defctype sizei
:int32
)
20 (defctype ubyte
:uint8
)
21 (defctype ushort
:uint16
)
22 (defctype uint
:uint32
)
23 (defctype float
:float
)
24 (defctype clampf
:float
)
25 (defctype double
:double
)
26 (defctype clampd
:double
)
29 #-cffi-features
:no-long-long
30 (defctype uint64
:uint64
)
31 #-cffi-features
:no-long-long
32 (defctype int64
:int64
)
34 ;; Find a CFFI integer type the same foreign-size as a pointer
35 (defctype intptr
#.
(find-symbol (format nil
"INT~d" (* 8 (cffi:foreign-type-size
:pointer
))) (find-package '#:keyword
)))
36 (defctype sizeiptr
#.
(find-symbol (format nil
"INT~d" (* 8 (cffi:foreign-type-size
:pointer
))) (find-package '#:keyword
)))
38 (defctype handle
:unsigned-int
)
42 (defctype string
:string
)
44 (defctype half
:unsigned-short
) ; this is how glext.h defines it anyway
46 (defmethod cffi:expand-to-foreign
(value (type (eql 'boolean
)))
49 (defmethod cffi:expand-from-foreign
(value (type (eql 'boolean
)))
52 (defmethod cffi:expand-to-foreign
(value (type (eql 'clampf
)))
53 `(coerce ,value
'single-float
))
55 (defmethod cffi:expand-to-foreign
(value (type (eql 'clampd
)))
56 `(coerce ,value
'double-float
))
58 (defmethod cffi:expand-to-foreign
(value (type (eql 'float
)))
59 `(coerce ,value
'single-float
))
61 (defmethod cffi:expand-to-foreign
(value (type (eql 'double
)))
62 `(coerce ,value
'double-float
))
64 ;; TODO: Maybe we can find/write a converter to a half? Does anyone want it?
65 ;; TODO: Might we want converters to integer types? What would it be? round, or floor (or even ceil)?