mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Added call to objc_create_block_classes_as_subclasses_of() in NSObject's +load method. This is called as soon as NSObject is loaded and creates the _NSBlock family of classes, which are statically allocated in the runtime but not statically initialised. If you create blocks without linking GNUstep-base, the isa pointer in the block will point to a class that has all of its fields set to 0.
Any blocks will have their isa pointer set to the two classes statically allocated in libobjc, but these classes can't be used for message lookup (or introspection) until after the call. This means that you can't send messages to blocks until after NSObject's +load method has been called. This shouldn't be a problem in most code, but if you use __attribute__((constructor)) instead of a +load method then be careful about sending messages to blocks (you can still call them as normal). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29144 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e96f74362f
commit
c19a717b67
2 changed files with 21 additions and 2 deletions
|
@ -1,3 +1,7 @@
|
|||
2009-12-20 David Chisnall <theraven@gna.org>
|
||||
|
||||
* Source/NSObject.m: Set block superclass.
|
||||
|
||||
2009-12-19 13:53-EST Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/GNUmakefile: Add synchronization.m to GNU_MFILES
|
||||
|
|
|
@ -892,6 +892,21 @@ GSGarbageCollectorLog(char *msg, GC_word arg)
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Semi-private function in libobjc2 that initialises the classes used for
|
||||
* blocks.
|
||||
*/
|
||||
BOOL
|
||||
objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
/* When NSObject is loaded, register it as the superclass of the block
|
||||
* classes */
|
||||
if (objc_create_block_classes_as_subclasses_of)
|
||||
objc_create_block_classes_as_subclasses_of(self);
|
||||
}
|
||||
|
||||
/**
|
||||
* This message is sent to a class once just before it is used for the first
|
||||
* time. If class has a superclass, its implementation of +initialize is
|
||||
|
@ -2450,9 +2465,9 @@ GSGarbageCollectorLog(char *msg, GC_word arg)
|
|||
|
||||
|
||||
@implementation NSZombie
|
||||
- (Class) class
|
||||
- (Class) originalClass
|
||||
{
|
||||
return object_get_class(self);
|
||||
return NSMapGet(zombieMap, (void*)self);
|
||||
}
|
||||
- (retval_t) forward:(SEL)aSel :(arglist_t)argFrame
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue