Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 55 lines (46 sloc) 1.83 kb
dc5be1c Initial check-in.
uli authored
1 //
2 // UKHelperMacros.h
3 //
4 // Created by Uli Kusterer on 09.08.07.
5 // Copyright 2007 M. Uli Kusterer. All rights reserved.
6 //
7 // Use, modify and distribute freely, as long as you mark modified versions as
8 // having been modified. I don't like getting bug reports for code I did not
9 // write.
10
11 // DIRECTIONS:
12 // You'd generally #import this file in your project's prefix header.
13
14 //
15 // Use UKLog() instead of NSLog() to output debug-only messages that you don't
16 // want in release builds. You'll have to add DEBUG=1 to the preprocessor macros
17 // in your target's compiler settings for the Development build configuration.
18 //
19 // This prefixes the method or function name to the message.
20 //
21
22 #if DEBUG
23 #define UKLog(args...) NSLog( @"%s: %@", __PRETTY_FUNCTION__, [NSString stringWithFormat: args])
24 #else
25 #define UKLog(args...) // stubbed out
26 #endif
27
28
29 // The following use the same syntax as the ones in GNUstep. Just cuz that's
30 // the closest we have to a standard for stuff like this.
31 //
32 // Create a pool around some code by doing:
33 // CREATE_AUTORELEASE_POOL(myPool);
34 // // Use the pool.
35 // DESTROY(myPool);
36 //
37 // ASSIGN() is a neat macro to use inside mutators, DESTROY() is a shorthand
38 // that lets you release an object and clear its variable in one go.
39 //
40 // The do/while(0) stuff is just there so the macro behaves just like any other
41 // function call, as far as if/else etc. are concerned.
42
43 #define CREATE_AUTORELEASE_POOL(pool) NSAutoreleasePool* (pool) = [[NSAutoreleasePool alloc] init]
44
45 #define ASSIGN(targ,newval) do {\
46 id __UKHELPERMACRO_OLDTARG = (id)(targ);\
47 (targ) = [(newval) retain];\
48 [__UKHELPERMACRO_OLDTARG release];\
49 } while(0)
50
51 #define DESTROY(obj) do {\
52 [obj release];\
53 obj = nil;\
54 } while(0)
Something went wrong with that request. Please try again.