Skip to content

Instantly share code, notes, and snippets.

@CodaFi
Created January 19, 2016 04:54
Show Gist options
  • Save CodaFi/559cb6102032d6dd433b to your computer and use it in GitHub Desktop.
Save CodaFi/559cb6102032d6dd433b to your computer and use it in GitHub Desktop.
The headers of the oldest version of the Objective-C runtime I could still find. Extracted from an old NeXT image.
#ident "@(#) hashtable.h, Rev 2.5, 96/08/02"
//
// Copyright (c) 1995-1996, Sun Microsystems, Inc.
// portions (c) Copyright 1989 NeXT, Inc.
// All rights reserved.
//
// Scalable hash table.
#ifndef _OBJC_LITTLE_HASHTABLE_H_
#define _OBJC_LITTLE_HASHTABLE_H_
#include <objc/objc.h>
#include <objc/zone.h>
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************************
* Hash tables of arbitrary data
*************************************************************************/
/* This module allows hashing of arbitrary data. Such data must be pointers or integers, and client is responsible for allocating/deallocating this data. A deallocation call-back is provided.
The objective C class HashTable is prefered when dealing with (key, values) associations because it is easier to use in that situation.
As well-behaved scalable data structures, hash tables double in size when they start becoming full, thus guaranteeing both average constant time access and linear size. */
typedef struct {
unsigned (*hash)(const void *info, const void *data);
int (*isEqual)(const void *info, const void *data1, const void *data2);
void (*free)(const void *info, void *data);
int style; /* reserved for future expansion; currently 0 */
} NXHashTablePrototype;
/* the info argument allows a certain generality, such as freeing according to some owner information */
/* invariants assumed by the implementation:
1 - data1 = data2 => hash(data1) = hash(data2)
when data varies over time, hash(data) must remain invariant
e.g. if data hashes over a string key, the string must not be changed
2- isEqual (data1, data2) => data1= data2
*/
typedef struct {
const NXHashTablePrototype *prototype;
unsigned count;
unsigned nbBuckets;
void *buckets;
const void *info;
} NXHashTable;
/* private data structure; may change */
extern NXHashTable *NXCreateHashTableFromZone (NXHashTablePrototype prototype, unsigned capacity, const void *info, NXZone *zone);
extern NXHashTable *NXCreateHashTable (NXHashTablePrototype prototype, unsigned capacity, const void *info);
/* if hash is 0, pointer hash is assumed */
/* if isEqual is 0, pointer equality is assumed */
/* if free is 0, elements are not freed */
/* capacity is only a hint; 0 creates a small table */
/* info allows call backs to be very general */
extern void NXFreeHashTable (NXHashTable *table);
/* calls free for each data, and recovers table */
extern void NXEmptyHashTable (NXHashTable *table);
/* does not deallocate table nor data; keeps current capacity */
extern void NXResetHashTable (NXHashTable *table);
/* frees each entry; keeps current capacity */
extern BOOL NXCompareHashTables (NXHashTable *table1, NXHashTable *table2);
/* Returns YES if the two sets are equal (each member of table1 in table2, and table have same size) */
extern NXHashTable *NXCopyHashTable (NXHashTable *table);
/* makes a fresh table, copying data pointers, not data itself. */
extern unsigned NXCountHashTable (NXHashTable *table);
/* current number of data in table */
extern int NXHashMember (NXHashTable *table, const void *data);
/* returns non-0 iff data is present in table.
Example of use when the hashed data is a struct containing the key,
and when the callee only has a key:
MyStruct pseudo;
pseudo.key = myKey;
return NXHashMember (myTable, &pseudo)
*/
extern void *NXHashGet (NXHashTable *table, const void *data);
/* return original table data or NULL.
Example of use when the hashed data is a struct containing the key,
and when the callee only has a key:
MyStruct pseudo;
MyStruct *original;
pseudo.key = myKey;
original = NXHashGet (myTable, &pseudo)
*/
extern void *NXHashInsert (NXHashTable *table, const void *data);
/* previous data or NULL is returned. */
extern void *NXHashInsertIfAbsent (NXHashTable *table, const void *data);
/* If data already in table, returns the one in table
else adds argument to table and returns argument. */
extern void *NXHashRemove (NXHashTable *table, const void *data);
/* previous data or NULL is returned */
/* Iteration over all elements of a table consists in setting up an iteration state and then to progress until all entries have been visited. An example of use for counting elements in a table is:
unsigned count = 0;
MyData *data;
NXHashState state = NXInitHashState(table);
while (NXNextHashState(table, &state, &data)) {
count++;
}
*/
typedef struct {int i; int j;} NXHashState;
/* callers should not rely on actual contents of the struct */
extern NXHashState NXInitHashState(NXHashTable *table);
extern int NXNextHashState(NXHashTable *table, NXHashState *state, void **data);
/* returns 0 when all elements have been visited */
/*************************************************************************
* Conveniences for writing hash, isEqual and free functions
* and common prototypes
*************************************************************************/
extern unsigned NXPtrHash(const void *info, const void *data);
/* scrambles the address bits; info unused */
extern unsigned NXStrHash(const void *info, const void *data);
/* string hashing; info unused */
extern int NXPtrIsEqual(const void *info, const void *data1, const void *data2);
/* pointer comparison; info unused */
extern int NXStrIsEqual(const void *info, const void *data1, const void *data2);
/* string comparison; NULL ok; info unused */
extern void NXNoEffectFree(const void *info, void *data);
/* no effect; info unused */
extern void NXReallyFree(const void *info, void *data);
/* frees it; info unused */
/* The two following prototypes are useful for manipulating set of pointers or set of strings; For them free is defined as NXNoEffectFree */
extern const NXHashTablePrototype NXPtrPrototype;
/* prototype when data is a pointer (void *) */
extern const NXHashTablePrototype NXStrPrototype;
/* prototype when data is a string (char *) */
/* following prototypes help describe mappings where the key is the first element of a struct and is either a pointer or a string.
For example NXStrStructKeyPrototype can be used to hash pointers to Example, where Example is:
typedef struct {
char *key;
int data1;
...
} Example
For the following prototypes, free is defined as NXReallyFree.
*/
extern const NXHashTablePrototype NXPtrStructKeyPrototype;
extern const NXHashTablePrototype NXStrStructKeyPrototype;
/*************************************************************************
* Unique strings and buffers
*************************************************************************/
/* Unique strings allows C users to enjoy the benefits of Lisp's atoms:
A unique string is a string that is allocated once for all (never de-allocated) and that has only one representant (thus allowing comparison with == instead of strcmp). A unique string should never be modified (and in fact some memory protection is done to ensure that). In order to more explicitly insist on the fact that the string has been uniqued, a synonym of (const char *) has been added, NXAtom. */
typedef const char *NXAtom;
extern NXAtom NXUniqueString(const char *buffer);
/* assumes that buffer is \0 terminated, and returns
a previously created string or a new string that is a copy of buffer.
If NULL is passed returns NULL.
Returned string should never be modified. To ensure this invariant,
allocations are made in a special read only zone. */
extern NXAtom NXUniqueStringWithLength(const char *buffer, int length);
/* assumes that buffer is a non NULL buffer of at least
length characters. Returns a previously created string or
a new string that is a copy of buffer.
If buffer contains \0, string will be truncated.
As for NXUniqueString, returned string should never be modified. */
extern NXAtom NXUniqueStringNoCopy(const char *string);
/* If there is already a unique string equal to string, returns the original.
Otherwise, string is entered in the table, without making a copy. Argument should then never be modified. */
extern char *NXCopyStringBuffer(const char *buffer);
/* given a buffer, allocates a new string copy of buffer.
Buffer should be \0 terminated; returned string is \0 terminated. */
extern char *NXCopyStringBufferFromZone(const char *buffer, NXZone *zone);
/* given a buffer, allocates a new string copy of buffer.
Buffer should be \0 terminated; returned string is \0 terminated. */
#ifdef __cplusplus
}
#endif
#endif /* _OBJC_LITTLE_HASHTABLE_H_ */
#ident "@(#) objc-class.h, Rev 2.15, 96/08/02"
//
// Copyright (c) 1995-1996, Sun Microsystems, Inc.
// portions (c) Copyright 1988, NeXT, Inc.
// All rights reserved.
#ifndef _OBJC_CLASS_H_
#define _OBJC_CLASS_H_
#import <objc/objc.h>
#import <objc/zone.h>
#define SPARC_VERSION 10
#define SPARC_VERSION_MT 11
#define CLASS_VERSION SPARC_VERSION_MT
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class Template
*/
struct objc_class {
struct objc_class *isa;
struct objc_class *super_class;
const char *name;
long version;
long info; // 8 high order bits contain class lock
long instance_size;
struct objc_ivar_list *ivars;
struct objc_method_list *methods;
struct objc_cache *cache;
struct objc_protocol_list *protocols;
int thread_id; // really contains thread_id during initialization
void *dispatch_code;
};
#define CLS_GETINFO(cls,infomask) ((cls)->info & infomask)
#define CLS_SETINFO(cls,infomask) ((cls)->info |= infomask)
#define CLS_CLASS 0x1L
#define CLS_META 0x2L
#define CLS_INITIALIZED 0x4L
#define CLS_POSING 0x8L
#define CLS_PRIVATE_CAT 0x10L
#define CLS_FLUSH_CACHE 0x20L
#define CLS_METHODS 0x40L
#define CLS_INITVTABLE 0x80L
/*
* Category Template
*/
typedef struct objc_category *Category;
struct objc_category {
char *category_name;
char *class_name;
struct objc_method_list *instance_methods;
struct objc_method_list *class_methods;
struct objc_protocol_list *protocols;
};
/*
* Instance Variable Template
*/
typedef struct objc_ivar {
char *ivar_name;
char *ivar_type;
int ivar_offset;
} *Ivar;
struct objc_ivar_list {
int ivar_count;
struct objc_ivar ivar_list[1]; /* variable length structure */
};
/*
* Method Template
*/
typedef struct objc_method {
SEL method_name;
char *method_types;
IMP method_imp;
} *Method;
struct objc_method_list {
struct objc_method_list *method_next;
int method_count;
struct objc_method method_list[1]; /* variable length structure */
};
/* Protocol support */
@class Protocol;
struct objc_protocol_list {
struct objc_protocol_list *next;
int count;
Protocol *list[1];
};
/* Definitions of filer types */
#define _C_ID '@'
#define _C_CLASS '#'
#define _C_SEL ':'
#define _C_CHR 'c'
#define _C_UCHR 'C'
#define _C_SHT 's'
#define _C_USHT 'S'
#define _C_INT 'i'
#define _C_UINT 'I'
#define _C_LNG 'l'
#define _C_ULNG 'L'
#define _C_FLT 'f'
#define _C_DBL 'd'
#define _C_BFLD 'b'
#define _C_VOID 'v'
#define _C_UNDEF '?'
#define _C_PTR '^'
#define _C_CHARPTR '*'
#define _C_ARY_B '['
#define _C_ARY_E ']'
#define _C_UNION_B '('
#define _C_UNION_E ')'
#define _C_STRUCT_B '{'
#define _C_STRUCT_E '}'
/* Structure for method cache - allocated/sized at runtime */
typedef struct objc_cache *Cache;
struct objc_cache {
unsigned int mask; /* total = mask + 1 */
unsigned int occupied;
Method buckets[1];
};
/* operations */
extern id class_createInstance(Class, unsigned idxIvars);
extern id class_createInstanceFromZone(Class, unsigned idxIvars, NXZone *zone);
extern void class_setVersion(Class, int);
extern int class_getVersion(Class);
extern Ivar class_getInstanceVariable(Class, const char *);
extern Method class_getInstanceMethod(Class, SEL);
extern Method class_getClassMethod(Class, SEL);
// extern void class_addMethods(Class, struct objc_method_list *);
extern Class class_poseAs(Class imposter, Class original);
extern int create_selector_table();
extern Class objc_get_cls(void * cls_candidate);
extern unsigned struct_ret(Method);
extern unsigned method_getNumberOfArguments(Method);
extern unsigned method_getSizeOfArguments(Method);
extern unsigned method_getArgumentInfo(Method m, int arg, const char **type, int *offset);
typedef void *marg_list;
#define marg_getRef(margs, offset, type) \
( (type *)((char *)margs + offset) )
#define marg_getValue(margs, offset, type) \
( *marg_getRef(margs, offset, type) )
#define marg_setValue(margs, offset, type, value) \
( marg_getValue(margs, offset, type) = (value) )
#ifdef __cplusplus
}
#endif
#endif /* _OBJC_CLASS_H_ */
#ident "@(#) objc-debug.h, Rev 1.9, 96/08/02"
//
// Copyright (c) 1996, Sun Microsystems, Inc.
// All rights reserved.
#define OBJC_REMOTE_DEBUG 1
enum {
DisableDebugSilently = -1,
DisableDebug = 0,
EnableDebug = 1,
EnableDebugShowAllMessages = 2,
EnableDebugSilently = 3
};
// These two enums do not, as yet, refer to any public API
enum {
ShowMetaAndNonMeta = -1,
ShowOnlyMeta = '+',
ShowOnlyNonMeta = '-'
};
enum {
StartLeakChecking = '1',
StopLeakChecking = '2',
AddFilter = '3',
UpdateFilter = '4',
UpdateFilterID = '5',
RemoveFilter = '6',
RemoveAllFilters = '7',
DumpFiltersToRemote = '8'
};
typedef struct _FilterData
{
int filterID;
SEL selector;
id receiver;
const char *receiverClassName;
char metaMethodVisibility;
BOOL callMessageMatchedFilterFunction;
unsigned int matchCount;
struct _FilterData *next;
struct _FilterData *prev;
} FilterData;
extern int objc_enableMessageSendDebug(int flag);
extern void objc_messageSendDebugHelp();
// Conveniences... use "objc_addFilterFromString" for real power.
extern BOOL objc_addFilterForClass(const char *className);
extern BOOL objc_addFilterForSelector(const char *selectorName);
extern BOOL objc_addFilterForReceiver(id receiver);
// Pass this a string of the form:
// "1,NSScrollView,drawRect:,0x15a6,some message I want to see,NO"
// Where above fields map to:
// "FilterID, ClassName | *, [+ | -]selectorName | [+ | -]*, receiverID or *, UserInfoString | 0, YES | NO [whether or not to call objc_messageMatchedFilter() when a filter matches]"
// OR SIMPLY "GENERIC_FILTER"
extern BOOL objc_parseStringIntoFilter(const char *filterString, FilterData *newFilter);
// Same as above, but adds the created filter to the filterList.
extern BOOL objc_addFilterFromString(const char *filterString);
// Will cause "objc_messageMatchedFilter()" to be called for *any* filter
// match!
extern void objc_callMessageMatchedFilter(BOOL callOrNot);
// To set whether or not you want the call level indicated by indenting output.
extern void objc_enableFilterCallLevelIndentation(BOOL enable);
/* Called when a filter matches, so you can put a breakpoint here, and stop */
/* when your filter matches. */
extern void objc_messageMatchedFilter();
// Creates default "liberal" filter. Use this as a basis, then change fields
// as needed, then objc_addFilter with "objc_addFilter".
// This function will always return the same pointer, to the same "static"
// filter, however the fields will all be reset to their "liberal" values
// (like the media and Bill Clinton), with each call to this function.
extern FilterData *objc_genericFilter(void);
extern void objc_addFilter(FilterData *aFilter);
// Put these values into filter with matching FilterID...
extern void objc_updateFilter(FilterData *aFilter);
extern void objc_removeFilter(FilterData *aFilter);
extern void objc_removeAllFilters();
extern void objc_remoteAlloc(id receiver);
extern void objc_remoteDealloc(id receiver);
// Advanced:
// Set your own function to be called whenever a message comes in. You
// can do your own filter testing here, and/or call to the default function.
extern void objc_setMessageSendFilterFunction(void (*customFilterFunction)(Class receiverClass,id receiver, SEL selector,void *callLevel, void *threadID));
// Might be desirable from within your own messageSendFilterFunction...
extern void objc_defaultMessageSendFilterFunction(Class receiverClass,id receiver, SEL selector,void *callLevel, void *threadID);
// Use this to get at the linked list of filters...
extern FilterData *objc_filterList(void);
#ident "@(#) objc-runtime.h, Rev 2.17, 95/11/08"
//
// Copyright (c) 1995-1996, Sun Microsystems, Inc.
// portions (c) Copyright 1988, NeXT, Inc.
// All rights reserved.
#ifndef _OBJC_RUNTIME_H_
#define _OBJC_RUNTIME_H_
#import <objc/objc.h>
#import <objc/objc-class.h>
#import <objc/hashtable.h>
#import <objc/Object.h>
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif
extern void *_MT_SAFE_INIT_CODE;
extern void *_MT_SAFE_CODE;
extern void *_MT_UNSAFE_CODE;
extern void *_MT_SAFE_INIT_TRACE_CODE;
extern void *_MT_SAFE_TRACE_CODE;
extern void *_MT_UNSAFE_TRACE_CODE;
extern void *_MT_SAFE_INIT_PROFILE_CODE;
extern void *_MT_SAFE_PROFILE_CODE;
extern void *_MT_UNSAFE_PROFILE_CODE;
// this label contains the address of the 'unimp' instrcution
// inside objc_msgSendStructV() that must be uodated at each call
// with the size of the structure returned.
extern int * _UNIMP_LABEL;
/* globals for command line args */
extern int NSArgc;
extern char **NSArgv;
typedef struct objc_symtab *Symtab;
struct objc_symtab {
Class *cls_inst;
SEL *refs;
unsigned short cls_def_cnt;
unsigned short cat_def_cnt;
#ifndef hpux
int obj_defs;
int proto_defs;
#endif
void *defs[1]; /* variable size */
};
typedef struct objc_module *Module;
struct objc_module {
unsigned long version;
unsigned long size;
const char *name;
Symtab symtab;
};
struct objc_super {
id receiver;
Class cls;
};
/* kernel operations */
extern id objc_getClass(const char *name);
extern id objc_getMetaClass(const char *name);
extern id objc_msgSend(id self, SEL op, ...);
extern id objc_msgSendSuper(struct objc_super *super, SEL op, ...);
/* forwarding operations */
extern id objc_msgSendv(id self, SEL op, unsigned arg_size, marg_list arg_frame);
extern id objc_msgSendvStruct(id self, SEL op, unsigned arg_size, marg_list arg_frame);
extern id objc_msgSendStructV(id self, SEL op, unsigned arg_size, marg_list arg_frame);
/*
iterating over all the classes in the application...
NXHashTable *class_hash = objc_getClasses();
NXHashState state = NXInitHashState(class_hash);
Class cls;
while (NXNextHashState(class_hash, &state, &cls)
...;
*/
extern NXHashTable *objc_getClasses();
extern Module *objc_getModules();
extern id objc_lookUpClass(const char *name);
// defined in objc-errors.m
extern int _objc_enable_warnings(int enable);
extern int _objc_enable_consoleError(int enable);
/* customizing the error handling for objc_getClass/objc_getMetaClass */
extern void objc_setClassHandler(int (*)(const char *));
/* Making the Objective-C runtime thread safe. */
extern void objc_setMultithreaded (BOOL flag);
/* overriding the default object allocation and error handling routines */
extern id (*_alloc)(Class, unsigned int);
extern id (*_copy)(Object *, unsigned int);
extern id (*_realloc)(Object *, unsigned int);
extern id (*_dealloc)(Object *);
extern id (*_zoneAlloc)(Class, unsigned int, NXZone *);
extern id (*_zoneRealloc)(Object *, unsigned int, NXZone *);
extern id (*_zoneCopy)(Object *, unsigned int, NXZone *);
extern void (*_error)(Object *, const char *, va_list);
// Register callbacks invoked after _objcInit
int _objcPostInit(void (*initfunc)(int ismain));
// Clear callbacks
int _objcPostInitClear();
// form objc-load.h: merged here
// loading a shared object in an application
extern long objc_loadModule(
char *modulePath, /* input */
void (*loadCallback)(Class, Category), /* input (optional) */
char ** errMsg /* output */
);
#ifdef __cplusplus
}
#endif
#endif /* _OBJC_RUNTIME_H_ */
#ident "@(#) objc.h, Rev 2.12, 96/08/02"
//
// Copyright (c) 1995-1996, Sun Microsystems, Inc.
// portions (c) Copyright 1988, NeXT, Inc.
// All rights reserved.
#ifndef _OBJC_OBJC_H_
#define _OBJC_OBJC_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef struct objc_class *Class;
typedef struct objc_object {
Class isa;
} *id;
typedef struct objc_selector *SEL;
typedef char * STR_NS;
typedef id (*IMP)(id, SEL, ...);
#ifndef XMD_H
typedef unsigned char BOOL;
#endif
extern BOOL sel_isMapped(SEL sel);
extern const char *sel_getName(SEL sel);
extern SEL sel_getUid(const char *str);
extern SEL sel_registerName(const char *str);
extern const char *object_getClassName(id obj);
extern void *object_getIndexedIvars(id obj);
extern int objc_build_selector_table(const char * path);
extern void _objc_print_selector_table();
#define YES (BOOL)1
#define NO (BOOL)0
#define ISSELECTOR(sel) sel_isMapped(sel)
#define SELNAME(sel) sel_getName(sel)
#define SELUID(str) sel_getUid(str)
#define NAMEOF(obj) object_getClassName(obj)
#define IV(obj) object_getIndexedIvars(obj)
#define SEL_EQUAL(S1,S2) ((S1) == (S2))
#define Nil (Class)0 /* id of Nil class */
#define nil (id)0 /* id of Nil instance */
#ifdef __cplusplus
}
#endif
#endif /* _OBJC_OBJC_H_ */
#ident "@(#) objc_seltable.h, Rev 1.4, 96/08/02"
//
// Copyright (c) 1995-1996, Sun Microsystems, Inc.
// All rights reserved.
typedef struct objc_hash_elem {
struct objc_hash_elem *next;
char *key;
int index; // this index replaces the string selector;
};
typedef struct objc_selector_info {
unsigned long blobsize;
unsigned long stringsize;
unsigned long hashsize;
unsigned long fullsize;
};
#define SELECTOR_FILE "objc_selector_table.bin"
#define SELECTOR_LIB "libObjcSelector.so"
#define SELECTOR_TABLE_SIZE 1637
/* utilities */
static inline unsigned int _objc_strhash (const unsigned char *s)
{
unsigned int hash = 0;
/* Unroll the loop. */
while (1)
{
if (*s == '\0')
break;
hash ^= *s++;
if (*s == '\0')
break;
hash ^= *s++ << 8;
if (*s == '\0')
break;
hash ^= *s++ << 16;
if (*s == '\0')
break;
hash ^= *s++ << 24;
}
return hash;
}
#ident "@(#) Object.h, Rev 2.10, 96/08/02"
//
// Copyright (c) 1995-1996, Sun Microsystems, Inc.
// portions (c) Copyright 1988, 1989 NeXT, Inc.
// All rights reserved.
#ifndef _OBJC_OBJECT_H_
#define _OBJC_OBJECT_H_
#import <objc/objc.h>
#import <objc/objc-class.h>
#import <objc/zone.h>
#define SELECTOR(x) @selector(x)
@class Protocol;
@interface Object
{
Class isa; /* A pointer to the instance's class structure */
}
/* Initializing classes and instances */
+ initialize;
- init;
/* Creating, copying, and freeing instances */
+ new;
+ free;
- free;
+ alloc;
- copy;
+ allocFromZone:(NXZone *)zone;
- copyFromZone:(NXZone *)zone;
- (NXZone *)zone;
/* Identifying classes */
+ class;
+ superclass;
+ (const char *) name;
- class;
- superclass;
- (const char *) name;
/* Identifying and comparing instances */
- self;
- (unsigned int) hash;
- (BOOL) isEqual:anObject;
/* Testing inheritance relationships */
- (BOOL) isKindOf: aClassObject;
- (BOOL) isMemberOf: aClassObject;
- (BOOL) isKindOfClassNamed: (const char *)aClassName;
- (BOOL) isMemberOfClassNamed: (const char *)aClassName;
/* Testing class functionality */
+ (BOOL) instancesRespondTo:(SEL)aSelector;
- (BOOL) respondsTo:(SEL)aSelector;
/* Testing protocol conformance */
- (BOOL) conformsTo: (Protocol *)aProtocolObject;
+ (BOOL) conformsTo: (Protocol *)aProtocolObject;
/* Obtaining method descriptors from protocols */
- (struct objc_method_description *) descriptionForMethod:(SEL)aSel;
+ (struct objc_method_description *) descriptionForInstanceMethod:(SEL)aSel;
/* Obtaining method handles */
- (IMP) methodFor:(SEL)aSelector;
+ (IMP) instanceMethodFor:(SEL)aSelector;
/* Sending messages determined at run time */
- perform:(SEL)aSelector;
- perform:(SEL)aSelector with:anObject;
- perform:(SEL)aSelector with:object1 with:object2;
/* Posing */
+ poseAs: aClassObject;
/* Enforcing intentions */
- subclassResponsibility:(SEL)aSelector;
- notImplemented:(SEL)aSelector;
/* Error handling */
- doesNotRecognize:(SEL)aSelector;
- error:(const char *)aString, ...;
/* Archiving */
- awake;
+ (int) version;
+ setVersion: (int) aVersion;
/* Forwarding */
- forward: (SEL)sel : (marg_list)args;
- performv: (SEL)sel : (marg_list)args;
@end
#ifdef __cplusplus
extern "C" {
#endif
extern id object_dispose(id anObject);
extern id object_copy(id anObject, unsigned nBytes);
extern id object_copyFromZone(id anObject, unsigned nBytes, NXZone *);
extern id object_realloc(id anObject, unsigned nBytes);
extern id object_reallocFromZone(id anObject, unsigned nBytes, NXZone *);
extern Ivar object_setInstanceVariable(id, const char *name, void *);
extern Ivar object_getInstanceVariable(id, const char *name, void **);
#ifdef __cplusplus
}
#endif
#endif /* _OBJC_OBJECT_H_ */
#ident "@(#) Protocol.h, Rev 2.6, 96/08/02"
//
// Copyright (c) 1995-1996, Sun Microsystems, Inc.
// portions (c) Copyright 1991 NeXT, Inc.
// All rights reserved.
#ifndef _OBJC_PROTOCOL_H_
#define _OBJC_PROTOCOL_H_
#import <objc/Object.h>
struct objc_method_description {
SEL name;
char *types;
};
struct objc_method_description_list {
int count;
struct objc_method_description list[1];
};
@interface Protocol : Object
{
@private
char *protocol_name;
struct objc_protocol_list *protocol_list;
struct objc_method_description_list *instance_methods, *class_methods;
#ifdef __hpux
unsigned long risc_pad;
#endif __hpux
}
/* Obtaining attributes intrinsic to the protocol */
- (const char *)name;
/* Testing protocol conformance */
- (BOOL) conformsTo: (Protocol *)aProtocolObject;
/* Looking up information specific to a protocol */
- (struct objc_method_description *) descriptionForInstanceMethod:(SEL)aSel;
- (struct objc_method_description *) descriptionForClassMethod:(SEL)aSel;
@end
#endif /* _OBJC_PROTOCOL_H_ */
#ident "@(#) zone.h, Rev 2.6, 96/08/02"
//
// Copyright (c) 1995-1996, Sun Microsystems, Inc.
// All rights reserved.
#ifndef _OBJC_ZONE_H_
#define _OBJC_ZONE_H_
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Interface to zone based malloc.
*/
typedef struct _NXZone {
void *(*realloc)(struct _NXZone *zonep, void *ptr, size_t size);
void *(*malloc)(struct _NXZone *zonep, size_t size);
void (*free)(struct _NXZone *zonep, void *ptr);
void (*destroy)(struct _NXZone *zonep);
/* Implementation specific entries */
/* Do not depend on the size of this structure */
} NXZone;
#define NX_NOZONE ((NXZone *)0)
/*
* Returns the default zone used by the malloc(3) calls.
*/
extern NXZone *NXDefaultMallocZone(void);
/*
* Create a new zone with its own memory pool.
* If canfree is 0 the allocator will never free memory and mallocing will be fast
*/
extern NXZone *NXCreateZone(size_t startSize, size_t granularity, int canFree);
/*
* Create a new zone who obtains memory from another zone.
* Returns NX_NOZONE if the passed zone is already a child.
*/
extern NXZone *NXCreateChildZone(NXZone *parentZone, size_t startSize, size_t granularity, int canFree);
/*
* The zone is destroyed and all memory reclaimed.
*/
#define NXDestroyZone(zonep) \
((*(zonep)->destroy)(zonep))
/*
* Will merge zone with the parent zone. Malloced areas are still valid.
* Must be an child zone.
*/
extern void NXMergeZone(NXZone *zonep);
/* jjh 7feb95
* The following casts to _NXZone * solves the problem that objects based on
* NSObject have a NSZone zone instance var. This is passed as zonep
* to the following macros. But, The NSZone struct is not defined in
* the .h file so the func ptrs it contains are hidden.
* The following will work, but only because currently, the NSZone
* struct isn't actually used for anything. All the NSZone mallocing
* is done by calling the old NXZone routines.
*/
#define NXZoneMalloc(zonep, size) \
((*( (struct _NXZone *)zonep )->malloc)(zonep, size))
#define NXZoneRealloc(zonep, ptr, size) \
((*( (struct _NXZone *)zonep )->realloc)(zonep, ptr, size))
#define NXZoneFree(zonep, ptr) \
((*( (struct _NXZone *)zonep )->free)(zonep, ptr))
/*
* Calls NXZoneMalloc and then bzero.
*/
extern void *NXZoneCalloc(NXZone *zonep, size_t numElems, size_t byteSize);
/*
* Returns the zone for a pointer.
* NX_NOZONE if not in any zone.
* The ptr must have been returned from a malloc or realloc call.
*/
extern NXZone *NXZoneFromPtr(void *ptr);
/*
* Debugging Helpers.
*/
/*
* Will print to stdout if this pointer is in the malloc heap, free status, and size.
*/
extern void NXZonePtrInfo(void *ptr);
/*
* Will verify all internal malloc information.
* This is what malloc_debug calls.
*/
extern int NXMallocCheck(void);
/*
* Give a zone a name.
*
* The string will be copied.
*/
extern void NXNameZone(NXZone *z, const char *name);
/*
* Internal functions
*/
extern size_t malloc_size(void *);
extern int malloc_debug(int level);
#ifdef __cplusplus
}
#endif
#endif /* _OBJC_ZONE_H_ */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment