*SMOKE-MODULE* must be passed instead of *QT-SMOKE*.
Annotate for file src/list.lisp
2010-01-10 tobias 1 (in-package :cl-smoke.qt-impl)
08:52:49 ' 2
2009-09-02 tobias 3 (defmacro define-qlist-wrapper (type-name &optional c-name)
2010-01-10 tobias 4 (let* ((c-name (or c-name type-name))
08:52:49 ' 5 (type (string-upcase c-name))
' 6 (list-type (symbolicate 'qlist- type)))
' 7 `(progn
' 8 (defcfun ,(concatenate 'string "qt_smoke_list_" c-name "_size") :int
' 9 "Returns the size of LIST."
' 10 (list :pointer))
' 11 (defcfun ,(concatenate 'string "qt_smoke_free_list_" c-name) :void
' 12 "Frees LIST."
' 13 (list :pointer))
' 14 (defcfun ,(concatenate 'string "qt_smoke_make_list_" c-name) :pointer
' 15 "Makes a list.")
' 16 (defcfun ,(concatenate 'string "qt_smoke_list_" c-name "_at") :pointer
' 17 "Returns the a newly constructed copy of the element at position AT of LIST."
' 18 (list :pointer)
' 19 (index :int))
' 20 (defcfun ,(concatenate 'string "qt_smoke_list_" c-name "_append") :pointer
' 21 "Appends NEW-ELEMENT to LIST."
' 22 (list :pointer)
' 23 (new-element :pointer))
2009-08-02 tobias 24 (define-foreign-type ,list-type ()
11:15:21 ' 25 ()
' 26 (:actual-type :pointer))
' 27 (define-parse-method ,list-type ()
' 28 (make-instance ',list-type))
' 29 (eval-when (:load-toplevel :execute)
' 30 ,@(loop for type-name in (ensure-list type-name) collect
2009-07-01 tobias 31 `(smoke::add-type ,(format nil "const QList<~A>&" type-name)
10:58:06 ' 32 ',list-type))
2009-08-02 tobias 33 ,@(loop for type-name in (ensure-list type-name) collect
2009-07-01 tobias 34 `(smoke::add-type ,(format nil "QList<~A>" type-name) ',list-type)))
2010-01-10 tobias 35 ,@(loop for type-name in (ensure-list type-name) collect
2009-07-01 tobias 36 `(defmethod translate-from-foreign (list (type ,list-type))
10:58:06 ' 37 (let ((vector (make-array (,(symbolicate 'qt-smoke-list-
' 38 type '-size)
' 39 list))))
' 40 (dotimes (index (length vector) vector)
' 41 (setf (aref vector index)
' 42 ;; FIXME the retuned object is not wrapped by Smoke
' 43 ;; -> change this?
' 44 (smoke::object-to-lisp
' 45 (,(symbolicate 'qt-smoke-list-
' 46 type '-at)
' 47 list index)
2009-06-21 tobias 48 (smoke::make-smoke-type *smoke-module* ,type-name)))))))
2009-08-02 tobias 49 (defmethod free-translated-object (pointer (type ,list-type) param)
11:15:21 ' 50 (declare (ignore param))
' 51 (,(symbolicate 'qt-smoke-free-list- type)
' 52 pointer))
2010-01-10 tobias 53 (defun ,(symbolicate 'coerce- list-type) (list)
08:52:49 ' 54 (let ((qlist (,(symbolicate 'qt-smoke-make-list- type))))
2009-09-02 tobias 55 (loop for element in list do
2010-01-10 tobias 56 (,(symbolicate 'qt-smoke-list- type '-append)
2009-09-02 tobias 57 qlist (pointer (make-instance ',type :args (list element)))))
2009-08-02 tobias 58 (smoke::make-cleanup-pointer
2010-01-10 tobias 59 qlist
08:52:49 ' 60 (function ,(symbolicate 'qt-smoke-free-list- type)))))
' 61 ,@(loop for type-name in (ensure-list type-name) collect
2009-07-01 tobias 62 `(define-from-lisp-translation (,(format nil "const QList<~A>&" type-name)
10:58:06 ' 63 ,(format nil "QLIst<~A>" type-name))
' 64 list ;; FIXME allow seqence and define element type
' 65 ,(symbolicate 'coerce- list-type))))))
2010-01-10 tobias 66
2009-09-02 tobias 67 (define-qlist-wrapper "QVariant")
12:00:35 ' 68 (define-qlist-wrapper ("QObject*" "QWidget*") "void")
' 69 (define-qlist-wrapper "QByteArray")