Various minor modifications.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@8245 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-12-02 11:47:30 +00:00
parent 7961c760c9
commit a1d9d92494
5 changed files with 121 additions and 84 deletions

View file

@ -1,3 +1,11 @@
2000-12-02 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSDate.m: GSTime() added millisecond info.
* Source/NSCalendarDate.m: GSTime() added millisecond info.
* Headers/Foundation/NSDate.h: GSTime() added millisecond info.
* Source/NSObject.m: key-value-coding restructured to simplify
future implementation for non-object values.
2000-11-30 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSCalendarDate.m: ([-initWithString:calendarFormat:locale:])

View file

@ -107,7 +107,7 @@ typedef double NSTimeInterval;
@end
NSTimeInterval GSTimeNow(); /* Get time since reference date*/
NSTimeInterval GSTime(int day, int mon, int year, int hour, int min, int sec);
NSTimeInterval GSTime(int d, int m, int y, int hh, int mm, int ss, int mil);
#endif

View file

@ -86,7 +86,7 @@ absoluteGregorianDay(int day, int month, int year)
* External - so NSDate can use it.
*/
NSTimeInterval
GSTime(int day, int month, int year, int h, int m, int s)
GSTime(int day, int month, int year, int h, int m, int s, int mil)
{
NSTimeInterval a;
@ -98,6 +98,7 @@ GSTime(int day, int month, int year, int h, int m, int s)
a += h * 3600;
a += m * 60;
a += s;
a += mil/1000.0;
return a;
}
@ -932,7 +933,7 @@ static inline int getDigits(const char *from, char *to, int limit)
NSTimeInterval s;
// Calculate date as GMT
s = GSTime(day, month, year, hour, minute, second);
s = GSTime(day, month, year, hour, minute, second, 0);
// Assign time zone detail
_time_zone = RETAIN([aTimeZone

View file

@ -147,8 +147,8 @@ GSTimeNow()
* Get current GMT time, convert to NSTimeInterval since reference date,
*/
GetSystemTime(&sys_time);
t = GSTime(sys_time.wDay, sys_time.wMonth, sys_time.wYear,
sys_time.wHour, sys_time.wMinute, sys_time.wSecond);
t = GSTime(sys_time.wDay, sys_time.wMonth, sys_time.wYear, sys_time.wHour,
sys_time.wMinute, sys_time.wSecond, sys_time.wMilliseconds);
#endif
return t + sys_time.wMilliseconds / 1000.0;
#endif /* __MINGW__ */

View file

@ -1375,7 +1375,9 @@ static BOOL deallocNotifications = NO;
- (void) takeStoredValue: (id)anObject forKey: (NSString*)aKey
{
SEL sel;
SEL sel = 0;
const char *type = 0;
NSString *name;
if ([[self class] useStoredAccessor] == NO)
{
@ -1383,73 +1385,88 @@ static BOOL deallocNotifications = NO;
return;
}
sel = NSSelectorFromString([NSString stringWithFormat: @"_set%@:",
[aKey capitalizedString]]);
if ([self respondsToSelector: sel] == YES)
name = [NSString stringWithFormat: @"_set%@:", [aKey capitalizedString]];
sel = NSSelectorFromString(name);
if ([self respondsToSelector: sel] == NO)
{
[self performSelector: sel withObject: anObject];
return;
}
sel = 0;
if ([[self class] accessInstanceVariablesDirectly] == YES)
{
if (GSSetInstanceVariable(self, [NSString stringWithFormat: @"_%@", aKey],
(void*)&anObject) == YES)
name = [NSString stringWithFormat: @"_%@", aKey];
type = GSInstanceVariableType(self, name);
if (type == 0)
{
return;
name = aKey;
type = GSInstanceVariableType(self, name);
}
if (GSSetInstanceVariable(self, aKey, (void*)&anObject) == YES)
}
if (type == 0)
{
return;
name = [NSString stringWithFormat: @"set%@:",
[aKey capitalizedString]];
sel = NSSelectorFromString(name);
if ([self respondsToSelector: sel] == NO)
{
sel = 0;
}
}
}
sel = NSSelectorFromString([NSString stringWithFormat: @"set%@:",
[aKey capitalizedString]]);
if ([self respondsToSelector: sel] == YES)
if (sel != 0)
{
[self performSelector: sel withObject: anObject];
return;
}
else if (type != 0)
{
GSSetInstanceVariable(self, name, (void*)&anObject);
}
else
{
[self handleTakeValue: anObject forUnboundKey: aKey];
}
}
- (void) takeValue: (id)anObject forKey: (NSString*)aKey
{
SEL sel;
SEL sel = 0;
const char *type = 0;
NSString *name = nil;
sel = NSSelectorFromString([NSString stringWithFormat: @"set%@:",
[aKey capitalizedString]]);
if ([self respondsToSelector: sel] == YES)
name = [NSString stringWithFormat: @"set%@:", [aKey capitalizedString]];
sel = NSSelectorFromString(name);
if ([self respondsToSelector: sel] == NO)
{
[self performSelector: sel withObject: anObject];
return;
}
sel = NSSelectorFromString([NSString stringWithFormat: @"_set%@:",
[aKey capitalizedString]]);
if ([self respondsToSelector: sel] == YES)
name = [NSString stringWithFormat: @"_set%@:", [aKey capitalizedString]];
sel = NSSelectorFromString(name);
if ([self respondsToSelector: sel] == NO)
{
[self performSelector: sel withObject: anObject];
return;
}
sel = 0;
if ([[self class] accessInstanceVariablesDirectly] == YES)
{
if (GSSetInstanceVariable(self, [NSString stringWithFormat: @"_%@", aKey],
(void*)&anObject) == YES)
name = [NSString stringWithFormat: @"_%@", aKey];
type = GSInstanceVariableType(self, name);
if (type == 0)
{
return;
name = aKey;
type = GSInstanceVariableType(self, name);
}
}
if (GSSetInstanceVariable(self, aKey, (void*)&anObject) == YES)
{
return;
}
}
if (sel != 0)
{
[self performSelector: sel withObject: anObject];
}
else if (type != 0)
{
GSSetInstanceVariable(self, name, (void*)&anObject);
}
else
{
[self handleTakeValue: anObject forUnboundKey: aKey];
}
}
- (void) takeValue: (id)anObject forKeyPath: (NSString*)aKey
{
@ -1494,50 +1511,61 @@ static BOOL deallocNotifications = NO;
- (id) valueForKey: (NSString*)aKey
{
SEL sel;
SEL sel = 0;
NSString *name = nil;
const char *type = 0;
sel = NSSelectorFromString([NSString stringWithFormat: @"get%@",
[aKey capitalizedString]]);
if ([self respondsToSelector: sel] == YES)
name = [NSString stringWithFormat: @"get%@", [aKey capitalizedString]];
sel = NSSelectorFromString(name);
if ([self respondsToSelector: sel] == NO)
{
return [self performSelector: sel];
name = aKey;
sel = NSSelectorFromString(name);
if ([self respondsToSelector: sel] == NO)
{
name = [NSString stringWithFormat: @"_get%@",
[aKey capitalizedString]];
sel = NSSelectorFromString(name);
if ([self respondsToSelector: sel] == NO)
{
name = [NSString stringWithFormat: @"_%@", aKey];
sel = NSSelectorFromString(name);
if ([self respondsToSelector: sel] == NO)
{
sel = 0;
}
}
}
sel = NSSelectorFromString(aKey);
if ([self respondsToSelector: sel] == YES)
{
return [self performSelector: sel];
}
sel = NSSelectorFromString([NSString stringWithFormat: @"_get%@",
[aKey capitalizedString]]);
if ([self respondsToSelector: sel] == YES)
if (sel == 0 && [[self class] accessInstanceVariablesDirectly] == YES)
{
return [self performSelector: sel];
name = [NSString stringWithFormat: @"_%@", aKey];
type = GSInstanceVariableType(self, name);
if (type == 0)
{
name = aKey;
type = GSInstanceVariableType(self, name);
}
sel = NSSelectorFromString([NSString stringWithFormat: @"_%@", aKey]);
if ([self respondsToSelector: sel] == YES)
{
return [self performSelector: sel];
}
if ([[self class] accessInstanceVariablesDirectly] == YES)
if (sel != 0)
{
return [self performSelector: sel];
}
else if (type != 0)
{
id v;
if (GSGetInstanceVariable(self, [NSString stringWithFormat: @"_%@", aKey],
(void*)&v) == YES)
{
GSGetInstanceVariable(self, name, (void*)&v);
return v;
}
if (GSGetInstanceVariable(self, aKey, (void*)&v) == YES)
else
{
return v;
}
}
[self handleTakeValue: nil forUnboundKey: aKey];
return nil;
}
}
- (id) valueForKeyPath: (NSString*)aKey
{