* EOControl/EOClassDescription.m

(-dictionaryForInstanceProperties): Remove casts.
        ([NSObject-shallowCopy], [NSObject-snapshot])
        ([NSObject-updateFromSnapshot:]): Ditto.
        ([NSObject-validateValue:forKey:]): Correct key determination and
        use GSSelectorFromName instead of sel_get_any_uid.
        ([NSObject-addObject:toPropertyWithKey:]): Use GSSelectorFromName
        instead of sel_get_any_uid.  Minor optimization.
        ([NSObject-removeObject:fromPropertyWithKey:]): Ditto.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20711 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Ayers 2005-02-14 14:24:46 +00:00
parent 985f02b360
commit 2d006a1535
2 changed files with 36 additions and 30 deletions

View file

@ -6,6 +6,15 @@
and only initialize instance variable if call to super init was and only initialize instance variable if call to super init was
successfull. successfull.
(-shallowCopy): Correct signature. (-shallowCopy): Correct signature.
* EOControl/EOClassDescription.m
(-dictionaryForInstanceProperties): Remove casts.
([NSObject-shallowCopy], [NSObject-snapshot])
([NSObject-updateFromSnapshot:]): Ditto.
([NSObject-validateValue:forKey:]): Correct key determination and
use GSSelectorFromName instead of sel_get_any_uid.
([NSObject-addObject:toPropertyWithKey:]): Use GSSelectorFromName
instead of sel_get_any_uid. Minor optimization.
([NSObject-removeObject:fromPropertyWithKey:]): Ditto.
2005-02-13 Manuel Guesdon <mguesdon@orange-concept.com> 2005-02-13 Manuel Guesdon <mguesdon@orange-concept.com>
* EOControl/EOClassDescription.m: * EOControl/EOClassDescription.m:

View file

@ -271,7 +271,7 @@ static NSRecursiveLock *local_lock = nil;
} }
/** returns a new autoreleased mutable dictionary to store properties **/ /** returns a new autoreleased mutable dictionary to store properties **/
- (NSMutableDictionary*) dictionaryForInstanceProperties - (NSMutableDictionary *)dictionaryForInstanceProperties
{ {
// Default implementation create a new EOMKKDInitializer. But subclass // Default implementation create a new EOMKKDInitializer. But subclass
// implementation like EOEntityClassDescription can (should :-) use the // implementation like EOEntityClassDescription can (should :-) use the
@ -283,7 +283,7 @@ static NSRecursiveLock *local_lock = nil;
EOFLOGObjectFnStart(); EOFLOGObjectFnStart();
// Get class properties (attributes + relationships) // Get class properties (attributes + relationships)
classPropertyNames = [((NSMutableArray*)[NSMutableArray alloc]) classPropertyNames = [[NSMutableArray alloc]
initWithArray: [self attributeKeys]]; initWithArray: [self attributeKeys]];
[classPropertyNames addObjectsFromArray: [classPropertyNames addObjectsFromArray:
[self toOneRelationshipKeys]]; [self toOneRelationshipKeys]];
@ -951,20 +951,23 @@ fromInsertionInEditingContext: (EOEditingContext *)anEditingContext
} }
else else
{ {
SEL validateSelector=NULL; SEL validateSelector;
char buf[size+8]; // 8 characters for validate unsigned length = [key length];
strcpy(buf, "validate"); unsigned char buf[length + 10];
[key getCString: &buf[8]];
if (islower(buf[8]))
buf[8]=toupper(buf[8]);
validateSelector = sel_get_any_uid(buf);
strcpy(buf, "validate");
[key getCString: &buf[8]];
buf[8] = toupper(buf[8]);
buf[length + 8] = ':';
buf[length + 9] = 0;
validateSelector = GSSelectorFromName(buf);
if (validateSelector && [self respondsToSelector: validateSelector]) if (validateSelector && [self respondsToSelector: validateSelector])
exception = [self performSelector: validateSelector {
withObject: *valueP]; exception = [self performSelector: validateSelector
}; withObject: *valueP];
}
}
} }
EOFLOGObjectFnStop(); EOFLOGObjectFnStop();
@ -1085,7 +1088,7 @@ fromInsertionInEditingContext: (EOEditingContext *)anEditingContext
- (NSArray *)shallowCopy - (NSArray *)shallowCopy
{ {
return [((NSMutableArray*)[NSArray alloc]) initWithArray: self]; return [[NSArray alloc] initWithArray: self];
} }
@end @end
@ -1193,7 +1196,7 @@ fromInsertionInEditingContext: (EOEditingContext *)anEditingContext
NSDebugMLLog(@"gsdb", @"TOMANY snap=%p key=%@ ==> value %p=%@", NSDebugMLLog(@"gsdb", @"TOMANY snap=%p key=%@ ==> value %p=%@",
snapshot, key, value, value); snapshot, key, value, value);
value = AUTORELEASE([((NSArray*)value) shallowCopy]); value = AUTORELEASE([value shallowCopy]);
NSDebugMLLog(@"gsdb", @"TOMANY snap=%p key=%@ ==> value %p=%@", NSDebugMLLog(@"gsdb", @"TOMANY snap=%p key=%@ ==> value %p=%@",
snapshot, key, value, value); snapshot, key, value, value);
@ -1236,7 +1239,7 @@ fromInsertionInEditingContext: (EOEditingContext *)anEditingContext
val = nil; val = nil;
if ([val isKindOfClass: GDL2NSArrayClass]) if ([val isKindOfClass: GDL2NSArrayClass])
val = AUTORELEASE([AUTORELEASE([((NSArray*)val) shallowCopy]) mutableCopy]); val = AUTORELEASE([val mutableCopy]);
GDL2TakeStoredValueForKeyWithImpPtr(self,&selfTSVFK,val,key); GDL2TakeStoredValueForKeyWithImpPtr(self,&selfTSVFK,val,key);
} }
@ -1410,8 +1413,6 @@ toPropertyWithKey: (NSString *)key
else else
{ {
char buf[size+7]; char buf[size+7];
char lo;
char hi;
GDL2IMP_BOOL rtsIMP=NULL; GDL2IMP_BOOL rtsIMP=NULL;
SEL sel=NULL; SEL sel=NULL;
@ -1419,16 +1420,15 @@ toPropertyWithKey: (NSString *)key
strcpy(buf, "addTo"); strcpy(buf, "addTo");
[key getCString: &buf[5]]; [key getCString: &buf[5]];
lo = buf[5]; buf[5] = toupper(buf[5]);
hi = islower(lo) ? toupper(lo) : lo;
buf[5] = hi;
buf[size+5] = ':'; buf[size+5] = ':';
buf[size+6] = '\0'; buf[size+6] = '\0';
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"A aKey=%@ Method [addToKey:] name=%s", EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
@"A aKey=%@ Method [addToKey:] name=%s",
key, buf); key, buf);
sel = sel_get_any_uid(buf); sel = GSSelectorFromName(buf);
if (sel && GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == YES) if (sel && GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == YES)
{ {
@ -1526,8 +1526,6 @@ toPropertyWithKey: (NSString *)key
else else
{ {
char buf[size+12]; char buf[size+12];
char lo;
char hi;
GDL2IMP_BOOL rtsIMP=NULL; GDL2IMP_BOOL rtsIMP=NULL;
SEL sel=NULL; SEL sel=NULL;
@ -1535,16 +1533,15 @@ toPropertyWithKey: (NSString *)key
strcpy(buf, "removeFrom"); strcpy(buf, "removeFrom");
[key getCString: &buf[10]]; [key getCString: &buf[10]];
lo = buf[10]; buf[10] = toupper(buf[10]);
hi = islower(lo) ? toupper(lo) : lo;
buf[10] = hi;
buf[size+10] = ':'; buf[size+10] = ':';
buf[size+11] = '\0'; buf[size+11] = '\0';
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"A aKey=%@ Method [removeFromKey:] name=%s", EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
@"A aKey=%@ Method [removeFromKey:] name=%s",
key, buf); key, buf);
sel = sel_get_any_uid(buf); sel = GSSelectorFromName(buf);
if (sel && GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == YES) if (sel && GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == YES)
{ {