Better Lisp vector to QList<*> conversion.
Wed Sep 2 14:00:35 CEST 2009 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Better Lisp vector to QList<*> conversion.
hunk ./src/list.lisp 3
-(defmacro define-qlist-wrapper (type-name &optional c-name)
+(defmacro define-qlist-wrapper (type-name element-type &optional c-name)
hunk ./src/list.lisp 49
- (loop for element in list do
+ (loop for element across list do
hunk ./src/list.lisp 51
- qlist (pointer (make-instance ',type :args (list element)))))
+ qlist (pointer (make-instance ',element-type :args (list element)))))
hunk ./src/list.lisp 55
+ (defun ,(symbolicate list-type '-p) (list)
+ (every #'(lambda (element)
+ (typep element ',element-type))
+ list))
hunk ./src/list.lisp 62
- list ;; FIXME allow sequence and define element type
+ ;; FIXME allow sequence
+ (and (vector ,element-type)
+ (satisfies ,(symbolicate list-type '-p)))
hunk ./src/list.lisp 67
-(define-qlist-wrapper "QVariant")
-(define-qlist-wrapper ("QObject*" "QWidget*") "void")
-(define-qlist-wrapper "QByteArray")
+;; FIXME it would be nice to have QList<QVariant> as fallback for any
+;; list we can not convert otherwise. e.g.: '("a" 1)
+(define-qlist-wrapper "QVariant" qt:variant)
+
+(define-qlist-wrapper ("QObject*" "QWidget*") qt:object "void")
+(define-qlist-wrapper "QByteArray" qt:byte-array)
hunk ./src/signal-slot/signal.lisp 91
-;;; The first element of args would be used for the return value by
-;;; QMetaObject::invokeMethod(), but for signal-slot connection it is
-;;; ignored.
+ ;;; The first element of args would be used for the return value by
+ ;;; QMetaObject::invokeMethod(), but for signal-slot connection it is
+ ;;; ignored.
hunk ./src/signal-slot/signal.lisp 96
- (cffi:with-foreign-object (args :pointer (1+ (length arguments)))
+ (with-foreign-object (args :pointer (1+ (length arguments)))
hunk ./src/string-list.lisp 43
+(defun string-list-p (sequence)
+ (every #'stringp sequence))
+
hunk ./src/string-list.lisp 47
- (vector string) coerce-string-list)
+ (and (vector string)
+ (satisfies string-list-p))
+ coerce-string-list)