diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2010-09-12 00:43:15 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2010-09-12 00:43:15 +0000 |
commit | 7b8699866416f7a55116e19bf6fe2c28bae12a68 (patch) | |
tree | e22bed6f4601015a5042c0e66fd318e63707468e /libobjc/objc | |
parent | 201fb1f2283994930d4bc07f9eaeaaf7d98052c0 (diff) | |
download | gcc-7b8699866416f7a55116e19bf6fe2c28bae12a68.zip gcc-7b8699866416f7a55116e19bf6fe2c28bae12a68.tar.gz gcc-7b8699866416f7a55116e19bf6fe2c28bae12a68.tar.bz2 |
In libobjc/:
* objc/deprecated/objc_error.h: New file.
* objc/objc-api.h: Include deprecated/objc_error.h instead of
defining objc_error and related.
* error.c: New file. Added _objc_abort function which replaces
objc_error. No change in functionality as they both print an
error and abort.
* misc.c: File removed. Code moved into memory.c and error.c.
* memory.c: New file.
* objc-private/error.h: New file.
* archive.c: Include objc-private/error.h and use _objc_abort
instead of objc_error everywhere.
* class.c: Same change.
* encoding.c: Same change.
* init.c: Same change, and simplified init_check_module_version.
* memory.c: Same change.
* sendmsg.c: Same change.
* thr.c: Same change.
* Makefile.in (OBJ_DEPRECATED_H): Added objc_error.h.
(OBJ_H): Reordered list.
(OBJS): Removed misc.lo, added memory.lo and error.lo.
(OBJS_GC): Removed misc_gc.lo, added memory_gc.lo and error_gc.lo.
(misc_gc.lo): Rule removed.
(error_gc.lo): Rule added.
(memory_gc.lo): Rule added.
From-SVN: r164223
Diffstat (limited to 'libobjc/objc')
-rw-r--r-- | libobjc/objc/deprecated/objc_error.h | 56 | ||||
-rw-r--r-- | libobjc/objc/objc-api.h | 50 |
2 files changed, 57 insertions, 49 deletions
diff --git a/libobjc/objc/deprecated/objc_error.h b/libobjc/objc/deprecated/objc_error.h new file mode 100644 index 0000000..7a7ebe9 --- /dev/null +++ b/libobjc/objc/deprecated/objc_error.h @@ -0,0 +1,56 @@ +/* This API is incredibly limited and unsophisticated. objc_error() + generally causes the program to abort, so it should only be used + when something so dramatic happens that it could be pointless to + continue. Only two cases I can think of: failure to allocate new + memory or failure to load an Objective-C module. +*/ +/* Error handling + + Call objc_error() or objc_verror() to record an error; this error + routine will generally exit the program but not necessarily if the + user has installed his own error handler. + + Call objc_set_error_handler to assign your own function for + handling errors. The function should return YES if it is ok + to continue execution, or return NO or just abort if the + program should be stopped. The default error handler is just to + print a message on stderr. + + The error handler function should be of type objc_error_handler + The first parameter is an object instance of relevance. + The second parameter is an error code. + The third parameter is a format string in the printf style. + The fourth parameter is a variable list of arguments. */ +void objc_error(id object, int code, const char* fmt, ...); +void objc_verror(id object, int code, const char* fmt, va_list ap); +typedef BOOL (*objc_error_handler)(id, int code, const char *fmt, va_list ap); +objc_error_handler objc_set_error_handler(objc_error_handler func); + +/* Error codes + These are used by the runtime library, and your + error handling may use them to determine if the error is + hard or soft thus whether execution can continue or abort. */ +#define OBJC_ERR_UNKNOWN 0 /* Generic error */ + +#define OBJC_ERR_OBJC_VERSION 1 /* Incorrect runtime version */ +#define OBJC_ERR_GCC_VERSION 2 /* Incorrect compiler version */ +#define OBJC_ERR_MODULE_SIZE 3 /* Bad module size */ +#define OBJC_ERR_PROTOCOL_VERSION 4 /* Incorrect protocol version */ + +#define OBJC_ERR_MEMORY 10 /* Out of memory */ + +#define OBJC_ERR_RECURSE_ROOT 20 /* Attempt to archive the root + object more than once. */ +#define OBJC_ERR_BAD_DATA 21 /* Didn't read expected data */ +#define OBJC_ERR_BAD_KEY 22 /* Bad key for object */ +#define OBJC_ERR_BAD_CLASS 23 /* Unknown class */ +#define OBJC_ERR_BAD_TYPE 24 /* Bad type specification */ +#define OBJC_ERR_NO_READ 25 /* Cannot read stream */ +#define OBJC_ERR_NO_WRITE 26 /* Cannot write stream */ +#define OBJC_ERR_STREAM_VERSION 27 /* Incorrect stream version */ +#define OBJC_ERR_BAD_OPCODE 28 /* Bad opcode */ + +#define OBJC_ERR_UNIMPLEMENTED 30 /* Method is not implemented */ + +#define OBJC_ERR_BAD_STATE 40 /* Bad thread state */ + diff --git a/libobjc/objc/objc-api.h b/libobjc/objc/objc-api.h index 0ae4322..89c5fcd 100644 --- a/libobjc/objc/objc-api.h +++ b/libobjc/objc/objc-api.h @@ -83,55 +83,7 @@ struct objc_method_description #define _C_COMPLEX 'j' -/* 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. */ -extern void objc_error(id object, int code, const char* fmt, ...); -extern 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); -extern 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 */ +#include "deprecated/objc_error.h" /* For every class which happens to have statically allocated instances in |