[Openmcl-devel] Beginner bugs?

Willem Rein Oudshoorn woudshoo at xs4all.nl
Tue Sep 7 11:04:11 PDT 2010


Hello,

I just started using CCL to try to develop cocoa applications, but it
seems that I keep hitting some bugs.  

At the moment I got:

1. Crash when I hit cmd-P  (which is annoying because
   my fingers like cmd-P from emacs).

2. Mysterious non creation of CLOS object with slots with type
   specificiers

3. A documentation issue or misunderstanding.

I am not sure if this is the right place to report this, if not, please
point me in the right direction.

Just to be clear, I use the .dmg file pre-build version:  1.5-r13651  (DarwinX8664)!

1. Crash
=======

1. Start Clozure CL64.app  [ 1.5-r13651  (DarwinX8664)! ]
2. Wait till it is started up
3. Press Cmd-P  (this normally brings up the print window)
4. This generates a crash, with the alt console showing an infinite number of:

...for help
[3339] Clozure CL kernel debugger: Unhandled exception 10 at 0x7fff800a1ee3, context->regs at #x7fff5fbd9730
Exception occurred while executing foreign code
 at malloc_zone_from_ptr + 2307
? for help
[3339] Clozure CL kernel debugger: Unhandled exception 10 at 0x7fff800a1ee3, context->regs at #x7fff5fbd8d20
Exception occurred while executing foreign code
 at malloc_zone_from_ptr + 2307
? for help
[3339] Clozure CL kernel debu...

(well, it keeps scrolling by with no change of using the kernel
debugger)



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)))
<-------------------------------------------------------------------------------->

     

3. A documentation issue or misunderstanding.
============================================

In section 13.3 of the documentation 
   (ccl-documentation.html#Instantiating-Objective-C-Objects)

Near the end the following sentence:

> This example calls (make-instance) with no initargs. When you do this,
> the object is only allocated, and not initialized. It then sends the
> "init" message to do the initialization by hand.

refers to the code line:

> ? (defvar *controller*
>      (make-instance 'ns:ns-window-controller))
>      *CONTROLLER*
> ? (setq *controller*
>      (ccl::send *controller*
>      :init-with-window-nib-name #@"DataWindow"
>      :owner *controller*))

I think/hope, this is not correct.

1. If make-instance with no arguments does not correspond to

    [[CLASS alloc] init]

   You can not use make-instance to create full initialized objects,
   while if the class does have init.. methods with arguments, 
   you can create fully initialized instances.
   Anyway, in my experience (from NextStep) it is not very common
   to want a reference to an object which is only allocated.

2. Also I think it is not correct because of:

   ? (#/alloc ns:ns-string)
     #<NS-STRING [uninitialized] (#x1AC2D0)>

   vs.

   ? (make-instance 'ns:ns-string)
     #<NS-MUTABLE-STRING "" (#x7FFF70542E40)>

   ? (#/init (#/alloc ns:ns-string))
    #<NS-MUTABLE-STRING "" (#x7FFF70542E40)>


Kind regards,
Wim Oudshoorn.




More information about the Openmcl-devel mailing list