[Openmcl-devel] Cocoa - small question about send

alex crain alexcrain at mail2.widgetworks.com
Sun Nov 7 17:25:39 PST 2004


You're very close. You want

(ccl:send (find-clss 'ns:ns-bundle) 'main-bundle)

Keyword arguments must have an an actual argument, so if you're sending 
a message that
doesn't take an argument, you just quote it.

You have the same problem when you declare new methods, so while 
terminate looks like this:

;;
;;- (void)terminate:(id)sender
;;

(define-objc-method ((:void :terminate sender)
	                         	     lisp-application)
   (declare (ignore sender))
   (quit))

The init method doesn't take an argument and you would code it like 
this:
;;
;;- (id)init
;;

(define-objc-method ((::void init)
                                     ns-lisp-exception)
   (send self
	:init-with-name #@"lisp exception"
	:reason #@"lisp exception"
	:user-info (%null-ptr)))

Notice that init is not a keyword.

:alex

On Nov 7, 2004, at 5:56 PM, Dan Knapp wrote:

>   In order to better understand the Cocoa bridge, I'm trying to write 
> something
> small in it.  Specifically, I want to figure out how exactly an 
> interface defined in
> a Nib is loaded and used by Lisp code.  I've been reading the example 
> source
> and making some headway.
>
>   In the course of doing this, I wanted to access the application 
> bundle, which
> is done with the objc method "mainBundle".  I eventually got that 
> working:
>
> CL-USER> (ccl::send (find-class 'ns:ns-bundle) "mainBundle")
> #<NS-BUNDLE NSBundle </Applications/openmcl/ccl/OpenMCL.app> (loaded) 
> (#x155640)>
>
>   It seems, though, as if my first attempt should have been correct:
>
> CL-USER> (ccl::send (find-class 'ns:ns-bundle) :main-bundle)
>
> Improperly formatted argument list: (:MAIN-BUNDLE)
>    [Condition of type SIMPLE-ERROR]
>
> Restarts:
>   0: [ABORT] Abort handling SLIME request.
>   1: [ABORT-BREAK] Reset this process
>   2: [ABORT] Kill this process
>
> Backtrace:
>   0: (CCL::%PARSE-MESSAGE ':MAIN-BUNDLE)
>   1: (CCL::MAKE-OPTIMIZED-SEND '(FIND-CLASS 'NS:NS-BUNDLE) 
> ':MAIN-BUNDLE 'NIL 'NIL 'NIL 'NIL #<CCL::DESTRUCTURE-STATE 
> #x85CE8AD6>)
>   2: (CCL::SEND '(CCL::SEND (FIND-CLASS 'NS:NS-BUNDLE) :MAIN-BUNDLE) 
> 'NIL)
>   3: (FUNCALL #<Compiled-function CCL::SEND Macroexpander #x659FD4E>)
>   4: (MACROEXPAND-1 '(CCL::SEND (FIND-CLASS 'NS:NS-BUNDLE) 
> :MAIN-BUNDLE) 'CCL::SEND)
>   5: (CCL::CHEAP-EVAL-IN-ENVIRONMENT #<STRING-INPUT-STREAM  #x71CF8BE> 
> '(CCL::SEND (FIND-CLASS 'NS:NS-BUNDLE) :MAIN-BUNDLE))
>   6: (SWANK::EVAL-REGION "(ccl::send (find-class 'ns:ns-bundle) 
> :main-bundle)
> [... rest deleted ...]
>
>   Is this a bug in parse-message?  Or is there something I'm not 
> understanding?
>
> -- Dan Knapp
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 3049 bytes
Desc: not available
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20041107/319864bb/attachment.bin>


More information about the Openmcl-devel mailing list