Move method declarations on blocks from EtoileFoundation into GNUstep.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32376 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Chisnall 2011-02-26 13:10:49 +00:00
parent 0241a4347b
commit a139de7bcb
2 changed files with 49 additions and 0 deletions

View file

@ -149,6 +149,7 @@ BASE_MFILES = \
CXXException.m\
GSArray.m \
GSAttributedString.m \
GSBlocks.m \
GSConcreteValue.m \
GSCountedSet.m \
GSDictionary.m \

48
Source/GSBlocks.m Normal file
View file

@ -0,0 +1,48 @@
#import <Foundation/NSObject.h>
// 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 *);
@interface GSBlock : NSObject
@end
@implementation GSBlock
+ (void)load
{
unsigned int methodCount;
Method *methods =
class_copyMethodList(self, &methodCount);
id blockClass = objc_lookUpClass("_NSBlock");
// 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 (Method *m = methods ; NULL!=*m ; m++)
{
class_addMethod(blockClass, method_getName(*m),
method_getImplementation(*m), method_getTypeEncoding(*m));
}
}
- (id)copyWithZone: (NSZone*)aZone
{
return Block_copy(self);
}
- (id)copy
{
return Block_copy(self);
}
- (id)retain
{
return Block_copy(self);
}
- (void)release
{
Block_release(self);
}
@end