1 /* GNUstep.h - macros to make easier to port gnustep apps to macos-x 2 Copyright (C) 2001 Free Software Foundation, Inc. 3 4 Written by: Nicola Pero <n.pero@mi.flashnet.it> 5 Date: March, October 2001 6 7 This file is part of GNUstep. 8 9 This library is free software; you can redistribute it and/or 10 modify it under the terms of the GNU Library General Public 11 License as published by the Free Software Foundation; either 12 version 2 of the License, or (at your option) any later version. 13 14 This library is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 Library General Public License for more details. 18 19 You should have received a copy of the GNU Library General Public 20 License along with this library; if not, write to the Free 21 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 */ 23 24 #ifndef __GNUSTEP_GNUSTEP_H_INCLUDED_ 25 #define __GNUSTEP_GNUSTEP_H_INCLUDED_ 26 27 #ifdef MACOSX 28 #ifndef GNUSTEP 29 30 #define AUTORELEASE(object) [object autorelease] 31 #define TEST_AUTORELEASE(object) ({ if (object) [object autorelease]; }) 32 33 #define RELEASE(object) [object release] 34 #define TEST_RELEASE(object) ({ if (object) [object release]; }) 35 36 #define RETAIN(object) [object retain] 37 #define TEST_RETAIN(object) ({ if (object) [object retain]; }) 38 39 #define ASSIGN(object,value) ({\ 40 id __value = (id)(value); \ 41 id __object = (id)(object); \ 42 if (__value != __object) \ 43 { \ 44 if (__value != nil) \ 45 { \ 46 [__value retain]; \ 47 } \ 48 object = __value; \ 49 if (__object != nil) \ 50 { \ 51 [__object release]; \ 52 } \ 53 } \ 54 }) 55 56 #define ASSIGNCOPY(object,value) ASSIGN(object, [[value copy] autorelease]); 57 58 #define DESTROY(object) ({ \ 59 if (object) \ 60 { \ 61 id __o = object; \ 62 object = nil; \ 63 [__o release]; \ 64 } \ 65 }) 66 67 #define CREATE_AUTORELEASE_POOL(X) \ 68 NSAutoreleasePool *(X) = [NSAutoreleasePool new] 69 70 #define NSLocalizedString(key, comment) \ 71 [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil] 72 73 #define _(X) NSLocalizedString (X, nil) 74 #define __(X) X 75 76 #define NSLocalizedStaticString(X, Y) X 77 78 #endif /* GNUSTEP */ 79 #endif /* MACOSX */ 80 #endif /* __GNUSTEP_GNUSTEP_H_INCLUDED_ */ 81