* gcc.target/mips/mips.exp: Comment !CPU in the isa* pseudo-options.
[official-gcc.git] / libobjc / objc / objc.h
blobcc822edf5d37c693c4eab075e80e80e727e9cfc6
1 /* Basic data types for Objective C.
2 Copyright (C) 1993, 1995, 1996, 2004 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING. If not, write to
18 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
21 /* As a special exception, if you link this library with files
22 compiled with GCC to produce an executable, this does not cause
23 the resulting executable to be covered by the GNU General Public License.
24 This exception does not however invalidate any other reasons why
25 the executable file might be covered by the GNU General Public License. */
27 #ifndef __objc_INCLUDE_GNU
28 #define __objc_INCLUDE_GNU
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
34 #include <stddef.h>
37 ** Definition of the boolean type.
39 #ifdef __vxworks
40 typedef int BOOL;
41 #else
42 #undef BOOL
43 typedef unsigned char BOOL;
44 #endif
45 #define YES (BOOL)1
46 #define NO (BOOL)0
49 ** Definition of a selector. Selectors themselves are not unique, but
50 ** the sel_id is a unique identifier.
52 typedef const struct objc_selector
54 void *sel_id;
55 const char *sel_types;
56 } *SEL;
58 inline static BOOL
59 sel_eq (SEL s1, SEL s2)
61 if (s1 == 0 || s2 == 0)
62 return s1 == s2;
63 else
64 return s1->sel_id == s2->sel_id;
69 ** ObjC uses this typedef for untyped instances.
71 typedef struct objc_object {
72 struct objc_class* class_pointer;
73 } *id;
76 ** Definition of method type. When retrieving the implementation of a
77 ** method, this is type of the pointer returned. The idea of the
78 ** definition of IMP is to represent a 'pointer to a general function
79 ** taking an id, a SEL, followed by other unspecified arguments'. You
80 ** must always cast an IMP to a pointer to a function taking the
81 ** appropriate, specific types for that function, before calling it -
82 ** to make sure the appropriate arguments are passed to it. The code
83 ** generated by the compiler to perform method calls automatically
84 ** does this cast inside method calls.
86 typedef id (*IMP)(id, SEL, ...);
89 ** More simple types...
91 #define nil (id)0 /* id of Nil instance */
92 #define Nil (Class)0 /* id of Nil class */
93 typedef char *STR; /* String alias */
96 ** The compiler generates one of these structures for each class.
97 **
98 ** This structure is the definition for classes.
99 **
100 ** This structure is generated by the compiler in the executable and used by
101 ** the run-time during normal messaging operations. Therefore some members
102 ** change type. The compiler generates "char* const" and places a string in
103 ** the following member variables: super_class.
105 typedef struct objc_class *MetaClass;
106 typedef struct objc_class *Class;
107 struct objc_class {
108 MetaClass class_pointer; /* Pointer to the class's
109 meta class. */
110 struct objc_class* super_class; /* Pointer to the super
111 class. NULL for class
112 Object. */
113 const char* name; /* Name of the class. */
114 long version; /* Unknown. */
115 unsigned long info; /* Bit mask. See class masks
116 defined above. */
117 long instance_size; /* Size in bytes of the class.
118 The sum of the class
119 definition and all super
120 class definitions. */
121 struct objc_ivar_list* ivars; /* Pointer to a structure that
122 describes the instance
123 variables in the class
124 definition. NULL indicates
125 no instance variables. Does
126 not include super class
127 variables. */
128 struct objc_method_list* methods; /* Linked list of instance
129 methods defined for the
130 class. */
131 struct sarray * dtable; /* Pointer to instance
132 method dispatch table. */
133 struct objc_class* subclass_list; /* Subclasses */
134 struct objc_class* sibling_class;
136 struct objc_protocol_list *protocols; /* Protocols conformed to */
137 void* gc_object_type;
140 #ifndef __OBJC__
141 typedef struct objc_protocol {
142 struct objc_class* class_pointer;
143 char *protocol_name;
144 struct objc_protocol_list *protocol_list;
145 struct objc_method_description_list *instance_methods, *class_methods;
146 } Protocol;
148 #else /* __OBJC__ */
149 @class Protocol;
150 #endif
152 typedef void* retval_t; /* return value */
153 typedef void(*apply_t)(void); /* function pointer */
154 typedef union arglist {
155 char *arg_ptr;
156 char arg_regs[sizeof (char*)];
157 } *arglist_t; /* argument frame */
160 IMP objc_msg_lookup(id receiver, SEL op);
162 #ifdef __cplusplus
164 #endif
166 #endif /* not __objc_INCLUDE_GNU */