discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: retain, release, and autorelease operations


From: Nicola Pero
Subject: Re: retain, release, and autorelease operations
Date: Wed, 3 Oct 2001 14:37:25 +0200 (CEST)

Many months ago, someone asked me how to port Gomoku.app to MacOSX.  I
produced the attached header (cleaned up for the occasion), but never had
any response from the guy.  (The macros in the attached headers are not as
optimized as the ones used by gnustep itself, I wrote them from scratch
without thinking too much at performance, but the definition should be
very easy to understand).

I think you might use the same header.  Even better - my original idea -
we might make a tiny standalone LGPL library for MacOS-X out of this
header (some other gnustep-dev has to provide MacOS-X makefiles because I
don't have any apple stuff), the idea being that people would install this
tiny library on their macosx, and then they can simply include the library
header to compile code containing the gnustep macros on their systems. 
There would be two advantages: 

 * all apps can share the same header so no need to write the header again
   and again;

 * this header is LGPL and can *not* be included directly in proprietary
   or non-GPL and non-LGPL software.  But if it is installed as a library,
   then any software can use it.  Because we want these macros to become
   standard, we just want any software to be able to use them. 

Let me know.

> Hi,
> 
> One of my friend is porting GNUMail.app / Pantomime to MacOS-X.
> 
> Since GNUstep defines RETAIN(), RELEASE(), and AUTORELEASE() as
> placeholders for GC (in a distant future), is it safe to simply define
> in both projects:
> 
> #ifndef GNUSTEP_BASE_VERSION
> 
> #define RETAIN(object)          [object retain]
> #define RELEASE(object)         [object release]
> #define AUTORELEASE(object)     [object autorelease]
> 
> #endif
> 
> (and maybe ASSIGN, TEST_*, ...)
> 
> ?
> 
> Thanks,
>               Ludovic
/* GNUstep.h - macros to make easier to port gnustep apps to macos-x
   Copyright (C) 2001 Free Software Foundation, Inc.

   Written by: Nicola Pero <n.pero@mi.flashnet.it>
   Date: March, October 2001
   
   This file is part of GNUstep.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
   
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.
   
   You should have received a copy of the GNU Library General Public
   License along with this library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
   */ 

#ifndef __GNUSTEP_GNUSTEP_H_INCLUDED_
# define __GNUSTEP_GNUSTEP_H_INCLUDED_
#
# ifndef GNUSTEP
#
#  define AUTORELEASE(X) [X autorelease]
#  define TEST_AUTORELEASE(X) [X autorelease]
#
#  define RELEASE(X) [X release]
#  define TEST_RELEASE(X) [X release]
#
#  define RETAIN(X) [X retain]
#  define TEST_RETAIN(X) [X retain]
#
#  define ASSIGN(X,Y) ({\
id __GNUSTEP_X = (id)X; \
X = [Y retain]; \
[__GNUSTEP_X release]; \
})
#
#  define ASSIGNCOPY(X,Y) ASSIGN (X, [[Y copy] autorelease]);
#
#  define DESTROY(X) ASSIGN (X, nil)
#
#  define CREATE_AUTORELEASE_POOL(X) \
NSAutoreleasePool *(X) = [NSAutoreleasePool new]
#
#  define _(X) NSLocalizedString (X, nil)
#
#  define __(X) X
#
#  define NSLocalizedStaticString(X, Y) X
#
# endif /* GNUSTEP */
#
#endif /* __GNUSTEP_GNUSTEP_H_INCLUDED_ */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]