diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libobjc/objc/deprecated | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'libobjc/objc/deprecated')
29 files changed, 1194 insertions, 0 deletions
diff --git a/libobjc/objc/deprecated/METHOD_NULL.h b/libobjc/objc/deprecated/METHOD_NULL.h new file mode 100644 index 000000000..6912be345 --- /dev/null +++ b/libobjc/objc/deprecated/METHOD_NULL.h @@ -0,0 +1,2 @@ +/* For functions which return Method_t */ +#define METHOD_NULL (Method_t)0 diff --git a/libobjc/objc/deprecated/MetaClass.h b/libobjc/objc/deprecated/MetaClass.h new file mode 100644 index 000000000..01597782c --- /dev/null +++ b/libobjc/objc/deprecated/MetaClass.h @@ -0,0 +1 @@ +typedef struct objc_class *MetaClass; diff --git a/libobjc/objc/deprecated/Object.h b/libobjc/objc/deprecated/Object.h new file mode 100644 index 000000000..e15cf7dd9 --- /dev/null +++ b/libobjc/objc/deprecated/Object.h @@ -0,0 +1,84 @@ +/* The following methods were deprecated in GCC 4.6.0 and will be + removed in the next GCC release. */ +@interface Object (Deprecated) +/* Initializing classes and instances */ ++ initialize; +- init; + +/* Creating, freeing, and copying instances */ ++ new; ++ alloc; +- free; +- copy; +- shallowCopy; +- deepen; +- deepCopy; + +/* Identifying classes */ +- (Class)superClass; +- (MetaClass)metaClass; +- (const char *)name; + +/* Identifying and comparing objects */ +- self; +- (unsigned int)hash; +- (int)compare:(id)anotherObject; + +/* Testing object type */ +- (BOOL)isMetaClass; +- (BOOL)isClass; +- (BOOL)isInstance; + +/* Testing inheritance relationships */ +- (BOOL)isKindOf:(Class)aClassObject; +- (BOOL)isMemberOf:(Class)aClassObject; +- (BOOL)isKindOfClassNamed:(const char *)aClassName; +- (BOOL)isMemberOfClassNamed:(const char *)aClassName; + +/* Testing class functionality */ ++ (BOOL)instancesRespondTo:(SEL)aSel; +- (BOOL)respondsTo:(SEL)aSel; + +/* Testing protocol conformance */ +- (BOOL)conformsTo:(Protocol*)aProtocol; + +/* Introspection */ ++ (IMP)instanceMethodFor:(SEL)aSel; +- (IMP)methodFor:(SEL)aSel; ++ (struct objc_method_description *)descriptionForInstanceMethod:(SEL)aSel; +- (struct objc_method_description *)descriptionForMethod:(SEL)aSel; + +/* Sending messages determined at run time */ +- perform:(SEL)aSel; +- perform:(SEL)aSel with:anObject; +- perform:(SEL)aSel with:anObject1 with:anObject2; + +/* Forwarding */ +- (retval_t)forward:(SEL)aSel :(arglist_t)argFrame; +- (retval_t)performv:(SEL)aSel :(arglist_t)argFrame; + +/* Posing */ ++ poseAs:(Class)aClassObject; +- (Class)transmuteClassTo:(Class)aClassObject; + +/* Enforcing intentions */ +- subclassResponsibility:(SEL)aSel; +- notImplemented:(SEL)aSel; +- shouldNotImplement:(SEL)aSel; + +/* Error handling */ +- doesNotRecognize:(SEL)aSel; +- error:(const char *)aString, ...; + +/* Archiving */ ++ (int)version; ++ setVersion:(int)aVersion; + ++ (int)streamVersion: (TypedStream*)aStream; /* __attribute__ ((deprecated)) */ + +- read: (TypedStream*)aStream; /* __attribute__ ((deprecated)) */ +- write: (TypedStream*)aStream; /* __attribute__ ((deprecated)) */ +- awake; /* __attribute__ ((deprecated)) */ + +@end + diff --git a/libobjc/objc/deprecated/Protocol.h b/libobjc/objc/deprecated/Protocol.h new file mode 100644 index 000000000..7a77f51a0 --- /dev/null +++ b/libobjc/objc/deprecated/Protocol.h @@ -0,0 +1,13 @@ +/* The following methods were deprecated in GCC 4.6.0 and will be + removed in the next GCC release. */ +@interface Protocol (Deprecated) +/* 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 diff --git a/libobjc/objc/deprecated/README b/libobjc/objc/deprecated/README new file mode 100644 index 000000000..3f105196e --- /dev/null +++ b/libobjc/objc/deprecated/README @@ -0,0 +1,11 @@ +This directory contains declarations and features that are deprecated +and that will be removed in future versions of the compiler. + +Note that files in this directory are not really usable headers on +their own - they shouldn't be included directly by end users. They +are header fragments containing deprecated APIs that are still +included (until removed) from the real headers in objc/. + +Files in this directory should not #include any other objc header. +Any include that they need should be done in the real objc/ headers +before including these fragments. diff --git a/libobjc/objc/deprecated/STR.h b/libobjc/objc/deprecated/STR.h new file mode 100644 index 000000000..17c20e2d6 --- /dev/null +++ b/libobjc/objc/deprecated/STR.h @@ -0,0 +1,2 @@ +/* Incredibly obsolete. */ +typedef char *STR; /* String alias */ diff --git a/libobjc/objc/deprecated/hash.h b/libobjc/objc/deprecated/hash.h new file mode 100644 index 000000000..8b718a441 --- /dev/null +++ b/libobjc/objc/deprecated/hash.h @@ -0,0 +1,211 @@ +/* Hash tables for Objective C method dispatch. + Copyright (C) 1993, 1995, 1996, 2004, 2009 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. */ + + + +#ifndef __hash_INCLUDE_GNU +#define __hash_INCLUDE_GNU + +#include <stddef.h> +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * This data structure is used to hold items + * stored in a hash table. Each node holds + * a key/value pair. + * + * Items in the cache are really of type void *. + */ +typedef struct cache_node +{ + struct cache_node *next; /* Pointer to next entry on the list. + NULL indicates end of list. */ + const void *key; /* Key used to locate the value. Used + to locate value when more than one + key computes the same hash + value. */ + void *value; /* Value stored for the key. */ +} *node_ptr; + + +/* + * This data type is the function that computes a hash code given a key. + * Therefore, the key can be a pointer to anything and the function specific + * to the key type. + * + * Unfortunately there is a mutual data structure reference problem with this + * typedef. Therefore, to remove compiler warnings the functions passed to + * objc_hash_new will have to be casted to this type. + */ +typedef unsigned int (*hash_func_type) (void *, const void *); + +/* + * This data type is the function that compares two hash keys and returns an + * integer greater than, equal to, or less than 0, according as the first + * parameter is lexicographically greater than, equal to, or less than the + * second. + */ + +typedef int (*compare_func_type) (const void *, const void *); + + +/* + * This data structure is the cache. + * + * It must be passed to all of the hashing routines + * (except for new). + */ +typedef struct cache +{ + /* Variables used to implement the hash itself. */ + node_ptr *node_table; /* Pointer to an array of hash nodes. */ + /* Variables used to track the size of the hash table so to determine + when to resize it. */ + unsigned int size; /* Number of buckets allocated for the hash table + (number of array entries allocated for + "node_table"). Must be a power of two. */ + unsigned int used; /* Current number of entries in the hash table. */ + unsigned int mask; /* Precomputed mask. */ + + /* Variables used to implement indexing through the hash table. */ + + unsigned int last_bucket; /* Tracks which entry in the array where + the last value was returned. */ + /* Function used to compute a hash code given a key. + This function is specified when the hash table is created. */ + hash_func_type hash_func; + /* Function used to compare two hash keys to see if they are equal. */ + compare_func_type compare_func; +} *cache_ptr; + + +/* Allocate and initialize a hash table. */ + +cache_ptr objc_hash_new (unsigned int size, + hash_func_type hash_func, + compare_func_type compare_func); + +/* Deallocate all of the hash nodes and the cache itself. */ + +void objc_hash_delete (cache_ptr cache); + +/* Add the key/value pair to the hash table. If the + hash table reaches a level of fullness then it will be resized. + + assert if the key is already in the hash. */ + +void objc_hash_add (cache_ptr *cachep, const void *key, void *value); + +/* Remove the key/value pair from the hash table. + assert if the key isn't in the table. */ + +void objc_hash_remove (cache_ptr cache, const void *key); + +/* Used to index through the hash table. Start with NULL + to get the first entry. + + Successive calls pass the value returned previously. + ** Don't modify the hash during this operation *** + + Cache nodes are returned such that key or value can + be extracted. */ + +node_ptr objc_hash_next (cache_ptr cache, node_ptr node); + +/* Used to return a value from a hash table using a given key. */ + +void *objc_hash_value_for_key (cache_ptr cache, const void *key); + +/* Used to determine if the given key exists in the hash table */ + +BOOL objc_hash_is_key_in_hash (cache_ptr cache, const void *key); + +/************************************************ + + Useful hashing functions. + + Declared inline for your pleasure. + +************************************************/ + +/* Calculate a hash code by performing some + manipulation of the key pointer. (Use the lowest bits + except for those likely to be 0 due to alignment.) */ + +static inline unsigned int +objc_hash_ptr (cache_ptr cache, const void *key) +{ + return ((size_t)key / sizeof (void *)) & cache->mask; +} + + +/* Calculate a hash code by iterating over a NULL + terminate string. */ +static inline unsigned int +objc_hash_string (cache_ptr cache, const void *key) +{ + unsigned int ret = 0; + unsigned int ctr = 0; + const char *ckey = (const char *) key; + + while (*ckey) { + ret ^= *ckey++ << ctr; + ctr = (ctr + 1) % sizeof (void *); + } + + return ret & cache->mask; +} + + +/* Compare two pointers for equality. */ +static inline int +objc_compare_ptrs (const void *k1, const void *k2) +{ + return (k1 == k2); +} + + +/* Compare two strings. */ +static inline int +objc_compare_strings (const void *k1, const void *k2) +{ + if (k1 == k2) + return 1; + else if (k1 == 0 || k2 == 0) + return 0; + else + return ! strcmp ((const char *) k1, (const char *) k2); +} + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* not __hash_INCLUDE_GNU */ diff --git a/libobjc/objc/deprecated/objc-list.h b/libobjc/objc/deprecated/objc-list.h new file mode 100644 index 000000000..e542bfc04 --- /dev/null +++ b/libobjc/objc/deprecated/objc-list.h @@ -0,0 +1,155 @@ +/* Generic single linked list to keep various information + Copyright (C) 1993, 1994, 1996, 2009 Free Software Foundation, Inc. + Contributed by Kresten Krab Thorup. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. */ + + +#ifndef __GNU_OBJC_LIST_H +#define __GNU_OBJC_LIST_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +struct objc_list { + void *head; + struct objc_list *tail; +}; + +/* Return a cons cell produced from (head . tail) */ + +static inline struct objc_list* +list_cons(void* head, struct objc_list* tail) +{ + struct objc_list* cell; + + cell = (struct objc_list*)objc_malloc(sizeof(struct objc_list)); + cell->head = head; + cell->tail = tail; + return cell; +} + +/* Return the length of a list, list_length(NULL) returns zero */ + +static inline int +list_length(struct objc_list* list) +{ + int i = 0; + while(list) + { + i += 1; + list = list->tail; + } + return i; +} + +/* Return the Nth element of LIST, where N count from zero. If N + larger than the list length, NULL is returned */ + +static inline void* +list_nth(int indx, struct objc_list* list) +{ + while(indx-- != 0) + { + if(list->tail) + list = list->tail; + else + return 0; + } + return list->head; +} + +/* Remove the element at the head by replacing it by its successor */ + +static inline void +list_remove_head(struct objc_list** list) +{ + if ((*list)->tail) + { + struct objc_list* tail = (*list)->tail; /* fetch next */ + *(*list) = *tail; /* copy next to list head */ + objc_free(tail); /* free next */ + } + else /* only one element in list */ + { + objc_free(*list); + (*list) = 0; + } +} + + +/* Remove the element with `car' set to ELEMENT */ + +static inline void +list_remove_elem(struct objc_list** list, void* elem) +{ + while (*list) { + if ((*list)->head == elem) + list_remove_head(list); + list = &((*list)->tail); + } +} + +/* Map FUNCTION over all elements in LIST */ + +static inline void +list_mapcar(struct objc_list* list, void(*function)(void*)) +{ + while(list) + { + (*function)(list->head); + list = list->tail; + } +} + +/* Return element that has ELEM as car */ + +static inline struct objc_list** +list_find(struct objc_list** list, void* elem) +{ + while(*list) + { + if ((*list)->head == elem) + return list; + list = &((*list)->tail); + } + return NULL; +} + +/* Free list (backwards recursive) */ + +static inline void +list_free(struct objc_list* list) +{ + if(list) + { + list_free(list->tail); + objc_free(list); + } +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* not __GNU_OBJC_LIST_H */ diff --git a/libobjc/objc/deprecated/objc_error.h b/libobjc/objc/deprecated/objc_error.h new file mode 100644 index 000000000..7a7ebe941 --- /dev/null +++ b/libobjc/objc/deprecated/objc_error.h @@ -0,0 +1,56 @@ +/* This API is incredibly limited and unsophisticated. objc_error() + generally causes the program to abort, so it should only be used + when something so dramatic happens that it could be pointless to + continue. Only two cases I can think of: failure to allocate new + memory or failure to load an Objective-C module. +*/ +/* Error handling + + Call objc_error() or objc_verror() to record an error; this error + routine will generally exit the program but not necessarily if the + user has installed his own error handler. + + Call objc_set_error_handler to assign your own function for + handling errors. The function should return YES if it is ok + to continue execution, or return NO or just abort if the + program should be stopped. The default error handler is just to + print a message on stderr. + + The error handler function should be of type objc_error_handler + The first parameter is an object instance of relevance. + The second parameter is an error code. + The third parameter is a format string in the printf style. + The fourth parameter is a variable list of arguments. */ +void objc_error(id object, int code, const char* fmt, ...); +void objc_verror(id object, int code, const char* fmt, va_list ap); +typedef BOOL (*objc_error_handler)(id, int code, const char *fmt, va_list ap); +objc_error_handler objc_set_error_handler(objc_error_handler func); + +/* Error codes + These are used by the runtime library, and your + error handling may use them to determine if the error is + hard or soft thus whether execution can continue or abort. */ +#define OBJC_ERR_UNKNOWN 0 /* Generic error */ + +#define OBJC_ERR_OBJC_VERSION 1 /* Incorrect runtime version */ +#define OBJC_ERR_GCC_VERSION 2 /* Incorrect compiler version */ +#define OBJC_ERR_MODULE_SIZE 3 /* Bad module size */ +#define OBJC_ERR_PROTOCOL_VERSION 4 /* Incorrect protocol version */ + +#define OBJC_ERR_MEMORY 10 /* Out of memory */ + +#define OBJC_ERR_RECURSE_ROOT 20 /* Attempt to archive the root + object more than once. */ +#define OBJC_ERR_BAD_DATA 21 /* Didn't read expected data */ +#define OBJC_ERR_BAD_KEY 22 /* Bad key for object */ +#define OBJC_ERR_BAD_CLASS 23 /* Unknown class */ +#define OBJC_ERR_BAD_TYPE 24 /* Bad type specification */ +#define OBJC_ERR_NO_READ 25 /* Cannot read stream */ +#define OBJC_ERR_NO_WRITE 26 /* Cannot write stream */ +#define OBJC_ERR_STREAM_VERSION 27 /* Incorrect stream version */ +#define OBJC_ERR_BAD_OPCODE 28 /* Bad opcode */ + +#define OBJC_ERR_UNIMPLEMENTED 30 /* Method is not implemented */ + +#define OBJC_ERR_BAD_STATE 40 /* Bad thread state */ + diff --git a/libobjc/objc/deprecated/objc_get_uninstalled_dtable.h b/libobjc/objc/deprecated/objc_get_uninstalled_dtable.h new file mode 100644 index 000000000..48d508a15 --- /dev/null +++ b/libobjc/objc/deprecated/objc_get_uninstalled_dtable.h @@ -0,0 +1,2 @@ +objc_EXPORT struct sarray* +objc_get_uninstalled_dtable(void); diff --git a/libobjc/objc/deprecated/objc_malloc.h b/libobjc/objc/deprecated/objc_malloc.h new file mode 100644 index 000000000..cf6c6e9d0 --- /dev/null +++ b/libobjc/objc/deprecated/objc_malloc.h @@ -0,0 +1,17 @@ +/* +** Hook functions for memory allocation and disposal. +** This makes it easy to substitute garbage collection systems +** such as Boehm's GC by assigning these function pointers +** to the GC's allocation routines. By default these point +** to the ANSI standard malloc, realloc, free, etc. +** +** Users should call the normal objc routines above for +** memory allocation and disposal within their programs. +*/ +objc_EXPORT void *(*_objc_malloc)(size_t); +objc_EXPORT void *(*_objc_atomic_malloc)(size_t); +objc_EXPORT void *(*_objc_valloc)(size_t); +objc_EXPORT void *(*_objc_realloc)(void *, size_t); +objc_EXPORT void *(*_objc_calloc)(size_t, size_t); +objc_EXPORT void (*_objc_free)(void *); + diff --git a/libobjc/objc/deprecated/objc_msg_sendv.h b/libobjc/objc/deprecated/objc_msg_sendv.h new file mode 100644 index 000000000..825d9a766 --- /dev/null +++ b/libobjc/objc/deprecated/objc_msg_sendv.h @@ -0,0 +1,12 @@ +/* The following types and functions are provided only for + backwards-compatibility and should not be used in new code. They + were deprecated in GCC 4.6 and will be removed in the next + release. */ +typedef void* retval_t; /* return value */ +typedef void(*apply_t)(void); /* function pointer */ +typedef union arglist { + char *arg_ptr; + char arg_regs[sizeof (char*)]; +} *arglist_t; /* argument frame */ + +objc_EXPORT retval_t objc_msg_sendv(id, SEL, arglist_t); diff --git a/libobjc/objc/deprecated/objc_object_alloc.h b/libobjc/objc/deprecated/objc_object_alloc.h new file mode 100644 index 000000000..f6336ca8e --- /dev/null +++ b/libobjc/objc/deprecated/objc_object_alloc.h @@ -0,0 +1,8 @@ +/* These functions are deprecated and currently ignored. */ +/* +** Hook functions for allocating, copying and disposing of instances +*/ +objc_EXPORT id (*_objc_object_alloc)(Class _class); +objc_EXPORT id (*_objc_object_copy)(id object); +objc_EXPORT id (*_objc_object_dispose)(id object); + diff --git a/libobjc/objc/deprecated/objc_unexpected_exception.h b/libobjc/objc/deprecated/objc_unexpected_exception.h new file mode 100644 index 000000000..69ffd4e87 --- /dev/null +++ b/libobjc/objc/deprecated/objc_unexpected_exception.h @@ -0,0 +1,9 @@ +/* +** Hook for uncaught exceptions. This hook is called when an +** exception is thrown and no valid exception handler is in place. +** The function is expected never to return. If the function returns +** the result is currently undefined. This is deprecated. Please use +** objc_set_uncaught_exception_handler() from objc/objc-exception.h +** instead. +*/ +objc_EXPORT void (*_objc_unexpected_exception)(id) __attribute__ ((deprecated)); diff --git a/libobjc/objc/deprecated/objc_valloc.h b/libobjc/objc/deprecated/objc_valloc.h new file mode 100644 index 000000000..a715f1a73 --- /dev/null +++ b/libobjc/objc/deprecated/objc_valloc.h @@ -0,0 +1,2 @@ +void * +objc_valloc(size_t size); diff --git a/libobjc/objc/deprecated/sarray.h b/libobjc/objc/deprecated/sarray.h new file mode 100644 index 000000000..aa2f3350a --- /dev/null +++ b/libobjc/objc/deprecated/sarray.h @@ -0,0 +1,240 @@ +/* Sparse Arrays for Objective C dispatch tables + Copyright (C) 1993, 1995, 1996, 2004, 2009 Free Software Foundation, Inc. + Contributed by Kresten Krab Thorup. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. */ + + +#ifndef __sarray_INCLUDE_GNU +#define __sarray_INCLUDE_GNU + +#define OBJC_SPARSE2 /* 2-level sparse array */ +/* #define OBJC_SPARSE3 */ /* 3-level sparse array */ + +#ifdef OBJC_SPARSE2 +extern const char* __objc_sparse2_id; +#endif + +#ifdef OBJC_SPARSE3 +extern const char* __objc_sparse3_id; +#endif + +#include <stddef.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +extern int nbuckets; /* for stats */ +extern int nindices; +extern int narrays; +extern int idxsize; + +/* An unsigned integer of same size as a pointer */ +#define SIZET_BITS (sizeof(size_t)*8) + +#if defined(__sparc__) || defined(OBJC_SPARSE2) +#define PRECOMPUTE_SELECTORS +#endif + +#ifdef OBJC_SPARSE3 + +/* Buckets are 8 words each */ +#define BUCKET_BITS 3 +#define BUCKET_SIZE (1<<BUCKET_BITS) +#define BUCKET_MASK (BUCKET_SIZE-1) + +/* Indices are 16 words each */ +#define INDEX_BITS 4 +#define INDEX_SIZE (1<<INDEX_BITS) +#define INDEX_MASK (INDEX_SIZE-1) + +#define INDEX_CAPACITY (BUCKET_SIZE*INDEX_SIZE) + +#else /* OBJC_SPARSE2 */ + +/* Buckets are 32 words each */ +#define BUCKET_BITS 5 +#define BUCKET_SIZE (1<<BUCKET_BITS) +#define BUCKET_MASK (BUCKET_SIZE-1) + +#endif /* OBJC_SPARSE2 */ + +typedef size_t sidx; + +#ifdef PRECOMPUTE_SELECTORS + +struct soffset { +#ifdef OBJC_SPARSE3 + unsigned int unused : SIZET_BITS/4; + unsigned int eoffset : SIZET_BITS/4; + unsigned int boffset : SIZET_BITS/4; + unsigned int ioffset : SIZET_BITS/4; +#else /* OBJC_SPARSE2 */ +#ifdef __sparc__ + unsigned long boffset : (SIZET_BITS - 2) - BUCKET_BITS; + unsigned int eoffset : BUCKET_BITS; + unsigned int unused : 2; +#else + unsigned int boffset : SIZET_BITS/2; + unsigned int eoffset : SIZET_BITS/2; +#endif +#endif /* OBJC_SPARSE2 */ +}; + +union sofftype { + struct soffset off; + sidx idx; +}; + +#endif /* not PRECOMPUTE_SELECTORS */ + +union sversion { + int version; + void *next_free; +}; + +struct sbucket { + void* elems[BUCKET_SIZE]; /* elements stored in array */ + union sversion version; /* used for copy-on-write */ +}; + +#ifdef OBJC_SPARSE3 + +struct sindex { + struct sbucket* buckets[INDEX_SIZE]; + union sversion version; /* used for copy-on-write */ +}; + +#endif /* OBJC_SPARSE3 */ + +struct sarray { +#ifdef OBJC_SPARSE3 + struct sindex** indices; + struct sindex* empty_index; +#else /* OBJC_SPARSE2 */ + struct sbucket** buckets; +#endif /* OBJC_SPARSE2 */ + struct sbucket* empty_bucket; + union sversion version; /* used for copy-on-write */ + short ref_count; + struct sarray* is_copy_of; + size_t capacity; +}; + +struct sarray* sarray_new(int, void* default_element); +void sarray_free(struct sarray*); +struct sarray* sarray_lazy_copy(struct sarray*); +void sarray_realloc(struct sarray*, int new_size); +void sarray_at_put(struct sarray*, sidx indx, void* elem); +void sarray_at_put_safe(struct sarray*, sidx indx, void* elem); + +struct sarray* sarray_hard_copy(struct sarray*); /* ... like the name? */ +void sarray_remove_garbage(void); + + +#ifdef PRECOMPUTE_SELECTORS +/* Transform soffset values to ints and vica verca */ +static inline unsigned int +soffset_decode(sidx indx) +{ + union sofftype x; + x.idx = indx; +#ifdef OBJC_SPARSE3 + return x.off.eoffset + + (x.off.boffset*BUCKET_SIZE) + + (x.off.ioffset*INDEX_CAPACITY); +#else /* OBJC_SPARSE2 */ + return x.off.eoffset + (x.off.boffset*BUCKET_SIZE); +#endif /* OBJC_SPARSE2 */ +} + +static inline sidx +soffset_encode(size_t offset) +{ + union sofftype x; + x.off.eoffset = offset%BUCKET_SIZE; +#ifdef OBJC_SPARSE3 + x.off.boffset = (offset/BUCKET_SIZE)%INDEX_SIZE; + x.off.ioffset = offset/INDEX_CAPACITY; +#else /* OBJC_SPARSE2 */ + x.off.boffset = offset/BUCKET_SIZE; +#endif + return (sidx)x.idx; +} + +#else /* not PRECOMPUTE_SELECTORS */ + +static inline size_t +soffset_decode(sidx indx) +{ + return indx; +} + +static inline sidx +soffset_encode(size_t offset) +{ + return offset; +} +#endif /* not PRECOMPUTE_SELECTORS */ + +/* Get element from the Sparse array `array' at offset `indx' */ + +static inline void* sarray_get(struct sarray* array, sidx indx) +{ +#ifdef PRECOMPUTE_SELECTORS + union sofftype x; + x.idx = indx; +#ifdef OBJC_SPARSE3 + return + array-> + indices[x.off.ioffset]-> + buckets[x.off.boffset]-> + elems[x.off.eoffset]; +#else /* OBJC_SPARSE2 */ + return array->buckets[x.off.boffset]->elems[x.off.eoffset]; +#endif /* OBJC_SPARSE2 */ +#else /* not PRECOMPUTE_SELECTORS */ +#ifdef OBJC_SPARSE3 + return array-> + indices[indx/INDEX_CAPACITY]-> + buckets[(indx/BUCKET_SIZE)%INDEX_SIZE]-> + elems[indx%BUCKET_SIZE]; +#else /* OBJC_SPARSE2 */ + return array->buckets[indx/BUCKET_SIZE]->elems[indx%BUCKET_SIZE]; +#endif /* not OBJC_SPARSE3 */ +#endif /* not PRECOMPUTE_SELECTORS */ +} + +static inline void* sarray_get_safe(struct sarray* array, sidx indx) +{ + if(soffset_decode(indx) < array->capacity) + return sarray_get(array, indx); + else + return (array->empty_bucket->elems[0]); +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __sarray_INCLUDE_GNU */ diff --git a/libobjc/objc/deprecated/struct_objc_category.h b/libobjc/objc/deprecated/struct_objc_category.h new file mode 100644 index 000000000..6de3980a9 --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_category.h @@ -0,0 +1,21 @@ +/* +** The compiler generates one of these structures for each category. A class +** may have many categories and contain both instance and factory methods. +*/ +struct objc_category { + const char* category_name; /* Name of the category. Name + contained in the () of the + category definition. */ + const char* class_name; /* Name of the class to which + the category belongs. */ + MethodList_t instance_methods; /* Linked list of instance + methods defined in the + category. NULL indicates no + instance methods defined. */ + MethodList_t class_methods; /* Linked list of factory + methods defined in the + category. NULL indicates no + class methods defined. */ + struct objc_protocol_list *protocols; /* List of Protocols + conformed to */ +}; diff --git a/libobjc/objc/deprecated/struct_objc_class.h b/libobjc/objc/deprecated/struct_objc_class.h new file mode 100644 index 000000000..07927feb6 --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_class.h @@ -0,0 +1,56 @@ +/* This structure used to be public, but is now private to the runtime. */ +#define __objc_STRUCT_OBJC_CLASS_defined + +/* +** The compiler generates one of these structures for each class. +** +** This structure is the definition for classes. +** +** This structure is generated by the compiler in the executable and used by +** the run-time during normal messaging operations. Therefore some members +** change type. The compiler generates "char* const" and places a string in +** the following member variables: super_class. +*/ +struct objc_class { + MetaClass class_pointer; /* Pointer to the class's + meta class. */ + struct objc_class* super_class; /* Pointer to the super + class. NULL for class + Object. */ + const char* name; /* Name of the class. */ + long version; /* Unknown. */ + unsigned long info; /* Bit mask. See class masks + defined above. */ + long instance_size; /* Size in bytes of the class. + The sum of the class + definition and all super + class definitions. */ +#ifdef _WIN64 + /* We pad the structure manually to prevent warning when -Wpadded + is used. The compiler automatically pads the structures that it + generates, so this manually padded structure still matches the one + generated by the compiler, but if we don't pad manually, -Wpadded + detects that padding is being added and generates annoying warnings. + This hack is necessary as on LLP64 targets sizeof (long) isn't equal + to sizeof (void *). */ + long pad; +#endif + struct objc_ivar_list* ivars; /* Pointer to a structure that + describes the instance + variables in the class + definition. NULL indicates + no instance variables. Does + not include super class + variables. */ + struct objc_method_list* methods; /* Linked list of instance + methods defined for the + class. */ + struct sarray * dtable; /* Pointer to instance + method dispatch table. */ + struct objc_class* subclass_list; /* Subclasses */ + struct objc_class* sibling_class; + + struct objc_protocol_list *protocols; /* Protocols conformed to */ + void* gc_object_type; +}; + diff --git a/libobjc/objc/deprecated/struct_objc_ivar.h b/libobjc/objc/deprecated/struct_objc_ivar.h new file mode 100644 index 000000000..57170ad11 --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_ivar.h @@ -0,0 +1,15 @@ +/* +** The compiler generates one of these structures for a class that has +** instance variables defined in its specification. +*/ +typedef struct objc_ivar { + const char* ivar_name; /* Name of the instance + variable as entered in the + class definition. */ + const char* ivar_type; /* Description of the Ivar's + type. Useful for + debuggers. */ + int ivar_offset; /* Byte offset from the base + address of the instance + structure to the variable. */ +} *Ivar_t; diff --git a/libobjc/objc/deprecated/struct_objc_ivar_list.h b/libobjc/objc/deprecated/struct_objc_ivar_list.h new file mode 100644 index 000000000..8f5051fb9 --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_ivar_list.h @@ -0,0 +1,10 @@ +typedef struct objc_ivar_list { + int ivar_count; /* Number of structures (Ivar) + contained in the list. One + structure per instance + variable defined in the + class. */ + struct objc_ivar ivar_list[1]; /* Variable length + structure. */ +} IvarList, *IvarList_t; + diff --git a/libobjc/objc/deprecated/struct_objc_method.h b/libobjc/objc/deprecated/struct_objc_method.h new file mode 100644 index 000000000..af83c07b6 --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_method.h @@ -0,0 +1,22 @@ +/* +** The compiler generates one (or more) of these structures for a class that +** has methods defined in its specification. +** +** The implementation of a class can be broken into separate pieces in a file +** and categories can break them across modules. To handle this problem is a +** singly linked list of methods. +*/ +struct objc_method { + SEL method_name; /* This variable is the method's + name. It is a char*. + The unique integer passed to + objc_msg_send is a char* too. + It is compared against + method_name using strcmp. */ + const char* method_types; /* Description of the method's + parameter list. Useful for + debuggers. */ + IMP method_imp; /* Address of the method in the + executable. */ +}; + diff --git a/libobjc/objc/deprecated/struct_objc_method_list.h b/libobjc/objc/deprecated/struct_objc_method_list.h new file mode 100644 index 000000000..5156cabbf --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_method_list.h @@ -0,0 +1,9 @@ +typedef struct objc_method_list { + struct objc_method_list* method_next; /* This variable is used to link + a method list to another. It + is a singly linked list. */ + int method_count; /* Number of methods defined in + this structure. */ + Method method_list[1]; /* Variable length + structure. */ +} MethodList, *MethodList_t; diff --git a/libobjc/objc/deprecated/struct_objc_module.h b/libobjc/objc/deprecated/struct_objc_module.h new file mode 100644 index 000000000..57950851f --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_module.h @@ -0,0 +1,24 @@ +/* +** The compiler generates one of these structures for each module that +** composes the executable (eg main.m). +** +** This data structure is the root of the definition tree for the module. +** +** A collect program runs between ld stages and creates a ObjC ctor array. +** That array holds a pointer to each module structure of the executable. +*/ +typedef struct objc_module { + unsigned long version; /* Version of the Module data structure. */ + unsigned long size; /* sizeof(Module) according to the compiler - + only used to sanity check that it matches + sizeof(Module) according to the + runtime. */ + const char* name; /* Name of the file used to compile the + module - not set by modern compilers for + security reasons. */ + Symtab_t symtab; /* Pointer to the Symtab of the module. The + Symtab holds an array of pointers to the + classes and categories defined in the + module. */ +} Module, *Module_t; + diff --git a/libobjc/objc/deprecated/struct_objc_protocol.h b/libobjc/objc/deprecated/struct_objc_protocol.h new file mode 100644 index 000000000..5344e3f54 --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_protocol.h @@ -0,0 +1,6 @@ +typedef struct objc_protocol { + struct objc_class* class_pointer; + char *protocol_name; + struct objc_protocol_list *protocol_list; + struct objc_method_description_list *instance_methods, *class_methods; +} Protocol; diff --git a/libobjc/objc/deprecated/struct_objc_protocol_list.h b/libobjc/objc/deprecated/struct_objc_protocol_list.h new file mode 100644 index 000000000..5e5788b50 --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_protocol_list.h @@ -0,0 +1,5 @@ +struct objc_protocol_list { + struct objc_protocol_list *next; + size_t count; + Protocol *list[1]; +}; diff --git a/libobjc/objc/deprecated/struct_objc_selector.h b/libobjc/objc/deprecated/struct_objc_selector.h new file mode 100644 index 000000000..34aaf0d8b --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_selector.h @@ -0,0 +1,20 @@ +/* This struct used to be public, but is now private to the runtime. */ + +/* +** Definition of a selector. Selectors themselves are not unique, but +** the sel_id is a unique identifier. +*/ +struct objc_selector +{ + void *sel_id; + const char *sel_types; +}; + +inline static BOOL +sel_eq (SEL s1, SEL s2) +{ + if (s1 == 0 || s2 == 0) + return s1 == s2; + else + return s1->sel_id == s2->sel_id; +} diff --git a/libobjc/objc/deprecated/struct_objc_static_instances.h b/libobjc/objc/deprecated/struct_objc_static_instances.h new file mode 100644 index 000000000..9d889bfc0 --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_static_instances.h @@ -0,0 +1,14 @@ +/* For every class which happens to have statically allocated instances in + this module, one OBJC_STATIC_INSTANCES is allocated by the compiler. + INSTANCES is NULL terminated and points to all statically allocated + instances of this class. */ +struct objc_static_instances +{ + char *class_name; +#ifdef __cplusplus + id instances[1]; +#else + id instances[0]; +#endif +}; + diff --git a/libobjc/objc/deprecated/struct_objc_symtab.h b/libobjc/objc/deprecated/struct_objc_symtab.h new file mode 100644 index 000000000..75bb27f1b --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_symtab.h @@ -0,0 +1,26 @@ +/* Whereas a Module (defined further down) is the root (typically) of a file, + a Symtab is the root of the class and category definitions within the + module. + + A Symtab contains a variable length array of pointers to classes and + categories defined in the module. */ +typedef struct objc_symtab { + unsigned long sel_ref_cnt; /* Unused (always set to 0). */ + SEL refs; /* The table of selectors referenced in + this module. This is terminated by a + selector with NULL sel_id and NULL + sel_types. */ + unsigned short cls_def_cnt; /* Number of classes compiled + (defined) in the module. */ + unsigned short cat_def_cnt; /* Number of categories + compiled (defined) in the + module. */ + + void *defs[1]; /* Variable array of pointers. + cls_def_cnt of type Class + followed by cat_def_cnt of + type Category_t, followed + by a NULL terminated array + of objc_static_instances. */ +} Symtab, *Symtab_t; + diff --git a/libobjc/objc/deprecated/typedstream.h b/libobjc/objc/deprecated/typedstream.h new file mode 100644 index 000000000..4d948d5fb --- /dev/null +++ b/libobjc/objc/deprecated/typedstream.h @@ -0,0 +1,141 @@ +/* GNU Objective-C Typed Streams interface. + Copyright (C) 1993, 1995, 2004, 2009 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3, or (at your option) any +later version. + +GCC is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. */ + + +#ifndef __typedstream_INCLUDE_GNU +#define __typedstream_INCLUDE_GNU + +/* The API in this file was entirely deprecated in GCC 4.6.0 and will + be removed in the following GCC release. +*/ + +#include <stdio.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef int (*objc_typed_read_func)(void*, char*, int); +typedef int (*objc_typed_write_func)(void*, const char*, int); +typedef int (*objc_typed_flush_func)(void*); +typedef int (*objc_typed_eof_func)(void*); + +#define OBJC_READONLY 0x01 +#define OBJC_WRITEONLY 0x02 + +#define OBJC_MANAGED_STREAM 0x01 +#define OBJC_FILE_STREAM 0x02 +#define OBJC_MEMORY_STREAM 0x04 + +#define OBJC_TYPED_STREAM_VERSION 0x01 + +typedef struct objc_typed_stream { + void* physical; + cache_ptr object_table; /* read/written objects */ + cache_ptr stream_table; /* other read/written but shared things.. */ + cache_ptr class_table; /* class version mapping */ + cache_ptr object_refs; /* forward references */ + int mode; /* OBJC_READONLY or OBJC_WRITEONLY */ + int type; /* MANAGED, FILE, MEMORY etc bit string */ + int version; /* version used when writing */ + int writing_root_p; + objc_typed_read_func read; + objc_typed_write_func write; + objc_typed_eof_func eof; + objc_typed_flush_func flush; +} TypedStream; + +/* opcode masks */ +#define _B_VALUE 0x1fU +#define _B_CODE 0xe0U +#define _B_SIGN 0x10U +#define _B_NUMBER 0x0fU + +/* standard opcodes */ +#define _B_INVALID 0x00U +#define _B_SINT 0x20U +#define _B_NINT 0x40U +#define _B_SSTR 0x60U +#define _B_NSTR 0x80U +#define _B_RCOMM 0xa0U +#define _B_UCOMM 0xc0U +#define _B_EXT 0xe0U + +/* eXtension opcodes */ +#define _BX_OBJECT 0x00U +#define _BX_CLASS 0x01U +#define _BX_SEL 0x02U +#define _BX_OBJREF 0x03U +#define _BX_OBJROOT 0x04U +#define _BX_EXT 0x1fU + +/* +** Read and write objects as specified by TYPE. All the `last' +** arguments are pointers to the objects to read/write. +*/ + +int objc_write_type (TypedStream* stream, const char* type, const void* data) __attribute__ ((deprecated)); +int objc_read_type (TypedStream* stream, const char* type, void* data) __attribute__ ((deprecated)); + +int objc_write_types (TypedStream* stream, const char* type, ...) __attribute__ ((deprecated)); +int objc_read_types (TypedStream* stream, const char* type, ...) __attribute__ ((deprecated)); + +int objc_write_object_reference (TypedStream* stream, id object) __attribute__ ((deprecated)); +int objc_write_root_object (TypedStream* stream, id object) __attribute__ ((deprecated)); + +long objc_get_stream_class_version (TypedStream* stream, Class class_type) __attribute__ ((deprecated)); + + +/* +** Convenience functions +*/ + +int objc_write_array (TypedStream* stream, const char* type, + int count, const void* data) __attribute__ ((deprecated)); +int objc_read_array (TypedStream* stream, const char* type, + int count, void* data) __attribute__ ((deprecated)); + +int objc_write_object (TypedStream* stream, id object) __attribute__ ((deprecated)); +int objc_read_object (TypedStream* stream, id* object) __attribute__ ((deprecated)); + + + +/* +** Open a typed stream for reading or writing. MODE may be either of +** OBJC_READONLY or OBJC_WRITEONLY. +*/ + +TypedStream* objc_open_typed_stream (FILE* physical, int mode) __attribute__ ((deprecated)); +TypedStream* objc_open_typed_stream_for_file (const char* file_name, int mode) __attribute__ ((deprecated)); + +void objc_close_typed_stream (TypedStream* stream) __attribute__ ((deprecated)); + +BOOL objc_end_of_typed_stream (TypedStream* stream) __attribute__ ((deprecated)); +void objc_flush_typed_stream (TypedStream* stream) __attribute__ ((deprecated)); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* not __typedstream_INCLUDE_GNU */ |