Support ownership transfer to non smoke wrapped QObjects & cleanup C++ to Lisp translation.
Annotate for file src/qstring.lisp
2010-01-10 tobias 1 (in-package :cl-smoke.qt-impl)
08:52:49 ' 2
' 3 (defcfun qt-smoke-string-to-qstring :pointer
' 4 (data :string)
' 5 (length :int))
' 6
' 7 (defcfun qt-smoke-free-qstring :void
' 8 (string :pointer))
' 9
' 10 (defcfun qt-smoke-qstring-to-byte-array :pointer
' 11 (qstring :pointer))
' 12
' 13 ;;; make sure, that you have configured slime correctly.
' 14 ;;; e.g.:
' 15 ;;; (string #\U9999) crashed slime for me. Adding
' 16 ;;; (set-language-environment "UTF-8")
' 17 ;;; (setq slime-net-coding-system 'utf-8-unix)
' 18 ;;; to .emacs helps.
' 19 ;;; Use emacs 23 for better unicode support.
' 20 (smoke:eval-startup (:compile-toplevel :execute)
' 21 (qt:text-codec.set-codec-for-cstrings
' 22 (qt:text-codec.codec-for-name (string *default-foreign-encoding*)))
' 23 (qt:text-codec.set-codec-for-locale
' 24 (qt:text-codec.codec-for-name (string *default-foreign-encoding*))))
' 25
' 26 (smoke:eval-startup (:compile-toplevel :execute)
2009-08-02 tobias 27 (let ((method (smoke::make-smoke-method-from-name (find-class 'qt:byte-array)
11:15:21 ' 28 "data")))
' 29 (defmethod cxx:data ((array qt:byte-array))
' 30 (values ;; Discharge second return value (length of string)
' 31 (foreign-string-to-lisp (smoke::pointer-call method
' 32 (smoke::pointer array))
' 33 :count (cxx:size array))))))
2010-01-10 tobias 34
2009-08-02 tobias 35 (defun from-qstring (qstring)
2009-08-27 tobias 36 (cxx:data (make-instance 'qt:byte-array
2009-08-02 tobias 37 :pointer (qt-smoke-qstring-to-byte-array qstring))))
2010-01-10 tobias 38
2009-08-02 tobias 39 (define-to-lisp-translation ("QString" "const QString&")
11:15:21 ' 40 from-qstring qt-smoke-free-qstring)
2010-01-10 tobias 41
08:52:49 ' 42 (defun coerce-qstring (string)
' 43 (make-cleanup-pointer
' 44 (with-foreign-string ((data length) string :null-terminated-p nil)
' 45 (qt-smoke-string-to-qstring data length))
2009-08-02 tobias 46 #'qt-smoke-free-qstring))
2010-01-10 tobias 47
08:52:49 ' 48 (define-from-lisp-translation ("const QString&" "QString") string
' 49 coerce-qstring)
' 50