mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
fixup ugly coding stype to improve maintainability
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32384 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
74472f9089
commit
ed9082d7b0
1 changed files with 38 additions and 29 deletions
|
@ -1,7 +1,8 @@
|
|||
#import <Foundation/NSObject.h>
|
||||
|
||||
// Declare the block copy functions ourself so that we don't depend on a
|
||||
// specific header location.
|
||||
/* Declare the block copy functions ourself so that we don't depend on a
|
||||
* specific header location.
|
||||
*/
|
||||
void *_Block_copy(void *);
|
||||
void _Block_release(void *);
|
||||
|
||||
|
@ -9,44 +10,52 @@ void _Block_release(void *);
|
|||
@end
|
||||
|
||||
@implementation GSBlock
|
||||
+ (void)load
|
||||
+ (void) load
|
||||
{
|
||||
unsigned int methodCount;
|
||||
Method *m = NULL;
|
||||
Method *methods =
|
||||
class_copyMethodList(self, &methodCount);
|
||||
id blockClass = objc_lookUpClass("_NSBlock");
|
||||
Protocol *nscopying = NULL;
|
||||
unsigned int methodCount;
|
||||
Method *m = NULL;
|
||||
Method *methods = class_copyMethodList(self, &methodCount);
|
||||
id blockClass = objc_lookUpClass("_NSBlock");
|
||||
Protocol *nscopying = NULL;
|
||||
|
||||
// If we don't have an _NSBlock class, we don't have blocks support in the
|
||||
// runtime, so give up.
|
||||
if (nil == blockClass) { return; }
|
||||
/* If we don't have an _NSBlock class, we don't have blocks support in the
|
||||
* runtime, so give up.
|
||||
*/
|
||||
if (nil == blockClass)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy all of the methods in this class onto the block-runtime-provided
|
||||
// _NSBlock
|
||||
for (m = methods ; NULL!=*m ; m++)
|
||||
{
|
||||
class_addMethod(blockClass, method_getName(*m),
|
||||
method_getImplementation(*m), method_getTypeEncoding(*m));
|
||||
}
|
||||
nscopying = objc_getProtocol("NSCopying");
|
||||
class_addProtocol(blockClass, nscopying);
|
||||
/* Copy all of the methods in this class onto the block-runtime-provided
|
||||
* _NSBlock
|
||||
*/
|
||||
for (m = methods; NULL != *m; m++)
|
||||
{
|
||||
class_addMethod(blockClass, method_getName(*m),
|
||||
method_getImplementation(*m), method_getTypeEncoding(*m));
|
||||
}
|
||||
nscopying = objc_getProtocol("NSCopying");
|
||||
class_addProtocol(blockClass, nscopying);
|
||||
}
|
||||
- (id)copyWithZone: (NSZone*)aZone
|
||||
|
||||
- (id) copyWithZone: (NSZone*)aZone
|
||||
{
|
||||
return _Block_copy(self);
|
||||
return _Block_copy(self);
|
||||
}
|
||||
- (id)copy
|
||||
|
||||
- (id) copy
|
||||
{
|
||||
return _Block_copy(self);
|
||||
return _Block_copy(self);
|
||||
}
|
||||
- (id)retain
|
||||
|
||||
- (id) retain
|
||||
{
|
||||
return _Block_copy(self);
|
||||
return _Block_copy(self);
|
||||
}
|
||||
- (void)release
|
||||
|
||||
- (void) release
|
||||
{
|
||||
_Block_release(self);
|
||||
_Block_release(self);
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in a new issue