Changes between Version 1 and Version 2 of ObjectiveC/Classes


Ignore:
Timestamp:
Jan 10, 2009 2:53:02 PM (5 years ago)
Author:
chak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ObjectiveC/Classes

    v1 v2  
    77foreign export "@class MyUIView : UIView" 
    88}}} 
    9 The class would then be populated with methods in subsequent `foreign export` declarations.  '''Would that make sense?''' 
     9The class would then be populated with methods in subsequent `foreign export` declarations. 
     10 
     11We have the following problems:  
     12 * The ObjC runtime uses two functions to initiate and finalise the declaration of a new class, namely `objc_allocateClassPair` and `objc_registerClassPair`.  All ivars must be added between these two calls (except for the 64-bit runtime, I guess, but the runtime ref doesn't say that).  Methods and protocols can still be added after registering. 
     13 * `objc_allocateClassPair` expects the superclass as a value of type `Class`.  The documentation does not say whether the superclass must already be registered (or whether it is sufficient to have it allocated at that point). 
     14Problems arise because Haskell declarations are unordered, so we should make no assumption about the order of foreign declarations.  Moreover, we need to have foreign imported all class that we subclass (and which are not locally defined) – or we just call `objc_getClass`.  On the other hand, when you subclass an existing class, you almost certainly need to foreign import the superclass anyway, to implement the methods for the new class (so an implicit `objc_getClass` is probably not worth the effort). 
     15 
     16What about ObjC classes that have been declared in other Haskell modules, do we have to foreign import them again or do we just import the Haskell representation? 
     17 
     18We may have to compute the class DAG and make sure we generate class initialisation code that at module load time allocates, registers, and subclasses all Objective-C classes in the right order.