~ubuntu-branches/ubuntu/trusty/gnustep-base/trusty

« back to all changes in this revision

Viewing changes to Headers/Additions/GNUstepBase/GSObjCRuntime.h

Tags: upstream-1.20.0
ImportĀ upstreamĀ versionĀ 1.20.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
#ifndef __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE
31
31
#define __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE
32
 
#include <GNUstepBase/GSVersionMacros.h>
33
 
 
 
32
 
 
33
#import <GNUstepBase/GSVersionMacros.h>
 
34
#import <GNUstepBase/GSConfig.h>
 
35
 
 
36
#include <stdio.h>
34
37
#include <objc/objc.h>
35
38
#include <objc/objc-api.h>
36
39
 
 
40
#if     OBJC2RUNTIME
 
41
/* We have a real ObjC2 runtime.
 
42
 */
 
43
#include <objc/runtime.h>
 
44
#else
 
45
/* We emulate an ObjC2 runtime.
 
46
 */
 
47
#include <ObjectiveC2/runtime.h>
 
48
#endif
 
49
 
 
50
#include <stdarg.h>
 
51
 
37
52
#ifdef __cplusplus
38
53
extern "C" {
39
54
#endif
40
55
 
41
 
#include <stdarg.h>
42
 
 
43
 
#ifdef GNUSTEP_WITH_DLL
44
 
 
45
 
#if BUILD_libgnustep_base_DLL
46
 
#
47
 
# if defined(__MINGW32__)
48
 
  /* On Mingw, the compiler will export all symbols automatically, so
49
 
   * __declspec(dllexport) is not needed.
50
 
   */
51
 
#  define GS_EXPORT  extern
52
 
#  define GS_DECLARE 
53
 
# else
54
 
#  define GS_EXPORT  __declspec(dllexport)
55
 
#  define GS_DECLARE __declspec(dllexport)
56
 
# endif
57
 
#else
58
 
#  define GS_EXPORT  extern __declspec(dllimport)
59
 
#  define GS_DECLARE __declspec(dllimport)
60
 
#endif
61
 
 
62
 
#else /* GNUSTEP_WITH[OUT]_DLL */
63
 
 
64
 
#  define GS_EXPORT extern
65
 
#  define GS_DECLARE 
66
 
 
67
 
#endif
68
 
 
69
 
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
70
 
#define GS_ATTRIB_DEPRECATED __attribute__ ((deprecated))
71
 
#else
72
 
#define GS_ATTRIB_DEPRECATED
73
 
#endif
74
 
 
75
56
@class  NSArray;
76
57
@class  NSDictionary;
77
58
@class  NSObject;
88
69
#define nil             0
89
70
#endif
90
71
 
91
 
#ifdef NeXT_RUNTIME
 
72
#if     !defined(_C_CONST)
92
73
#define _C_CONST        'r'
 
74
#endif
 
75
#if     !defined(_C_IN)
93
76
#define _C_IN           'n'
 
77
#endif
 
78
#if     !defined(_C_INOUT)
94
79
#define _C_INOUT        'N'
 
80
#endif
 
81
#if     !defined(_C_OUT)
95
82
#define _C_OUT          'o'
 
83
#endif
 
84
#if     !defined(_C_BYCOPY)
96
85
#define _C_BYCOPY       'O'
 
86
#endif
 
87
#if     !defined(_C_BYREF)
97
88
#define _C_BYREF        'R'
 
89
#endif
 
90
#if     !defined(_C_ONEWAY)
98
91
#define _C_ONEWAY       'V'
 
92
#endif
 
93
#if     !defined(_C_GCINVISIBLE)
99
94
#define _C_GCINVISIBLE  '!'
100
95
#endif
101
96
 
102
 
#ifndef NO_GNUSTEP
103
97
/*
104
98
 * Functions for accessing instance variables directly -
105
99
 * We can copy an ivar into arbitrary data,
117
111
GSObjCSetVariable(id obj, int offset, unsigned int size, const void *data);
118
112
 
119
113
GS_EXPORT NSArray *
120
 
GSObjCMethodNames(id obj);
 
114
GSObjCMethodNames(id obj, BOOL recurse);
121
115
 
122
116
GS_EXPORT NSArray *
123
 
GSObjCVariableNames(id obj);
 
117
GSObjCVariableNames(id obj, BOOL recurse);
124
118
 
 
119
/**
 
120
 * <p>A Behavior can be seen as a "Protocol with an implementation" or a
 
121
 * "Class without any instance variables".  A key feature of behaviors
 
122
 * is that they give a degree of multiple inheritance.
 
123
 * </p>
 
124
 * <p>Behavior methods, when added to a class, override the class's
 
125
 * superclass methods, but not the class's methods.
 
126
 * </p>
 
127
 * <p>Whan a behavior class is added to a receiver class, not only are the
 
128
 * methods defined in the behavior class added, but the methods from the
 
129
 * behavior's class hierarchy are also added (unless already present).
 
130
 * </p>
 
131
 * <p>It's not the case that a class adding behaviors from another class
 
132
 * must have "no instance vars".  The receiver class just has to have the
 
133
 * same layout as the behavior class (optionally with some additional
 
134
 * ivars after those of the behavior class).
 
135
 * </p>
 
136
 * <p>This function provides Behaviors without adding any new syntax to
 
137
 * the Objective C language.  Simply define a class with the methods you
 
138
 * want to add, then call this function with that class as the behavior
 
139
 * argument.
 
140
 * </p>
 
141
 * <p>This function should be called in the +initialize method of the receiver.
 
142
 * </p>
 
143
 * <p>If you add several behaviors to a class, be aware that the order of
 
144
 * the additions is significant.
 
145
 * </p>
 
146
 */
125
147
GS_EXPORT void
126
148
GSObjCAddClassBehavior(Class receiver, Class behavior);
127
149
 
 
150
/**
 
151
 * <p>An Override can be seen as a "category implemented as a separate class
 
152
 * and manually added to the receiver class under program control, rather
 
153
 * than automatically added by the compiler/runtime.
 
154
 * </p>
 
155
 * <p>Override methods, when added to a receiver class, replace the class's
 
156
 * class's methods of the same name (or are added if the class did not define
 
157
 * methods with that name).
 
158
 * </p>
 
159
 * <p>It's not the case that a class adding overrides from another class
 
160
 * must have "no instance vars".  The receiver class just has to have the
 
161
 * same layout as the override class (optionally with some additional
 
162
 * ivars after those of the override class).
 
163
 * </p>
 
164
 * <p>This function provides overrides without adding any new syntax to
 
165
 * the Objective C language.  Simply define a class with the methods you
 
166
 * want to add, then call this function with that class as the override
 
167
 * argument.
 
168
 * </p>
 
169
 * <p>This function should usually be called in the +initialize method
 
170
 * of the receiver.
 
171
 * </p>
 
172
 * <p>If you add several overrides to a class, be aware that the order of
 
173
 * the additions is significant.
 
174
 * </p>
 
175
 */
 
176
GS_EXPORT void
 
177
GSObjCAddClassOverride(Class receiver, Class override);
 
178
 
 
179
/** Turn on (YES), off (NO) or test (-1) behavior debugging.
 
180
 */
 
181
GS_EXPORT BOOL GSObjCBehaviorDebug(int setget);
 
182
 
128
183
GS_EXPORT NSValue *
129
184
GSObjCMakeClass(NSString *name, NSString *superName, NSDictionary *iVars);
130
185
 
131
186
GS_EXPORT void
132
187
GSObjCAddClasses(NSArray *classes);
133
188
 
 
189
/**
 
190
 * Given a NULL terminated list of methods, add them to the class.<br />
 
191
 * If the method already exists in a superclass, the new version overrides
 
192
 * that one, but if the method already exists in the class itsself, the
 
193
 * new one is quietly ignored (replace==NO) or replaced with the new
 
194
 * version (if replace==YES).<br />
 
195
 * To add class methods, cls should be the metaclass of the class to
 
196
 * which the methods are being added.
 
197
 */
 
198
GS_EXPORT void
 
199
GSObjCAddMethods(Class cls, Method *list, BOOL replace);
 
200
 
134
201
/*
135
202
 * Functions for key-value encoding ... they access values in an object
136
203
 * either by selector or directly, but do so using NSNumber for the
144
211
GSObjCSetVal(NSObject *self, const char *key, id val, SEL sel,
145
212
  const char *type, unsigned size, int offset);
146
213
 
147
 
#include <GNUstepBase/objc-gnu2next.h>
148
 
 
149
214
/*
150
215
 * This section includes runtime functions
151
216
 * to query and manipulate the ObjC runtime structures.
154
219
 * where applicable.
155
220
 */
156
221
 
157
 
#define GS_STATIC_INLINE static inline
158
 
 
159
222
/**
160
 
 * Fills a nil terminated array of Class objects referenced by buffer
161
 
 * with max number of classes registered with the objc runtime.  
162
 
 * The provided buffer must be large enough to hold max + 1 Class objects.
163
 
 * If buffer is nil, the function returns the number of Class
164
 
 * objects that would be inserted if the buffer is large enough.
165
 
 * Otherwise returns the number of Class objects that did not fit
166
 
 * into the provided buffer.  This function keeps a cache of the class
167
 
 * list for future invocations when used with the GNU runtime.  If
168
 
 * clearCache is YES, this cache will be invalidated and rebuild.  The
169
 
 * flag has no effect for the NeXT runtime.
170
 
 * This function is provided as consistent API to both runtimes.  
171
 
 * In the case of the GNU runtime it is likely more efficient to use
172
 
 * objc_next_class() to iterate over the classes.
 
223
 * Deprecated ... use objc_getClassList()
173
224
 */
174
225
GS_EXPORT unsigned int
175
226
GSClassList(Class *buffer, unsigned int max, BOOL clearCache);
176
227
 
177
228
/**
178
 
 * GSObjCClass() return the class of an instance.
179
 
 * Returns a nul pointer if the argument is nil.
180
 
 */
181
 
GS_STATIC_INLINE Class
182
 
GSObjCClass(id obj)
183
 
{
184
 
  if (obj == nil)
185
 
    return 0;
186
 
  return obj->class_pointer;
187
 
}
188
 
 
189
 
/**
190
 
 * Returns the superclass of this.
191
 
 */
192
 
GS_STATIC_INLINE Class
193
 
GSObjCSuper(Class cls)
194
 
{
195
 
#ifndef NeXT_RUNTIME
196
 
  if (cls != 0 && CLS_ISRESOLV (cls) == NO)
197
 
    {
198
 
      const char *name;
199
 
      name = (const char *)cls->super_class;
200
 
      if (name == NULL)
201
 
        {
202
 
          return 0;
203
 
        }
204
 
      return objc_lookup_class (name);
205
 
    }
206
 
#endif
207
 
  return class_get_super_class(cls);
208
 
}
209
 
 
210
 
/**
211
 
 * GSObjCIsInstance() tests to see if an id is an instance.
212
 
 * Returns NO if the argument is nil.
213
 
 */
214
 
GS_STATIC_INLINE BOOL
215
 
GSObjCIsInstance(id obj)
216
 
{
217
 
  if (obj == nil)
218
 
    return NO;
219
 
  return object_is_instance(obj);
220
 
}
221
 
 
222
 
/**
223
 
 * GSObjCIsClass() tests to see if an id is a class.
224
 
 * Returns NO if the argument is nil.
225
 
 */
226
 
GS_STATIC_INLINE BOOL
227
 
GSObjCIsClass(Class cls)
228
 
{
229
 
  if (cls == nil)
230
 
    return NO;
231
 
  return object_is_class(cls);
232
 
}
233
 
 
234
 
/**
235
 
 * GSObjCIsKindOf() tests to see if a class inherits from another class
 
229
 * GSObjCClass() is deprecated ... use object_getClass()
 
230
 */
 
231
GS_EXPORT Class GSObjCClass(id obj);
 
232
 
 
233
/**
 
234
 * GSObjCSuper() is deprecated ... use class_getSuperclass()
 
235
 */
 
236
GS_EXPORT Class GSObjCSuper(Class cls);
 
237
 
 
238
/**
 
239
 * GSObjCIsInstance() is deprecated ... use object_getClass()
 
240
 * in conjunction with class_isMetaClass()
 
241
 */
 
242
GS_EXPORT BOOL GSObjCIsInstance(id obj);
 
243
 
 
244
/**
 
245
 * GSObjCIsClass() is deprecated ... use object_getClass()
 
246
 * in conjunction with class_isMetaClass()
 
247
 */
 
248
GS_EXPORT BOOL GSObjCIsClass(Class cls);
 
249
 
 
250
/**
 
251
 * Test to see if class inherits from another class
236
252
 * The argument to this function must NOT be nil.
237
253
 */
238
 
GS_STATIC_INLINE BOOL
239
 
GSObjCIsKindOf(Class cls, Class other)
240
 
{
241
 
  while (cls != Nil)
242
 
    {
243
 
      if (cls == other)
244
 
        {
245
 
          return YES;
246
 
        }
247
 
      cls = GSObjCSuper(cls);
248
 
    }
249
 
  return NO;
250
 
}
251
 
 
252
 
/**
253
 
 * Given a class name, return the corresponding class or
254
 
 * a nul pointer if the class cannot be found. <br />
255
 
 * If the argument is nil, return a nul pointer.
256
 
 */
257
 
GS_STATIC_INLINE Class
258
 
GSClassFromName(const char *name)
259
 
{
260
 
  if (name == 0)
261
 
    return 0;
262
 
  return objc_lookup_class(name);
263
 
}
264
 
 
265
 
/**
266
 
 * Return the name of the supplied class, or a nul pointer if no class
267
 
 * was supplied.
268
 
 */
269
 
GS_STATIC_INLINE const char *
270
 
GSNameFromClass(Class cls)
271
 
{
272
 
  if (cls == 0)
273
 
    return 0;
274
 
  return class_get_class_name(cls);
275
 
}
276
 
 
277
 
/**
278
 
 * Return the name of the object's class, or a nul pointer if no object
279
 
 * was supplied.
280
 
 */
281
 
GS_STATIC_INLINE const char *
282
 
GSClassNameFromObject(id obj)
283
 
{
284
 
  if (obj == 0)
285
 
    return 0;
286
 
  return object_get_class_name(obj);
287
 
}
288
 
 
289
 
/**
290
 
 * Return the name of the supplied selector, or a nul pointer if no selector
291
 
 * was supplied.
292
 
 */
293
 
GS_STATIC_INLINE const char *
294
 
GSNameFromSelector(SEL sel)
295
 
{
296
 
  if (sel == 0)
297
 
    return 0;
298
 
  return sel_get_name(sel);
299
 
}
300
 
 
301
 
/**
302
 
 * Return a selector matching the specified name, or nil if no name is
303
 
 * supplied.  The returned selector could be any one with the name.<br />
304
 
 * If no selector exists, returns nil.
305
 
 */
306
 
GS_STATIC_INLINE SEL
307
 
GSSelectorFromName(const char *name)
308
 
{
309
 
  if (name == 0)
310
 
    {
311
 
      return 0;
312
 
    }
313
 
  else
314
 
    {
315
 
      return sel_get_uid(name);
316
 
    }
317
 
}
 
254
GS_EXPORT BOOL GSObjCIsKindOf(Class cls, Class other);
 
255
 
 
256
/**
 
257
 * GSClassFromName() is deprecated ... use objc_lookUpClass()
 
258
 */
 
259
GS_EXPORT Class GSClassFromName(const char *name);
 
260
 
 
261
/**
 
262
 * GSNameFromClass() is deprecated ... use class_getName()
 
263
 */
 
264
GS_EXPORT const char *GSNameFromClass(Class cls);
 
265
 
 
266
/**
 
267
 * GSClassNameFromObject() is deprecated ... use object_getClass()
 
268
 * in conjunction with class_getName()
 
269
 */
 
270
GS_EXPORT const char *GSClassNameFromObject(id obj);
 
271
 
 
272
/**
 
273
 * GSNameFromSelector() is deprecated ... use sel_getName()
 
274
 */
 
275
GS_EXPORT const char *GSNameFromSelector(SEL sel);
 
276
 
 
277
/**
 
278
 * GSSelectorFromName() is deprecated ... use sel_getUid()
 
279
 */
 
280
GS_EXPORT SEL
 
281
GSSelectorFromName(const char *name);
318
282
 
319
283
/**
320
284
 * Return the selector for the specified name and types.  Returns a nul
322
286
 * argument is nul. <br />
323
287
 * Creates a new selector if necessary.
324
288
 */
325
 
GS_STATIC_INLINE SEL
326
 
GSSelectorFromNameAndTypes(const char *name, const char *types)
327
 
{
328
 
  if (name == 0)
329
 
    {
330
 
      return 0;
331
 
    }
332
 
  else
333
 
    {
334
 
      SEL s;
335
 
 
336
 
      if (types == 0)
337
 
        {
338
 
          s = sel_get_any_typed_uid(name);
339
 
        }
340
 
      else
341
 
        {
342
 
          s = sel_get_typed_uid(name, types);
343
 
        }
344
 
      if (s == 0)
345
 
        {
346
 
          if (types == 0)
347
 
            {
348
 
              s = sel_register_name(name);
349
 
            }
350
 
          else
351
 
            {
352
 
              s = sel_register_typed_name(name, types);
353
 
            }
354
 
        }
355
 
      return s;
356
 
    }
357
 
 
358
 
}
 
289
GS_EXPORT SEL
 
290
GSSelectorFromNameAndTypes(const char *name, const char *types);
359
291
 
360
292
/**
361
293
 * Return the type information from the specified selector.
362
294
 * May return a nul pointer if the selector was a nul pointer or if it
363
295
 * was not typed.
364
296
 */
365
 
GS_STATIC_INLINE const char *
366
 
GSTypesFromSelector(SEL sel)
367
 
{
368
 
  if (sel == 0)
369
 
    return 0;
370
 
  return sel_get_type(sel);
371
 
}
 
297
GS_EXPORT const char *
 
298
GSTypesFromSelector(SEL sel);
372
299
 
373
300
/**
374
301
 * Compare only the type information ignoring qualifiers, the frame layout
403
330
 * are incompatible between the GNU and NeXT/Apple runtimes.
404
331
 * We introduce GSMethod, GSMethodList and GSIVar to allow portability.
405
332
 */
406
 
typedef struct objc_method      *GSMethod;
407
 
typedef struct objc_method_list *GSMethodList;
408
 
typedef struct objc_ivar        *GSIVar;
 
333
typedef Method  GSMethod;
 
334
typedef Ivar    GSIVar;
409
335
 
410
336
/**
411
337
 * Returns the pointer to the method structure
427
353
            BOOL searchSuperClasses);
428
354
 
429
355
/**
430
 
 * Flushes the cached method dispatch table for the class.
431
 
 * Call this function after any manipulations in the method structures.<br/>
432
 
 * It should be safe to use this function in +load implementations.<br/>
433
 
 * This function should currently (June 2003) be considered WIP.
434
 
 * Please follow potential changes (Name, parameters, ...) closely until
435
 
 * it stabilizes.
 
356
 * Deprecated .. does nothing.
436
357
 */
437
 
GS_STATIC_INLINE void
438
 
GSFlushMethodCacheForClass (Class cls)
439
 
{
440
 
  extern void __objc_update_dispatch_table_for_class (Class);
441
 
  __objc_update_dispatch_table_for_class (cls);
442
 
}
 
358
GS_EXPORT void
 
359
GSFlushMethodCacheForClass (Class cls);
443
360
 
444
361
/**
445
 
 * Returns the pointer to the instance variable structure
446
 
 * for the instance variable name in the specified class.
447
 
 * This function searches the specified class and its superclasses.<br/>
448
 
 * It should be safe to use this function in +load implementations.<br/>
449
 
 * This function should currently (June 2003) be considered WIP.
450
 
 * Please follow potential changes (Name, parameters, ...) closely until
451
 
 * it stabilizes.
 
362
 * Deprecated .. use class_getInstanceVariable()
452
363
 */
453
364
GS_EXPORT GSIVar
454
365
GSCGetInstanceVariableDefinition(Class cls, const char *name);
455
366
 
456
367
/**
457
 
 * Returns the pointer to the instance variable structure
458
 
 * for the instance variable name in the specified class.
459
 
 * This function searches the specified class and its superclasses.<br/>
460
 
 * It is not necessarily safe to use this function
461
 
 * in +load implementations.<br/>
462
 
 * This function should currently (June 2003) be considered WIP.
463
 
 * Please follow potential changes (Name, parameters, ...) closely until
464
 
 * it stabilizes.
 
368
 * Deprecated .. use class_getInstanceVariable()
465
369
 */
466
370
GS_EXPORT GSIVar
467
371
GSObjCGetInstanceVariableDefinition(Class cls, NSString *name);
468
372
 
469
373
/**
470
 
 * <p>Returns a pointer to objc_malloc'ed memory large enough
471
 
 * to hold a struct objc_method_list with 'count' number of
472
 
 * struct objc_method entries.  The memory returned is
473
 
 * initialized with 0, including the method count and
474
 
 * next method list fields.  </p>
475
 
 * <p> This function is intended for use in conjunction with
476
 
 * GSAppendMethodToList() to fill the memory and GSAddMethodList()
477
 
 * to activate the method list.  </p>
478
 
 * <p>After method list manipulation you should call
479
 
 * GSFlushMethodCacheForClass() for the changes to take effect.</p>
480
 
 * <p><em>WARNING:</em> Manipulating the runtime structures
481
 
 * can be hazardous!</p>
482
 
 * <p>This function should currently (June 2004) be considered WIP.
483
 
 * Please follow potential changes (Name, parameters, ...) closely until
484
 
 * it stabilizes.</p>
485
 
 */
486
 
GSMethodList
487
 
GSAllocMethodList (unsigned int count);
488
 
 
489
 
/**
490
 
 * <p>Inserts the method described by sel, types and imp
491
 
 * into the slot of the list's method_count incremented by 1.
492
 
 * This function does not and cannot check whether
493
 
 * the list provided has the necessary capacity.</p>
494
 
 * <p>The GNU runtime makes a difference between method lists
495
 
 * that are "free standing" and those that "attached" to classes.
496
 
 * For "free standing" method lists (e.g. created with GSAllocMethodList()
497
 
 * that have not been added to a class or those which have been removed
498
 
 * via GSRemoveMethodList()) isFree must be passed YES.
499
 
 * When manipulating "attached" method lists, specify NO.</p>
500
 
 * <p>This function is intended for use in conjunction with
501
 
 * GSAllocMethodList() to allocate the list and GSAddMethodList()
502
 
 * to activate the method list. </p>
503
 
 * <p>After method list manipulation you should call
504
 
 * GSFlushMethodCacheForClass() for the changes to take effect.</p>
505
 
 * <p><em>WARNING:</em> Manipulating the runtime structures
506
 
 * can be hazardous!</p>
507
 
 * <p>This function should currently (June 2004) be considered WIP.
508
 
 * Please follow potential changes (Name, parameters, ...) closely until
509
 
 * it stabilizes.</p>
510
 
 */
511
 
void
512
 
GSAppendMethodToList (GSMethodList list,
513
 
                      SEL sel,
514
 
                      const char *types,
515
 
                      IMP imp,
516
 
                      BOOL isFree);
517
 
 
518
 
/**
519
 
 * <p>Removes the method identified by sel
520
 
 * from the method list moving the following methods up in the list,
521
 
 * leaving the last entry blank.  After this call, all references
522
 
 * of previous GSMethodFromList() calls with this list should be
523
 
 * considered invalid.  If the values they referenced are needed, they
524
 
 * must be copied to external buffers before this function is called.</p>
525
 
 * <p>Returns YES if the a matching method was found a removed,
526
 
 * NO otherwise.</p>
527
 
 * <p>The GNU runtime makes a difference between method lists
528
 
 * that are "free standing" and those that "attached" to classes.
529
 
 * For "free standing" method lists (e.g. created with GSAllocMethodList()
530
 
 * that have not been added to a class or those which have been removed
531
 
 * via GSRemoveMethodList()) isFree must be passed YES.
532
 
 * When manipulating "attached" method lists, specify NO.</p>
533
 
 * <p>After method list manipulation you should call
534
 
 * GSFlushMethodCacheForClass() for the changes to take effect.</p>
535
 
 * <p><em>WARNING:</em> Manipulating the runtime structures
536
 
 * can be hazardous!</p>
537
 
 * <p>This function should currently (June 2004) be considered WIP.
538
 
 * Please follow potential changes (Name, parameters, ...) closely until
539
 
 * it stabilizes.</p>
540
 
 */
541
 
BOOL
542
 
GSRemoveMethodFromList (GSMethodList list,
543
 
                        SEL sel,
544
 
                        BOOL isFree);
545
 
 
546
 
/**
547
 
 * <p>Returns a method list of the class that contains the selector.
548
 
 * Depending on searchInstanceMethods either instance or class methods
549
 
 * are searched.
550
 
 * Returns NULL if none are found.
551
 
 * This function does not search the superclasses method lists.
552
 
 * Call this method with the address of a <code>void *</code>
553
 
 * pointing to NULL to obtain the first (active) method list
554
 
 * containing the selector.
555
 
 * Subsequent calls will return further method lists which contain the
556
 
 * selector.  If none are found, it returns NULL.
557
 
 * You may instead pass NULL as the iterator in which case the first
558
 
 * method list containing the selector will be returned.
559
 
 * Do not call it with an uninitialized iterator.
560
 
 * If either class or selector are NULL the function returns NULL.
561
 
 * If subsequent calls to this function with the same non-NULL iterator yet
562
 
 * different searchInstanceMethods value are called, the behavior
563
 
 * is undefined.</p>
564
 
 * <p>This function should currently (June 2004) be considered WIP.
565
 
 * Please follow potential changes (Name, parameters, ...) closely until
566
 
 * it stabilizes.</p>
567
 
 */
568
 
GSMethodList
569
 
GSMethodListForSelector(Class cls,
570
 
                        SEL selector,
571
 
                        void **iterator,
572
 
                        BOOL searchInstanceMethods);
573
 
 
574
 
/**
575
 
 * <p>Returns the (first) GSMethod contained in the supplied list
576
 
 * that corresponds to sel.
577
 
 * Returns NULL if none is found.</p>
578
 
 * <p>The GNU runtime makes a difference between method lists
579
 
 * that are "free standing" and those that "attached" to classes.
580
 
 * For "free standing" method lists (e.g. created with GSAllocMethodList()
581
 
 * that have not been added to a class or those which have been removed
582
 
 * via GSRemoveMethodList()) isFree must be passed YES.
583
 
 * When manipulating "attached" method lists, specify NO.</p>
584
 
 */
585
 
GSMethod
586
 
GSMethodFromList(GSMethodList list,
587
 
                 SEL sel,
588
 
                 BOOL isFree);
589
 
 
590
 
/**
591
 
 * <p>Add the method list to the class as the first list to be
592
 
 * searched during method invocation for the given class.
593
 
 * Depending on toInstanceMethods, this list will be added as 
594
 
 * an instance or a class method list.
595
 
 * If the list is in use by another class, behavior is undefined.
596
 
 * Create a new list with GSAllocMethodList() or use GSRemoveMethodList()
597
 
 * to remove a list before inserting it in a class.</p>
598
 
 * <p>After method list manipulation you should call
599
 
 * GSFlushMethodCacheForClass() for the changes to take effect.</p>
600
 
 * <p>This function should currently (June 2004) be considered WIP.
601
 
 * Please follow potential changes (Name, parameters, ...) closely until
602
 
 * it stabilizes.</p>
603
 
 */
604
 
void
605
 
GSAddMethodList(Class cls,
606
 
                GSMethodList list,
607
 
                BOOL toInstanceMethods);
608
 
 
609
 
/**
610
 
 * <p>Removes the method list from the classes instance or class method
611
 
 * lists depending on fromInstanceMethods.
612
 
 * If the list is not part of the class, behavior is undefined.</p>
613
 
 * <p>After method list manipulation you should call
614
 
 * GSFlushMethodCacheForClass() for the changes to take effect.</p>
615
 
 * <p>This function should currently (June 2004) be considered WIP.
616
 
 * Please follow potential changes (Name, parameters, ...) closely until
617
 
 * it stabilizes.</p>
618
 
 */
619
 
void
620
 
GSRemoveMethodList(Class cls,
621
 
                   GSMethodList list,
622
 
                   BOOL fromInstanceMethods);
623
 
 
624
 
 
625
 
/**
626
 
 * Returns the version number of this.
627
 
 */
628
 
GS_STATIC_INLINE int
629
 
GSObjCVersion(Class cls)
630
 
{
631
 
  return class_get_version(cls);
632
 
}
633
 
 
634
 
#ifndef NeXT_Foundation_LIBRARY
635
 
#include        <Foundation/NSZone.h>
636
 
#else
637
 
#include <Foundation/Foundation.h>
638
 
#endif
639
 
 
640
 
/**
641
 
 * Return the zone in which an object belongs, without using the zone method
642
 
 */
643
 
GS_EXPORT NSZone *
644
 
GSObjCZone(NSObject *obj);
 
374
 * GSObjCVersion() is deprecated ... use class_getVersion()
 
375
 */
 
376
GS_EXPORT int GSObjCVersion(Class cls);
645
377
 
646
378
/**
647
379
 * Quickly return autoreleased data storage area.
650
382
GSAutoreleasedBuffer(unsigned size);
651
383
 
652
384
/**
653
 
 * Allocate a new objc_mutex_t and store it in the location
654
 
 * pointed to by request.  A mutex is only created if the value
655
 
 * pointed to by request is NULL.  This function is thread safe
656
 
 * in the sense that multiple threads my call this function with the same
657
 
 * value of request and only one will actually set the mutex.
658
 
 * It is the users responsibility that no one else attempts to set
659
 
 * the mutex pointed to.  This function should be
660
 
 * used with objc_mutex_t variables which were statically initialized
661
 
 * to NULL like:
662
 
 * <example>
663
 
 * void function (void)
664
 
 * {
665
 
 *   static objc_mutex_t my_lock = NULL;
666
 
 *   if (my_lock == NULL)
667
 
 *     GSAllocateMutexAt(&amp;my_lock);
668
 
 *   objc_mutex_lock(my_lock);
669
 
 *   do_work ();
670
 
 *   objc_mutex_unlock(my_lock);
671
 
 * }
672
 
 * </example>
673
 
 */
674
 
GS_EXPORT void
675
 
GSAllocateMutexAt(objc_mutex_t *request);
676
 
 
677
 
/**
678
385
 * <p>Prints a message to fptr using the format string provided and any
679
386
 * additional arguments.  The format string is interpreted as by
680
387
 * the NSString formatted initialisers, and understands the '%@' syntax
840
547
  if (__count > __max) \
841
548
    { \
842
549
      unsigned int      __tmp; \
843
 
      __objects = (id*)objc_malloc(__count*sizeof(id)); \
 
550
      __objects = (id*)NSZoneMalloc(NSDefaultMallocZone(),__count*sizeof(id)); \
844
551
      va_start(__ap, firstObject); \
845
552
      __objects[0] = firstObject; \
846
553
      for (__tmp = 1; __tmp < __count; __tmp++) \
850
557
      va_end(__ap); \
851
558
    } \
852
559
  code; \
853
 
  if (__objects != __buf) objc_free(__objects); \
 
560
  if (__objects != __buf) NSZoneFree (NSDefaultMallocZone(),__objects); \
854
561
})
855
562
 
856
563
 
857
 
#endif /* NO_GNUSTEP */
858
 
 
859
564
#ifdef __cplusplus
860
565
}
861
566
#endif