Export delete-app since other modules (qt.gui) might like to add methods to it. --> to head
Sun Mar 13 20:40:35 CET 2011 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Fix loading on OSX.
Thanks to Elliott Slaughter
hunk ./src/qt.core.lisp 36
- (:unix "libclsmokeqtcore.so")
+ (:darwin "libclsmokeqtcore.dylib")
+ (:unix "libclsmokeqtcore.so")
Sat Apr 3 14:34:21 CEST 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Account for possible lisp-object metatype id change when loading an image.
hunk ./src/variant.lisp 79
-(macrolet
- ((variant-conversions ((variant) &body types)
- (let* ((special-types '(long-long ulong-long map list hash))
- (exclude-types
- (append '(63) ;; ColorGroup
- (mapcar #'(lambda (s)
- (value
- (symbol-value
- (intern (format nil "VARIANT.+~A+" s)
- :qt))))
- special-types)))
- (qt-types (loop for i from 1 to (value qt:variant.+user-type+)
- when (and (qt:variant.type-to-name i)
- ;; type-to-name returns longlong but
- ;; should be LongLong
- (not (member i exclude-types)))
- collect
- (smoke::lispify (qt:variant.type-to-name i)
- :qt))))
- `(ecase (cxx:user-type ,variant)
- ,@(loop for type in (append types special-types
- (remove nil qt-types))
- collect
- (if (symbolp type)
- `(,(value (symbol-value [_$_]
- (let ((*package*
- (find-package :cl-smoke.qt)))
- (symbolicate 'variant.+ type '+))))
- ,(if (fboundp (intern (format nil "TO-~A" type) :cxx))
- `(,(intern (format nil "TO-~A" type) :cxx) ,variant)
- `(copy-object-from-pointer
- ;; intern since these types are in
- ;; qt.gui not qt.core
- (intern ,(symbol-name type) :qt)
- (cxx:const-data ,variant))))
- type))))))
- (defun qt:from-variant (variant)
- "Returns the value of VARIANT."
- (variant-conversions (variant)
- (#.(value qt:variant.+invalid+)
- (cerror "Return (VALUES)" "Type of variant ~A is invalid." variant)
- (values))
- (#.*cxx-lisp-object-metatype*
- (let* ((lisp-object (cl-smoke-lisp-object-value (pointer variant)))
- (value))
- (setf value (translate-cxx-lisp-object lisp-object))
- (free-cxx-lisp-object lisp-object)
- value)))))
+(eval-startup ()
+;; *cxx-lisp-object-metatype* can change when loading an image
+(eval '
+ (macrolet
+ ((variant-conversions ((variant) &body types)
+ (let* ((special-types '(long-long ulong-long map list hash))
+ (exclude-types
+ (append '(63) ;; ColorGroup
+ (mapcar #'(lambda (s)
+ (value
+ (symbol-value
+ (intern (format nil "VARIANT.+~A+" s)
+ :qt))))
+ special-types)))
+ (qt-types (loop for i from 1 to (value qt:variant.+user-type+)
+ when (and (qt:variant.type-to-name i)
+ ;; type-to-name returns longlong but
+ ;; should be LongLong
+ (not (member i exclude-types)))
+ collect
+ (smoke::lispify (qt:variant.type-to-name i)
+ :qt))))
+ `(ecase (cxx:user-type ,variant)
+ ,@(loop for type in (append special-types
+ (remove nil qt-types))
+ collect
+ `(,(value (symbol-value [_$_]
+ (let ((*package*
+ (find-package :cl-smoke.qt)))
+ (symbolicate 'variant.+ type '+))))
+ ,(if (fboundp (intern (format nil "TO-~A" type) :cxx))
+ `(,(intern (format nil "TO-~A" type) :cxx) ,variant)
+ `(copy-object-from-pointer
+ ;; intern since these types are in
+ ;; qt.gui not qt.core
+ (intern ,(symbol-name type) :qt)
+ (cxx:const-data ,variant)))))
+ ,@(loop for type in types
+ collect
+ `(,(eval (first type))
+ ,@(rest type)))))))
+ (defun qt:from-variant (variant)
+ "Returns the value of VARIANT."
+ (variant-conversions (variant)
+ ((value qt:variant.+invalid+)
+ (cerror "Return (VALUES)" "Type of variant ~A is invalid." variant)
+ (values))
+ (*cxx-lisp-object-metatype*
+ (let* ((lisp-object (cl-smoke-lisp-object-value (pointer variant)))
+ (value))
+ (setf value (translate-cxx-lisp-object lisp-object))
+ (free-cxx-lisp-object lisp-object)
+ value)))))))
Sat Feb 20 22:04:46 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* cleanup
hunk ./src/list.lisp 75
- list-pointer))))
+ list-pointer))))
hunk ./src/list.lisp 80
- (smoke:object-to-lisp
+ (object-to-lisp
hunk ./src/list.lisp 83
- (smoke:make-smoke-type ,(symbolicate '*smoke-module*)
- ,type-name)))))))
+ (make-smoke-type ,(symbolicate '*smoke-module*)
+ ,type-name)))))))
hunk ./src/vector.lisp 96
-(defun from-vector-point (elements)
- (make-cleanup-pointer
- (make-qvector (make-smoke-type *smoke-module* "QPoint")
- elements)
- #'free-qvector))
-
-(defun vector-point-p (sequence)
- (every #'(lambda (element) (typep element 'qt:point))
- sequence))
-
Sat Feb 20 22:02:38 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Make qt:application cleanup more stable
hunk ./src/application.lisp 60
- (cxx:quit application)
- ;; Call the destructor; -> destructed callback is called,
- ;; (~QApplication() is virtual) which takes care of cleanup on the
- ;; Lisp side.
- (smoke::delete-pointer (smoke:pointer application) (class-of application))
- (setf (slot-value application 'pointer) (null-pointer))
+ (unless (null-pointer-p (smoke:pointer application))
+ (cxx:quit application)
+ ;; Call the destructor; -> destructed callback is called,
+ ;; (~QApplication() is virtual) which takes care of cleanup on the
+ ;; Lisp side.
+ (smoke::delete-pointer (smoke:pointer application) (class-of application)))
Sat Feb 20 22:00:30 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* support all from qt:variant conversions.
hunk ./src/variant.lisp 76
-(defmacro variant-conversions ((variant) &body types)
- `(ecase (cxx:user-type ,variant)
- [_$_]
- ,@(loop for type in types collect
- (if (symbolp type)
- `(,(value (symbol-value [_$_]
- (let ((*package* (find-package :cl-smoke.qt)))
- (alexandria:symbolicate 'variant.+ type '+))))
- (,(intern (format nil "TO-~A" type) :cxx) ,variant))
- type))))
+(defun copy-object-from-pointer (class pointer)
+ (make-instance class :arg0 (make-instance class :pointer pointer)))
hunk ./src/variant.lisp 79
-(defun qt:from-variant (variant)
- "Returns the value of VARIANT."
- (variant-conversions (variant)
- (#.(value qt:variant.+invalid+)
- (cerror "Return (VALUES)" "Type of variant ~A is invalid." variant)
- (values))
- 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 (cl-smoke-lisp-object-value (pointer variant)))
- (value))
- (setf value (translate-cxx-lisp-object lisp-object))
- (free-cxx-lisp-object lisp-object)
- value))))
+(macrolet
+ ((variant-conversions ((variant) &body types)
+ (let* ((special-types '(long-long ulong-long map list hash))
+ (exclude-types
+ (append '(63) ;; ColorGroup
+ (mapcar #'(lambda (s)
+ (value
+ (symbol-value
+ (intern (format nil "VARIANT.+~A+" s)
+ :qt))))
+ special-types)))
+ (qt-types (loop for i from 1 to (value qt:variant.+user-type+)
+ when (and (qt:variant.type-to-name i)
+ ;; type-to-name returns longlong but
+ ;; should be LongLong
+ (not (member i exclude-types)))
+ collect
+ (smoke::lispify (qt:variant.type-to-name i)
+ :qt))))
+ `(ecase (cxx:user-type ,variant)
+ ,@(loop for type in (append types special-types
+ (remove nil qt-types))
+ collect
+ (if (symbolp type)
+ `(,(value (symbol-value [_$_]
+ (let ((*package*
+ (find-package :cl-smoke.qt)))
+ (symbolicate 'variant.+ type '+))))
+ ,(if (fboundp (intern (format nil "TO-~A" type) :cxx))
+ `(,(intern (format nil "TO-~A" type) :cxx) ,variant)
+ `(copy-object-from-pointer
+ ;; intern since these types are in
+ ;; qt.gui not qt.core
+ (intern ,(symbol-name type) :qt)
+ (cxx:const-data ,variant))))
+ type))))))
+ (defun qt:from-variant (variant)
+ "Returns the value of VARIANT."
+ (variant-conversions (variant)
+ (#.(value qt:variant.+invalid+)
+ (cerror "Return (VALUES)" "Type of variant ~A is invalid." variant)
+ (values))
+ (#.*cxx-lisp-object-metatype*
+ (let* ((lisp-object (cl-smoke-lisp-object-value (pointer variant)))
+ (value))
+ (setf value (translate-cxx-lisp-object lisp-object))
+ (free-cxx-lisp-object lisp-object)
+ value)))))
Mon Feb 15 16:33:05 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Build a shared library not a module.
Fixes a build error on OS X.
hunk ./src/lib/CMakeLists.txt 14
-add_library(clsmokeqtcore MODULE ${QT_SMOKE_SOURCES})
+add_library(clsmokeqtcore SHARED ${QT_SMOKE_SOURCES})
Thu Feb 4 16:06:38 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Test building libclsmokeqtcore
hunk ./test.lisp 2
+cmake ./ || exit 1
+make || exit 1
Thu Feb 4 10:22:53 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Add qvector.cpp
addfile ./src/lib/qvector.cpp
hunk ./src/lib/qvector.cpp 1
+#include "cl_smoke_qt.h"
+
+#include <QVector>
+#include <QPoint>
+
+extern "C" {
+
+/** Construct a 0 sized QVector.
+ * Since the QVectorData is QVectorData::shared_null the template type does not matter.
+ * @return A null QVector
+ */
+CL_SMOKE_QT_EXPORT void*
+cl_smoke_make_qvector()
+{
+ return new QVector<QPoint>();
+}
+
+/** Deletes a null QVector. i.e.: The QVectorData pointer is 0.
+ * @param qvector a null QVector
+ */
+CL_SMOKE_QT_EXPORT void
+cl_smoke_delete_qvector(void* qvector)
+{
+ delete static_cast<QVector<QPoint>*>(qvector);
+}
+
+} // extern "C"
Sat Jan 30 16:40:15 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Get the QList size using Lisp instead of an external C function.
hunk ./src/lib/qlist.h 35
-CL_SMOKE_QT_EXPORT int \
-cl_smoke_list_ ## NAME ## _size(const void* list) \
-{ \
- return static_cast<const QList< TYPE >*>(list)->size(); \
-} \
-\
hunk ./src/list.lisp 3
+(defbitfield qlist-data-flags
+ :sharable)
+
+(defcstruct qlist-data
+ (ref :char :count #.(class-size (find-class 'qt:basic-atomic-int)))
+ (alloc :int)
+ (begin :int)
+ (end :int)
+ (flags qlist-data-flags)
+ (array :pointer))
+
+(defcstruct qlist
+ (data (:pointer qlist-data)))
+
+(defun qlist-size (qlist)
+ (let ((data (foreign-slot-value qlist 'qlist 'data)))
+ (- (foreign-slot-value data 'qlist-data 'end)
+ (foreign-slot-value data 'qlist-data 'begin))))
+
hunk ./src/list.lisp 44
- (fun-names-let ((list-size "cl-smoke-list-" "-size")
- (list-free "cl-smoke-free-list-")
+ (fun-names-let ((list-free "cl-smoke-free-list-")
hunk ./src/list.lisp 56
- (defcfun ,(c-name (list-size type)) :int
- "Returns the size of LIST."
- (list :pointer))
hunk ./src/list.lisp 73
- (let ((vector (make-array (,(list-size type)
+ (declare (optimize (speed 3)))
+ (let ((vector (make-array (qlist-size
Tue Jan 26 17:19:51 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Fix define-qlist-wrapper usage for other modules. (i.e. qt.gui)
hunk ./src/list.lisp 3
-(eval-when (:compile-toplevel :execute)
+(eval-when (:compile-toplevel :load-toplevel :execute)
Mon Jan 25 20:07:22 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Export delete-app since other modules (qt.gui) might like to add methods to it.
hunk ./src/package.lisp 5
+ #:delete-app