[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openmcl-devel
Subject:    Re: [Openmcl-devel] Cocoa - small question about send
From:       alex crain <alexcrain () mail2 ! widgetworks ! com>
Date:       2004-11-08 1:25:39
Message-ID: 19369AD7-3125-11D9-93FF-000A95E098D4 () widgetworks ! com
[Download RAW message or body]

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@clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>


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:


<fontfamily><param>Courier</param><x-tad-bigger>;;

;;-
(void)</x-tad-bigger><bold><x-tad-bigger>terminate:</x-tad-bigger></bold><x-tad-bigger>(id)</x-tad-bigger><italic><x-tad-bigger>sender


;;

</x-tad-bigger></italic></fontfamily>

(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:

<fontfamily><param>Courier</param><x-tad-bigger>;;

;;- (id)</x-tad-bigger><bold><x-tad-bigger>init

;;</x-tad-bigger></bold></fontfamily>


(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:


<excerpt>  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@clozure.com

http://clozure.com/mailman/listinfo/openmcl-devel


</excerpt>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic