several macros added to properly support protocols containing @optional

also on GCC >= 4.6


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37525 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
znek 2013-12-30 13:37:40 +00:00
parent 27e3e2f3f5
commit 2011f25eff
7 changed files with 44 additions and 25 deletions

View file

@ -1,3 +1,18 @@
2013-12-30 Marcus Mueller <znek@mulle-kybernetik.com>
* Headers/GNUstepBase/GSVersionMacros.h: added macros
GS_GCC_MINREQ(maj,min) and GS_CLANG_MINREQ(maj,min) to check for
minimum required versions of GCC and CLANG compilers. Changed several
occurrences of previous macros to improve readability.
Added GS_PROTOCOLS_HAVE_OPTIONAL to correctly mark all appropriate
declarations.
* Headers/Foundation/NSNetServices.h,
* Headers/Foundation/NSStream.h,
* Headers/Foundation/NSXMLParser.h,
* Headers/GNUstepBase/NSNetServices+GNUstepBase.h,
* Source/GSNetServices.h:
use GS_PROTOCOLS_HAVE_OPTIONAL macro where appropriate
2013-12-26 Marcus Mueller <znek@mulle-kybernetik.com>
* Headers/Foundation/NSNetServices.h:

View file

@ -114,7 +114,7 @@ GS_EXPORT NSString * const NSNetServicesErrorDomain;
@protocol NSNetServiceDelegate
#ifdef __clang__ /* FIXME ... this is not clang specific */
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST) && GS_PROTOCOLS_HAVE_OPTIONAL
@optional
#else
@end
@ -243,7 +243,7 @@ GS_EXPORT NSString * const NSNetServicesErrorDomain;
*/
@protocol NSNetServiceBrowserDelegate
#ifdef __clang__ /* FIXME ... this is not clang specific */
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST) && GS_PROTOCOLS_HAVE_OPTIONAL
@optional
#else
@end

View file

@ -270,8 +270,7 @@ GS_EXPORT NSString * const NSStreamSOCKSProxyVersion4;
GS_EXPORT NSString * const NSStreamSOCKSProxyVersion5;
GS_EXPORT NSString * const NSStreamSOCKSProxyVersionKey;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7,GS_API_LATEST) && defined(__clang__)
/* FIXME ... this is not clang specific */
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7,GS_API_LATEST) && GS_PROTOCOLS_HAVE_OPTIONAL
@protocol NSStreamDelegate <NSObject>
@optional
#else

View file

@ -190,7 +190,7 @@ GS_EXPORT NSString* const NSXMLParserErrorDomain;
* This is now a formal protocol.
*/
@protocol NSXMLParserDelegate <NSObject>
#ifdef __clang__ /* FIXME ... this is not clang specific */
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST) && GS_PROTOCOLS_HAVE_OPTIONAL
@optional
#else
@end

View file

@ -220,6 +220,20 @@
#endif
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__clang__)
# define GS_GCC_MINREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
# define GS_GCC_MINREQ(maj, min) 0
#endif
#if defined(__clang__)
# define GS_CLANG_MINREQ(maj, min) \
((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min))
#else
# define GS_CLANG_MINREQ(maj, min) 0
#endif
/* Attribute definitions for attributes which may or may not be supported
* depending on the compiler being used.
* NB we currently expect gcc to be version 4 or later.
@ -229,7 +243,7 @@
* depending on where the attribute can be applied.
*/
#if __GNUC__*10+__GNUC_MINOR__ >= 31
#if defined(__clang__) || GS_GCC_MINREQ(3,1)
# define GS_DEPRECATED_FUNC __attribute__ ((deprecated))
#else
# define GS_DEPRECATED_FUNC
@ -392,7 +406,7 @@ static inline void gs_consumed(id NS_CONSUMED GS_UNUSED_ARG o) { return; }
/* Attribute macros compatible with Apple.
*/
#if __GNUC__*10+__GNUC_MINOR__ >= 42
#if defined(__clang__) || GS_GCC_MINREQ(4,2)
# define NS_FORMAT_ARGUMENT(A) __attribute__((format_arg(A)))
#else
# define NS_FORMAT_ARGUMENT(F,A)
@ -407,5 +421,12 @@ static inline void gs_consumed(id NS_CONSUMED GS_UNUSED_ARG o) { return; }
#define NS_REQUIRES_NIL_TERMINATION __attribute__((sentinel))
/* Check if compiler supports @optional in protocols
*/
#if defined(__clang__) || GS_GCC_MINREQ(4,6)
# define GS_PROTOCOLS_HAVE_OPTIONAL 1
#else
# define GS_PROTOCOLS_HAVE_OPTIONAL 0
#endif
#endif /* __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_ */

View file

@ -81,12 +81,12 @@
@protocol GSNetServiceDelegate <NSNetServiceDelegate>
#ifdef __clang__
#if GS_PROTOCOLS_HAVE_OPTIONAL
@optional
#else
@end
@interface NSObject (GSNetServiceDelegateMethods)
#endif // __clang__
#endif // GS_PROTOCOLS_HAVE_OPTIONAL
/**
* Notifies the delegate that the addresses for the <var>service</var> have

View file

@ -74,11 +74,7 @@ NSString* GSNetServiceDotTerminatedNSStringFromString(const char* string);
/**
* NSNetService using the avahi-client API.
*/
#ifdef __clang__ /* FIXME ... this is not clang specific! */
@interface GSAvahiNetService : NSNetService <NSNetServiceDelegate>
#else
@interface GSAvahiNetService : NSNetService
#endif
{
// GSAvahiClient behaviour ivars:
// From superclass: id _delegate;
@ -120,12 +116,8 @@ NSString* GSNetServiceDotTerminatedNSStringFromString(const char* string);
/**
* NSNetServiceBrowser using the avahi-client API.
*/
#ifdef __clang__ /* FIXME ... this is not clang specific! */
@interface GSAvahiNetServiceBrowser
: NSNetServiceBrowser <NSNetServiceBrowserDelegate>
#else
@interface GSAvahiNetServiceBrowser: NSNetServiceBrowser
#endif
{
// GSAvahiClient behaviour ivars:
// from superclass: id _delegate;
@ -147,21 +139,13 @@ NSString* GSNetServiceDotTerminatedNSStringFromString(const char* string);
/**
* NSNetService using the mDNSResponder API.
*/
#ifdef __clang__ /* FIXME ... this is not clang specific! */
@interface GSMDNSNetService : NSNetService <NSNetServiceDelegate>
#else
@interface GSMDNSNetService : NSNetService
#endif
@end
/**
* NSNetServiceBrowser using the mDNSResponder API.
*/
#ifdef __clang__ /* FIXME ... this is not clang specific! */
@interface GSMDNSNetServiceBrowser : NSNetServiceBrowser <NSNetServiceBrowserDelegate>
#else
@interface GSMDNSNetServiceBrowser : NSNetServiceBrowser
#endif
@end
#endif // GS_USE_AVAHI