mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Merge branch 'master' of github.com:gnustep/libs-base into NSSecureCoding_branch2
This commit is contained in:
commit
96f88dcc95
7 changed files with 55 additions and 32 deletions
|
@ -1,3 +1,8 @@
|
|||
2020-05-25 Frederik Seiffert <frederik@algoriddim.com>
|
||||
|
||||
* Source/NSUserDefaults.m:
|
||||
Store NSNumber instead of NSString for NSUserDefaults -setBool:forKey:.
|
||||
|
||||
2020-05-14 Frederik Seiffert <frederik@algoriddim.com>
|
||||
|
||||
* Headers/Foundation/NSException.h:
|
||||
|
|
|
@ -1140,7 +1140,7 @@ scalarSize(char type)
|
|||
return;
|
||||
case 4:
|
||||
*(int32_t*)address = (int32_t)big;
|
||||
if (big > 2147483647 || big < -2147483648)
|
||||
if (big > 2147483647 || big + 2147483648 < 0)
|
||||
{
|
||||
NSLog(@"Lost information converting decoded value to int32_t");
|
||||
}
|
||||
|
|
|
@ -860,14 +860,7 @@ unregisterActiveThread(NSThread *thread)
|
|||
{
|
||||
if (thread->_active == YES)
|
||||
{
|
||||
/*
|
||||
* Set the thread to be inactive to avoid any possibility of recursion.
|
||||
*/
|
||||
thread->_active = NO;
|
||||
thread->_finished = YES;
|
||||
|
||||
/*
|
||||
* Let observers know this thread is exiting.
|
||||
/* Let observers know this thread is exiting.
|
||||
*/
|
||||
if (nc == nil)
|
||||
{
|
||||
|
@ -877,6 +870,12 @@ unregisterActiveThread(NSThread *thread)
|
|||
object: thread
|
||||
userInfo: nil];
|
||||
|
||||
/* Set the thread to be finished *after* notification it will exit.
|
||||
* This is the order OSX 10.15.4 does it (May 2020).
|
||||
*/
|
||||
thread->_active = NO;
|
||||
thread->_finished = YES;
|
||||
|
||||
[(GSRunLoopThreadInfo*)thread->_runLoopInfo invalidate];
|
||||
RELEASE(thread);
|
||||
pthread_setspecific(thread_object_key, nil);
|
||||
|
|
|
@ -1398,7 +1398,7 @@ scalarSize(char type)
|
|||
return;
|
||||
case 4:
|
||||
*(int32_t*)address = (int32_t)big;
|
||||
if (big > 2147483647 || big + 2147483648 < 0 )
|
||||
if (big > 2147483647 || big + 2147483648 < 0)
|
||||
{
|
||||
NSLog(@"Lost information converting decoded value to int32_t");
|
||||
}
|
||||
|
|
|
@ -1420,14 +1420,9 @@ newLanguages(NSArray *oldNames)
|
|||
|
||||
- (void) setBool: (BOOL)value forKey: (NSString*)defaultName
|
||||
{
|
||||
if (value == YES)
|
||||
{
|
||||
[self setObject: @"YES" forKey: defaultName];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setObject: @"NO" forKey: defaultName];
|
||||
}
|
||||
NSNumber *n = [NSNumberClass numberWithBool: value];
|
||||
|
||||
[self setObject: n forKey: defaultName];
|
||||
}
|
||||
|
||||
- (void) setDouble: (double)value forKey: (NSString*)defaultName
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
BOOL deallocated;
|
||||
}
|
||||
|
||||
- (void)onThreadExit: (NSNotification*)n;
|
||||
- (BOOL)isDone;
|
||||
- (void) onThreadExit: (NSNotification*)n;
|
||||
- (BOOL) isDone;
|
||||
@end
|
||||
|
||||
@implementation ThreadExpectation
|
||||
|
||||
- (id)init
|
||||
- (id) init
|
||||
{
|
||||
if (nil == (self = [super init]))
|
||||
{
|
||||
|
@ -33,26 +33,36 @@
|
|||
|
||||
|
||||
|
||||
- (void)inThread: (NSThread*)thread
|
||||
- (void) inThread: (NSThread*)thread
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
/* We explicitly don't retain this so that we can check that it actually says
|
||||
* alive until the notification is sent. That check is implicit since
|
||||
* PASS_EQUAL in the -onThreadExit method will throw or crash if that isn't
|
||||
* the case.
|
||||
*/
|
||||
origThread = thread;
|
||||
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||
selector: @selector(onThreadExit:)
|
||||
name: NSThreadWillExitNotification
|
||||
object: thread];
|
||||
[nc addObserver: self
|
||||
selector: @selector(onThreadExit:)
|
||||
name: NSThreadWillExitNotification
|
||||
object: thread];
|
||||
}
|
||||
|
||||
- (void)onThreadExit: (NSNotification*)thr
|
||||
- (void) onThreadExit: (NSNotification*)thr
|
||||
{
|
||||
NSThread *current = [NSThread currentThread];
|
||||
NSThread *current = [NSThread currentThread];
|
||||
NSThread *passed = [thr object];
|
||||
|
||||
PASS_EQUAL(passed, origThread,
|
||||
"NSThreadWillExitNotification passes expected thread")
|
||||
PASS_EQUAL(origThread, current,
|
||||
"Correct thread reference can be obtained on exit")
|
||||
PASS([passed isExecuting],
|
||||
"exiting thread is still executing at point of notification")
|
||||
PASS(![passed isFinished],
|
||||
"exiting thread is not finished at point of notification")
|
||||
|
||||
PASS_EQUAL(origThread,current,
|
||||
"Correct thread reference can be obtained on exit");
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
origThread = nil;
|
||||
[condition lock];
|
||||
|
@ -61,7 +71,7 @@
|
|||
[condition unlock];
|
||||
}
|
||||
|
||||
- (BOOL)isDone
|
||||
- (BOOL) isDone
|
||||
{
|
||||
return done;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSNotification.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
#import "ObjectTesting.h"
|
||||
|
||||
@interface Observer : NSObject
|
||||
|
@ -40,27 +42,39 @@ int main()
|
|||
[defs setBool: YES forKey: @"Test Suite Bool"];
|
||||
PASS([defs boolForKey: @"Test Suite Bool"],
|
||||
"NSUserDefaults can set/get a BOOL");
|
||||
PASS([[defs objectForKey: @"Test Suite Bool"] isKindOfClass:[NSNumber class]],
|
||||
"NSUserDefaults returns NSNumber for a BOOL");
|
||||
|
||||
PASS_EQUAL([obs count], @"1", "setting a boolean causes notification");
|
||||
|
||||
[defs setInteger: 34 forKey: @"Test Suite Int"];
|
||||
PASS([defs integerForKey: @"Test Suite Int"] == 34,
|
||||
"NSUserDefaults can set/get an int");
|
||||
PASS([[defs objectForKey: @"Test Suite Int"] isKindOfClass:[NSNumber class]],
|
||||
"NSUserDefaults returns NSNumber for an int");
|
||||
|
||||
PASS_EQUAL([obs count], @"2", "setting an integer causes notification");
|
||||
|
||||
[defs setObject: @"SetString" forKey: @"Test Suite Str"];
|
||||
PASS([[defs stringForKey: @"Test Suite Str"] isEqual: @"SetString"],
|
||||
"NSUserDefaults can set/get a string");
|
||||
|
||||
PASS([[defs objectForKey: @"Test Suite Str"] isKindOfClass:[NSString class]],
|
||||
"NSUserDefaults returns NSString for a string");
|
||||
|
||||
PASS_EQUAL([obs count], @"3", "setting a string causes notification");
|
||||
|
||||
[defs removeObjectForKey: @"Test Suite Bool"];
|
||||
PASS(nil == [defs objectForKey: @"Test Suite Bool"],
|
||||
"NSUserDefaults can use -removeObjectForKey: to remove a bool");
|
||||
|
||||
PASS_EQUAL([obs count], @"4", "removing a key causes notification");
|
||||
|
||||
[defs setObject: nil forKey: @"Test Suite Int"];
|
||||
PASS(nil == [defs objectForKey: @"Test Suite Int"],
|
||||
"NSUserDefaults can use -setObject:forKey: to remove an int");
|
||||
|
||||
PASS_EQUAL([obs count], @"5", "setting nil object causes notification");
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue