:qt and :qt-impl packages to prevent collision with :cl symbols and fix object with non smoke parent.
Annotate for file src/signal-slot/slot.lisp
2009-06-11 tobias 1 (in-package :cl-smoke.qt-impl)
2010-01-10 tobias 2
2009-06-11 tobias 3 (defclass qslot (qt:object)
2010-01-10 tobias 4 ((arguments :reader arguments :initarg :argument-types
08:52:49 ' 5 :documentation "List of the argument types for the slot.")
' 6 (function :reader slot-function :initarg :slot-function
2009-08-02 tobias 7 :initform (error "no function specified")
2010-01-10 tobias 8 :documentation "The function called when the slot is invoked."))
08:52:49 ' 9 (:metaclass cxx:class)
' 10 (:documentation "A Qt slot that calls its associated function"))
' 11
2009-06-11 tobias 12 (defun qt:make-slot (function &optional (arguments nil arguments-p))
2010-01-10 tobias 13 "Returns a slot that calls FUNCTION when it receives a signal."
08:52:49 ' 14 (if arguments-p
' 15 (make-instance 'qslot
' 16 :slot-function function
' 17 :argument-types arguments)
' 18 (make-instance 'qslot
' 19 :slot-function function)))
' 20
' 21 (defmethod id ((slot qslot))
' 22 (cxx:method-count (cxx:meta-object slot)))
' 23
' 24 (defparameter *sender* nil "The sender of the signal.")
' 25 (defparameter *this* nil "The slot that is invoked.")
2009-06-11 tobias 26 (defmacro qt:sender ()
2010-01-10 tobias 27 "Returns the sender that invoked the slot."
08:52:49 ' 28 `*sender*)
' 29
' 30 (defmethod cxx:qt-metacall ((slot qslot) call id arguments)
' 31 "Invoke the slots function when it is called. The return value
' 32 of the invoked slot function is ignored."
' 33 (let ((id (call-next-method)))
' 34 (if (< id 0)
' 35 id
2009-06-11 tobias 36 (if (enum= call qt:meta-object.+invoke-meta-method+)
2010-01-10 tobias 37 (progn
08:52:49 ' 38 (ccase id
' 39 (0 (let ((*sender* (cxx:sender slot))
' 40 (*this* slot))
' 41 (with-simple-restart
' 42 (continue "Skip the function ~A of slot ~A."
' 43 (slot-function slot) slot)
' 44 (apply (slot-function slot)
' 45 (arguments-to-lisp arguments (arguments slot)))))))
' 46 (1- id))
' 47 id))))
' 48
' 49 (defun find-signal-id (sender signal)
' 50 "Returns the ID of SIGNAL from SENDER."
2009-07-01 tobias 51 ;; For efficency assume that SIGNAL is normalized and fallback
10:58:06 ' 52 ;; to normalzing when not. (Just like Qt does.)
2010-01-10 tobias 53 (let ((id (cxx:index-of-signal (cxx:meta-object sender)
08:52:49 ' 54 signal)))
' 55 (when (< id 0)
' 56 (setf id (cxx:index-of-signal (cxx:meta-object sender)
2009-06-11 tobias 57 (cxx:data (qt:meta-object.normalized-signature signal)))))
2010-01-10 tobias 58 (when (< id 0)
08:52:49 ' 59 (error "No signal ~S for class ~S."
' 60 signal (class-of sender)))
' 61 id))
' 62