[Openmcl-devel] ObjC callbacks - self and dynamic extent

Anders Conradi beque at telia.com
Thu Feb 10 22:51:52 UTC 2005


On torsdag, feb 10, 2005, at 22:00 Europe/Stockholm, alex crain wrote:

> This doesn't work...
>
> ? (defvar *x* nil)
> *X*
> ? (define-objc-method ((:void my-method sender) my-class)
>     (setq *x* sender))
> |-[MyClass myMethod:]|
> ? *x*
> #<BOGUS object @ #xCE63E>
> ?
>
> Not what I had in mind. I gather from reading the lisp kernel code 
> that sender is
> dereferenced off the stack, my question is how to get it off without 
> copying the object.
> I can to some hackery like this (for NSDocuments)

What I have done, and what seems to work is:
   (setq *ptr* (%setf-macptr (%null-ptr) self))

This copies the macptr into a newly allocated macptr.

> (send (send (send self 'window-controllers) :object-at-index 0) 
> 'document)
>
> Which works, but I can't believe that there isn't an easier way.
>
> Clues?
>
> :alex
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>




More information about the Openmcl-devel mailing list