git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32465 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2011-03-05 18:12:55 +00:00
parent 3830644de3
commit d084034e84
39 changed files with 90 additions and 72 deletions

View file

@ -35,17 +35,20 @@
* @public GS_X_IVARS;
* # endif
* #else
* @private void *_internal GS_UNUSED_IVAR;
* @private id _internal GS_UNUSED_IVAR;
* #endif
*
* In the non fragile case, this means that the public header has nothing
* visible, but the ivars defined in GS_X_IVARS are visible within the
* implementation.
*
* In the fragile case, the '_internal' pinter is visible in the public
* header, but as an opaque private instance variable, while macros from
* this file allow the actual memory to be accessed either as a malloc'ed
* structure or as a private class.
* In the fragile case, the '_internal' instance variable is visible in the
* public header, but as an opaque private instance variable, while macros
* from this file allow the actual memory to be accessed either as a private
* class. The use of a private class rather than simple heap memory is
* necessary for garbage collection... the runtime is able to ensure that
* garbage collection works properly for the instance variables in the
* private class.
*
* Before including the header file containing the public class declaration,
* you must define GS_X_IVARS (where X is the class name) to be the
@ -72,32 +75,8 @@
#if !GS_NONFRAGILE
/* Code for when we don't have non-fragile instance variables
* The presence of GS_INTERNAL_STRUCT means that the instance variables are
* accessible as a struct rather than as a class.
*/
#if defined(GS_INTERNAL_STRUCT)
/* Start declaration of internal ivars.
*/
#define GS_PRIVATE_INTERNAL(name) \
typedef struct name ## InternalStruct \
{ \
GS_##name##_IVARS; \
} name ## Internal;
/* Create holder for internal ivars.
*/
#define GS_CREATE_INTERNAL(name) \
_internal = (void*)NSZoneCalloc([self zone], 1, sizeof(name ## Internal));
/* Destroy holder for internal ivars.
*/
#define GS_DESTROY_INTERNAL(name) \
if (_internal != 0) { NSZoneFree([self zone], _internal); _internal = 0; }
#else /* GS_INTERNAL_STRUCT */
/* Start declaration of internal ivars.
*/
#define GS_PRIVATE_INTERNAL(name) \
@ -113,14 +92,13 @@ GS_##name##_IVARS; \
/* Create holder for internal ivars.
*/
#define GS_CREATE_INTERNAL(name) \
_internal = (void*)[name ## Internal new];
_internal = [name ## Internal new];
/* Destroy holder for internal ivars.
*/
#define GS_DESTROY_INTERNAL(name) \
if (_internal != 0) {[(id)_internal release]; _internal = 0; }
if (nil != _internal) {[_internal release]; _internal = nil; }
#endif /* GS_INTERNAL_STRUCT */
#undef internal
#define internal ((GSInternal*)_internal)