Make NSNetServices use formal protocol, as in 10.6. When compiling with clang, use @optional, otherwise fall back to defining an empty protocol and defining an informal protocol with the methods.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31594 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
theraven 2010-11-07 15:43:46 +00:00
parent 8a814588b3
commit 079d27f3bc
2 changed files with 31 additions and 12 deletions

View file

@ -33,6 +33,8 @@
extern "C" { extern "C" {
#endif #endif
@protocol NSNetServiceBrowserDelegate, NSNetServiceDelegate;
enum enum
{ {
NSNetServicesUnknownError = -72000L, NSNetServicesUnknownError = -72000L,
@ -165,8 +167,13 @@ GS_EXPORT NSString * const NSNetServicesErrorDomain;
- (void) startMonitoring; - (void) startMonitoring;
- (void) stopMonitoring; - (void) stopMonitoring;
- (id) delegate; #if OS_API_VERSION(100500,GS_API_LATEST)
- (void) setDelegate: (id) delegate; - (NSInteger)port;
- (void) publishWithOptions: (NSNetServiceOptions)options;
#endif
- (id<NSNetServiceDelegate>) delegate;
- (void) setDelegate: (id<NSNetServiceDelegate>) delegate;
- (NSArray *) addresses; - (NSArray *) addresses;
- (NSString *) domain; - (NSString *) domain;
@ -238,15 +245,15 @@ GS_EXPORT NSString * const NSNetServicesErrorDomain;
- (void) stop; - (void) stop;
- (id) delegate; - (id<NSNetServiceBrowserDelegate>) delegate;
- (void) setDelegate: (id) delegate; - (void) setDelegate: (id<NSNetServiceBrowserDelegate>) delegate;
@end @end
/** /**
* <unit> * <unit>
* <heading> * <heading>
* NSObject (NSNetServiceDelegateMethods) class description * NSNetServiceDelegate protocol description
* </heading> * </heading>
* <p> * <p>
* <!-- Foreword --> * <!-- Foreword -->
@ -257,12 +264,18 @@ GS_EXPORT NSString * const NSNetServicesErrorDomain;
* </p> * </p>
* </unit> * </unit>
* <p> * <p>
* This informal protocol must be adopted by any class wishing to implement * This protocol must be adopted by any class wishing to implement
* an [NSNetService] delegate. * an [NSNetService] delegate.
* </p> * </p>
*/ */
@protocol NSNetServiceDelegate
#ifdef __clang__
@optional
#else
@end
@interface NSObject (NSNetServiceDelegateMethods) @interface NSObject (NSNetServiceDelegateMethods)
#endif
/** /**
* Notifies the delegate that the network is ready to publish the service. * Notifies the delegate that the network is ready to publish the service.
@ -353,7 +366,7 @@ GS_EXPORT NSString * const NSNetServicesErrorDomain;
/** /**
* <unit> * <unit>
* <heading> * <heading>
* NSObject (NSNetServiceBrowserDelegateMethods) class description * NSNetServiceBrowserDelegate protocol description
* </heading> * </heading>
* <p> * <p>
* <!-- Foreword --> * <!-- Foreword -->
@ -364,12 +377,18 @@ GS_EXPORT NSString * const NSNetServicesErrorDomain;
* </p> * </p>
* </unit> * </unit>
* <p> * <p>
* This informal protocol must be adopted by any class wishing to implement * This protocol must be adopted by any class wishing to implement
* an [NSNetServiceBrowser] delegate. * an [NSNetServiceBrowser] delegate.
* </p> * </p>
*/ */
@protocol NSNetServiceBrowserDelegate
#ifdef __clang__
@optional
#else
@end
@interface NSObject (NSNetServiceBrowserDelegateMethods) @interface NSObject (NSNetServiceBrowserDelegateMethods)
#endif
/** /**
* Notifies the delegate that the search is about to begin. * Notifies the delegate that the search is about to begin.

View file

@ -155,12 +155,12 @@ static Class concreteBrowserClass;
} }
- (id) delegate - (id<NSNetServiceDelegate>) delegate
{ {
return _delegate; return _delegate;
} }
- (void) setDelegate: (id) delegate - (void) setDelegate: (id<NSNetServiceDelegate>) delegate
{ {
_delegate = delegate; _delegate = delegate;
} }
@ -449,12 +449,12 @@ static Class concreteBrowserClass;
} }
- (id) delegate - (id<NSNetServiceBrowserDelegate>) delegate
{ {
return _delegate; return _delegate;
} }
- (void) setDelegate: (id) delegate - (void) setDelegate: (id<NSNetServiceBrowserDelegate>) delegate
{ {
_delegate = delegate; _delegate = delegate;
} }