support packages for symbols as property names.
Annotate for file src/operator.lisp
2010-01-10 tobias 1 (in-package :cl-smoke.qt-impl)
08:52:49 ' 2
' 3 (defun cxx:= (object &rest more-objects)
' 4 (if (null more-objects)
' 5 t
' 6 (every #'(lambda (o)
' 7 ;; Consider Class::operator== and operator==
' 8 ;; FIXME integrate this in the overload resolution
2009-08-27 tobias 9 (handler-case (qt:operator== object o)
08:37:36 ' 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."
' 77 (declare ((integer 0) index))
' 78 (assert (< index (cxx:size object))
' 79 (index)
' 80 "Index ~A for ~A requested, but the length is ~A"
' 81 index object (cxx:size object))
' 82 (cxx:at object index))
' 83
' 84
' 85 (defun (setf cxx:aref) (new-value object index)
' 86 (declare ((integer 0) index))
' 87 (assert (< index (cxx:size object))
' 88 (index)
' 89 "Index ~A for ~A requested, but the length is ~A"
' 90 index object (cxx:size object))
2009-08-27 tobias 91 ;; FIXME smoke generates no destructor for QByteRef
08:37:36 ' 92 ;; kaylptusCxxToSmoke.pm 954:
' 93 ;; # Also, if the class has no explicit destructor, generate a default one.
' 94 ;; if ( !$hasDestructor && !$hasPrivatePureVirtual && !$isGlobalSpace && $classNode->{NodeType} ne 'namespace' ) {
' 95 ;; > $hasPublicDestructor = 1;
' 96 ;; > $hasPublicProtectedConstructor = 1;
' 97 ;;
2009-07-22 tobias 98 ;; RESOLUTION:
22:21:01 ' 99 ;; wait for KDE 4.4 -- the new smoke_generator should fix this.
2010-01-10 tobias 100 (cxx:operator= (cxx:operator[] object index)
08:52:49 ' 101 new-value)
' 102 new-value)