~ubuntu-branches/ubuntu/oneiric/gnustep-base/oneiric

« back to all changes in this revision

Viewing changes to Headers/GNUstepBase/GSObjCRuntime.h

  • Committer: Bazaar Package Importer
  • Author(s): Yavor Doganov
  • Date: 2011-05-31 11:03:16 UTC
  • mfrom: (1.2.12 upstream) (7.2.4 experimental)
  • Revision ID: james.westby@ubuntu.com-20110531110316-0uny1hmsdl3gmn5v
Tags: 1.22.0-1
* New major upstream release:
  + Includes support for the new Objective-C runtime (Closes: #624928).
* debian/control.m4 (Vcs-Arch): Replace with...
  (Vcs-Git): ...since tla-buildpackage is gone.
  (Vcs-Browser): New field.
  (Standards-Version): Bump to 3.9.2; no changes needed.
  (Build-Depends): Add libicu-dev, needed for NSLocale.
  (libgnustep-base`'SOV_BASE-dbg) <Conflicts>: Set to
  libgnustep-base1.20-dbg only.
  <Recommends>: Set to libobjc3-dbg.
* debian/control: Regenerate.
* debian/patches/gnutls-deprecated.patch: New; fix usage of deprecated
  GnuTLS function (Closes: #624054).
* debian/patches/missing-header.patch:
* debian/patches/no-march.patch: Delete; fixed upstream.
* debian/patches/NSBundle-PROCFS_EXE_LINK.patch: Delete; apparently not
  needed anymore.
* debian/patches/manpage-fixes.patch: A few more fixes.
* debian/patches/avoid-nsl-linkage.patch: Refresh.
* debian/patches/autoreconf.patch: Regenerate.
* debian/patches/series: Update.
* debian/rules (v_objc, v_make): Bump to 4:4.6 (for libobjc3) and 2.6
  (for the sake of the testsuite) accordingly.
  (debian/build-shared-stamp): Run the testsuite.
  (install-shared): Do not delete non-existent .swp file.
  (install-common): Use $(sov_base) instead of hardcoded version.
* debian/copyright: Update copyright years.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** Interface to ObjC runtime for GNUStep
 
2
   Copyright (C) 1995, 1997, 2000, 2002, 2003 Free Software Foundation, Inc.
 
3
 
 
4
   Written by:  Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
 
5
   Date: 1995
 
6
   Written by:  Richard Frith-Macdonald <rfm@gnu.org>
 
7
   Date: 2002
 
8
   
 
9
   This file is part of the GNUstep Base Library.
 
10
 
 
11
   This library is free software; you can redistribute it and/or
 
12
   modify it under the terms of the GNU Lesser General Public
 
13
   License as published by the Free Software Foundation; either
 
14
   version 2 of the License, or (at your option) any later version.
 
15
   
 
16
   This library is distributed in the hope that it will be useful,
 
17
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
19
   Library General Public License for more details.
 
20
   
 
21
   You should have received a copy of the GNU Lesser General Public
 
22
   License along with this library; if not, write to the Free
 
23
   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
24
   Boston, MA 02111 USA.
 
25
 
 
26
    AutogsdocSource: Additions/GSObjCRuntime.m
 
27
 
 
28
   */ 
 
29
 
 
30
#ifndef __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE
 
31
#define __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE
 
32
 
 
33
#import <GNUstepBase/GSVersionMacros.h>
 
34
#import <GNUstepBase/GSConfig.h>
 
35
 
 
36
#include <stdio.h>
 
37
#include <objc/objc.h>
 
38
 
 
39
#if     OBJC2RUNTIME
 
40
/* We have a real ObjC2 runtime.
 
41
 */
 
42
#include <objc/runtime.h>
 
43
#else
 
44
/* We emulate an ObjC2 runtime.
 
45
 */
 
46
#include <objc/objc-api.h>
 
47
#include <ObjectiveC2/runtime.h>
 
48
#endif
 
49
 
 
50
#include <stdarg.h>
 
51
 
 
52
#ifdef __cplusplus
 
53
extern "C" {
 
54
#endif
 
55
 
 
56
@class  NSArray;
 
57
@class  NSDictionary;
 
58
@class  NSObject;
 
59
@class  NSString;
 
60
@class  NSValue;
 
61
 
 
62
#ifndef YES
 
63
#define YES             1
 
64
#endif
 
65
#ifndef NO
 
66
#define NO              0
 
67
#endif
 
68
#ifndef nil
 
69
#define nil             0
 
70
#endif
 
71
 
 
72
#if     !defined(_C_CONST)
 
73
#define _C_CONST        'r'
 
74
#endif
 
75
#if     !defined(_C_IN)
 
76
#define _C_IN           'n'
 
77
#endif
 
78
#if     !defined(_C_INOUT)
 
79
#define _C_INOUT        'N'
 
80
#endif
 
81
#if     !defined(_C_OUT)
 
82
#define _C_OUT          'o'
 
83
#endif
 
84
#if     !defined(_C_BYCOPY)
 
85
#define _C_BYCOPY       'O'
 
86
#endif
 
87
#if     !defined(_C_BYREF)
 
88
#define _C_BYREF        'R'
 
89
#endif
 
90
#if     !defined(_C_ONEWAY)
 
91
#define _C_ONEWAY       'V'
 
92
#endif
 
93
#if     !defined(_C_GCINVISIBLE)
 
94
#define _C_GCINVISIBLE  '!'
 
95
#endif
 
96
 
 
97
/*
 
98
 * Functions for accessing instance variables directly -
 
99
 * We can copy an ivar into arbitrary data,
 
100
 * Get the type encoding for a named ivar,
 
101
 * and copy a value into an ivar.
 
102
 */
 
103
GS_EXPORT BOOL
 
104
GSObjCFindVariable(id obj, const char *name,
 
105
                   const char **type, unsigned int *size, int *offset);
 
106
 
 
107
GS_EXPORT void
 
108
GSObjCGetVariable(id obj, int offset, unsigned int size, void *data);
 
109
 
 
110
GS_EXPORT void
 
111
GSObjCSetVariable(id obj, int offset, unsigned int size, const void *data);
 
112
 
 
113
GS_EXPORT NSArray *
 
114
GSObjCMethodNames(id obj, BOOL recurse);
 
115
 
 
116
GS_EXPORT NSArray *
 
117
GSObjCVariableNames(id obj, BOOL recurse);
 
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
 */
 
147
GS_EXPORT void
 
148
GSObjCAddClassBehavior(Class receiver, Class behavior);
 
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
 
 
183
GS_EXPORT NSValue *
 
184
GSObjCMakeClass(NSString *name, NSString *superName, NSDictionary *iVars);
 
185
 
 
186
GS_EXPORT void
 
187
GSObjCAddClasses(NSArray *classes);
 
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
 
 
201
/*
 
202
 * Functions for key-value encoding ... they access values in an object
 
203
 * either by selector or directly, but do so using NSNumber for the
 
204
 * scalar types of data.
 
205
 */
 
206
GS_EXPORT id
 
207
GSObjCGetVal(NSObject *self, const char *key, SEL sel,
 
208
  const char *type, unsigned size, int offset);
 
209
 
 
210
GS_EXPORT void
 
211
GSObjCSetVal(NSObject *self, const char *key, id val, SEL sel,
 
212
  const char *type, unsigned size, int offset);
 
213
 
 
214
/*
 
215
 * This section includes runtime functions
 
216
 * to query and manipulate the ObjC runtime structures.
 
217
 * These functions take care to not use ObjC code so
 
218
 * that they can safely be used in +(void)load implementations
 
219
 * where applicable.
 
220
 */
 
221
 
 
222
/**
 
223
 * Deprecated ... use objc_getClassList()
 
224
 */
 
225
GS_EXPORT unsigned int
 
226
GSClassList(Class *buffer, unsigned int max, BOOL clearCache);
 
227
 
 
228
/**
 
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
 
252
 * The argument to this function must NOT be nil.
 
253
 */
 
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);
 
282
 
 
283
/**
 
284
 * Return the selector for the specified name and types.<br />
 
285
 * Returns a nul pointer if the name is nul.<br />
 
286
 * Creates a new selector if necessary.<br />
 
287
 * Code must NOT rely on this providing a selector with type information.
 
288
 */
 
289
GS_EXPORT SEL
 
290
GSSelectorFromNameAndTypes(const char *name, const char *types);
 
291
 
 
292
/**
 
293
 * Return the type information from the specified selector.<br />
 
294
 * May return a nul pointer if the selector was a nul pointer or if it
 
295
 * was not typed (or if the runtime does not support typed selectors).<br />
 
296
 * Code must NOT rely on this providing any type information.
 
297
 */
 
298
GS_EXPORT const char *
 
299
GSTypesFromSelector(SEL sel);
 
300
 
 
301
/**
 
302
 * Compare only the type information ignoring qualifiers, the frame layout
 
303
 * and register markers.  Unlike sel_types_match, this function also
 
304
 * handles comparisons of types with and without any layout information.
 
305
 */
 
306
GS_EXPORT BOOL
 
307
GSSelectorTypesMatch(const char *types1, const char *types2);
 
308
 
 
309
/**
 
310
 * Returns a protocol object with the corresponding name.
 
311
 * This function searches the registered classes for any protocol
 
312
 * with the supplied name.  If one is found, it is cached in
 
313
 * for future requests.  If efficiency is a factor then use
 
314
 * GSRegisterProtocol() to insert a protocol explicitly into the cache
 
315
 * used by this function.  If no protocol is found this function returns
 
316
 * nil.
 
317
 */
 
318
GS_EXPORT Protocol *
 
319
GSProtocolFromName(const char *name);
 
320
 
 
321
/**
 
322
 * Registers proto in the cache used by GSProtocolFromName().
 
323
 */
 
324
GS_EXPORT void
 
325
GSRegisterProtocol(Protocol *proto);
 
326
 
 
327
/**
 
328
 * A variant of protocol_getMethodDescription which recursively searches
 
329
 * parent protocols if the requested selector isn't found in the given
 
330
 * protocol.
 
331
 *
 
332
 * Returns a {NULL, NULL} structure if the requested selector couldn't be
 
333
 * found.
 
334
 */
 
335
GS_EXPORT struct objc_method_description
 
336
GSProtocolGetMethodDescriptionRecursive(Protocol *aProtocol, SEL aSel, BOOL isRequired, BOOL isInstance);
 
337
 
 
338
/*
 
339
 * Unfortunately the definition of the symbols
 
340
 * 'Method(_t)', 'MethodList(_t)'  and 'IVar(_t)'
 
341
 * are incompatible between the GNU and NeXT/Apple runtimes.
 
342
 * We introduce GSMethod, GSMethodList and GSIVar to allow portability.
 
343
 */
 
344
typedef Method  GSMethod;
 
345
typedef Ivar    GSIVar;
 
346
 
 
347
/**
 
348
 * Returns the pointer to the method structure
 
349
 * for the selector in the specified class.
 
350
 * Depending on searchInstanceMethods, this function searches
 
351
 * either instance or class methods.
 
352
 * Depending on searchSuperClassesm this function searches
 
353
 * either the specified class only or also its superclasses.<br/>
 
354
 * To obtain the implementation pointer IMP use returnValue->method_imp
 
355
 * which should be safe across all runtimes.<br/>
 
356
 * It should be safe to use this function in +load implementations.<br/>
 
357
 * This function should currently (June 2004) be considered WIP.
 
358
 * Please follow potential changes (Name, parameters, ...) closely until
 
359
 * it stabilizes.
 
360
 */
 
361
GS_EXPORT GSMethod
 
362
GSGetMethod(Class cls, SEL sel,
 
363
            BOOL searchInstanceMethods,
 
364
            BOOL searchSuperClasses);
 
365
 
 
366
/**
 
367
 * Deprecated .. does nothing.
 
368
 */
 
369
GS_EXPORT void
 
370
GSFlushMethodCacheForClass (Class cls);
 
371
 
 
372
/**
 
373
 * Deprecated .. use class_getInstanceVariable()
 
374
 */
 
375
GS_EXPORT GSIVar
 
376
GSCGetInstanceVariableDefinition(Class cls, const char *name);
 
377
 
 
378
/**
 
379
 * Deprecated .. use class_getInstanceVariable()
 
380
 */
 
381
GS_EXPORT GSIVar
 
382
GSObjCGetInstanceVariableDefinition(Class cls, NSString *name);
 
383
 
 
384
/**
 
385
 * GSObjCVersion() is deprecated ... use class_getVersion()
 
386
 */
 
387
GS_EXPORT int GSObjCVersion(Class cls);
 
388
 
 
389
/**
 
390
 * Quickly return autoreleased data storage area.
 
391
 */
 
392
GS_EXPORT void *
 
393
GSAutoreleasedBuffer(unsigned size);
 
394
 
 
395
/**
 
396
 * <p>Prints a message to fptr using the format string provided and any
 
397
 * additional arguments.  The format string is interpreted as by
 
398
 * the NSString formatted initialisers, and understands the '%@' syntax
 
399
 * for printing an object.
 
400
 * </p>
 
401
 * <p>The data is written to the file pointer in the default CString
 
402
 * encoding if possible, as a UTF8 string otherwise.
 
403
 * </p>
 
404
 * <p>This function is recommended for printing general log messages.
 
405
 * For debug messages use NSDebugLog() and friends.  For error logging
 
406
 * use NSLog(), and for warnings you might consider NSWarnLog().
 
407
 * </p>
 
408
 */
 
409
GS_EXPORT BOOL
 
410
GSPrintf (FILE *fptr, NSString *format, ...);
 
411
 
 
412
 
 
413
 
 
414
GS_EXPORT NSArray *
 
415
GSObjCAllSubclassesOfClass(Class cls);
 
416
 
 
417
GS_EXPORT NSArray *
 
418
GSObjCDirectSubclassesOfClass(Class cls);
 
419
 
 
420
/** Function to change the class of the specified instance to newClass.
 
421
 * This handles memory debugging issues in GNUstep-base and also
 
422
 * deals with class finalisation issues in a garbage collecting
 
423
 * environment, so you should use this function rather than attempting
 
424
 * to swizzle class pointers directly.
 
425
 */
 
426
GS_EXPORT void
 
427
GSClassSwizzle(id instance, Class newClass);
 
428
 
 
429
#if GS_API_VERSION(GS_API_ANY,011500)
 
430
 
 
431
GS_EXPORT const char *
 
432
GSLastErrorStr(long error_id) GS_DEPRECATED_FUNC;
 
433
 
 
434
#endif
 
435
 
 
436
 
 
437
 
 
438
#ifndef GS_MAX_OBJECTS_FROM_STACK
 
439
/**
 
440
 * The number of objects to try to get from varargs into an array on
 
441
 * the stack ... if there are more than this, use the heap.
 
442
 * NB. This MUST be a multiple of 2
 
443
 */
 
444
#define GS_MAX_OBJECTS_FROM_STACK       128
 
445
#endif
 
446
 
 
447
/**
 
448
 * <p>This is a macro designed to minimise the use of memory allocation and
 
449
 * deallocation when you need to work with a vararg list of objects.<br />
 
450
 * The objects are unpacked from the vararg list into two 'C' arrays and
 
451
 * then a code fragment you specify is able to make use of them before
 
452
 * that 'C' array is destroyed. 
 
453
 * </p>
 
454
 * <p>The firstObject argument is the name of the formal parameter in your
 
455
 * method or function which precedes the ', ...' denoting variable args.
 
456
 * </p>
 
457
 * <p>The code argument is a piece of objective-c code to be executed to
 
458
 * make use of the objects stored in the 'C' arrays.<br />
 
459
 * When this code is called the unsigned integer '__count' will contain the
 
460
 * number of objects unpacked, the pointer '__objects' will point to
 
461
 * the first object in each pair, and the pointer '__pairs' will point
 
462
 * to an array containing the second halves of the pairs of objects
 
463
 * whose first halves are in '__objects'.<br />
 
464
 * This lets you pack a list of the form 'key, value, key, value, ...'
 
465
 * into an array of keys and an array of values.
 
466
 * </p>
 
467
 */
 
468
#define GS_USEIDPAIRLIST(firstObject, code...) ({\
 
469
  va_list       __ap; \
 
470
  unsigned int  __max = GS_MAX_OBJECTS_FROM_STACK; \
 
471
  unsigned int  __count = 0; \
 
472
  id            __buf[__max]; \
 
473
  id            *__objects = __buf; \
 
474
  id            *__pairs = &__objects[__max/2]; \
 
475
  id            __obj = firstObject; \
 
476
  va_start(__ap, firstObject); \
 
477
  while (__obj != nil && __count < __max) \
 
478
    { \
 
479
      if ((__count % 2) == 0) \
 
480
        { \
 
481
          __objects[__count/2] = __obj; \
 
482
        } \
 
483
      else \
 
484
        { \
 
485
          __pairs[__count/2] = __obj; \
 
486
        } \
 
487
      __obj = va_arg(__ap, id); \
 
488
      if (++__count == __max) \
 
489
        { \
 
490
          while (__obj != nil) \
 
491
            { \
 
492
              __count++; \
 
493
              __obj = va_arg(__ap, id); \
 
494
            } \
 
495
        } \
 
496
    } \
 
497
  if ((__count % 2) == 1) \
 
498
    { \
 
499
      __pairs[__count/2] = nil; \
 
500
      __count++; \
 
501
    } \
 
502
  va_end(__ap); \
 
503
  if (__count > __max) \
 
504
    { \
 
505
      unsigned int      __tmp; \
 
506
      __objects = (id*)malloc(__count*sizeof(id)); \
 
507
      __pairs = &__objects[__count/2]; \
 
508
      __objects[0] = firstObject; \
 
509
      va_start(__ap, firstObject); \
 
510
      for (__tmp = 1; __tmp < __count; __tmp++) \
 
511
        { \
 
512
          if ((__tmp % 2) == 0) \
 
513
            { \
 
514
              __objects[__tmp/2] = va_arg(__ap, id); \
 
515
            } \
 
516
          else \
 
517
            { \
 
518
              __pairs[__tmp/2] = va_arg(__ap, id); \
 
519
            } \
 
520
        } \
 
521
      va_end(__ap); \
 
522
    } \
 
523
  code; \
 
524
  if (__objects != __buf) free(__objects); \
 
525
})
 
526
 
 
527
/**
 
528
 * <p>This is a macro designed to minimise the use of memory allocation and
 
529
 * deallocation when you need to work with a vararg list of objects.<br />
 
530
 * The objects are unpacked from the vararg list into a 'C' array and
 
531
 * then a code fragment you specify is able to make use of them before
 
532
 * that 'C' array is destroyed. 
 
533
 * </p>
 
534
 * <p>The firstObject argument is the name of the formal parameter in your
 
535
 * method or function which precedes the ', ...' denoting variable args.
 
536
 * </p>
 
537
 * <p>The code argument is a piece of objective-c code to be executed to
 
538
 * make use of the objects stored in the 'C' array.<br />
 
539
 * When this code is called the unsigned integer '__count' will contain the
 
540
 * number of objects unpacked, and the pointer '__objects' will point to
 
541
 * the unpacked objects, ie. firstObject followed by the vararg arguments
 
542
 * up to (but not including) the first nil.
 
543
 * </p>
 
544
 */
 
545
#define GS_USEIDLIST(firstObject, code...) ({\
 
546
  va_list       __ap; \
 
547
  unsigned int  __max = GS_MAX_OBJECTS_FROM_STACK; \
 
548
  unsigned int  __count = 0; \
 
549
  id            __buf[__max]; \
 
550
  id            *__objects = __buf; \
 
551
  id            __obj = firstObject; \
 
552
  va_start(__ap, firstObject); \
 
553
  while (__obj != nil && __count < __max) \
 
554
    { \
 
555
      __objects[__count] = __obj; \
 
556
      __obj = va_arg(__ap, id); \
 
557
      if (++__count == __max) \
 
558
        { \
 
559
          while (__obj != nil) \
 
560
            { \
 
561
              __count++; \
 
562
              __obj = va_arg(__ap, id); \
 
563
            } \
 
564
        } \
 
565
    } \
 
566
  va_end(__ap); \
 
567
  if (__count > __max) \
 
568
    { \
 
569
      unsigned int      __tmp; \
 
570
      __objects = (id*)NSZoneMalloc(NSDefaultMallocZone(),__count*sizeof(id)); \
 
571
      va_start(__ap, firstObject); \
 
572
      __objects[0] = firstObject; \
 
573
      for (__tmp = 1; __tmp < __count; __tmp++) \
 
574
        { \
 
575
          __objects[__tmp] = va_arg(__ap, id); \
 
576
        } \
 
577
      va_end(__ap); \
 
578
    } \
 
579
  code; \
 
580
  if (__objects != __buf) NSZoneFree (NSDefaultMallocZone(),__objects); \
 
581
})
 
582
 
 
583
 
 
584
#ifdef __cplusplus
 
585
}
 
586
#endif
 
587
 
 
588
#endif /* __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */