repos
/
qt.gui
/ annotate_shade
summary
|
shortlog
|
log
|
tree
|
commit
|
commitdiff
|
headdiff
|
annotate
|
filehistory
normal
|
plain
|
shade
|
zebra
QList<QByteArray> and QList<QVariant> conversion & use cxx:operator== and qt:operator== in cxx:=
Annotate for file src/list.lisp
2009-05-27 tobias
1
(in-package :qt)
17:18:41 '
2
'
3
(defmacro define-qlist-wrapper (type-name)
'
4
(let* ((type (string-upcase type-name))
'
5
(list-type (symbolicate 'qlist- type)))
'
6
`(progn
'
7
(defcfun ,(concatenate 'string "qt_smoke_list_" type-name "_size") :int
'
8
"Returns the size of LIST."
'
9
(list :pointer))
'
10
(defcfun ,(concatenate 'string "qt_smoke_free_list_" type-name) :void
'
11
"Frees LIST."
'
12
(list :pointer))
'
13
(defcfun ,(concatenate 'string "qt_smoke_make_list_" type-name) :pointer
'
14
"Makes a list.")
'
15
(defcfun ,(concatenate 'string "qt_smoke_list_" type-name "_at") :pointer
'
16
"Returns the a newly constructed copy of the element at position AT of LIST."
'
17
(list :pointer)
'
18
(index :int))
'
19
(defcfun ,(concatenate 'string "qt_smoke_list_" type-name "_append") :pointer
'
20
"Appends NEW-ELEMENT to LIST."
'
21
(list :pointer)
'
22
(new-element :pointer))
'
23
(define-foreign-type ,list-type ()
'
24
()
'
25
(:actual-type :pointer))
'
26
(define-parse-method ,list-type ()
'
27
(make-instance ',list-type))
'
28
(eval-when (:load-toplevel :execute)
'
29
(smoke::add-type ,(format nil "const QList<~A>&" type-name)
'
30
',list-type)
'
31
(smoke::add-type ,(format nil "QList<~A>" type-name) ',list-type))
'
32
(defmethod translate-from-foreign (list (type ,list-type))
'
33
(let ((vector (make-array (,(symbolicate 'qt-smoke-list-
'
34
type '-size)
'
35
list))))
'
36
(dotimes (index (length vector) vector)
'
37
(setf (aref vector index)
'
38
;; FIXME the retuned object is not wrapped by Smoke
'
39
;; -> change this?
'
40
(smoke::object-to-lisp
'
41
(,(symbolicate 'qt-smoke-list-
'
42
type '-at)
'
43
list index)
'
44
(smoke::make-smoke-type *qt-smoke* ,type-name))))))
'
45
(defmethod free-translated-object (pointer (type ,list-type) param)
'
46
(declare (ignore param))
'
47
(,(symbolicate 'qt-smoke-free-list- type)
'
48
pointer))
'
49
(defun ,(symbolicate 'coerce- list-type) (list)
'
50
(let ((qlist (,(symbolicate 'qt-smoke-make-list- type))))
'
51
(loop for element in list do
'
52
(,(symbolicate 'qt-smoke-list- type '-append)
'
53
qlist (pointer (make-instance ',type :args (list element)))))
'
54
(smoke::make-cleanup-pointer
'
55
qlist
'
56
(function ,(symbolicate 'qt-smoke-free-list- type)))))
'
57
(define-from-lisp-translation (,(format nil "const QList<~A>&" type-name)
'
58
,(format nil "QLIst<~A>" type-name))
'
59
list ;; FIXME allow seqence and define element type
'
60
,(symbolicate 'coerce- list-type)))))
'
61
'
62
(define-qlist-wrapper "QVariant")
'
63
;(define-qlist-wrapper "void")
'
64
(define-qlist-wrapper "QByteArray")