diff options
Diffstat (limited to 'libobjc')
32 files changed, 146 insertions, 2908 deletions
diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog index 00cf2ac7b8a..03441de2062 100644 --- a/libobjc/ChangeLog +++ b/libobjc/ChangeLog @@ -1,3 +1,136 @@ +2011-06-03 Nicola Pero <nicola.pero@meta-innovation.com> + + * Makefile.in (OBJC_DEPRECATED_H): Removed struct_objc_static_instances.h + and objc_get_uninstalled_dtable.h. + * objc/deprecated/struct_objc_static_instances.h: Removed. + * objc/deprecated/objc_get_uninstalled_dtable.h: Removed. + * objc/objc-api.h: Do not include deprecated/objc_static_instances.h + and deprecated/objc_get_uninstalled_dtable.h. + +2011-06-03 Nicola Pero <nicola.pero@meta-innovation.com> + + * Makefile.in (OBJC_DEPRECATED_H): Removed objc_object_alloc.h. + * objc/deprecated/objc_object_alloc.h: Removed. + * objc/objc-api.h: Do not include deprecated/objc_object_alloc.h. + * objects.c (_objc_object_alloc, _objc_object_dispose, + _objc_object_copy): Removed. + * libobjc.def (__objc_object_alloc, __objc_object_copy, + __objc_object_dispose): Removed. + +2011-06-03 Nicola Pero <nicola.pero@meta-innovation.com> + + * Makefile.in (OBJC_DEPRECATED_H): Removed METHOD_NULL.h. + * objc/objc-api.h: Do not include deprecated/METHOD_NULL.h. + * objc/deprecated/METHOD_NULL.h: Removed. + +2011-06-03 Nicola Pero <nicola.pero@meta-innovation.com> + + * Makefile.in (OBJC_DEPRECATED_H): Removed objc_valloc.h, + objc_malloc.h and objc_unexpected_exception.h. + (exception.lo): Do not use -Wno-deprecated-declarations. + (exception_gc.lo): Likewise. + * objc/objc-api.h: Do not include deprecated/objc_valloc.h, + deprecated/objc_malloc.h and + deprecated/objc_unexpected_exception.h. + * objc/deprecated/objc_valloc.h: Removed. + * objc/deprecated/objc_malloc.h: Removed. + * objc/deprecated/objc_unexpected_exception.h: Removed. + * exception.c (_objc_unexpected_exception): Removed. + (objc_exception_throw): Do not check for + _objc_unexpected_exception. + * memory.c (objc_valloc, _objc_malloc, _objc_atomic_malloc, + _objc_valloc, _objc_realloc, _objc_calloc, _objc_free): Removed. + * libobjc.def (_objc_unexpected_exception, objc_valloc): Removed. + +2011-06-03 Nicola Pero <nicola.pero@meta-innovation.com> + + * objc/objc.h: Do not include deprecated/STR.h. + * objc/deprecated/STR.h: Removed. + * Makefile.in (OBJC_DEPRECATED_H): removed STR.h. + +2011-06-03 Nicola Pero <nicola.pero@meta-innovation.com> + + * Makefile.in (OBJC_H): Removed hash.h and sarray.h. + (OBJC_DEPRECATED_H): Likewise. + * libobjc.def (objc_hash_new, objc_hash_delete, objc_hash_add, + objc_hash_remove, objc_hash_next, objc_hash_value_for_key, + objc_hash_is_key_in_hash, hash_add, hash_delete, hash_new, + hash_next, hash_remove, hash_value_for_key, hash_is_key_in_hash, + sarray_at_put, sarray_at_put_safe, sarray_free, sarray_lazy_copy, + sarray_new, sarray_realloc, sarray_remove_garbage): Removed. + * objc/sarray.h: Removed. + * objc/hash.h: Removed. + * objc/deprecated/sarray.h: Removed. + * objc/deprecated/hash.h: Removed. + * objc/Object.h: Do not include objc/deprecated/hash.h + * Object.m: Include string.h. + * objc/objc-api.h: Do not include objc/deprecated/hash.h. + * objc-private/common.h (GNU_LIBOBJC_COMPILING_LIBOBJC_ITSELF): + Removed. + +2011-06-03 Nicola Pero <nicola.pero@meta-innovation.com> + + * Object.m ([-forward::]): Removed. + * objc/deprecated/Object.h ([-forward::]): Removed. + * sendmsg.c (__objc_forward): Updated comments. + +2011-06-03 Nicola Pero <nicola.pero@meta-innovation.com> + + * Makefile.in (OBJC_H): Removed objc-list.h. + (OBJC_DEPRECATED_H): Removed objc-list.h. + * objc/objc-list.h: File removed. + * objc/deprecated/objc-list.h: File removed. + +2011-06-03 Nicola Pero <nicola.pero@meta-innovation.com> + + * Makefile.in (OBJC_H): Removed typedstream.h. + (OBJC_DEPRECATED_H): Removed typedstream.h. + (C_SOURCE_FILES): Removed archive.c. + (Object.lo): Rule removed. + (Object_gc.lo): Likewise. + (archive.lo): Likewise. + (archive_gc.lo): Likewise. + * objc/deprecated/Object.h ([+streamVersion:], [-read], [-write], + [-awake]): Removed. + Do not include deprecated/typedstream.h. + * Object.m: Removed the same methods. + * archive.c: File removed. + * objc/typedstream.h: File removed. + * objc/deprecated/typedstream.h: File removed. + * libobjc.def (__objc_read_nbyte_uint, __objc_read_nbyte_ulong, + __objc_write_class, __objc_write_object, __objc_write_selector, + objc_close_typed_stream, objc_end_of_typed_stream, + objc_flush_typed_stream, objc_get_stream_class_version, + objc_open_typed_stream, objc_open_typed_stream_for_file, + objc_read_array, objc_read_char, objc_read_int, objc_read_long, + objc_read_object, objc_read_selector, objc_read_short, + objc_read_string, objc_read_type, objc_read_types, + objc_read_unsigned_char, objc_read_unsigned_int, + objc_read_unsigned_long, objc_read_unsigned_short, + objc_write_array, objc_write_char, objc_write_int, + objc_write_long, objc_write_object, objc_write_object_reference, + objc_write_root_object, objc_write_selector, objc_write_short, + objc_write_string, objc_write_string_atomic, objc_write_type, + objc_write_types, objc_write_unsigned_char, + objc_write_unsigned_int, objc_write_unsigned_long, + objc_write_unsigned_short): Removed. + +2011-06-02 Nicola Pero <nicola.pero@meta-innovation.com> + + * Makefile.in (OBJC_DEPRECATED_H): Removed objc_error.h. + * objc/deprecated/objc_error.h: Removed. + * objc/objc-api.h: Do not include deprecated/objc_error.h. + * libobjc.def (objc_error, objc_verror): Removed. + * error.c (_objc_error_handler, objc_error, objc_verror, + objc_set_error_handler): Removed. + * Object.m ([-error:], [-perform:], [-perform:with:], + [-perform:with:with], [-subclassResponsibility:], + [-notImplemented:], [-shouldNotImplement:], [-doesNotRecognize:]): + Removed. + * objc/deprecated/Object.h: Removed the same methods. + * sendmsg.c (__objc_forward): Do not try to invoke the "error:" + method after trying to invoke the "doesNotRecognize:" method. + 2011-05-26 Nicola Pero <nicola.pero@meta-innovation.com> * sendmsg.c: Reindented part of the file. No non-trivial changes diff --git a/libobjc/Makefile.in b/libobjc/Makefile.in index e52f441d47a..baadc897a2e 100644 --- a/libobjc/Makefile.in +++ b/libobjc/Makefile.in @@ -122,31 +122,15 @@ OBJC_H = \ objc-api.h \ objc-decls.h \ runtime.h \ - thr.h \ - \ - hash.h \ - objc-list.h \ - sarray.h \ - typedstream.h + thr.h # User-visible header files containing deprecated APIs, from the # objc/deprecated directory OBJC_DEPRECATED_H = \ - METHOD_NULL.h \ MetaClass.h \ Object.h \ Protocol.h \ - STR.h \ - hash.h \ - objc-list.h \ - objc_error.h \ - objc_get_uninstalled_dtable.h \ - objc_malloc.h \ objc_msg_sendv.h \ - objc_object_alloc.h \ - objc_unexpected_exception.h \ - objc_valloc.h \ - sarray.h \ struct_objc_category.h \ struct_objc_class.h \ struct_objc_ivar.h \ @@ -157,9 +141,7 @@ OBJC_DEPRECATED_H = \ struct_objc_protocol.h \ struct_objc_protocol_list.h \ struct_objc_selector.h \ - struct_objc_static_instances.h \ - struct_objc_symtab.h \ - typedstream.h + struct_objc_symtab.h # Objective-C source files to compile OBJC_SOURCE_FILES = \ @@ -171,7 +153,6 @@ OBJC_SOURCE_FILES = \ # C source files to compile C_SOURCE_FILES = \ - archive.c \ class.c \ encoding.c \ error.c \ @@ -279,38 +260,15 @@ sendmsg_gc.lo: sendmsg.c runtime-info.h # These files have separate rules because they require special # compiler flags. -archive.lo: archive.c - $(LIBTOOL_COMPILE) $(CC) $< -c \ - $(ALL_CFLAGS) $(INCLUDES) -Wno-deprecated-declarations \ - -o $@ - -archive_gc.lo: archive.c - $(LIBTOOL_COMPILE) $(CC) $< -c \ - $(ALL_CFLAGS) $(INCLUDES) $(OBJC_GCFLAGS) -Wno-deprecated-declarations \ - -o $@ - -# -Wno-deprecated-declarations is for the objc/typedstream.h functions. -Object.lo: Object.m - $(LIBTOOL_COMPILE) $(CC) $< -c \ - $(ALL_CFLAGS) $(INCLUDES) -fgnu-runtime -Wno-deprecated-declarations \ - -o $@ - -# -Wno-deprecated-declarations is for the objc/typedstream.h functions. -Object_gc.lo: Object.m - $(LIBTOOL_COMPILE) $(CC) $< -c \ - $(ALL_CFLAGS) $(INCLUDES) $(OBJC_GCFLAGS) -fgnu-runtime -Wno-deprecated-declarations \ - -o $@ -# -Wno-deprecated-declarations is to silence warnings from using -# _objc_unexpected_exception. exception.lo: exception.c $(LIBTOOL_COMPILE) $(CC) $< -c \ - $(ALL_CFLAGS) $(INCLUDES) -fexceptions -Wno-deprecated-declarations \ + $(ALL_CFLAGS) $(INCLUDES) -fexceptions \ -o $@ exception_gc.lo: exception.c $(LIBTOOL_COMPILE) $(CC) $< -c \ - $(ALL_CFLAGS) $(INCLUDES) $(OBJC_GCFLAGS) -fexceptions -Wno-deprecated-declarations \ + $(ALL_CFLAGS) $(INCLUDES) $(OBJC_GCFLAGS) -fexceptions \ -o $@ doc: info dvi pdf html diff --git a/libobjc/Object.m b/libobjc/Object.m index 224c0aa66bc..9781fad1d7f 100644 --- a/libobjc/Object.m +++ b/libobjc/Object.m @@ -25,6 +25,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "objc-private/common.h" #include <stdarg.h> +#include <string.h> /* For strcmp. */ #include <errno.h> #include "objc/Object.h" #include "objc/Protocol.h" @@ -248,36 +249,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see :class_get_class_method(self->isa, aSel))); } -- perform:(SEL)aSel -{ - IMP msg = objc_msg_lookup(self, aSel); - if (!msg) - return [self error:"invalid selector passed to %s", sel_get_name(_cmd)]; - return (*msg)(self, aSel); -} - -- perform:(SEL)aSel with:anObject -{ - IMP msg = objc_msg_lookup(self, aSel); - if (!msg) - return [self error:"invalid selector passed to %s", sel_get_name(_cmd)]; - return (*msg)(self, aSel, anObject); -} - -- perform:(SEL)aSel with:anObject1 with:anObject2 -{ - IMP msg = objc_msg_lookup(self, aSel); - if (!msg) - return [self error:"invalid selector passed to %s", sel_get_name(_cmd)]; - return (*msg)(self, aSel, anObject1, anObject2); -} - -- (retval_t)forward:(SEL)aSel :(arglist_t)argFrame -{ - (void) argFrame; /* UNUSED */ - return (retval_t)[self doesNotRecognize: aSel]; -} - - (retval_t)performv:(SEL)aSel :(arglist_t)argFrame { return objc_msg_sendv(self, aSel, argFrame); @@ -302,45 +273,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see return nil; } -- subclassResponsibility:(SEL)aSel -{ - return [self error:"subclass should override %s", sel_get_name(aSel)]; -} - -- notImplemented:(SEL)aSel -{ - return [self error:"method %s not implemented", sel_get_name(aSel)]; -} - -- shouldNotImplement:(SEL)aSel -{ - return [self error:"%s should not implement %s", - object_get_class_name(self), sel_get_name(aSel)]; -} - -- doesNotRecognize:(SEL)aSel -{ - return [self error:"%s does not recognize %s", - object_get_class_name(self), sel_get_name(aSel)]; -} - -- error:(const char *)aString, ... -{ -#define FMT "error: %s (%s)\n%s\n" - char fmt[(strlen((char*)FMT)+strlen((char*)object_get_class_name(self)) - +((aString!=NULL)?strlen((char*)aString):0)+8)]; - va_list ap; - - sprintf(fmt, FMT, object_get_class_name(self), - object_is_instance(self)?"instance":"class", - (aString!=NULL)?aString:""); - va_start(ap, aString); - objc_verror(self, OBJC_ERR_UNKNOWN, fmt, ap); - va_end(ap); - return nil; -#undef FMT -} - + (int)version { return class_get_version(self); @@ -352,38 +284,4 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see return self; } -+ (int)streamVersion: (TypedStream*)aStream -{ - if (aStream->mode == OBJC_READONLY) - return objc_get_stream_class_version (aStream, self); - else - return class_get_version (self); -} - -// These are used to write or read the instance variables -// declared in this particular part of the object. Subclasses -// should extend these, by calling [super read/write: aStream] -// before doing their own archiving. These methods are private, in -// the sense that they should only be called from subclasses. - -- read: (TypedStream*)aStream -{ - (void) aStream; /* UNUSED */ - // [super read: aStream]; - return self; -} - -- write: (TypedStream*)aStream -{ - (void) aStream; /* UNUSED */ - // [super write: aStream]; - return self; -} - -- awake -{ - // [super awake]; - return self; -} - @end diff --git a/libobjc/archive.c b/libobjc/archive.c deleted file mode 100644 index f691b13b601..00000000000 --- a/libobjc/archive.c +++ /dev/null @@ -1,1656 +0,0 @@ - /* GNU Objective C Runtime archiving - Copyright (C) 1993, 1995, 1996, 1997, 2002, 2004, 2009, - 2010 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/>. */ - -/* This file is entirely deprecated and will be removed. */ - -#include "objc-private/common.h" -#include "objc-private/error.h" -#include "tconfig.h" -#include "objc/objc-api.h" -#include "objc/hash.h" -#include "objc/objc-list.h" -#include "objc-private/runtime.h" -#include "objc/typedstream.h" -#include "objc/encoding.h" -#include <stdlib.h> - -extern int fflush (FILE *); - -#define ROUND(V, A) \ - ({ typeof (V) __v = (V); typeof (A) __a = (A); \ - __a * ((__v + __a - 1)/__a); }) - -#define PTR2LONG(P) (((char *) (P))-(char *) 0) -#define LONG2PTR(L) (((char *) 0) + (L)) - -/* Declare some functions... */ - -static int -objc_read_class (struct objc_typed_stream *stream, Class *class); - -int objc_sizeof_type (const char *type); - -static int -objc_write_use_common (struct objc_typed_stream *stream, unsigned long key); - -static int -objc_write_register_common (struct objc_typed_stream *stream, - unsigned long key); - -static int -objc_write_class (struct objc_typed_stream *stream, - struct objc_class *class); - -const char *objc_skip_type (const char *type); - -static void __objc_finish_write_root_object (struct objc_typed_stream *); -static void __objc_finish_read_root_object (struct objc_typed_stream *); - -static inline int -__objc_code_unsigned_char (unsigned char *buf, unsigned char val) -{ - if ((val&_B_VALUE) == val) - { - buf[0] = val|_B_SINT; - return 1; - } - else - { - buf[0] = _B_NINT|0x01; - buf[1] = val; - return 2; - } -} - -int -objc_write_unsigned_char (struct objc_typed_stream *stream, - unsigned char value) -{ - unsigned char buf[sizeof (unsigned char) + 1]; - int len = __objc_code_unsigned_char (buf, value); - return (*stream->write) (stream->physical, (char*)buf, len); -} - -static inline int -__objc_code_char (unsigned char *buf, signed char val) -{ - if (val >= 0) - return __objc_code_unsigned_char (buf, val); - else - { - buf[0] = _B_NINT|_B_SIGN|0x01; - buf[1] = -val; - return 2; - } -} - -int -objc_write_char (struct objc_typed_stream *stream, signed char value) -{ - unsigned char buf[sizeof (char) + 1]; - int len = __objc_code_char (buf, value); - return (*stream->write) (stream->physical, (char*)buf, len); -} - -static inline int -__objc_code_unsigned_short (unsigned char *buf, unsigned short val) -{ - if ((val&_B_VALUE) == val) - { - buf[0] = val|_B_SINT; - return 1; - } - else - { - int c, b; - - buf[0] = _B_NINT; - - for (c = sizeof (short); c != 0; c -= 1) - if (((val >> (8*(c - 1)))%0x100) != 0) - break; - - buf[0] |= c; - - for (b = 1; c != 0; c--, b++) - { - buf[b] = (val >> (8*(c - 1)))%0x100; - } - - return b; - } -} - -int -objc_write_unsigned_short (struct objc_typed_stream *stream, - unsigned short value) -{ - unsigned char buf[sizeof (unsigned short) + 1]; - int len = __objc_code_unsigned_short (buf, value); - return (*stream->write) (stream->physical, (char*)buf, len); -} - -static inline int -__objc_code_short (unsigned char *buf, short val) -{ - int sign = (val < 0); - int size = __objc_code_unsigned_short (buf, sign ? -val : val); - if (sign) - buf[0] |= _B_SIGN; - return size; -} - -int -objc_write_short (struct objc_typed_stream *stream, short value) -{ - unsigned char buf[sizeof (short) + 1]; - int len = __objc_code_short (buf, value); - return (*stream->write) (stream->physical, (char*)buf, len); -} - - -static inline int -__objc_code_unsigned_int (unsigned char *buf, unsigned int val) -{ - if ((val&_B_VALUE) == val) - { - buf[0] = val|_B_SINT; - return 1; - } - else - { - int c, b; - - buf[0] = _B_NINT; - - for (c = sizeof (int); c != 0; c -= 1) - if (((val >> (8*(c - 1)))%0x100) != 0) - break; - - buf[0] |= c; - - for (b = 1; c != 0; c--, b++) - { - buf[b] = (val >> (8*(c-1)))%0x100; - } - - return b; - } -} - -int -objc_write_unsigned_int (struct objc_typed_stream *stream, unsigned int value) -{ - unsigned char buf[sizeof (unsigned int) + 1]; - int len = __objc_code_unsigned_int (buf, value); - return (*stream->write) (stream->physical, (char*)buf, len); -} - -static inline int -__objc_code_int (unsigned char *buf, int val) -{ - int sign = (val < 0); - int size = __objc_code_unsigned_int (buf, sign ? -val : val); - if (sign) - buf[0] |= _B_SIGN; - return size; -} - -int -objc_write_int (struct objc_typed_stream *stream, int value) -{ - unsigned char buf[sizeof (int) + 1]; - int len = __objc_code_int (buf, value); - return (*stream->write) (stream->physical, (char*)buf, len); -} - -static inline int -__objc_code_unsigned_long (unsigned char *buf, unsigned long val) -{ - if ((val&_B_VALUE) == val) - { - buf[0] = val|_B_SINT; - return 1; - } - else - { - int c, b; - - buf[0] = _B_NINT; - - for (c = sizeof (long); c != 0; c -= 1) - if (((val >> (8*(c - 1)))%0x100) != 0) - break; - - buf[0] |= c; - - for (b = 1; c != 0; c--, b++) - { - buf[b] = (val >> (8*(c - 1)))%0x100; - } - - return b; - } -} - -int -objc_write_unsigned_long (struct objc_typed_stream *stream, - unsigned long value) -{ - unsigned char buf[sizeof (unsigned long) + 1]; - int len = __objc_code_unsigned_long (buf, value); - return (*stream->write) (stream->physical, (char*)buf, len); -} - -static inline int -__objc_code_long (unsigned char *buf, long val) -{ - int sign = (val < 0); - int size = __objc_code_unsigned_long (buf, sign ? -val : val); - if (sign) - buf[0] |= _B_SIGN; - return size; -} - -int -objc_write_long (struct objc_typed_stream *stream, long value) -{ - unsigned char buf[sizeof (long) + 1]; - int len = __objc_code_long (buf, value); - return (*stream->write) (stream->physical, (char*)buf, len); -} - - -int -objc_write_string (struct objc_typed_stream *stream, - const unsigned char *string, unsigned int nbytes) -{ - unsigned char buf[sizeof (unsigned int) + 1]; - int len = __objc_code_unsigned_int (buf, nbytes); - - if ((buf[0]&_B_CODE) == _B_SINT) - buf[0] = (buf[0]&_B_VALUE)|_B_SSTR; - - else /* _B_NINT */ - buf[0] = (buf[0]&_B_VALUE)|_B_NSTR; - - if ((*stream->write) (stream->physical, (char*)buf, len) != 0) - return (*stream->write) (stream->physical, (char*)string, nbytes); - else - return 0; -} - -int -objc_write_string_atomic (struct objc_typed_stream *stream, - unsigned char *string, unsigned int nbytes) -{ - unsigned long key; - if ((key = PTR2LONG(objc_hash_value_for_key (stream->stream_table, string)))) - return objc_write_use_common (stream, key); - else - { - int length; - objc_hash_add (&stream->stream_table, - LONG2PTR(key=PTR2LONG(string)), string); - if ((length = objc_write_register_common (stream, key))) - return objc_write_string (stream, string, nbytes); - return length; - } -} - -static int -objc_write_register_common (struct objc_typed_stream *stream, - unsigned long key) -{ - unsigned char buf[sizeof (unsigned long)+2]; - int len = __objc_code_unsigned_long (buf + 1, key); - if (len == 1) - { - buf[0] = _B_RCOMM|0x01; - buf[1] &= _B_VALUE; - return (*stream->write) (stream->physical, (char*)buf, len + 1); - } - else - { - buf[1] = (buf[1]&_B_VALUE)|_B_RCOMM; - return (*stream->write) (stream->physical, (char*)buf + 1, len); - } -} - -static int -objc_write_use_common (struct objc_typed_stream *stream, unsigned long key) -{ - unsigned char buf[sizeof (unsigned long)+2]; - int len = __objc_code_unsigned_long (buf + 1, key); - if (len == 1) - { - buf[0] = _B_UCOMM|0x01; - buf[1] &= _B_VALUE; - return (*stream->write) (stream->physical, (char*)buf, 2); - } - else - { - buf[1] = (buf[1]&_B_VALUE)|_B_UCOMM; - return (*stream->write) (stream->physical, (char*)buf + 1, len); - } -} - -static inline int -__objc_write_extension (struct objc_typed_stream *stream, unsigned char code) -{ - if (code <= _B_VALUE) - { - unsigned char buf = code|_B_EXT; - return (*stream->write) (stream->physical, (char*)&buf, 1); - } - else - { - _objc_abort ("__objc_write_extension: bad opcode %c\n", code); - return -1; - } -} - -int -__objc_write_object (struct objc_typed_stream *stream, id object) -{ - unsigned char buf = '\0'; - SEL write_sel = sel_get_any_uid ("write:"); - if (object) - { - __objc_write_extension (stream, _BX_OBJECT); - objc_write_class (stream, object->class_pointer); - (*objc_msg_lookup (object, write_sel)) (object, write_sel, stream); - return (*stream->write) (stream->physical, (char*)&buf, 1); - } - else - return objc_write_use_common (stream, 0); -} - -int -objc_write_object_reference (struct objc_typed_stream *stream, id object) -{ - unsigned long key; - if ((key = PTR2LONG(objc_hash_value_for_key (stream->object_table, object)))) - return objc_write_use_common (stream, key); - - __objc_write_extension (stream, _BX_OBJREF); - return objc_write_unsigned_long (stream, PTR2LONG (object)); -} - -int -objc_write_root_object (struct objc_typed_stream *stream, id object) -{ - int len = 0; - if (stream->writing_root_p) - _objc_abort ("objc_write_root_object called recursively"); - else - { - stream->writing_root_p = 1; - __objc_write_extension (stream, _BX_OBJROOT); - if ((len = objc_write_object (stream, object))) - __objc_finish_write_root_object (stream); - stream->writing_root_p = 0; - } - return len; -} - -int -objc_write_object (struct objc_typed_stream *stream, id object) -{ - unsigned long key; - if ((key = PTR2LONG(objc_hash_value_for_key (stream->object_table, object)))) - return objc_write_use_common (stream, key); - - else if (object == nil) - return objc_write_use_common (stream, 0); - - else - { - int length; - objc_hash_add (&stream->object_table, - LONG2PTR(key=PTR2LONG(object)), object); - if ((length = objc_write_register_common (stream, key))) - return __objc_write_object (stream, object); - return length; - } -} - -int -__objc_write_class (struct objc_typed_stream *stream, struct objc_class *class) -{ - __objc_write_extension (stream, _BX_CLASS); - objc_write_string_atomic (stream, (unsigned char *) class->name, - strlen ((char *) class->name)); - return objc_write_unsigned_long (stream, class->version); -} - - -static int -objc_write_class (struct objc_typed_stream *stream, - struct objc_class *class) -{ - unsigned long key; - if ((key = PTR2LONG(objc_hash_value_for_key (stream->stream_table, class)))) - return objc_write_use_common (stream, key); - else - { - int length; - objc_hash_add (&stream->stream_table, - LONG2PTR(key = PTR2LONG(class)), class); - if ((length = objc_write_register_common (stream, key))) - return __objc_write_class (stream, class); - return length; - } -} - - -int -__objc_write_selector (struct objc_typed_stream *stream, SEL selector) -{ - const char *sel_name; - __objc_write_extension (stream, _BX_SEL); - /* to handle NULL selectors */ - if ((SEL)0 == selector) - return objc_write_string (stream, (unsigned char*)"", 0); - sel_name = sel_get_name (selector); - return objc_write_string (stream, (unsigned char*)sel_name, strlen ((char*)sel_name)); -} - -int -objc_write_selector (struct objc_typed_stream *stream, SEL selector) -{ - const char *sel_name; - unsigned long key; - - /* to handle NULL selectors */ - if ((SEL)0 == selector) - return __objc_write_selector (stream, selector); - - sel_name = sel_get_name (selector); - if ((key = PTR2LONG(objc_hash_value_for_key (stream->stream_table, - sel_name)))) - return objc_write_use_common (stream, key); - else - { - int length; - objc_hash_add (&stream->stream_table, - LONG2PTR(key = PTR2LONG(sel_name)), (char *) sel_name); - if ((length = objc_write_register_common (stream, key))) - return __objc_write_selector (stream, selector); - return length; - } -} - - - -/* -** Read operations -*/ - -int -objc_read_char (struct objc_typed_stream *stream, char *val) -{ - unsigned char buf; - int len; - len = (*stream->read) (stream->physical, (char*)&buf, 1); - if (len != 0) - { - if ((buf & _B_CODE) == _B_SINT) - (*val) = (buf & _B_VALUE); - - else if ((buf & _B_NUMBER) == 1) - { - len = (*stream->read) (stream->physical, val, 1); - if (buf&_B_SIGN) - (*val) = -1 * (*val); - } - - else - _objc_abort ("expected 8bit signed int, got %dbit int", - (int) (buf&_B_NUMBER)*8); - } - return len; -} - - -int -objc_read_unsigned_char (struct objc_typed_stream *stream, unsigned char *val) -{ - unsigned char buf; - int len; - if ((len = (*stream->read) (stream->physical, (char*)&buf, 1))) - { - if ((buf & _B_CODE) == _B_SINT) - (*val) = (buf & _B_VALUE); - - else if ((buf & _B_NUMBER) == 1) - len = (*stream->read) (stream->physical, (char*)val, 1); - - else - _objc_abort ("expected 8bit unsigned int, got %dbit int", - (int) (buf&_B_NUMBER)*8); - } - return len; -} - -int -objc_read_short (struct objc_typed_stream *stream, short *value) -{ - unsigned char buf[sizeof (short) + 1]; - int len; - if ((len = (*stream->read) (stream->physical, (char*)buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - { - int pos = 1; - int nbytes = buf[0] & _B_NUMBER; - if (nbytes > (int) sizeof (short)) - _objc_abort ("expected short, got bigger (%dbits)", nbytes*8); - len = (*stream->read) (stream->physical, (char*)buf + 1, nbytes); - (*value) = 0; - while (pos <= nbytes) - (*value) = ((*value)*0x100) + buf[pos++]; - if (buf[0] & _B_SIGN) - (*value) = -(*value); - } - } - return len; -} - -int -objc_read_unsigned_short (struct objc_typed_stream *stream, - unsigned short *value) -{ - unsigned char buf[sizeof (unsigned short) + 1]; - int len; - if ((len = (*stream->read) (stream->physical, (char*)buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - { - int pos = 1; - int nbytes = buf[0] & _B_NUMBER; - if (nbytes > (int) sizeof (short)) - _objc_abort ("expected short, got int or bigger"); - len = (*stream->read) (stream->physical, (char*)buf + 1, nbytes); - (*value) = 0; - while (pos <= nbytes) - (*value) = ((*value)*0x100) + buf[pos++]; - } - } - return len; -} - - -int -objc_read_int (struct objc_typed_stream *stream, int *value) -{ - unsigned char buf[sizeof (int) + 1]; - int len; - if ((len = (*stream->read) (stream->physical, (char*)buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - { - int pos = 1; - int nbytes = buf[0] & _B_NUMBER; - if (nbytes > (int) sizeof (int)) - _objc_abort ("expected int, got bigger"); - len = (*stream->read) (stream->physical, (char*)buf + 1, nbytes); - (*value) = 0; - while (pos <= nbytes) - (*value) = ((*value)*0x100) + buf[pos++]; - if (buf[0] & _B_SIGN) - (*value) = -(*value); - } - } - return len; -} - -int -objc_read_long (struct objc_typed_stream *stream, long *value) -{ - unsigned char buf[sizeof (long) + 1]; - int len; - if ((len = (*stream->read) (stream->physical, (char*)buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - { - int pos = 1; - int nbytes = buf[0] & _B_NUMBER; - if (nbytes > (int) sizeof (long)) - _objc_abort ("expected long, got bigger"); - len = (*stream->read) (stream->physical, (char*)buf + 1, nbytes); - (*value) = 0; - while (pos <= nbytes) - (*value) = ((*value)*0x100) + buf[pos++]; - if (buf[0] & _B_SIGN) - (*value) = -(*value); - } - } - return len; -} - -int -__objc_read_nbyte_uint (struct objc_typed_stream *stream, - unsigned int nbytes, unsigned int *val) -{ - int len; - unsigned int pos = 0; - unsigned char buf[sizeof (unsigned int) + 1]; - - if (nbytes > sizeof (int)) - _objc_abort ("expected int, got bigger"); - - len = (*stream->read) (stream->physical, (char*)buf, nbytes); - (*val) = 0; - while (pos < nbytes) - (*val) = ((*val)*0x100) + buf[pos++]; - return len; -} - - -int -objc_read_unsigned_int (struct objc_typed_stream *stream, - unsigned int *value) -{ - unsigned char buf[sizeof (unsigned int) + 1]; - int len; - if ((len = (*stream->read) (stream->physical, (char*)buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - len = __objc_read_nbyte_uint (stream, (buf[0] & _B_VALUE), value); - - } - return len; -} - -int -__objc_read_nbyte_ulong (struct objc_typed_stream *stream, - unsigned int nbytes, unsigned long *val) -{ - int len; - unsigned int pos = 0; - unsigned char buf[sizeof (unsigned long) + 1]; - - if (nbytes > sizeof (long)) - _objc_abort ("expected long, got bigger"); - - len = (*stream->read) (stream->physical, (char*)buf, nbytes); - (*val) = 0; - while (pos < nbytes) - (*val) = ((*val)*0x100) + buf[pos++]; - return len; -} - - -int -objc_read_unsigned_long (struct objc_typed_stream *stream, - unsigned long *value) -{ - unsigned char buf[sizeof (unsigned long) + 1]; - int len; - if ((len = (*stream->read) (stream->physical, (char*)buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), value); - - } - return len; -} - -int -objc_read_string (struct objc_typed_stream *stream, - char **string) -{ - unsigned char buf[sizeof (unsigned int) + 1]; - int len; - if ((len = (*stream->read) (stream->physical, (char*)buf, 1))) - { - unsigned long key = 0; - - if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */ - { - len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key); - len = (*stream->read) (stream->physical, (char*)buf, 1); - } - - switch (buf[0]&_B_CODE) { - case _B_SSTR: - { - int length = buf[0]&_B_VALUE; - (*string) = (char*)objc_malloc (length + 1); - if (key) - objc_hash_add (&stream->stream_table, LONG2PTR(key), *string); - len = (*stream->read) (stream->physical, *string, length); - (*string)[length] = '\0'; - } - break; - - case _B_UCOMM: - { - char *tmp; - len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key); - tmp = objc_hash_value_for_key (stream->stream_table, LONG2PTR (key)); - *string = objc_malloc (strlen (tmp) + 1); - strcpy (*string, tmp); - } - break; - - case _B_NSTR: - { - unsigned int nbytes = buf[0]&_B_VALUE; - len = __objc_read_nbyte_uint (stream, nbytes, &nbytes); - if (len) { - (*string) = (char*)objc_malloc (nbytes + 1); - if (key) - objc_hash_add (&stream->stream_table, LONG2PTR(key), *string); - len = (*stream->read) (stream->physical, *string, nbytes); - (*string)[nbytes] = '\0'; - } - } - break; - - default: - _objc_abort ("expected string, got opcode %c\n", (buf[0]&_B_CODE)); - } - } - - return len; -} - - -int -objc_read_object (struct objc_typed_stream *stream, id *object) -{ - unsigned char buf[sizeof (unsigned int)]; - int len; - if ((len = (*stream->read) (stream->physical, (char*)buf, 1))) - { - SEL read_sel = sel_get_any_uid ("read:"); - unsigned long key = 0; - - if ((buf[0]&_B_CODE) == _B_RCOMM) /* register common */ - { - len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key); - len = (*stream->read) (stream->physical, (char*)buf, 1); - } - - if (buf[0] == (_B_EXT | _BX_OBJECT)) - { - Class class; - - /* get class */ - len = objc_read_class (stream, &class); - - /* create instance */ - (*object) = class_create_instance (class); - - /* register? */ - if (key) - objc_hash_add (&stream->object_table, LONG2PTR(key), *object); - - /* send -read: */ - if (__objc_responds_to (*object, read_sel)) - (*get_imp (class, read_sel)) (*object, read_sel, stream); - - /* check null-byte */ - len = (*stream->read) (stream->physical, (char*)buf, 1); - if (buf[0] != '\0') - _objc_abort ("expected null-byte, got opcode %c", buf[0]); - } - - else if ((buf[0]&_B_CODE) == _B_UCOMM) - { - if (key) - _objc_abort ("cannot register use upcode..."); - len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key); - (*object) = objc_hash_value_for_key (stream->object_table, - LONG2PTR(key)); - } - - else if (buf[0] == (_B_EXT | _BX_OBJREF)) /* a forward reference */ - { - struct objc_list *other; - len = objc_read_unsigned_long (stream, &key); - other - = (struct objc_list *) objc_hash_value_for_key (stream->object_refs, - LONG2PTR(key)); - objc_hash_add (&stream->object_refs, LONG2PTR(key), - (void *)list_cons (object, other)); - } - - else if (buf[0] == (_B_EXT | _BX_OBJROOT)) /* a root object */ - { - if (key) - _objc_abort ("cannot register root object..."); - len = objc_read_object (stream, object); - __objc_finish_read_root_object (stream); - } - - else - _objc_abort ("expected object, got opcode %c", buf[0]); - } - return len; -} - -static int -objc_read_class (struct objc_typed_stream *stream, Class *class) -{ - unsigned char buf[sizeof (unsigned int)]; - int len; - if ((len = (*stream->read) (stream->physical, (char*)buf, 1))) - { - unsigned long key = 0; - - if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */ - { - len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key); - len = (*stream->read) (stream->physical, (char*)buf, 1); - } - - if (buf[0] == (_B_EXT | _BX_CLASS)) - { - char temp[1] = ""; - char *class_name = temp; - unsigned long version; - - /* get class */ - len = objc_read_string (stream, &class_name); - (*class) = objc_get_class (class_name); - objc_free (class_name); - - /* register */ - if (key) - objc_hash_add (&stream->stream_table, LONG2PTR(key), *class); - - objc_read_unsigned_long (stream, &version); - objc_hash_add (&stream->class_table, - (*class)->name, (void *) ((size_t) version)); - } - - else if ((buf[0]&_B_CODE) == _B_UCOMM) - { - if (key) - _objc_abort ("cannot register use upcode..."); - len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key); - *class = objc_hash_value_for_key (stream->stream_table, - LONG2PTR(key)); - if (! *class) - _objc_abort ("cannot find class for key %lu", key); - } - - else - _objc_abort ("expected class, got opcode %c", buf[0]); - } - return len; -} - -int -objc_read_selector (struct objc_typed_stream *stream, SEL* selector) -{ - unsigned char buf[sizeof (unsigned int)]; - int len; - if ((len = (*stream->read) (stream->physical, (char*)buf, 1))) - { - unsigned long key = 0; - - if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */ - { - len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key); - len = (*stream->read) (stream->physical, (char*)buf, 1); - } - - if (buf[0] == (_B_EXT|_BX_SEL)) /* selector! */ - { - char temp[1] = ""; - char *selector_name = temp; - - /* get selector */ - len = objc_read_string (stream, &selector_name); - /* To handle NULL selectors */ - if (0 == strlen (selector_name)) - { - (*selector) = (SEL)0; - return 0; - } - else - (*selector) = sel_get_any_uid (selector_name); - objc_free (selector_name); - - /* register */ - if (key) - objc_hash_add (&stream->stream_table, - LONG2PTR(key), (void *) *selector); - } - - else if ((buf[0]&_B_CODE) == _B_UCOMM) - { - if (key) - _objc_abort ("cannot register use upcode..."); - len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key); - (*selector) = objc_hash_value_for_key (stream->stream_table, - LONG2PTR(key)); - } - - else - _objc_abort ("expected selector, got opcode %c", buf[0]); - } - return len; -} - -/* -** USER LEVEL FUNCTIONS -*/ - -/* -** Write one object, encoded in TYPE and pointed to by DATA to the -** typed stream STREAM. -*/ - -int -objc_write_type (TypedStream *stream, const char *type, const void *data) -{ - switch (*type) { - case _C_ID: - return objc_write_object (stream, *(id *) data); - break; - - case _C_CLASS: - return objc_write_class (stream, *(Class *) data); - break; - - case _C_SEL: - return objc_write_selector (stream, *(SEL *) data); - break; - - case _C_CHR: - return objc_write_char (stream, *(signed char *) data); - break; - - case _C_UCHR: - return objc_write_unsigned_char (stream, *(unsigned char *) data); - break; - - case _C_SHT: - return objc_write_short (stream, *(short *) data); - break; - - case _C_USHT: - return objc_write_unsigned_short (stream, *(unsigned short *) data); - break; - - case _C_INT: - return objc_write_int (stream, *(int *) data); - break; - - case _C_UINT: - return objc_write_unsigned_int (stream, *(unsigned int *) data); - break; - - case _C_LNG: - return objc_write_long (stream, *(long *) data); - break; - - case _C_ULNG: - return objc_write_unsigned_long (stream, *(unsigned long *) data); - break; - - case _C_CHARPTR: - return objc_write_string (stream, - *(unsigned char **) data, strlen (*(char **) data)); - break; - - case _C_ATOM: - return objc_write_string_atomic (stream, *(unsigned char **) data, - strlen (*(char **) data)); - break; - - case _C_ARY_B: - { - int len = atoi (type + 1); - while (isdigit ((unsigned char) *++type)) - ; - return objc_write_array (stream, type, len, data); - } - break; - - case _C_STRUCT_B: - { - int acc_size = 0; - int align; - while (*type != _C_STRUCT_E && *type++ != '=') - ; /* skip "<name>=" */ - while (*type != _C_STRUCT_E) - { - align = objc_alignof_type (type); /* padd to alignment */ - acc_size = ROUND (acc_size, align); - objc_write_type (stream, type, ((char *) data) + acc_size); - acc_size += objc_sizeof_type (type); /* add component size */ - type = objc_skip_typespec (type); /* skip component */ - } - return 1; - } - - default: - { - _objc_abort ("objc_write_type: cannot parse typespec: %s\n", type); - return 0; - } - } -} - -/* -** Read one object, encoded in TYPE and pointed to by DATA to the -** typed stream STREAM. DATA specifies the address of the types to -** read. Expected type is checked against the type actually present -** on the stream. -*/ - -int -objc_read_type(TypedStream *stream, const char *type, void *data) -{ - char c; - switch (c = *type) { - case _C_ID: - return objc_read_object (stream, (id*)data); - break; - - case _C_CLASS: - return objc_read_class (stream, (Class*)data); - break; - - case _C_SEL: - return objc_read_selector (stream, (SEL*)data); - break; - - case _C_CHR: - return objc_read_char (stream, (char*)data); - break; - - case _C_UCHR: - return objc_read_unsigned_char (stream, (unsigned char*)data); - break; - - case _C_SHT: - return objc_read_short (stream, (short*)data); - break; - - case _C_USHT: - return objc_read_unsigned_short (stream, (unsigned short*)data); - break; - - case _C_INT: - return objc_read_int (stream, (int*)data); - break; - - case _C_UINT: - return objc_read_unsigned_int (stream, (unsigned int*)data); - break; - - case _C_LNG: - return objc_read_long (stream, (long*)data); - break; - - case _C_ULNG: - return objc_read_unsigned_long (stream, (unsigned long*)data); - break; - - case _C_CHARPTR: - case _C_ATOM: - return objc_read_string (stream, (char**)data); - break; - - case _C_ARY_B: - { - int len = atoi (type + 1); - while (isdigit ((unsigned char) *++type)) - ; - return objc_read_array (stream, type, len, data); - } - break; - - case _C_STRUCT_B: - { - int acc_size = 0; - int align; - while (*type != _C_STRUCT_E && *type++ != '=') - ; /* skip "<name>=" */ - while (*type != _C_STRUCT_E) - { - align = objc_alignof_type (type); /* padd to alignment */ - acc_size = ROUND (acc_size, align); - objc_read_type (stream, type, ((char*)data)+acc_size); - acc_size += objc_sizeof_type (type); /* add component size */ - type = objc_skip_typespec (type); /* skip component */ - } - return 1; - } - - default: - { - _objc_abort ("objc_read_type: cannot parse typespec: %s\n", type); - return 0; - } - } -} - -/* -** Write the object specified by the template TYPE to STREAM. Last -** arguments specify addresses of values to be written. It might -** seem surprising to specify values by address, but this is extremely -** convenient for copy-paste with objc_read_types calls. A more -** down-to-the-earth cause for this passing of addresses is that values -** of arbitrary size is not well supported in ANSI C for functions with -** variable number of arguments. -*/ - -int -objc_write_types (TypedStream *stream, const char *type, ...) -{ - va_list args; - const char *c; - int res = 0; - - va_start(args, type); - - for (c = type; *c; c = objc_skip_typespec (c)) - { - switch (*c) { - case _C_ID: - res = objc_write_object (stream, *va_arg (args, id*)); - break; - - case _C_CLASS: - res = objc_write_class (stream, *va_arg (args, Class*)); - break; - - case _C_SEL: - res = objc_write_selector (stream, *va_arg (args, SEL*)); - break; - - case _C_CHR: - res = objc_write_char (stream, *va_arg (args, char*)); - break; - - case _C_UCHR: - res = objc_write_unsigned_char (stream, - *va_arg (args, unsigned char*)); - break; - - case _C_SHT: - res = objc_write_short (stream, *va_arg (args, short*)); - break; - - case _C_USHT: - res = objc_write_unsigned_short (stream, - *va_arg (args, unsigned short*)); - break; - - case _C_INT: - res = objc_write_int(stream, *va_arg (args, int*)); - break; - - case _C_UINT: - res = objc_write_unsigned_int(stream, *va_arg (args, unsigned int*)); - break; - - case _C_LNG: - res = objc_write_long(stream, *va_arg (args, long*)); - break; - - case _C_ULNG: - res = objc_write_unsigned_long(stream, *va_arg (args, unsigned long*)); - break; - - case _C_CHARPTR: - { - unsigned char **str = va_arg (args, unsigned char **); - res = objc_write_string (stream, *str, strlen ((char*)*str)); - } - break; - - case _C_ATOM: - { - unsigned char **str = va_arg (args, unsigned char **); - res = objc_write_string_atomic (stream, *str, strlen ((char*)*str)); - } - break; - - case _C_ARY_B: - { - int len = atoi (c + 1); - const char *t = c; - while (isdigit ((unsigned char) *++t)) - ; - res = objc_write_array (stream, t, len, va_arg (args, void *)); - t = objc_skip_typespec (t); - if (*t != _C_ARY_E) - _objc_abort ("expected `]', got: %s", t); - } - break; - - default: - _objc_abort ("objc_write_types: cannot parse typespec: %s\n", type); - } - } - va_end(args); - return res; -} - - -/* -** Last arguments specify addresses of values to be read. Expected -** type is checked against the type actually present on the stream. -*/ - -int -objc_read_types(TypedStream *stream, const char *type, ...) -{ - va_list args; - const char *c; - int res = 0; - - va_start (args, type); - - for (c = type; *c; c = objc_skip_typespec(c)) - { - switch (*c) { - case _C_ID: - res = objc_read_object(stream, va_arg (args, id*)); - break; - - case _C_CLASS: - res = objc_read_class(stream, va_arg (args, Class*)); - break; - - case _C_SEL: - res = objc_read_selector(stream, va_arg (args, SEL*)); - break; - - case _C_CHR: - res = objc_read_char(stream, va_arg (args, char*)); - break; - - case _C_UCHR: - res = objc_read_unsigned_char(stream, va_arg (args, unsigned char*)); - break; - - case _C_SHT: - res = objc_read_short(stream, va_arg (args, short*)); - break; - - case _C_USHT: - res = objc_read_unsigned_short(stream, va_arg (args, unsigned short*)); - break; - - case _C_INT: - res = objc_read_int(stream, va_arg (args, int*)); - break; - - case _C_UINT: - res = objc_read_unsigned_int(stream, va_arg (args, unsigned int*)); - break; - - case _C_LNG: - res = objc_read_long(stream, va_arg (args, long*)); - break; - - case _C_ULNG: - res = objc_read_unsigned_long(stream, va_arg (args, unsigned long*)); - break; - - case _C_CHARPTR: - case _C_ATOM: - { - char **str = va_arg (args, char **); - res = objc_read_string (stream, str); - } - break; - - case _C_ARY_B: - { - int len = atoi (c + 1); - const char *t = c; - while (isdigit ((unsigned char) *++t)) - ; - res = objc_read_array (stream, t, len, va_arg (args, void *)); - t = objc_skip_typespec (t); - if (*t != _C_ARY_E) - _objc_abort ("expected `]', got: %s", t); - } - break; - - default: - _objc_abort ("objc_read_types: cannot parse typespec: %s\n", type); - } - } - va_end (args); - return res; -} - -/* -** Write an array of COUNT elements of TYPE from the memory address DATA. -** This is equivalent of objc_write_type (stream, "[N<type>]", data) -*/ - -int -objc_write_array (TypedStream *stream, const char *type, - int count, const void *data) -{ - int off = objc_sizeof_type(type); - const char *where = data; - - while (count-- > 0) - { - objc_write_type(stream, type, where); - where += off; - } - return 1; -} - -/* -** Read an array of COUNT elements of TYPE into the memory address -** DATA. The memory pointed to by data is supposed to be allocated -** by the callee. This is equivalent of -** objc_read_type (stream, "[N<type>]", data) -*/ - -int -objc_read_array (TypedStream *stream, const char *type, - int count, void *data) -{ - int off = objc_sizeof_type(type); - char *where = (char*)data; - - while (count-- > 0) - { - objc_read_type(stream, type, where); - where += off; - } - return 1; -} - -static int -__objc_fread (FILE *file, char *data, int len) -{ - return fread(data, len, 1, file); -} - -static int -__objc_fwrite (FILE *file, char *data, int len) -{ - return fwrite(data, len, 1, file); -} - -static int -__objc_feof (FILE *file) -{ - return feof(file); -} - -static int -__objc_no_write (FILE *file __attribute__ ((__unused__)), - const char *data __attribute__ ((__unused__)), - int len __attribute__ ((__unused__))) -{ - _objc_abort ("TypedStream not open for writing"); - return 0; -} - -static int -__objc_no_read (FILE *file __attribute__ ((__unused__)), - const char *data __attribute__ ((__unused__)), - int len __attribute__ ((__unused__))) -{ - _objc_abort ("TypedStream not open for reading"); - return 0; -} - -static int -__objc_read_typed_stream_signature (TypedStream *stream) -{ - char buffer[80]; - int pos = 0; - do - (*stream->read) (stream->physical, buffer+pos, 1); - while (buffer[pos++] != '\0') - ; - sscanf (buffer, "GNU TypedStream %d", &stream->version); - if (stream->version != OBJC_TYPED_STREAM_VERSION) - _objc_abort ("cannot handle TypedStream version %d", stream->version); - return 1; -} - -static int -__objc_write_typed_stream_signature (TypedStream *stream) -{ - char buffer[80]; - sprintf(buffer, "GNU TypedStream %d", OBJC_TYPED_STREAM_VERSION); - stream->version = OBJC_TYPED_STREAM_VERSION; - (*stream->write) (stream->physical, buffer, strlen (buffer) + 1); - return 1; -} - -static void __objc_finish_write_root_object(struct objc_typed_stream *stream) -{ - objc_hash_delete (stream->object_table); - stream->object_table = objc_hash_new (64, - (hash_func_type) objc_hash_ptr, - (compare_func_type) objc_compare_ptrs); -} - -static void __objc_finish_read_root_object(struct objc_typed_stream *stream) -{ - node_ptr node; - SEL awake_sel = sel_get_any_uid ("awake"); - cache_ptr free_list = objc_hash_new (64, - (hash_func_type) objc_hash_ptr, - (compare_func_type) objc_compare_ptrs); - - /* resolve object forward references */ - for (node = objc_hash_next (stream->object_refs, NULL); node; - node = objc_hash_next (stream->object_refs, node)) - { - struct objc_list *reflist = node->value; - const void *key = node->key; - id object = objc_hash_value_for_key (stream->object_table, key); - while (reflist) - { - *((id*) reflist->head) = object; - if (objc_hash_value_for_key (free_list,reflist) == NULL) - objc_hash_add (&free_list,reflist,reflist); - - reflist = reflist->tail; - } - } - - /* apply __objc_free to all objects stored in free_list */ - for (node = objc_hash_next (free_list, NULL); node; - node = objc_hash_next (free_list, node)) - objc_free ((void *) node->key); - - objc_hash_delete (free_list); - - /* empty object reference table */ - objc_hash_delete (stream->object_refs); - stream->object_refs = objc_hash_new (8, (hash_func_type) objc_hash_ptr, - (compare_func_type) objc_compare_ptrs); - - /* call -awake for all objects read */ - if (awake_sel) - { - for (node = objc_hash_next (stream->object_table, NULL); node; - node = objc_hash_next (stream->object_table, node)) - { - id object = node->value; - if (__objc_responds_to (object, awake_sel)) - (*objc_msg_lookup (object, awake_sel)) (object, awake_sel); - } - } - - /* empty object table */ - objc_hash_delete (stream->object_table); - stream->object_table = objc_hash_new(64, - (hash_func_type)objc_hash_ptr, - (compare_func_type)objc_compare_ptrs); -} - -/* -** Open the stream PHYSICAL in MODE -*/ - -TypedStream * -objc_open_typed_stream (FILE *physical, int mode) -{ - TypedStream *s = (TypedStream *) objc_malloc (sizeof (TypedStream)); - - s->mode = mode; - s->physical = physical; - s->stream_table = objc_hash_new (64, - (hash_func_type) objc_hash_ptr, - (compare_func_type) objc_compare_ptrs); - s->object_table = objc_hash_new (64, - (hash_func_type) objc_hash_ptr, - (compare_func_type) objc_compare_ptrs); - s->eof = (objc_typed_eof_func) __objc_feof; - s->flush = (objc_typed_flush_func) fflush; - s->writing_root_p = 0; - if (mode == OBJC_READONLY) - { - s->class_table - = objc_hash_new (8, (hash_func_type) objc_hash_string, - (compare_func_type) objc_compare_strings); - s->object_refs = objc_hash_new (8, (hash_func_type) objc_hash_ptr, - (compare_func_type) objc_compare_ptrs); - s->read = (objc_typed_read_func) __objc_fread; - s->write = (objc_typed_write_func) __objc_no_write; - __objc_read_typed_stream_signature (s); - } - else if (mode == OBJC_WRITEONLY) - { - s->class_table = 0; - s->object_refs = 0; - s->read = (objc_typed_read_func) __objc_no_read; - s->write = (objc_typed_write_func) __objc_fwrite; - __objc_write_typed_stream_signature (s); - } - else - { - objc_close_typed_stream (s); - return NULL; - } - s->type = OBJC_FILE_STREAM; - return s; -} - -/* -** Open the file named by FILE_NAME in MODE -*/ - -TypedStream* -objc_open_typed_stream_for_file (const char *file_name, int mode) -{ - FILE *file = NULL; - TypedStream *s; - - if (mode == OBJC_READONLY) - file = fopen (file_name, "r"); - else - file = fopen (file_name, "w"); - - if (file) - { - s = objc_open_typed_stream (file, mode); - if (s) - s->type |= OBJC_MANAGED_STREAM; - return s; - } - else - return NULL; -} - -/* -** Close STREAM freeing the structure it self. If it was opened with -** objc_open_typed_stream_for_file, the file will also be closed. -*/ - -void -objc_close_typed_stream (TypedStream *stream) -{ - if (stream->mode == OBJC_READONLY) - { - __objc_finish_read_root_object (stream); /* Just in case... */ - objc_hash_delete (stream->class_table); - objc_hash_delete (stream->object_refs); - } - - objc_hash_delete (stream->stream_table); - objc_hash_delete (stream->object_table); - - if (stream->type == (OBJC_MANAGED_STREAM | OBJC_FILE_STREAM)) - fclose ((FILE *)stream->physical); - - objc_free(stream); -} - -BOOL -objc_end_of_typed_stream (TypedStream *stream) -{ - return (*stream->eof) (stream->physical); -} - -void -objc_flush_typed_stream (TypedStream *stream) -{ - (*stream->flush) (stream->physical); -} - -long -objc_get_stream_class_version (TypedStream *stream, Class class) -{ - if (stream->class_table) - return PTR2LONG(objc_hash_value_for_key (stream->class_table, - class->name)); - else - return class_get_version (class); -} - diff --git a/libobjc/error.c b/libobjc/error.c index 1dae36594f2..51d6402b998 100644 --- a/libobjc/error.c +++ b/libobjc/error.c @@ -45,53 +45,3 @@ _objc_abort (const char *fmt, ...) abort (); va_end (ap); } - -/* The rest of the file is deprecated. */ -#include "objc/objc-api.h" /* For objc_error_handler. */ - -/* -** Error handler function -** NULL so that default is to just print to stderr -*/ -static objc_error_handler _objc_error_handler = NULL; - -/* Trigger an objc error */ -void -objc_error (id object, int code, const char *fmt, ...) -{ - va_list ap; - - va_start (ap, fmt); - objc_verror (object, code, fmt, ap); - va_end (ap); -} - -/* Trigger an objc error */ -void -objc_verror (id object, int code, const char *fmt, va_list ap) -{ - BOOL result = NO; - - /* Call the error handler if its there - Otherwise print to stderr */ - if (_objc_error_handler) - result = (*_objc_error_handler) (object, code, fmt, ap); - else - vfprintf (stderr, fmt, ap); - - /* Continue if the error handler says its ok - Otherwise abort the program */ - if (result) - return; - else - abort (); -} - -/* Set the error handler */ -objc_error_handler -objc_set_error_handler (objc_error_handler func) -{ - objc_error_handler temp = _objc_error_handler; - _objc_error_handler = func; - return temp; -} diff --git a/libobjc/exception.c b/libobjc/exception.c index 1ffb80b5352..37daed8f30c 100644 --- a/libobjc/exception.c +++ b/libobjc/exception.c @@ -31,12 +31,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "unwind-pe.h" #include <string.h> /* For memcpy */ -/* This hook allows libraries to sepecify special actions when an - exception is thrown without a handler in place. This is deprecated - in favour of objc_set_uncaught_exception_handler (). */ -void (*_objc_unexpected_exception) (id exception); /* !T:SAFE */ - - /* 'is_kind_of_exception_matcher' is our default exception matcher - it determines if the object 'exception' is of class 'catch_class', or of a subclass. */ @@ -539,13 +533,6 @@ objc_exception_throw (id exception) (*__objc_uncaught_exception_handler) (exception); } - /* As a last resort support the old, deprecated way of setting an - uncaught exception handler. */ - if (_objc_unexpected_exception != 0) - { - (*_objc_unexpected_exception) (exception); - } - abort (); } diff --git a/libobjc/libobjc.def b/libobjc/libobjc.def index e84d839ad1d..8a295c824f7 100644 --- a/libobjc/libobjc.def +++ b/libobjc/libobjc.def @@ -23,13 +23,9 @@ LIBRARY libobjc EXPORTS search_for_method_in_list objc_get_uninstalled_dtable -objc_hash_is_key_in_hash -hash_is_key_in_hash -objc_verror _objc_load_callback objc_malloc objc_atomic_malloc -objc_valloc objc_realloc objc_calloc objc_free @@ -39,7 +35,6 @@ objc_mutex_deallocate objc_mutex_lock objc_mutex_trylock objc_mutex_unlock -_objc_unexpected_exception objc_thread_detach objc_thread_exit objc_thread_get_data @@ -53,10 +48,6 @@ objc_thread_remove __objc_class_name_Object __objc_class_name_Protocol __objc_class_name_NXConstantString -objc_error -__objc_object_alloc -__objc_object_copy -__objc_object_dispose class_create_instance object_copy object_dispose @@ -87,48 +78,6 @@ objc_skip_argspec objc_skip_offset objc_skip_type_qualifiers objc_skip_typespec -__objc_read_nbyte_uint -__objc_read_nbyte_ulong -__objc_write_class -__objc_write_object -__objc_write_selector -objc_close_typed_stream -objc_end_of_typed_stream -objc_flush_typed_stream -objc_get_stream_class_version -objc_open_typed_stream -objc_open_typed_stream_for_file -objc_read_array -objc_read_char -objc_read_int -objc_read_long -objc_read_object -objc_read_selector -objc_read_short -objc_read_string -objc_read_type -objc_read_types -objc_read_unsigned_char -objc_read_unsigned_int -objc_read_unsigned_long -objc_read_unsigned_short -objc_write_array -objc_write_char -objc_write_int -objc_write_long -objc_write_object -objc_write_object_reference -objc_write_root_object -objc_write_selector -objc_write_short -objc_write_string -objc_write_string_atomic -objc_write_type -objc_write_types -objc_write_unsigned_char -objc_write_unsigned_int -objc_write_unsigned_long -objc_write_unsigned_short __objc_exec_class __objc_init_dispatch_tables __objc_install_premature_dtable @@ -150,22 +99,3 @@ objc_get_class objc_get_meta_class objc_lookup_class objc_next_class -sarray_at_put -sarray_at_put_safe -sarray_free -sarray_lazy_copy -sarray_new -sarray_realloc -sarray_remove_garbage -objc_hash_add -hash_add -objc_hash_delete -hash_delete -objc_hash_new -hash_new -objc_hash_next -hash_next -objc_hash_remove -hash_remove -objc_hash_value_for_key -hash_value_for_key diff --git a/libobjc/memory.c b/libobjc/memory.c index b0519fc87a1..c02176ef874 100644 --- a/libobjc/memory.c +++ b/libobjc/memory.c @@ -133,38 +133,3 @@ objc_free (void *mem) } #endif /* !OBJC_WITH_GC */ - -/* The rest of the file contains deprecated code. */ - -#if OBJC_WITH_GC - -void * -objc_valloc (size_t size) -{ - void *res = (void *)(GC_malloc (size)); - if (! res) - _objc_abort ("Virtual memory exhausted\n"); - return res; -} - -#else - -void * -objc_valloc (size_t size) -{ - void *res = (void *)(malloc (size)); - if (! res) - _objc_abort ("Virtual memory exhausted\n"); - return res; -} - -#endif /* !OBJC_WITH_GC */ - -/* Hook functions for memory allocation and disposal. Deprecated and - currently unused. */ -void *(*_objc_malloc) (size_t) = malloc; -void *(*_objc_atomic_malloc) (size_t) = malloc; -void *(*_objc_valloc) (size_t) = malloc; -void *(*_objc_realloc) (void *, size_t) = realloc; -void *(*_objc_calloc) (size_t, size_t) = calloc; -void (*_objc_free) (void *) = free; diff --git a/libobjc/objc-private/common.h b/libobjc/objc-private/common.h index 4f4ec5cd077..d1f071114ec 100644 --- a/libobjc/objc-private/common.h +++ b/libobjc/objc-private/common.h @@ -28,11 +28,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see /* This file contains definitions that should be included by all .c and .m files in libobjc. */ -/* This variable allows the public headers to determine when they are - being included by a file inside libobjc itself, or when they are - being included by an external file. */ -#define GNU_LIBOBJC_COMPILING_LIBOBJC_ITSELF 1 - /* When debugging libobjc, add #define DEBUG 1 diff --git a/libobjc/objc/Object.h b/libobjc/objc/Object.h index f036b76b9a2..11c4617a98c 100644 --- a/libobjc/objc/Object.h +++ b/libobjc/objc/Object.h @@ -57,8 +57,6 @@ extern "C" { /* All of the following includes were deprecated in GCC 4.6 and will be removed in the next release. */ -#include "deprecated/hash.h" -#include "deprecated/typedstream.h" #include "deprecated/Object.h" #ifdef __cplusplus diff --git a/libobjc/objc/deprecated/METHOD_NULL.h b/libobjc/objc/deprecated/METHOD_NULL.h deleted file mode 100644 index 6912be345e1..00000000000 --- a/libobjc/objc/deprecated/METHOD_NULL.h +++ /dev/null @@ -1,2 +0,0 @@ -/* For functions which return Method_t */ -#define METHOD_NULL (Method_t)0 diff --git a/libobjc/objc/deprecated/Object.h b/libobjc/objc/deprecated/Object.h index e15cf7dd996..d7924e04761 100644 --- a/libobjc/objc/deprecated/Object.h +++ b/libobjc/objc/deprecated/Object.h @@ -48,37 +48,16 @@ + (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/STR.h b/libobjc/objc/deprecated/STR.h deleted file mode 100644 index 17c20e2d6e3..00000000000 --- a/libobjc/objc/deprecated/STR.h +++ /dev/null @@ -1,2 +0,0 @@ -/* Incredibly obsolete. */ -typedef char *STR; /* String alias */ diff --git a/libobjc/objc/deprecated/hash.h b/libobjc/objc/deprecated/hash.h deleted file mode 100644 index 8b718a4417d..00000000000 --- a/libobjc/objc/deprecated/hash.h +++ /dev/null @@ -1,211 +0,0 @@ -/* 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 deleted file mode 100644 index e542bfc0498..00000000000 --- a/libobjc/objc/deprecated/objc-list.h +++ /dev/null @@ -1,155 +0,0 @@ -/* 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 deleted file mode 100644 index 7a7ebe941b2..00000000000 --- a/libobjc/objc/deprecated/objc_error.h +++ /dev/null @@ -1,56 +0,0 @@ -/* 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 deleted file mode 100644 index 48d508a1592..00000000000 --- a/libobjc/objc/deprecated/objc_get_uninstalled_dtable.h +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index cf6c6e9d092..00000000000 --- a/libobjc/objc/deprecated/objc_malloc.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -** 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_object_alloc.h b/libobjc/objc/deprecated/objc_object_alloc.h deleted file mode 100644 index f6336ca8efa..00000000000 --- a/libobjc/objc/deprecated/objc_object_alloc.h +++ /dev/null @@ -1,8 +0,0 @@ -/* 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 deleted file mode 100644 index 69ffd4e87da..00000000000 --- a/libobjc/objc/deprecated/objc_unexpected_exception.h +++ /dev/null @@ -1,9 +0,0 @@ -/* -** 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 deleted file mode 100644 index a715f1a7330..00000000000 --- a/libobjc/objc/deprecated/objc_valloc.h +++ /dev/null @@ -1,2 +0,0 @@ -void * -objc_valloc(size_t size); diff --git a/libobjc/objc/deprecated/sarray.h b/libobjc/objc/deprecated/sarray.h deleted file mode 100644 index aa2f3350a45..00000000000 --- a/libobjc/objc/deprecated/sarray.h +++ /dev/null @@ -1,240 +0,0 @@ -/* 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_static_instances.h b/libobjc/objc/deprecated/struct_objc_static_instances.h deleted file mode 100644 index 9d889bfc08c..00000000000 --- a/libobjc/objc/deprecated/struct_objc_static_instances.h +++ /dev/null @@ -1,14 +0,0 @@ -/* 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/typedstream.h b/libobjc/objc/deprecated/typedstream.h deleted file mode 100644 index 4d948d5fb27..00000000000 --- a/libobjc/objc/deprecated/typedstream.h +++ /dev/null @@ -1,141 +0,0 @@ -/* 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 */ diff --git a/libobjc/objc/hash.h b/libobjc/objc/hash.h deleted file mode 100644 index 8225a0992e4..00000000000 --- a/libobjc/objc/hash.h +++ /dev/null @@ -1,3 +0,0 @@ -#include "objc.h" -#include "deprecated/hash.h" - diff --git a/libobjc/objc/objc-api.h b/libobjc/objc/objc-api.h index 521f79efb37..e6f6e26600d 100644 --- a/libobjc/objc/objc-api.h +++ b/libobjc/objc/objc-api.h @@ -49,9 +49,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see /* TODO: A deprecation warning any time the file is included ? */ #include "objc.h" -#ifndef GNU_LIBOBJC_COMPILING_LIBOBJC_ITSELF -# include "deprecated/hash.h" -#endif #include "thr.h" #include "objc-decls.h" #include <stdio.h> @@ -61,8 +58,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see extern "C" { #endif /* __cplusplus */ -#include "deprecated/METHOD_NULL.h" - /* Method descriptor returned by introspective Object methods. This is really just the first part of the more complete objc_method structure defined below and used internally by the runtime. */ @@ -109,9 +104,6 @@ struct objc_method_description equivalent to "*". */ #define _C_ATOM '%' -#include "deprecated/objc_error.h" - -#include "deprecated/struct_objc_static_instances.h" #include "deprecated/struct_objc_symtab.h" #include "deprecated/struct_objc_module.h" #include "deprecated/struct_objc_ivar.h" @@ -198,8 +190,6 @@ objc_EXPORT Class (*_objc_lookup_class)(const char *name); */ objc_EXPORT void (*_objc_load_callback)(Class _class, Category* category); -#include "deprecated/objc_object_alloc.h" - /* Standard functions for memory allocation and disposal. Users should use these functions in their ObjC programs so that they work so that @@ -223,11 +213,6 @@ objc_calloc(size_t nelem, size_t size); objc_EXPORT void objc_free(void *mem); -#include "deprecated/objc_valloc.h" -#include "deprecated/objc_malloc.h" - -#include "deprecated/objc_unexpected_exception.h" - objc_EXPORT Method_t class_get_class_method(MetaClass _class, SEL aSel); objc_EXPORT Method_t class_get_instance_method(Class _class, SEL aSel); @@ -399,8 +384,6 @@ object_is_meta_class (id object) && !object_is_class (object)); } -#include "deprecated/objc_get_uninstalled_dtable.h" - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/libobjc/objc/objc-list.h b/libobjc/objc/objc-list.h deleted file mode 100644 index b713a3c0ec9..00000000000 --- a/libobjc/objc/objc-list.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "deprecated/objc-list.h" - diff --git a/libobjc/objc/objc.h b/libobjc/objc/objc.h index ece0f884105..8719269bb35 100644 --- a/libobjc/objc/objc.h +++ b/libobjc/objc/objc.h @@ -125,8 +125,6 @@ typedef id (*IMP)(id, SEL, ...); compiler to do some type-checking. */ #define Nil (Class)0 -#include "deprecated/STR.h" - /* TODO: Move the 'Protocol' declaration into objc/runtime.h. A Protocol is simply an object, not a basic Objective-C type. The Apple runtime defines Protocol in objc/runtime.h too, so it's good diff --git a/libobjc/objc/sarray.h b/libobjc/objc/sarray.h deleted file mode 100644 index ff51e47f918..00000000000 --- a/libobjc/objc/sarray.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "deprecated/sarray.h" - diff --git a/libobjc/objc/typedstream.h b/libobjc/objc/typedstream.h deleted file mode 100644 index a39c51b29dc..00000000000 --- a/libobjc/objc/typedstream.h +++ /dev/null @@ -1,4 +0,0 @@ -#include "objc.h" -#include "deprecated/hash.h" -#include "deprecated/typedstream.h" - diff --git a/libobjc/objects.c b/libobjc/objects.c index 1c69456a630..bcfb25bd604 100644 --- a/libobjc/objects.c +++ b/libobjc/objects.c @@ -123,8 +123,3 @@ object_setClass (id object, Class class_) } } -/* Hook functions for memory allocation and disposal. Deprecated and - currently unused. */ -id (*_objc_object_alloc) (Class) = 0; -id (*_objc_object_dispose) (id) = 0; -id (*_objc_object_copy) (id) = 0; diff --git a/libobjc/sendmsg.c b/libobjc/sendmsg.c index c84e90f5b6e..bb525b155b4 100644 --- a/libobjc/sendmsg.c +++ b/libobjc/sendmsg.c @@ -936,9 +936,12 @@ __objc_block_forward (id rcv, SEL op, ...) } -/* This function is installed in the dispatch table for all methods - which are not implemented. Thus, it is called when a selector is - not recognized. */ +/* This function is called for methods which are not implemented, + unless a custom forwarding routine has been installed. Please note + that most serious users of libobjc (eg, GNUstep base) do install + their own forwarding routines, and hence this is never actually + used. But, if no custom forwarding routine is installed, this is + called when a selector is not recognized. */ static retval_t __objc_forward (id object, SEL sel, arglist_t args) { @@ -977,16 +980,8 @@ __objc_forward (id object, SEL sel, arglist_t args) : "instance" ), object->class_pointer->name, sel_getName (sel)); - /* TODO: support for error: is surely deprecated ? */ - err_sel = sel_get_any_uid ("error:"); - if (__objc_responds_to (object, err_sel)) - { - imp = get_implementation (object, object->class_pointer, err_sel); - return (*imp) (object, sel_get_any_uid ("error:"), msg); - } - - /* The object doesn't respond to doesNotRecognize: or error:; - Therefore, a default action is taken. */ + /* The object doesn't respond to doesNotRecognize:. Therefore, a + default action is taken. */ _objc_abort ("%s\n", msg); return 0; |