Wed Jun 10 14:02:01 CEST 2009 Tobias Rautenkranz * more qt:variant conversions diff -rN -u old-qt.gui/src/variant.lisp new-qt.gui/src/variant.lisp --- old-qt.gui/src/variant.lisp 2014-10-30 07:47:40.000000000 +0100 +++ new-qt.gui/src/variant.lisp 2014-10-30 07:47:40.000000000 +0100 @@ -73,33 +73,40 @@ "Returns true when VARIANT is valid (has a value) and false otherwise." (cxx:is-valid variant)) +(defmacro variant-conversions ((variant) &body types) + `(ecase (cxx:user-type ,variant) + + ,@(loop for type in types collect + (if (symbolp type) + `(,(value (symbol-value (alexandria:symbolicate 'variant.+ type '+))) + (,(intern (format nil "TO-~A" type) :cxx) ,variant)) + type)))) + (defun from-variant (variant) "Returns the value of VARIANT." - (ecase (cxx:user-type variant) + (variant-conversions (variant) (#.(value variant.+invalid+) (cerror "Return (VALUES)" "Type of variant ~A is invalid." variant) (values)) - (#.(value variant.+string+) - (cxx:to-string variant)) - (#.(value variant.+string-list+) - (cxx:to-string-list variant)) - (#.(value variant.+uint+) - (cxx:to-uint variant)) - (#.(value variant.+int+) - (cxx:to-int variant)) - (#.(value variant.+double+) - (cxx:to-double variant)) - (#.(value variant.+char+) - (cxx:to-char variant)) - (#.(value variant.+bool+) - (cxx:to-bool variant)) + bit-array bool byte-array + char + date date-time double + int + line line-f list locale long-long + point point-f + rect rect-f reg-exp + size size-f string string-list + time + uint + ulong-long + url (#.*cxx-lisp-object-metatype* (let* ((lisp-object (qt-smoke-lisp-object-value (smoke::pointer variant))) (value)) (setf value (translate-cxx-lisp-object lisp-object)) (free-cxx-lisp-object lisp-object) value)))) - + (defmethod value ((variant variant)) "Returns the value of VARIANT." (from-variant variant))