[Openmcl-devel] Beginner bugs?

Stas Boukarev stassats at gmail.com
Wed Sep 8 08:40:30 PDT 2010


Willem Rein Oudshoorn <woudshoo at xs4all.nl> writes:

> 2. Mysterious make-instance behaviour in Obj-C callbackes
> =========================================================
>
>
> 1. Paste, or load the following code in CCL
> 2. execute:  (make-test-window)
> 3. click on the button in the window created
> 4. inspect: *log*
>
> What I expect to see is a list containing:
>       
>   a. the string "clicked"
>   b. an instance of the class 'point-a
>   c. an instance of the class 'point-b
>
> However I do not get the instance of point-b.  It seems
> the type speficier of 'double-float inhibits the creation.
>
> But you can create instances of point-b easily from the listener.
> Is this a bug? Or do I something wrong?       
>
> <-------------- CODE -------------------------->
> (require :cocoa)
>
> (defparameter *log* (list))
>
> (defclass point-a ()
>   ((x :initform 0.0d0 :initarg :x)
>    (y :initform 0.0d0 :initarg :y)))
>
> (defclass point-b ()
>   ((x :initform 0.0d0 :initarg :x :type 'double-float)
>    (y :initform 0.0d0 :initarg :y :type 'double-float)))
>
> (defclass test-controller (ns:ns-object)
>   ()
>   (:metaclass ns:+ns-object))
>
> (ccl::define-objc-method ((:void :do-click (:id sender)) test-controller)
>   (push "clicked" *log*)
>   (push (make-instance 'point-a :x 1.0d0 :y 1.0d0) *log*)
>   (push (make-instance 'point-b :x 1.0d0 :y 1.0d0) *log*))
>
> (defun make-test-window ()
>   (let ((w (make-instance 'ns:ns-window))
> 	(b (make-instance 'ns:ns-button))
> 	(c (make-instance 'test-controller)))
>     (#/setAction: b (objc:@selector "doClick:"))
>     (#/setTarget: b c)
>     (#/setContentView: w b)
>     (#/makeKeyAndOrderFront: w nil)))
It should be double-float, not 'double-float.

-- 
With Best Regards, Stas.



More information about the Openmcl-devel mailing list