| 1 | /* GNU Objective-C Runtime API.
|
|---|
| 2 | Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
|
|---|
| 3 |
|
|---|
| 4 | This file is part of GNU CC.
|
|---|
| 5 |
|
|---|
| 6 | GNU CC is free software; you can redistribute it and/or modify it
|
|---|
| 7 | under the terms of the GNU General Public License as published by the
|
|---|
| 8 | Free Software Foundation; either version 2, or (at your option) any
|
|---|
| 9 | later version.
|
|---|
| 10 |
|
|---|
| 11 | GNU CC is distributed in the hope that it will be useful, but WITHOUT
|
|---|
| 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|---|
| 13 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|---|
| 14 | License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with GNU CC; see the file COPYING. If not, write to
|
|---|
| 18 | the Free Software Foundation, 59 Temple Place - Suite 330,
|
|---|
| 19 | Boston, MA 02111-1307, USA. */
|
|---|
| 20 |
|
|---|
| 21 | /* As a special exception, if you link this library with files compiled
|
|---|
| 22 | with GCC to produce an executable, this does not cause the resulting
|
|---|
| 23 | executable to be covered by the GNU General Public License. This
|
|---|
| 24 | exception does not however invalidate any other reasons why the
|
|---|
| 25 | executable file might be covered by the GNU General Public License. */
|
|---|
| 26 |
|
|---|
| 27 | #ifndef __objc_api_INCLUDE_GNU
|
|---|
| 28 | #define __objc_api_INCLUDE_GNU
|
|---|
| 29 |
|
|---|
| 30 | #include "objc/objc.h"
|
|---|
| 31 | #include "objc/hash.h"
|
|---|
| 32 | #include "objc/thr.h"
|
|---|
| 33 | #include <stdio.h>
|
|---|
| 34 | #include <stdarg.h>
|
|---|
| 35 |
|
|---|
| 36 | /* For functions which return Method_t */
|
|---|
| 37 | #define METHOD_NULL (Method_t)0
|
|---|
| 38 | /* Boolean typedefs */
|
|---|
| 39 | /*
|
|---|
| 40 | ** Method descriptor returned by introspective Object methods.
|
|---|
| 41 | ** This is really just the first part of the more complete objc_method
|
|---|
| 42 | ** structure defined below and used internally by the runtime.
|
|---|
| 43 | */
|
|---|
| 44 | struct objc_method_description
|
|---|
| 45 | {
|
|---|
| 46 | SEL name; /* this is a selector, not a string */
|
|---|
| 47 | char *types; /* type encoding */
|
|---|
| 48 | };
|
|---|
| 49 |
|
|---|
| 50 | /* Filer types used to describe Ivars and Methods. */
|
|---|
| 51 | #define _C_ID '@'
|
|---|
| 52 | #define _C_CLASS '#'
|
|---|
| 53 | #define _C_SEL ':'
|
|---|
| 54 | #define _C_CHR 'c'
|
|---|
| 55 | #define _C_UCHR 'C'
|
|---|
| 56 | #define _C_SHT 's'
|
|---|
| 57 | #define _C_USHT 'S'
|
|---|
| 58 | #define _C_INT 'i'
|
|---|
| 59 | #define _C_UINT 'I'
|
|---|
| 60 | #define _C_LNG 'l'
|
|---|
| 61 | #define _C_ULNG 'L'
|
|---|
| 62 | #define _C_FLT 'f'
|
|---|
| 63 | #define _C_DBL 'd'
|
|---|
| 64 | #define _C_BFLD 'b'
|
|---|
| 65 | #define _C_VOID 'v'
|
|---|
| 66 | #define _C_UNDEF '?'
|
|---|
| 67 | #define _C_PTR '^'
|
|---|
| 68 | #define _C_CHARPTR '*'
|
|---|
| 69 | #define _C_ATOM '%'
|
|---|
| 70 | #define _C_ARY_B '['
|
|---|
| 71 | #define _C_ARY_E ']'
|
|---|
| 72 | #define _C_UNION_B '('
|
|---|
| 73 | #define _C_UNION_E ')'
|
|---|
| 74 | #define _C_STRUCT_B '{'
|
|---|
| 75 | #define _C_STRUCT_E '}'
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 | /*
|
|---|
| 79 | ** Error handling
|
|---|
| 80 | **
|
|---|
| 81 | ** Call objc_error() or objc_verror() to record an error; this error
|
|---|
| 82 | ** routine will generally exit the program but not necessarily if the
|
|---|
| 83 | ** user has installed his own error handler.
|
|---|
| 84 | **
|
|---|
| 85 | ** Call objc_set_error_handler to assign your own function for
|
|---|
| 86 | ** handling errors. The function should return YES if it is ok
|
|---|
| 87 | ** to continue execution, or return NO or just abort if the
|
|---|
| 88 | ** program should be stopped. The default error handler is just to
|
|---|
| 89 | ** print a message on stderr.
|
|---|
| 90 | **
|
|---|
| 91 | ** The error handler function should be of type objc_error_handler
|
|---|
| 92 | ** The first parameter is an object instance of relevance.
|
|---|
| 93 | ** The second parameter is an error code.
|
|---|
| 94 | ** The third parameter is a format string in the printf style.
|
|---|
| 95 | ** The fourth parameter is a variable list of arguments.
|
|---|
| 96 | */
|
|---|
| 97 | extern void objc_error(id object, int code, const char* fmt, ...);
|
|---|
| 98 | extern void objc_verror(id object, int code, const char* fmt, va_list ap);
|
|---|
| 99 | typedef BOOL (*objc_error_handler)(id, int code, const char *fmt, va_list ap);
|
|---|
| 100 | objc_error_handler objc_set_error_handler(objc_error_handler func);
|
|---|
| 101 |
|
|---|
| 102 | /*
|
|---|
| 103 | ** Error codes
|
|---|
| 104 | ** These are used by the runtime library, and your
|
|---|
| 105 | ** error handling may use them to determine if the error is
|
|---|
| 106 | ** hard or soft thus whether execution can continue or abort.
|
|---|
| 107 | */
|
|---|
| 108 | #define OBJC_ERR_UNKNOWN 0 /* Generic error */
|
|---|
| 109 |
|
|---|
| 110 | #define OBJC_ERR_OBJC_VERSION 1 /* Incorrect runtime version */
|
|---|
| 111 | #define OBJC_ERR_GCC_VERSION 2 /* Incorrect compiler version */
|
|---|
| 112 | #define OBJC_ERR_MODULE_SIZE 3 /* Bad module size */
|
|---|
| 113 | #define OBJC_ERR_PROTOCOL_VERSION 4 /* Incorrect protocol version */
|
|---|
| 114 |
|
|---|
| 115 | #define OBJC_ERR_MEMORY 10 /* Out of memory */
|
|---|
| 116 |
|
|---|
| 117 | #define OBJC_ERR_RECURSE_ROOT 20 /* Attempt to archive the root
|
|---|
| 118 | object more than once. */
|
|---|
| 119 | #define OBJC_ERR_BAD_DATA 21 /* Didn't read expected data */
|
|---|
| 120 | #define OBJC_ERR_BAD_KEY 22 /* Bad key for object */
|
|---|
| 121 | #define OBJC_ERR_BAD_CLASS 23 /* Unknown class */
|
|---|
| 122 | #define OBJC_ERR_BAD_TYPE 24 /* Bad type specification */
|
|---|
| 123 | #define OBJC_ERR_NO_READ 25 /* Cannot read stream */
|
|---|
| 124 | #define OBJC_ERR_NO_WRITE 26 /* Cannot write stream */
|
|---|
| 125 | #define OBJC_ERR_STREAM_VERSION 27 /* Incorrect stream version */
|
|---|
| 126 | #define OBJC_ERR_BAD_OPCODE 28 /* Bad opcode */
|
|---|
| 127 |
|
|---|
| 128 | #define OBJC_ERR_UNIMPLEMENTED 30 /* Method is not implemented */
|
|---|
| 129 |
|
|---|
| 130 | #define OBJC_ERR_BAD_STATE 40 /* Bad thread state */
|
|---|
| 131 |
|
|---|
|
|---|