* EOControl/EONSAddOns.h/m

(GDL2_ActivateCategory, GDL2_ActivateAllGDL2Categories)
	(GDL2_DumpMethodList): New functions.

	* EOControl/EOKeyValueCoding.m
	(initialize): Make order of initialization more thread safe.
	(NilToNull): Remove helper class.
	([NSObject -unableToSetNilForKey:]): Implement.
	([NSObject -GDL2KVCNSObjectICategoryID]): New method.
	([NSObject +load]): Ditto.
	([NSDictionary -GDL2KVCNSDictionaryICategoryID]): Ditto.
	([NSDictionary +load]): Ditto.
	([NSMutableDictionary -GDL2KVCNSDictionaryICategoryID]):
	Ditto.
	([NSMutableDictionary +load]): Ditto.

	* EOControl/EOClassDescription.m
	([NSObject -GDL2CDNSObjectICategoryID]): New method.
	([NSObject +load]): New method.
	([NSObject -validateValue:forKey:]) Introduce temporary
	variable
	to allow correct formatting.
	([NSObject -snapshot]): Reformat log string.
	([NSObject -addObject], [NSObject -removeObject])
	([NSObject _setObject], [NSObject -editingContext]): Reformat.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@19760 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Ayers 2004-07-21 19:01:48 +00:00
parent 933ca098f5
commit c76a86efad
5 changed files with 153 additions and 60 deletions

View file

@ -1,3 +1,29 @@
2004-06-21 David Ayers <d.ayers@inode.at>
* EOControl/EONSAddOns.h/m
(GDL2_ActivateCategory, GDL2_ActivateAllGDL2Categories)
(GDL2_DumpMethodList): New functions.
* EOControl/EOKeyValueCoding.m
(initialize): Make order of initialization more thread safe.
(NilToNull): Remove helper class.
([NSObject -unableToSetNilForKey:]): Implement.
([NSObject -GDL2KVCNSObjectICategoryID]): New method.
([NSObject +load]): Ditto.
([NSDictionary -GDL2KVCNSDictionaryICategoryID]): Ditto.
([NSDictionary +load]): Ditto.
([NSMutableDictionary -GDL2KVCNSDictionaryICategoryID]): Ditto.
([NSMutableDictionary +load]): Ditto.
* EOControl/EOClassDescription.m
([NSObject -GDL2CDNSObjectICategoryID]): New method.
([NSObject +load]): New method.
([NSObject -validateValue:forKey:]) Introduce temporary variable
to allow correct formatting.
([NSObject -snapshot]): Reformat log string.
([NSObject -addObject], [NSObject -removeObject])
([NSObject _setObject], [NSObject -editingContext]): Reformat.
2004-06-04 Simon Stapelton <simon@tufty.co.uk> 2004-06-04 Simon Stapelton <simon@tufty.co.uk>
* EOControl/EOAndQualifier.m, * EOControl/EOAndQualifier.m,

View file

@ -711,6 +711,16 @@ fromInsertionInEditingContext: (EOEditingContext *)anEditingContext
@implementation NSObject (EOClassDescriptionPrimitives) @implementation NSObject (EOClassDescriptionPrimitives)
- (void)GDL2CDNSObjectICategoryID
{
}
+ (void)load
{
GDL2_ActivateCategory("NSObject",
@selector(GDL2CDNSObjectICategoryID), YES);
}
// when you enable the NSDebugMLLogs here you will have a loop. dave // when you enable the NSDebugMLLogs here you will have a loop. dave
- (EOClassDescription *)classDescription - (EOClassDescription *)classDescription
{ {
@ -891,13 +901,15 @@ fromInsertionInEditingContext: (EOEditingContext *)anEditingContext
forKey: key]; forKey: key];
if (exception) if (exception)
{ {
NSDictionary *userInfo
= [NSDictionary dictionaryWithObjectsAndKeys:
self, @"EOValidatedObjectUserInfoKey",
key, @"EOValidatedPropertyUserInfoKey",
nil];
exception = [NSException exceptionWithName: [exception name] exception = [NSException exceptionWithName: [exception name]
reason: [exception reason] reason: [exception reason]
userInfo: [NSDictionary userInfo: userInfo];
dictionaryWithObjectsAndKeys:
self, @"EOValidatedObjectUserInfoKey",
key, @"EOValidatedPropertyUserInfoKey",
nil, nil]];
} }
if (exception == nil) if (exception == nil)
@ -1065,7 +1077,8 @@ fromInsertionInEditingContext: (EOEditingContext *)anEditingContext
toOneRelationshipKeyCount = [toOneRelationshipKeys count]; toOneRelationshipKeyCount = [toOneRelationshipKeys count];
toManyRelationshipKeyCount = [toManyRelationshipKeys count]; toManyRelationshipKeyCount = [toManyRelationshipKeys count];
NSDebugMLLog(@"gsdb", @"attributeKeyCount=%d toOneRelationshipKeyCount=%d toManyRelationshipKeyCount=%d", NSDebugMLLog(@"gsdb", @"attributeKeyCount=%d toOneRelationshipKeyCount=%d "
@"toManyRelationshipKeyCount=%d",
attributeKeyCount, toOneRelationshipKeyCount, attributeKeyCount, toOneRelationshipKeyCount,
toManyRelationshipKeyCount); toManyRelationshipKeyCount);
@ -1289,7 +1302,7 @@ fromInsertionInEditingContext: (EOEditingContext *)anEditingContext
@implementation NSObject (EOKeyRelationshipManipulation) @implementation NSObject (EOKeyRelationshipManipulation)
- (void)addObject: object - (void)addObject: (id)object
toPropertyWithKey: (NSString *)key toPropertyWithKey: (NSString *)key
{ {
const char *str = NULL; const char *str = NULL;
@ -1389,7 +1402,7 @@ toPropertyWithKey: (NSString *)key
EOFLOGObjectFnStop(); EOFLOGObjectFnStop();
} }
- (void)removeObject: object - (void)removeObject: (id)object
fromPropertyWithKey: (NSString *)key fromPropertyWithKey: (NSString *)key
{ {
//self valueForKey: //self valueForKey:
@ -1479,7 +1492,7 @@ toPropertyWithKey: (NSString *)key
EOFLOGObjectFnStop(); EOFLOGObjectFnStop();
} }
-(void)_setObject: (id)object - (void)_setObject: (id)object
forBothSidesOfRelationshipWithKey: (NSString*)key forBothSidesOfRelationshipWithKey: (NSString*)key
{ {
//Near OK //Near OK
@ -1819,7 +1832,7 @@ fromBothSidesOfRelationshipWithKey: (NSString *)key
@implementation NSObject (_EOEditingContext) @implementation NSObject (_EOEditingContext)
-(EOEditingContext*)editingContext - (EOEditingContext*)editingContext
{ {
return [EOObserverCenter observerForObject: self return [EOObserverCenter observerForObject: self
ofClass: [EOEditingContext class]]; ofClass: [EOEditingContext class]];

View file

@ -80,9 +80,9 @@ initialize(void)
{ {
if (null == nil) if (null == nil)
{ {
null = [EONull null];
oaiSel = @selector(objectAtIndex:); oaiSel = @selector(objectAtIndex:);
strictWO = GSUseStrictWO451Compatibility(nil); strictWO = GSUseStrictWO451Compatibility(nil);
null = [EONull null];
} }
} }
@ -90,64 +90,24 @@ initialize(void)
of efficiency, we don't use the do {} while (0) pattern. */ of efficiency, we don't use the do {} while (0) pattern. */
#define INITIALIZE if (null == nil) initialize(); #define INITIALIZE if (null == nil) initialize();
/*
* This dummy class exists to provide a replacement implementation for @implementation NSObject (_EOKeyValueCodingCompatibility)
* NSObject -unableToSetNilForKey:, which calls -unableToSetNullForKey:
* as defined in WO4.5. We need this mechanism as a category cannot - (void)GDL2KVCNSObjectICategoryID
* reliably override the category in gnustep-base or Foundation. {
*/ }
@interface NilToNull : NSObject
@end
@interface NilToNull (SurrpressWarning)
- (void) unableToSetNullForKey: (NSString *)key;
@end
@implementation NilToNull
+ (void)load + (void)load
{ {
Class cls; GDL2_ActivateCategory("NSObject",
SEL sel; @selector(GDL2KVCNSObjectICategoryID), YES);
IMP imp;
GSMethod method;
imp = NULL;
sel = @selector(unableToSetNilForKey:);
cls = GSClassFromName("NSObject");
method = GSGetInstanceMethodNotInherited(self, sel);
if (method != METHOD_NULL)
{
imp = method->method_imp;
}
else
{
fprintf(stderr,
"%s: Could not find method unableToSetNilForKey: in NilToNil!\n",
__FILE__);
abort();
}
method = GSGetInstanceMethodNotInherited(cls, sel);
if (method != METHOD_NULL)
{
method->method_imp = imp;
}
else
{
fprintf(stderr,
"%s: Could not find method unableToSetNilForKey: in NSObject!\n",
__FILE__);
abort();
}
GSFlushMethodCacheForClass(cls);
} }
- (void) unableToSetNilForKey: (NSString *)key - (void) unableToSetNilForKey: (NSString *)key
{ {
[self unableToSetNullForKey: key]; [self unableToSetNullForKey: key];
} }
@end
@implementation NSObject (_EOKeyValueCodingCompatibility)
/* See EODeprecated.h. */ /* See EODeprecated.h. */
+ (void) flushClassKeyBindings + (void) flushClassKeyBindings
{ {
@ -184,6 +144,16 @@ initialize(void)
@implementation NSArray (EOKeyValueCoding) @implementation NSArray (EOKeyValueCoding)
- (void)GDL2KVCNSArrayICategoryID
{
}
+ (void)load
{
GDL2_ActivateCategory("NSArray",
@selector(GDL2KVCNSArrayICategoryID), YES);
}
/** /**
* EOKeyValueCoding protocol<br/> * EOKeyValueCoding protocol<br/>
* This overrides NSObjects implementation of this method. * This overrides NSObjects implementation of this method.
@ -497,6 +467,16 @@ initialize(void)
@implementation NSDictionary (EOKeyValueCoding) @implementation NSDictionary (EOKeyValueCoding)
- (void)GDL2KVCNSDictionaryICategoryID
{
}
+ (void)load
{
GDL2_ActivateCategory("NSDictionary",
@selector(GDL2KVCNSDictionaryICategoryID), YES);
}
/** /**
* Returns the object stored in the dictionary for this key. * Returns the object stored in the dictionary for this key.
* Unlike Foundation, this method may return objects for keys other than * Unlike Foundation, this method may return objects for keys other than
@ -795,6 +775,16 @@ initialize(void)
@implementation NSMutableDictionary (EOKVCGNUstepExtensions) @implementation NSMutableDictionary (EOKVCGNUstepExtensions)
- (void)GDL2KVCNSMutableDictionaryICategoryID
{
}
+ (void)load
{
GDL2_ActivateCategory("NSMutableDictionary",
@selector(GDL2KVCNSMutableDictionaryICategoryID), YES);
}
/** /**
* Method to augment the NSKeyValueCoding implementation * Method to augment the NSKeyValueCoding implementation
* to account for added functionality such as quoted key paths. * to account for added functionality such as quoted key paths.

View file

@ -46,9 +46,17 @@
: ( TYPE *)GSAutoreleasedBuffer((ID##_size) * sizeof( TYPE )); \ : ( TYPE *)GSAutoreleasedBuffer((ID##_size) * sizeof( TYPE )); \
TYPE *ID = ID##_base; TYPE *ID = ID##_base;
GDL2CONTROL_EXPORT BOOL GDL2CONTROL_EXPORT BOOL
GSUseStrictWO451Compatibility(NSString *key); GSUseStrictWO451Compatibility(NSString *key);
GDL2CONTROL_EXPORT void
GDL2_ActivateCategory(const char *className, SEL sel, BOOL isInstance);
GDL2CONTROL_EXPORT void
GDL2_ActivateAllGDL2Categories(void);
@interface NSObject (NSObjectPerformingSelector) @interface NSObject (NSObjectPerformingSelector)
- (NSArray *)resultsOfPerformingSelector: (SEL)sel - (NSArray *)resultsOfPerformingSelector: (SEL)sel
withEachObjectInArray: (NSArray *)array; withEachObjectInArray: (NSArray *)array;

View file

@ -90,6 +90,62 @@ GSUseStrictWO451Compatibility (NSString *key)
return GSStrictWO451Flag; return GSStrictWO451Flag;
} }
void
GDL2_DumpMethodList(Class cls, SEL sel, BOOL isInstance)
{
void *iterator = 0;
GSMethodList mList;
fprintf(stderr,"List for :%s %s (inst:%d)\n",
GSNameFromClass(cls), GSNameFromSelector(sel), isInstance);
while ((mList = GSMethodListForSelector(cls, sel,
&iterator, isInstance)))
{
GSMethod meth = GSMethodFromList(mList, sel, NO);
IMP imp = meth->method_imp;
fprintf(stderr,"List: %p Meth: %p Imp: %p\n",
mList, meth, imp);
}
fprintf(stderr,"List finished\n"); fflush(stderr);
}
void
GDL2_ActivateCategory(const char *className, SEL sel, BOOL isInstance)
{
Class cls;
GSMethodList mList;
cls = GSClassFromName(className);
mList = GSMethodListForSelector(cls, sel, 0, isInstance);
GSRemoveMethodList(cls, mList, isInstance);
GSAddMethodList(cls, mList, isInstance);
GSFlushMethodCacheForClass(cls);
}
void
GDL2_ActivateAllGDL2Categories(void)
{
/* EOKeyValueCoding */
GDL2_ActivateCategory("NSObject",
@selector(GDL2KVCNSObjectICategoryID), YES);
GDL2_ActivateCategory("NSArray",
@selector(GDL2KVCNSArrayICategoryID), YES);
GDL2_ActivateCategory("NSDictionary",
@selector(GDL2KVCNSDictionaryICategoryID), YES);
GDL2_ActivateCategory("NSMutableDictionary",
@selector(GDL2KVCNSMutableDictionaryICategoryID), YES);
/* EOClassDescription */
GDL2_ActivateCategory("NSObject",
@selector(GDL2CDNSObjectICategoryID), YES);
}
@implementation NSObject (NSObjectPerformingSelector) @implementation NSObject (NSObjectPerformingSelector)
- (NSArray*)resultsOfPerformingSelector: (SEL)sel - (NSArray*)resultsOfPerformingSelector: (SEL)sel