1994-11-04 16:29:24 +00:00
|
|
|
/* Definitions to allow compilation of GNU objc code with NeXT runtime
|
1996-05-27 15:10:24 +00:00
|
|
|
Copyright (C) 1993,1994, 1996 Free Software Foundation, Inc.
|
1994-11-04 16:29:24 +00:00
|
|
|
|
1996-04-17 20:17:45 +00:00
|
|
|
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
1994-11-04 16:29:24 +00:00
|
|
|
Date: May 1993
|
|
|
|
|
1996-05-12 00:56:10 +00:00
|
|
|
This file is part of the GNUstep Base Library.
|
1994-11-04 16:29:24 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library 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
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this library; if not, write to the Free
|
1999-09-09 02:56:20 +00:00
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
1994-11-04 16:29:24 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* This file is by no means complete. */
|
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
#ifndef __objc_gnu2next_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define __objc_gnu2next_h_GNUSTEP_BASE_INCLUDE
|
1994-11-04 16:29:24 +00:00
|
|
|
|
2001-04-10 22:18:36 +00:00
|
|
|
#if NeXT_RUNTIME
|
1994-11-04 16:29:24 +00:00
|
|
|
|
1994-11-14 15:58:43 +00:00
|
|
|
#include <objc/objc-class.h>
|
2001-04-12 17:16:55 +00:00
|
|
|
#include <stddef.h>
|
1994-11-14 15:58:43 +00:00
|
|
|
|
2001-05-04 21:14:06 +00:00
|
|
|
typedef union {
|
|
|
|
char *arg_ptr;
|
|
|
|
char arg_regs[sizeof (char*)];
|
|
|
|
} *arglist_t; /* argument frame */
|
|
|
|
//#define arglist_t marg_list
|
1994-11-04 16:29:24 +00:00
|
|
|
#define retval_t void*
|
2001-04-24 21:01:24 +00:00
|
|
|
#define TypedStream void*
|
1994-11-04 16:29:24 +00:00
|
|
|
|
2001-04-13 04:10:44 +00:00
|
|
|
#define class_pointer isa
|
|
|
|
|
1994-11-04 16:29:24 +00:00
|
|
|
#define class_create_instance(CLASS) class_createInstance(CLASS, 0)
|
2001-04-30 15:02:59 +00:00
|
|
|
|
|
|
|
#define sel_get_name sel_getName
|
|
|
|
#define sel_get_uid sel_getUid
|
|
|
|
#define sel_eq(s1, s2) (s1 == s2)
|
2001-04-12 17:16:55 +00:00
|
|
|
|
|
|
|
/* FIXME: Any equivalent for this ? */
|
|
|
|
#define sel_get_type(SELECTOR) \
|
|
|
|
(NULL)
|
|
|
|
|
2001-04-30 15:02:59 +00:00
|
|
|
#define class_get_instance_method class_getInstanceMethod
|
|
|
|
#define class_get_class_method class_getClassMethod
|
|
|
|
#define class_add_method_list class_addMethods
|
|
|
|
#define method_get_sizeof_arguments method_getSizeOfArguments
|
|
|
|
#define objc_lookup_class objc_lookUpClass
|
|
|
|
#define sel_get_any_uid sel_getUid
|
|
|
|
#define objc_get_class objc_getClass
|
|
|
|
#define class_get_version class_getVersion
|
2001-05-03 15:40:25 +00:00
|
|
|
#define sel_register_name sel_registerName
|
2001-04-30 15:02:59 +00:00
|
|
|
#define sel_is_mapped sel_isMapped
|
|
|
|
|
1994-11-04 16:29:24 +00:00
|
|
|
#define class_get_class_name(CLASSPOINTER) \
|
|
|
|
(((struct objc_class*)(CLASSPOINTER))->name)
|
|
|
|
#define object_get_class(OBJECT) \
|
|
|
|
(((struct objc_class*)(OBJECT))->isa)
|
|
|
|
#define class_get_super_class(CLASSPOINTER) \
|
|
|
|
(((struct objc_class*)(CLASSPOINTER))->super_class)
|
2001-04-30 15:02:59 +00:00
|
|
|
|
1994-11-04 16:29:24 +00:00
|
|
|
#define __objc_responds_to(OBJECT,SEL) \
|
|
|
|
class_getInstanceMethod(object_get_class(OBJECT), SEL)
|
1994-11-14 15:58:43 +00:00
|
|
|
#define CLS_ISCLASS(CLASSPOINTER) \
|
|
|
|
((((struct objc_class*)(CLASSPOINTER))->info) & CLS_CLASS)
|
1994-11-04 16:29:24 +00:00
|
|
|
#define CLS_ISMETA(CLASSPOINTER) \
|
|
|
|
((((struct objc_class*)(CLASSPOINTER))->info) & CLS_META)
|
|
|
|
#define objc_msg_lookup(OBJ,SEL) \
|
|
|
|
(class_getInstanceMethod(object_get_class(OBJ), SEL)->method_imp)
|
|
|
|
|
2001-04-30 15:02:59 +00:00
|
|
|
|
1994-11-04 16:29:24 +00:00
|
|
|
#define OBJC_READONLY 1
|
|
|
|
#define OBJC_WRITEONLY 2
|
|
|
|
|
2001-04-12 21:09:17 +00:00
|
|
|
/*
|
|
|
|
** Standard functions for memory allocation and disposal.
|
|
|
|
** Users should use these functions in their ObjC programs so
|
|
|
|
** that they work properly with garbage collectors as well as
|
|
|
|
** can take advantage of the exception/error handling available.
|
|
|
|
*/
|
|
|
|
void *
|
|
|
|
objc_malloc(size_t size);
|
|
|
|
|
|
|
|
void *
|
|
|
|
objc_atomic_malloc(size_t size);
|
|
|
|
|
|
|
|
void *
|
|
|
|
objc_valloc(size_t size);
|
|
|
|
|
|
|
|
void *
|
|
|
|
objc_realloc(void *mem, size_t size);
|
|
|
|
|
|
|
|
void *
|
|
|
|
objc_calloc(size_t nelem, size_t size);
|
|
|
|
|
|
|
|
void
|
|
|
|
objc_free(void *mem);
|
|
|
|
|
|
|
|
/*
|
|
|
|
** 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.
|
|
|
|
*/
|
2001-04-24 03:19:30 +00:00
|
|
|
extern void *(*_objc_malloc)(size_t);
|
|
|
|
extern void *(*_objc_atomic_malloc)(size_t);
|
|
|
|
extern void *(*_objc_valloc)(size_t);
|
|
|
|
extern void *(*_objc_realloc)(void *, size_t);
|
|
|
|
extern void *(*_objc_calloc)(size_t, size_t);
|
|
|
|
extern void (*_objc_free)(void *);
|
2001-04-12 21:09:17 +00:00
|
|
|
|
2001-05-04 21:14:06 +00:00
|
|
|
/* encoding functions */
|
|
|
|
extern int objc_sizeof_type(const char* type);
|
|
|
|
extern int objc_alignof_type(const char* type);
|
|
|
|
extern int objc_aligned_size (const char* type);
|
|
|
|
extern int objc_promoted_size (const char* type);
|
|
|
|
extern const char *objc_skip_type_qualifiers (const char* type);
|
|
|
|
extern const char *objc_skip_typespec (const char* type);
|
|
|
|
extern const char *objc_skip_argspec (const char* type);
|
|
|
|
extern unsigned objc_get_type_qualifiers (const char* type);
|
|
|
|
extern BOOL sel_types_match (const char* t1, const char* t2);
|
|
|
|
|
2001-05-14 21:14:22 +00:00
|
|
|
/* Error handling */
|
|
|
|
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);
|
|
|
|
objc_error_handler objc_set_error_handler(objc_error_handler func);
|
2001-05-04 21:14:06 +00:00
|
|
|
|
2001-05-14 21:14:22 +00:00
|
|
|
/*
|
|
|
|
** 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 */
|
2001-04-10 22:18:36 +00:00
|
|
|
#endif /* NeXT_RUNTIME */
|
1994-11-04 16:29:24 +00:00
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
#endif /* __objc_gnu2next_h_GNUSTEP_BASE_INCLUDE */
|