[Openmcl-devel] Accessing objc slots query...

Randall Beer beer at eecs.cwru.edu
Sat Jun 26 06:43:05 PDT 2004


On Jun 26, 2004, at 8:11 AM, Duncan Rose wrote:

>
> Hi all; I have a Cocoa (bridge?) query....
>
> I have defined a class in the following way:
>
> (defclass lisp-view (ns:ns-view)
>   ((trckrect :foreign-type :id :accessor tracking-rect))
>   (:metaclass ns:+ns-object))

This looks correct.

>
> My query is how I actually use the 'tracking-rect' accessor (assuming 
> this is defined properly in the first place, of course - it may well 
> not be). I have the following method defined:
>
> (define-objc-method ((:void establish-tracking-rect) lisp-view)
>   ;; If the view already has a tracking rectangle (each view should 
> have a single tracking
>   ;; rectangle, or none) remove it.
>   (when (not (eql (send self 'tracking-rectangle) (%null-ptr)))
>     (send self :remove-tracking-rect (tracking-rectangle self)))
>   ;; Establish a new tracking rectangle for the view's current bounds
>   (setf (tracking-rectangle self) (send self :add-tracking-rect (send 
> self 'bounds)
> 					     :owner self
> 					     :user-data (%null-ptr)
> 					     :assume-inside #$NO)))
>
> Note that the '(when ...)' originally attempted to invoke the accessor 
> the same way the '(setf ...)' does later on in the method - I left 
> both in to show the different approaches I've tried. This fails with 
> the following error:
>
> > Error in process Listener(3): Unknown message: "trackingRectangle"
> > While executing: CCL::MAKE-OPTIMIZED-SEND
> > Type :POP to abort.
> Type :? for other options.
> 1 >

The TRACKING-RECT is a CLOS method, not an ObjC method, so SENDing it 
won't work.

> When the '(when ...)' line used (tracking-rectangle self) instead of 
> (send ...), there isn't an error, but I'm warned:
>
> ;   Undefined function SETF::|CLIM-COCOA::TRACKING-RECTANGLE|, in 
> CLIM-COCOA::|-[LispView establishTrackingRect]|.
> ;   Undefined function CLIM-COCOA::TRACKING-RECTANGLE (2 references), 
> in CLIM-COCOA::|-[LispView establishTrackingRect]|.

Should TRACKING-RECTANGLE be TRACKING-RECT?  The latter works for me:

? (defclass lisp-view (ns:ns-view)
      ((trckrect :foreign-type :id :accessor tracking-rect))
      (:metaclass ns:+ns-object))
#<OBJC:OBJC-CLASS LISP-VIEW (#x1AFB90)>
? (setq x (make-instance 'lisp-view))
#<LISP-VIEW <LispView: 0x1aaa90> (#x1AAA90)>
? (tracking-rect x)
#<A Null Mac Pointer>
?

Randy




More information about the Openmcl-devel mailing list