add explicit bracketing for safer macros.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29969 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2010-03-15 21:16:20 +00:00
parent 0bdb508a21
commit 361f90ce35

View file

@ -52,13 +52,13 @@
#endif #endif
#ifndef ASSIGN #ifndef ASSIGN
#define ASSIGN(object,value) (object = value) #define ASSIGN(object,value) ((object) = (value))
#endif #endif
#ifndef ASSIGNCOPY #ifndef ASSIGNCOPY
#define ASSIGNCOPY(object,value) (object = [value copy]) #define ASSIGNCOPY(object,value) ((object) = [(id)(value) copy])
#endif #endif
#ifndef DESTROY #ifndef DESTROY
#define DESTROY(object) (object = nil) #define DESTROY(object) ((object) = nil)
#endif #endif
#ifndef CREATE_AUTORELEASE_POOL #ifndef CREATE_AUTORELEASE_POOL
@ -77,21 +77,21 @@
/** /**
* Basic retain operation ... calls [NSObject-retain] * Basic retain operation ... calls [NSObject-retain]
*/ */
#define RETAIN(object) [object retain] #define RETAIN(object) [(id)(object) retain]
#endif #endif
#ifndef RELEASE #ifndef RELEASE
/** /**
* Basic release operation ... calls [NSObject-release] * Basic release operation ... calls [NSObject-release]
*/ */
#define RELEASE(object) [object release] #define RELEASE(object) [(id)(object) release]
#endif #endif
#ifndef AUTORELEASE #ifndef AUTORELEASE
/** /**
* Basic autorelease operation ... calls [NSObject-autorelease] * Basic autorelease operation ... calls [NSObject-autorelease]
*/ */
#define AUTORELEASE(object) [object autorelease] #define AUTORELEASE(object) [(id)(object) autorelease]
#endif #endif
#ifndef TEST_RETAIN #ifndef TEST_RETAIN
@ -126,7 +126,7 @@ id __object = (id)(object); (__object != nil) ? [__object autorelease] : nil; })
*/ */
#define ASSIGN(object,value) ({\ #define ASSIGN(object,value) ({\
id __object = (id)(object); \ id __object = (id)(object); \
object = [((id)value) retain]; \ (object) = [(id)(value) retain]; \
[__object release]; \ [__object release]; \
}) })
#endif #endif
@ -138,7 +138,7 @@ id __object = (id)(object); (__object != nil) ? [__object autorelease] : nil; })
*/ */
#define ASSIGNCOPY(object,value) ({\ #define ASSIGNCOPY(object,value) ({\
id __object = (id)(object); \ id __object = (id)(object); \
object = [((id)value) copy];\ (object) = [(id)(value) copy];\
[__object release]; \ [__object release]; \
}) })
#endif #endif
@ -152,8 +152,8 @@ id __object = (id)(object); (__object != nil) ? [__object autorelease] : nil; })
* to reference the object being released through the variable. * to reference the object being released through the variable.
*/ */
#define DESTROY(object) ({ \ #define DESTROY(object) ({ \
id __o = object; \ id __o = (id)(object); \
object = nil; \ (object) = nil; \
[__o release]; \ [__o release]; \
}) })
#endif #endif