[Openmcl-devel] something is not quite right in cocoa land

alex crain alexcrain at mail.widgetworks.com
Fri Jun 10 19:41:37 UTC 2005


On Jun 8, 2005, at 11:13 PM, Gary Byers wrote:

> If the class involved is declared, the current mechanism is about the
> same as the old mechanism: we have search trees which contain all
> known (declared) ObjC classes and metaclasses; for a given pointer:
>
>   1) if the pointer is found in the metaclass tree, it's that  
> metaclass
>   2) if the pointer is found in the class tree, it's that class
>   3) if we think that it's safe to indirect through the first word in
>      the pointer (the "isa" field) and that first word is found in the
>      class tree, the pointer is an instance of that class.
>
> This mostly happens in the function RECOGNIZE-OBJC-OBJECT.
>
> When we start up/restart a saved images, we enumerate all foreign
> classes. (We should also ensure that this happens whenever someone
> loads an auxiliary ObjC library.)
>
> If the class is declared, it gets added to the search trees; this is
> how things have worked for a long time.
>
> If the class is undeclared, it gets added to another search tree
> (one used to track "private ObjC classes"; I don't remember its name
> offhand.)  The datum associated with each class in the private class
> tree is a little structure that's supposed to contain information
> about the nearest declared superclass.  That information isn't
> filled out yet; the code that enumerates all classes should make
> a pass over the private class tree and fill in that information.
>
> Once that information's available, case 3 above gets extended;
>
>   3b) if the pointer's "isa" field is found in the private class
>       tree, the pointer is an instance of the public class associated
>       with that private class.  We may or may not want to define some
>       extra pointer type bits so that we can recognize that the  
> instance
>       isn't a "true" or "direct" instance, but I think that we can
>       almost always ignore this distinction.

So if I'm tracking this right, an undeclared objc class is not an  
instance of a class
but rather and instance of PRIVATE-OBJC-CLASS-INFO. This isn't a problem
because the only thing that need to understand undeclared classes  
would be
SEND, %SEND, PRINT-OBJECT and a few assorted things that call OBJC- 
CLASS-OF.

CLASS-OF and TYPE-OF are going to need to return the nearest declared  
superclass
in order to be consistent but that seems reasonable enough since any  
slots/methods in
an undeclared type are effectively private.

There are several places in the code where we can safely assume that  
a macptr is
a objc instance or class: methods that return :ID and ALLOCATE- 
INSTANCE come to mind.
If we insert code in the method returns that will register objects on  
the fly then we should
catch all the cases.

Did I miss anything?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20050610/b1b02f89/attachment.html>


More information about the Openmcl-devel mailing list