repos
/
qt.gui
/ annotate_shade
summary
|
shortlog
|
log
|
tree
|
commit
|
commitdiff
|
headdiff
|
annotate
|
filehistory
normal
|
plain
|
shade
|
zebra
QList<QByteArray> and QList<QVariant> conversion & use cxx:operator== and qt:operator== in cxx:=
Annotate for file src/operator.lisp
2009-06-11 tobias
1
(in-package :qt)
2010-01-10 tobias
2
08:52:49 '
3
(defun cxx:= (object &rest more-objects)
'
4
(if (null more-objects)
'
5
t
'
6
(every #'(lambda (o)
2009-05-27 tobias
7
;; Consider Class::operator== and operator==
17:18:41 '
8
;; FIXME integrate this in the overload resolution
'
9
(handler-case (qt:operator== object o)
'
10
(smoke::no-applicable-cxx-method ()
'
11
(cxx:operator== object o))))
2010-01-10 tobias
12
more-objects)))
08:52:49 '
13
'
14
(defun cxx:/= (object &rest more-objects)
'
15
(if (null more-objects)
'
16
t
'
17
(some #'(lambda (o)
'
18
(qt:operator!= object o))
'
19
more-objects)))
'
20
'
21
(defun ordered-p (relation list)
'
22
"Returns true when LIST is ordered according to RELATION."
'
23
(if (or (null list) (null (rest list)))
'
24
t
'
25
(and (funcall relation (first list)
'
26
(second list))
'
27
(ordered-p relation (rest list)))))
'
28
'
29
(defmacro define-cxx-relation (relation)
'
30
`(defun ,(intern (symbol-name relation) :cxx) (object &rest more-objects)
'
31
(ordered-p (symbol-function (quote ,(intern (format nil "OPERATOR~A"
'
32
relation)
'
33
:qt)))
'
34
(cons object more-objects))))
'
35
'
36
(defmacro define-cxx-relations (&rest relations)
'
37
`(progn
'
38
,@(mapcar #'(lambda (r) `(define-cxx-relation ,r)) relations)))
'
39
'
40
(define-cxx-relations < <= >= >)
'
41
'
42
'
43
(defun cxx:incf (object &optional (delta 1))
'
44
(cxx:operator+= object delta))
'
45
'
46
(defun cxx:decf (object &optional (delta 1))
'
47
(cxx:operator-= object delta))
'
48
'
49
(defun cxx:+ (&rest args)
'
50
(if (null args)
'
51
0
'
52
(reduce #'qt:operator+ args)))
'
53
'
54
(defun cxx:- (object &rest subtrahends)
'
55
(if (null subtrahends)
'
56
(cxx:operator- object)
'
57
(reduce #'qt:operator- (cons object subtrahends))))
'
58
'
59
(defun cxx:* (&rest args)
'
60
(if (null args)
'
61
1
'
62
(reduce #'qt:operator- args)))
'
63
'
64
(defun cxx:/ (object &rest denominators)
'
65
(if (null denominators)
'
66
(qt:operator/ 1 object)
'
67
(qt:operator/ object (apply #'cxx:+ denominators))))
'
68
'
69
(defun cxx:1+ (object)
'
70
(qt:operator+ object 1))
'
71
'
72
(defun cxx:1- (object)
'
73
(qt:operator- object 1))
'
74
'
75
(defun cxx:aref (object index)
'
76
"Returns the element of OBJECT at position INDEX."
2009-06-03 tobias
77
;;FIXME smoke does not support casting operators => can not
22:02:12 '
78
;; return a useful value with operator[]."
'
79
;;(cxx:operator[] object index))
2010-01-10 tobias
80
(declare ((integer 0) index))
08:52:49 '
81
(assert (< index (cxx:size object))
'
82
(index)
'
83
"Index ~A for ~A requested, but the length is ~A"
'
84
index object (cxx:size object))
'
85
(cxx:at object index))
'
86
'
87
'
88
(defun (setf cxx:aref) (new-value object index)
'
89
(declare ((integer 0) index))
'
90
(assert (< index (cxx:size object))
'
91
(index)
'
92
"Index ~A for ~A requested, but the length is ~A"
'
93
index object (cxx:size object))
'
94
(cxx:operator= (cxx:operator[] object index)
'
95
new-value)
'
96
new-value)