gnustep-dev
[Top][All Lists]
Advanced

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

Re: Function move request.


From: Luboš Doležel
Subject: Re: Function move request.
Date: Thu, 16 May 2013 20:15:38 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5

CFRetain/CFRelease are specific to CF, how would you implement its logic in Base?

In my opinion, you should link against GNUstep's CF like you do on OS X. And if it for some reason doesn't work, then we should fix that instead.

Luboš


On 05/16/2013 03:53 PM, Maxthon Chan wrote:
I have some portability issues when I mix ARC with some occasional
manual retains (especially when hand writing encoders and decoders).

The offending function is CFRetain and CFRelease, which is, as
documented by Apple, recommended as replacements of (forbidden by ARC)
-[NSObject retain] and -[NSObject release] methods.

However due to the structural difference of GNUstep libraries, the
aforementioned two functions are missing.

Currently I resort to conditionally compiled inline function wrappers
(same name and signature, different implementation) to handle this
issue, as done in the following code snippet (extracted from ohttpd2
project, 2-clause BSDL licensed, hosted at
https://github.com/xcvista/ohttpd2):

#ifdef     GNUSTEP

#import <objc/objc_arc.h>

static inline id CGIRetain(id obj)
{
return objc_retain(obj);
}

static inline void CGIRelease(id obj)
{
     objc_release(obj);
}

#else // GNUSTEP

#import <CoreFoundation/CoreFoundation.h>

static inline id CGIRetain(id obj)
{
return(__bridgeid)CFRetain((__bridgeCFTypeRef)obj);
}

static inline void CGIRelease(id obj)
{
CFRelease((__bridge CFTypeRef)obj);
}

#endif // GNUSTEP

If you can move the aforementioned methods from CoreBase to Base, this
portability issue can be addressed.

Max


--
Luboš Doležel



reply via email to

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