[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GWorkspace porting troubles
From: |
Ludovic Marcotte |
Subject: |
Re: GWorkspace porting troubles |
Date: |
Sat, 27 Oct 2001 12:34:47 -0400 (EDT) |
Hi,
> I don't know, but I think the RETAIN, ASSIGN,... macros are there to
> make garbage collection possible, and I don't think Apple's in the same
> mindset as the GNUstep people regarding this issue. I would consider it
> inessential for existing apps that are anyway designed to not take
> advantage of GC. Therefore, I would rather patch GWorkspace so it
> doesn't use Macros, but that might well be a lot of work, I don't
> know... Or maybe you could write a quick hack that does this
> automatically...
There's no point in removing the use of macros (if, we consider them as
placeholders for GC).
Just do what I did in Pantomime. I've defined in an header:
#ifndef GNUSTEP_BASE_VERSION
#define RETAIN(object) [object retain]
#define RELEASE(object) [object release]
#define AUTORELEASE(object) [object autorelease]
#define TEST_RELEASE(object) ({ if (object) [object release]; })
#define ASSIGN(object,value) ({\
id __value = (id)(value); \
id __object = (id)(object); \
if (__value != __object) \
{ \
if (__value != nil) \
{ \
[__value retain]; \
} \
object = __value; \
if (__object != nil) \
{ \
[__object release]; \
} \
} \
})
#define DESTROY(object) ({ \
if (object) \
{ \
id __o = object; \
object = nil; \
[__o release]; \
} \
})
#define CREATE_AUTORELEASE_POOL(X) \
NSAutoreleasePool *(X) = [NSAutoreleasePool new]
#endif
#ifdef MACOSX
#import <MacOSXGlue.h>
#endif
You just include in every source files.
MacOSXGlue is category of NSObject that defines:
- (id) subclassResponsibility: (SEL)aSel
under MacOS-X. It's not included in a GNUstep build but only when you
compile Pantomime under MacOS-X. Since we use a different makefile for
both targets, it's not a problem.
Ludo
--
Live as if you were to die tomorrow.
Learn as if you were to live forever.
- Gandhi