[Openmcl-devel] How to determine a method's instance to access slot values

Gary Byers gb at clozure.com
Wed May 17 18:31:55 PDT 2006



On Wed, 17 May 2006, Phil wrote:

> My general question is how to determine/access an object instance within
> an objective-C method which doesn't pass the instance as a parameter.

The "receiver" (the object that "receives the message", in ObjC
terms) is always passed as a parameter.

DEFINE-OBJC-METHOD names this parameter SELF (in whatever package
is current when the DEFINE-OBJC-METHOD form is expanded) and declares
it to be IGNORABLE.

>
> Specifically, having sub-classed ns-opengl-view with a slot added to
> track what the opengl view contains, how do I access said slot in the
> draw-rect method?
>
> (defclass my-opengl-view (ns:ns-opengl-view)
>   (whichview)
>   (:metaclass ns:+ns-object))
>
> (ccl::define-objc-method ((:void :draw-rect (:<NSR>ect a-rect))
> my-opengl-view)
>   ; Cocoa will be calling this method so we'll need to access whichview
> to determine what needs to be redrawn. (slot-value ??? 'whichview)
>   )

(slot-value self 'whichview) should try to access the slot (and might
generate a SLOT-UNBOUND unless something's given the slot a value.)

>
> Thanks,
> Phil
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list