gnustep-dev
[Top][All Lists]
Advanced

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

Function move request.


From: Maxthon Chan
Subject: Function move request.
Date: Thu, 16 May 2013 21:53:21 +0800

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 (__bridge id)CFRetain((__bridge CFTypeRef)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

reply via email to

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