[Openmcl-devel] Subclassing NSWindow, receiving events

Gary Byers gb at clozure.com
Fri Dec 19 13:16:07 PST 2003



On Fri, 19 Dec 2003, Duncan Rose wrote:

>
> I'm not sure what's wrong with the following (but obviously something
> is!). I'm playing with programmatically created windows and events in
> Cocoa from Lisp. Here's a copy of my listener session:
>
> Welcome to OpenMCL Version (Alpha: Darwin) 0.14-031108!
> ? (ccl::def-objc-class newlisp-window ns-window)
> #<A Mac Pointer #xF01C60>
> ? (ccl::define-objc-method ((:void :send-event e) newlisp-window)
> (format t "** SEND-EVENT ~S~%" e))
> ;Compiler warnings :
> ;   Undeclared free variable CCL::SELF, in |-[NewlispWindow
> sendEvent:]|.
> ;   Unused lexical variable SELF, in |-[NewlispWindow sendEvent:]|.
> |-[NewlispWindow sendEvent:]|
> ? (setf window (ccl::make-objc-instance 'newlisp-window))
> #<A Mac Pointer #xF04070>
> ? (ccl::send window :order-front nil)
> ;Compiler warnings :
> ;   Undeclared free variable WINDOW, in an anonymous lambda form.
> NIL
> ?
>
> When I click on the window that appears, or move it around my terminal
> window (from which I started openmcl, and then did (require "COCOA") in
> this case) fills with:
>
> 2003-12-19 11:36:53.322 [3529] Error in event loop: Unbound variable:
> CCL::SELF
> 2003-12-19 11:36:53.365 [3529] Error in event loop: Unbound variable:
> CCL::SELF
> 2003-12-19 11:36:53.387 [3529] Error in event loop: Unbound variable:
> CCL::SELF
> 2003-12-19 11:36:53.405 [3529] Error in event loop: Unbound variable:
> CCL::SELF
> 2003-12-19 11:36:53.420 [3529] Error in event loop: Unbound variable:
> CCL::SELF
> 2003-12-19 11:36:53.449 [3529] Error in event loop: Unbound variable:
> CCL::SELF
> 2003-12-19 11:36:53.494 [3529] Error in event loop: Unbound variable:
> CCL::SELF
> 2003-12-19 11:36:53.549 [3529] Error in event loop: Unbound variable:
> CCL::SELF
>
> which I guess is related to the compile warning from earlier.
>
> I note (from objc-support.lisp) the following:
>
> (define-objc-method ((:id :init-with-lisp-id (:unsigned lisp-id))
> 		     ns-lisp-exception)
>    (setq self (send-super :init-with-name #@"lisp exception"
>                           :reason #@"lisp exception"
>                           :user-info (%null-ptr)))
>    (setq lispid lisp-id)
>    self)
>
> Do I need to override one of the NSWindow init methods to set "self" up?
> Sorry if this is documented somewhere, I haven't found anything on it
> yet (the tiny.lisp example comes close, but I can't see what I'm doing
> differently from it at a fundamental level - obviously something).

Randall Beer found this problem earlier today, and the fix is now in
CVS.

Every ObjC method receives at least two arguments: "SELF" is the
object that receives the message, and "_CMD" is the selector (message
name.)  DEFINE-OBJC-METHOD and friends intern "SELF" and "_CMD" in
the current package and bind those local variables correctly, but
(because of a missing comma in a backquoted form) there's a later
reference to CCL::SELF in some code that tries to set up the context
that SEND-SUPER might need.  Needless to say, that only works if the
current package is "CCL" when the method's defined; this suggests
that you may be the first person who's tried to use DEFINE-OBJC-METHOD
from outside of the CCL package ...

For those not in the mood to wrestle with CVS, the missing comma's
in line 1050 of apple-objc.lisp:

---
            (rlet ((,super :objc_super
			   :receiver ,self
				     ^
			   :class
			   ,@(if class-p
---

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

>
>



More information about the Openmcl-devel mailing list