mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Reapply "Implement NSDate as a small object (tagged pointer) - clang/libobjc2 only (#451)" because of GUI breakage: apps hang when loading NSMenu
This reverts commit cac43f7bfc
.
This commit is contained in:
parent
dfc7781b26
commit
7a59450341
6 changed files with 710 additions and 315 deletions
17
ChangeLog
17
ChangeLog
|
@ -15,7 +15,22 @@
|
||||||
* Source/NSFileManager.m: Create an NSError object when we fail to
|
* Source/NSFileManager.m: Create an NSError object when we fail to
|
||||||
copy because the destination item already exists.
|
copy because the destination item already exists.
|
||||||
|
|
||||||
2024-09-23: Hugo Melder <hugo@algoriddim.com>
|
2024-10-10: Hugo Melder <hugo@algoriddim.com>
|
||||||
|
|
||||||
|
* Source/NSDate.m:
|
||||||
|
* Source/NSDatePrivate.h:
|
||||||
|
NSDate is now a small object in slot 6, when configuring GNUstep with the
|
||||||
|
clang/libobjc2 toolchain. This is done by compressing the binary64 fp
|
||||||
|
holding the seconds since reference date (because someone at Apple thought
|
||||||
|
it would be a good idea to represent a time interval as a fp). Note that
|
||||||
|
this assumes that IEEE 754 is used.
|
||||||
|
* Source/NSCalendarDate.m:
|
||||||
|
Remove access to the NSDate private concrete Class
|
||||||
|
and implement -timeIntervalSinceReferenceDate instead.
|
||||||
|
Previously, all methods of the concrete date class were
|
||||||
|
added to NSCalendarDate via GSObjCAddClassBehavior.
|
||||||
|
|
||||||
|
2024-23-09: Hugo Melder <hugo@algoriddim.com>
|
||||||
|
|
||||||
* Headers/Foundation/NSThread.h:
|
* Headers/Foundation/NSThread.h:
|
||||||
* Source/NSString.m:
|
* Source/NSString.m:
|
||||||
|
|
|
@ -58,9 +58,6 @@
|
||||||
@class GSAbsTimeZone;
|
@class GSAbsTimeZone;
|
||||||
@interface GSAbsTimeZone : NSObject // Help the compiler
|
@interface GSAbsTimeZone : NSObject // Help the compiler
|
||||||
@end
|
@end
|
||||||
@class NSGDate;
|
|
||||||
@interface NSGDate : NSObject // Help the compiler
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
#define DISTANT_FUTURE 63113990400.0
|
#define DISTANT_FUTURE 63113990400.0
|
||||||
|
@ -396,7 +393,6 @@ GSPrivateTimeNow(void)
|
||||||
absAbrIMP = (NSString* (*)(id,SEL,id))
|
absAbrIMP = (NSString* (*)(id,SEL,id))
|
||||||
[absClass instanceMethodForSelector: abrSEL];
|
[absClass instanceMethodForSelector: abrSEL];
|
||||||
|
|
||||||
GSObjCAddClassBehavior(self, [NSGDate class]);
|
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,6 +459,11 @@ GSPrivateTimeNow(void)
|
||||||
return AUTORELEASE(d);
|
return AUTORELEASE(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSTimeInterval) timeIntervalSinceReferenceDate
|
||||||
|
{
|
||||||
|
return _seconds_since_ref;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new NSCalendarDate object by taking the
|
* Creates and returns a new NSCalendarDate object by taking the
|
||||||
* value of the receiver and adding the interval in seconds specified.
|
* value of the receiver and adding the interval in seconds specified.
|
||||||
|
|
948
Source/NSDate.m
948
Source/NSDate.m
File diff suppressed because it is too large
Load diff
41
Source/NSDatePrivate.h
Normal file
41
Source/NSDatePrivate.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/** NSDate Private Interface
|
||||||
|
Copyright (C) 2024 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Written by: Hugo Melder <hugo@algoriddim.com>
|
||||||
|
|
||||||
|
This file is part of the GNUstep Base Library.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Foundation/NSDate.h>
|
||||||
|
|
||||||
|
#if defined(OBJC_SMALL_OBJECT_SHIFT) && (OBJC_SMALL_OBJECT_SHIFT == 3)
|
||||||
|
#define USE_SMALL_DATE 1
|
||||||
|
#define DATE_CONCRETE_CLASS_NAME GSSmallDate
|
||||||
|
#else
|
||||||
|
#define USE_SMALL_DATE 0
|
||||||
|
#define DATE_CONCRETE_CLASS_NAME NSGDate
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@interface DATE_CONCRETE_CLASS_NAME : NSDate
|
||||||
|
#if USE_SMALL_DATE == 0
|
||||||
|
{
|
||||||
|
@public
|
||||||
|
NSTimeInterval _seconds_since_ref;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@end
|
|
@ -35,9 +35,8 @@
|
||||||
#import "Foundation/NSRunLoop.h"
|
#import "Foundation/NSRunLoop.h"
|
||||||
#import "Foundation/NSInvocation.h"
|
#import "Foundation/NSInvocation.h"
|
||||||
|
|
||||||
@class NSGDate;
|
#import "NSDatePrivate.h"
|
||||||
@interface NSGDate : NSObject // Help the compiler
|
|
||||||
@end
|
|
||||||
static Class NSDate_class;
|
static Class NSDate_class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,7 +57,7 @@ static Class NSDate_class;
|
||||||
{
|
{
|
||||||
if (self == [NSTimer class])
|
if (self == [NSTimer class])
|
||||||
{
|
{
|
||||||
NSDate_class = [NSGDate class];
|
NSDate_class = [DATE_CONCRETE_CLASS_NAME class];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#ifdef EQ
|
#ifdef EQ
|
||||||
#undef EQ
|
#undef EQ
|
||||||
#endif
|
#endif
|
||||||
#define EPSILON (FLT_EPSILON*100)
|
#define EPSILON (DBL_EPSILON*100)
|
||||||
#define EQ(x,y) ((x >= y - EPSILON) && (x <= y + EPSILON))
|
#define EQ(x,y) ((x >= y - EPSILON) && (x <= y + EPSILON))
|
||||||
|
|
||||||
@interface MyHandler : NSObject
|
@interface MyHandler : NSObject
|
||||||
|
@ -204,6 +204,7 @@ int main()
|
||||||
NSTimeInterval ot, nt;
|
NSTimeInterval ot, nt;
|
||||||
ot = [[oa fileCreationDate] timeIntervalSinceReferenceDate];
|
ot = [[oa fileCreationDate] timeIntervalSinceReferenceDate];
|
||||||
nt = [[na fileCreationDate] timeIntervalSinceReferenceDate];
|
nt = [[na fileCreationDate] timeIntervalSinceReferenceDate];
|
||||||
|
NSLog(@"ot = %f, nt = %f", ot, nt);
|
||||||
PASS(EQ(ot, nt), "copy creation date equals original")
|
PASS(EQ(ot, nt), "copy creation date equals original")
|
||||||
ot = [[oa fileModificationDate] timeIntervalSinceReferenceDate];
|
ot = [[oa fileModificationDate] timeIntervalSinceReferenceDate];
|
||||||
nt = [[na fileModificationDate] timeIntervalSinceReferenceDate];
|
nt = [[na fileModificationDate] timeIntervalSinceReferenceDate];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue