home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / DEV.Z / objc-runtime.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-11  |  2.5 KB  |  96 lines

  1. /*
  2.  *    objc-runtime.h
  3.  *    Copyright 1988-1996, NeXT Software, Inc.
  4.  */
  5.  
  6. #ifndef _OBJC_RUNTIME_H_
  7. #define _OBJC_RUNTIME_H_
  8.  
  9. #import <objc/objc.h>
  10. #import <objc/objc-class.h>
  11. #import <objc/hashtable2.h>
  12. #import <objc/Object.h>
  13.  
  14. typedef struct objc_symtab *Symtab;
  15.  
  16. struct objc_symtab {
  17.     unsigned long     sel_ref_cnt;
  18.     SEL         *refs;        
  19.     unsigned short     cls_def_cnt;
  20.     unsigned short     cat_def_cnt;
  21. #ifdef NeXT_PDO
  22.     arith_t        obj_defs;
  23.     arith_t        proto_defs;
  24. #endif
  25.     void          *defs[1];    /* variable size */
  26. };
  27.  
  28. typedef struct objc_module *Module;
  29.  
  30. struct objc_module {
  31.     unsigned long    version;
  32.     unsigned long    size;
  33.     const char    *name;
  34.     Symtab         symtab;    
  35. };
  36.  
  37. struct objc_super {
  38.     id receiver;
  39.     Class class;
  40. };
  41.  
  42. /* kernel operations */
  43.  
  44. OBJC_EXPORT id objc_getClass(const char *name);
  45. OBJC_EXPORT id objc_getMetaClass(const char *name);
  46. OBJC_EXPORT id objc_msgSend(id self, SEL op, ...);
  47. OBJC_EXPORT id objc_msgSendSuper(struct objc_super *super, SEL op, ...);
  48.  
  49. /* forwarding operations */
  50.  
  51. OBJC_EXPORT id objc_msgSendv(id self, SEL op, unsigned arg_size, marg_list arg_frame);
  52.  
  53. /* 
  54.    iterating over all the classes in the application...
  55.   
  56.    NXHashTable *class_hash = objc_getClasses();
  57.    NXHashState state = NXInitHashState(class_hash);
  58.    Class class;
  59.   
  60.    while (NXNextHashState(class_hash, &state, &class)
  61.      ...;
  62.  */
  63. OBJC_EXPORT NXHashTable *objc_getClasses(void);
  64. OBJC_EXPORT Module *objc_getModules(void);
  65. OBJC_EXPORT id objc_lookUpClass(const char *name);
  66. OBJC_EXPORT void objc_addClass(Class myClass);
  67.  
  68. /* customizing the error handling for objc_getClass/objc_getMetaClass */
  69.  
  70. OBJC_EXPORT void objc_setClassHandler(int (*)(const char *));
  71.  
  72. /* Making the Objective-C runtime thread safe. */
  73. OBJC_EXPORT void objc_setMultithreaded (BOOL flag);
  74.  
  75. /* overriding the default object allocation and error handling routines */
  76.  
  77. OBJC_EXPORT id    (*_alloc)(Class, unsigned int);
  78. OBJC_EXPORT id    (*_copy)(Object *, unsigned int);
  79. OBJC_EXPORT id    (*_realloc)(Object *, unsigned int);
  80. OBJC_EXPORT id    (*_dealloc)(Object *);
  81. OBJC_EXPORT id    (*_zoneAlloc)(Class, unsigned int, NXZone *);
  82. OBJC_EXPORT id    (*_zoneRealloc)(Object *, unsigned int, NXZone *);
  83. OBJC_EXPORT id    (*_zoneCopy)(Object *, unsigned int, NXZone *);
  84.  
  85. #if defined(NeXT_PDO)
  86.     OBJC_EXPORT void   (*_error)();
  87. #else
  88.     OBJC_EXPORT void    (*_error)(Object *, const char *, va_list);
  89. #endif
  90.  
  91. /* This seems like a strange place to put this, but there's really
  92.    no very appropriate place! */
  93. OBJC_EXPORT const char* NSRootDirectory(void);
  94.  
  95. #endif /* _OBJC_RUNTIME_H_ */
  96.