[Openmcl-devel] initializing objects that are created elsewhere

alex crain alexcrain at mail.widgetworks.com
Sun Jan 9 17:46:24 UTC 2005


My question about loading from nib files has turned into a more general 
OBJC problem.

Any time an object is created on the OBJC side, it is not properly 
initialized on the lisp
side, which means that if there are lisp slots, they don't get set up 
unless I do it explicitly.

My latest example is with NSDocuments, which are created through the 
File menu.

I have something like this:

(defclass ide-editor-document (ns:ns-document)
   (((nib-name)
    (window-controller-class :initform 'hemlock-window-controller 
:accessor document-window-controller)
    (textstorage :initform nil :accessor document-text-storage)
    )
   (:metaclass ns:+ns-object))

(defmethod initialize-instance :after ((doc ide-editor-document) &rest 
initargs)
   (declare (ignorable initargs))
   (setf (slot-value doc 'nib-name) "ide-editor")
)

Which is fine if use MAKE-INSTANCE, but if I have IdeEditorDocument as 
a value in the
Info.plist file, then clicking File->New causes OBJC to create the new 
object and all I get
is a pointer to an uninitialized lisp object: no slots and 
INITIALIZE-INSTANCE is never run.

In this case I just added (INITIALIZE-INSTANCE self) to the 
:makeWindowControllers method,
but the programmer shouldn't have to figure out if an object has been 
initialized or not.

Somewhere, there is code that maps the external MACPTR to an object 
structure. That code
knows what the object is and whether it already exists, so it should be 
able to handle this job.
Can anyone give me a hint as to where to look?

:alex




More information about the Openmcl-devel mailing list