repos
/
qt.core
/ annotate_shade
summary
|
shortlog
|
log
|
tree
|
commit
|
commitdiff
|
headdiff
|
annotate
|
headblob
|
headfilediff
|
filehistory
normal
|
plain
|
shade
|
zebra
initial import
Annotate for file src/qstring.lisp
2009-04-05 tobias
1
(in-package :qt)
17:56:16 '
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
(define-foreign-type qstring ()
'
14
()
'
15
(:actual-type :pointer))
'
16
'
17
(defun setup-type-map ()
'
18
(smoke::add-type "QString" 'qstring)
'
19
(smoke::add-type "const QString&" 'qstring))
'
20
'
21
(eval-when (:load-toplevel :execute)
'
22
(setup-type-map))
'
23
'
24
;;; make sure, that you have configured slime corretly.
'
25
;;; e.g.
'
26
;;; (string #\U9999) crashed slime for me. Adding
'
27
;;; (set-language-environment "UTF-8")
'
28
;;; (setq slime-net-coding-system 'utf-8-unix)
'
29
;;; to .emacs helps.
'
30
(eval-when (:compile-toplevel :load-toplevel :execute)
'
31
(text-codec.set-codec-for-cstrings
'
32
(text-codec.codec-for-name (string *default-foreign-encoding*)))
'
33
(text-codec.set-codec-for-locale
'
34
(text-codec.codec-for-name (string *default-foreign-encoding*))))
'
35
'
36
'
37
(define-parse-method qstring ()
'
38
(make-instance 'qstring))
'
39
'
40
(defmethod translate-to-foreign (string (type qstring))
'
41
(with-foreign-string ((data length) string :null-terminated-p nil)
'
42
(qt-smoke-string-to-qstring data length)))
'
43
'
44
(let ((method (smoke::make-smoke-method (find-class 'byte-array)
'
45
"data")))
'
46
(defmethod cxx:data ((array byte-array) &rest args)
'
47
(declare (ignore args))
'
48
(values ;; Discarge second return value (length of string)
'
49
(foreign-string-to-lisp (smoke::pointer-call method
'
50
(smoke::pointer array))
'
51
:count (cxx:size array)))))
'
52
'
53
(defmethod translate-from-foreign (string (type qstring))
'
54
(cxx:data (make-instance 'byte-array
'
55
:pointer (qt-smoke-qstring-to-byte-array string))))
'
56
'
57
(defmethod free-translated-object (pointer (type qstring) param)
'
58
(declare (ignore param))
'
59
(qt-smoke-free-qstring pointer))