[Openmcl-devel] How to determine a method's instance to access slot values
gb at clozure.com
Thu May 18 01:31:55 UTC 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)
> (:metaclass ns:+ns-object))
> (ccl::define-objc-method ((:void :draw-rect (:<NSR>ect a-rect))
> ; 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.)
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
More information about the Openmcl-devel