mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 09:41:15 +00:00
Merge branch 'master' of github.com:gnustep/libs-base into NSSecureCoding_branch2
This commit is contained in:
commit
3b315b9d21
11 changed files with 150 additions and 57 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2020-06-06 Frederik Seiffert <frederik@algoriddim.com>
|
||||||
|
|
||||||
|
* Source/NSBundle.m: Extend NSBundle resources support to handle
|
||||||
|
directories in Android assets.
|
||||||
|
* Source/NSFileManager.m: Fix NSFileManager -isReadableFileAtPath:
|
||||||
|
to also support directories in Android assets.
|
||||||
|
|
||||||
|
2020-06-05 Frederik Seiffert <frederik@algoriddim.com>
|
||||||
|
|
||||||
|
* Tests/base/NSMapTable/weakObjects.m,
|
||||||
|
* Source/NSConcreteMapTable.m:
|
||||||
|
Add test for and fix replacing an existing value in a weak objects map
|
||||||
|
table.
|
||||||
|
|
||||||
2020-05-25 Frederik Seiffert <frederik@algoriddim.com>
|
2020-05-25 Frederik Seiffert <frederik@algoriddim.com>
|
||||||
|
|
||||||
* Source/NSUserDefaults.m:
|
* Source/NSUserDefaults.m:
|
||||||
|
|
|
@ -39,11 +39,16 @@ DEFINE_BLOCK_TYPE(GSFilePresentedItemChangesWithCompletionHandler, void, NSError
|
||||||
|
|
||||||
@protocol NSFilePresenter <NSObject>
|
@protocol NSFilePresenter <NSObject>
|
||||||
|
|
||||||
// @required
|
|
||||||
- (NSURL *) presentedItemURL;
|
- (NSURL *) presentedItemURL;
|
||||||
- (NSOperationQueue *) presentedItemOperationQueue;
|
- (NSOperationQueue *) presentedItemOperationQueue;
|
||||||
|
|
||||||
// @optional
|
#if GS_PROTOCOLS_HAVE_OPTIONAL
|
||||||
|
@optional
|
||||||
|
#else
|
||||||
|
@end
|
||||||
|
@interface NSObject (NSFilePresenter)
|
||||||
|
#endif
|
||||||
|
|
||||||
- (NSURL *) primaryPresentedItemURL;
|
- (NSURL *) primaryPresentedItemURL;
|
||||||
- (NSString *) observedPresentedItemUbiquityAttributes;
|
- (NSString *) observedPresentedItemUbiquityAttributes;
|
||||||
|
|
||||||
|
|
|
@ -306,8 +306,18 @@ typedef struct {
|
||||||
#define WINVER Windows2000
|
#define WINVER Windows2000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Trick to distinguish between MSYS/MinGW and MSYS2/MinGW32, the latter defines
|
||||||
|
// __MINGW32_MAJOR_VERSION and __MINGW32_MINOR_VERSION for compatibility
|
||||||
|
// but to a lower version than older MSYS/MinGW, but not the compound version
|
||||||
|
//
|
||||||
|
#if defined(__MINGW32_VERSION)
|
||||||
|
#define __USE_W32_SOCKETS
|
||||||
|
#include <windows.h>
|
||||||
|
#include <winsock2.h>
|
||||||
|
#else
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef __OBJC_BOOL
|
#undef __OBJC_BOOL
|
||||||
#undef BOOL
|
#undef BOOL
|
||||||
|
|
|
@ -2228,6 +2228,22 @@ IF_NO_GC(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
/* Android: check for directory resources by passing file path as subpath,
|
||||||
|
* as AAssetDir and thereby NSDirectoryEnumerator doesn't list directories
|
||||||
|
*/
|
||||||
|
subPath = subPath ? [subPath stringByAppendingPathComponent: file] : file;
|
||||||
|
pathlist = [[self _bundleResourcePathsWithRootPath: rootPath
|
||||||
|
subPath: subPath localization: nil] objectEnumerator];
|
||||||
|
while ((path = [pathlist nextObject]) != nil)
|
||||||
|
{
|
||||||
|
if (YES == [mgr isReadableFileAtPath: path])
|
||||||
|
{
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* __ANDROID__ */
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1392,7 +1392,7 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
||||||
if (GSI_MAP_READ_VALUE(self, &node->value).obj != anObject)
|
if (GSI_MAP_READ_VALUE(self, &node->value).obj != anObject)
|
||||||
{
|
{
|
||||||
GSI_MAP_RELEASE_VAL(self, node->value);
|
GSI_MAP_RELEASE_VAL(self, node->value);
|
||||||
node->value.obj = anObject;
|
GSI_MAP_WRITE_VAL(self, &node->value, (GSIMapVal)anObject);
|
||||||
GSI_MAP_RETAIN_VAL(self, node->value);
|
GSI_MAP_RETAIN_VAL(self, node->value);
|
||||||
version++;
|
version++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1877,13 +1877,22 @@ static NSStringEncoding defaultEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
// Android: try using asset manager if path is in main bundle resources
|
/* Android: try using asset manager if path is in
|
||||||
|
* main bundle resources
|
||||||
|
*/
|
||||||
AAsset *asset = [NSBundle assetForPath: path];
|
AAsset *asset = [NSBundle assetForPath: path];
|
||||||
if (asset)
|
if (asset)
|
||||||
{
|
{
|
||||||
AAsset_close(asset);
|
AAsset_close(asset);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AAssetDir *assetDir = [NSBundle assetDirForPath: path];
|
||||||
|
if (assetDir)
|
||||||
|
{
|
||||||
|
AAssetDir_close(assetDir);
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
|
|
|
@ -97,7 +97,7 @@ static NSArray *empty = nil;
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
empty = [NSArray new];
|
empty = [NSArray new];
|
||||||
[[NSObject leakAt: &empty] release];
|
RELEASE([NSObject leakAt: &empty]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) addDependency: (NSOperation *)op
|
- (void) addDependency: (NSOperation *)op
|
||||||
|
@ -430,7 +430,8 @@ static NSArray *empty = nil;
|
||||||
|
|
||||||
- (void) start
|
- (void) start
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
ENTER_POOL
|
||||||
|
|
||||||
double prio = [NSThread threadPriority];
|
double prio = [NSThread threadPriority];
|
||||||
|
|
||||||
AUTORELEASE(RETAIN(self)); // Make sure we exist while running.
|
AUTORELEASE(RETAIN(self)); // Make sure we exist while running.
|
||||||
|
@ -486,7 +487,7 @@ static NSArray *empty = nil;
|
||||||
NS_ENDHANDLER;
|
NS_ENDHANDLER;
|
||||||
|
|
||||||
[self _finish];
|
[self _finish];
|
||||||
[pool release];
|
LEAVE_POOL
|
||||||
}
|
}
|
||||||
|
|
||||||
- (double) threadPriority
|
- (double) threadPriority
|
||||||
|
@ -507,7 +508,7 @@ static NSArray *empty = nil;
|
||||||
/* retain while finishing so that we don't get deallocated when our
|
/* retain while finishing so that we don't get deallocated when our
|
||||||
* queue removes and releases us.
|
* queue removes and releases us.
|
||||||
*/
|
*/
|
||||||
[self retain];
|
RETAIN(self);
|
||||||
[internal->lock lock];
|
[internal->lock lock];
|
||||||
if (NO == internal->finished)
|
if (NO == internal->finished)
|
||||||
{
|
{
|
||||||
|
@ -532,7 +533,7 @@ static NSArray *empty = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[internal->lock unlock];
|
[internal->lock unlock];
|
||||||
[self release];
|
RELEASE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -540,7 +541,33 @@ static NSArray *empty = nil;
|
||||||
|
|
||||||
@implementation NSBlockOperation
|
@implementation NSBlockOperation
|
||||||
|
|
||||||
// Initialize
|
+ (instancetype) blockOperationWithBlock: (GSBlockOperationBlock)block
|
||||||
|
{
|
||||||
|
NSBlockOperation *op = [[self alloc] init];
|
||||||
|
|
||||||
|
[op addExecutionBlock: block];
|
||||||
|
return AUTORELEASE(op);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) addExecutionBlock: (GSBlockOperationBlock)block
|
||||||
|
{
|
||||||
|
GSBlockOperationBlock blockCopy = [block copy];
|
||||||
|
|
||||||
|
[_executionBlocks addObject: blockCopy];
|
||||||
|
RELEASE(blockCopy);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
RELEASE(_executionBlocks);
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *) executionBlocks
|
||||||
|
{
|
||||||
|
return _executionBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
@ -551,34 +578,11 @@ static NSArray *empty = nil;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
|
||||||
{
|
|
||||||
RELEASE(_executionBlocks);
|
|
||||||
[super dealloc];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Managing the blocks in the Operation
|
|
||||||
+ (instancetype)blockOperationWithBlock: (GSBlockOperationBlock)block
|
|
||||||
{
|
|
||||||
NSBlockOperation *op = [[self alloc] init];
|
|
||||||
[op addExecutionBlock: block];
|
|
||||||
return op;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)addExecutionBlock: (GSBlockOperationBlock)block
|
|
||||||
{
|
|
||||||
[_executionBlocks addObject: block];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSArray *) executionBlocks
|
|
||||||
{
|
|
||||||
return _executionBlocks;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) main
|
- (void) main
|
||||||
{
|
{
|
||||||
NSEnumerator *en = [[self executionBlocks] objectEnumerator];
|
NSEnumerator *en = [[self executionBlocks] objectEnumerator];
|
||||||
GSBlockOperationBlock theBlock;
|
GSBlockOperationBlock theBlock;
|
||||||
|
|
||||||
while ((theBlock = [en nextObject]) != NULL)
|
while ((theBlock = [en nextObject]) != NULL)
|
||||||
{
|
{
|
||||||
CALL_BLOCK_NO_ARGS(theBlock);
|
CALL_BLOCK_NO_ARGS(theBlock);
|
||||||
|
@ -836,9 +840,9 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
internal->name
|
internal->name
|
||||||
= [[NSString alloc] initWithFormat: @"NSOperation %p", self];
|
= [[NSString alloc] initWithFormat: @"NSOperation %p", self];
|
||||||
}
|
}
|
||||||
s = [internal->name retain];
|
s = RETAIN(internal->name);
|
||||||
[internal->lock unlock];
|
[internal->lock unlock];
|
||||||
return [s autorelease];
|
return AUTORELEASE(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSUInteger) operationCount
|
- (NSUInteger) operationCount
|
||||||
|
@ -888,7 +892,7 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
if (NO == [internal->name isEqual: s])
|
if (NO == [internal->name isEqual: s])
|
||||||
{
|
{
|
||||||
[self willChangeValueForKey: @"name"];
|
[self willChangeValueForKey: @"name"];
|
||||||
[internal->name release];
|
RELEASE(internal->name);
|
||||||
internal->name = [s copy];
|
internal->name = [s copy];
|
||||||
[self didChangeValueForKey: @"name"];
|
[self didChangeValueForKey: @"name"];
|
||||||
}
|
}
|
||||||
|
@ -915,10 +919,10 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
[internal->lock lock];
|
[internal->lock lock];
|
||||||
while ((op = [internal->operations lastObject]) != nil)
|
while ((op = [internal->operations lastObject]) != nil)
|
||||||
{
|
{
|
||||||
[op retain];
|
RETAIN(op);
|
||||||
[internal->lock unlock];
|
[internal->lock unlock];
|
||||||
[op waitUntilFinished];
|
[op waitUntilFinished];
|
||||||
[op release];
|
RELEASE(op);
|
||||||
[internal->lock lock];
|
[internal->lock lock];
|
||||||
}
|
}
|
||||||
[internal->lock unlock];
|
[internal->lock unlock];
|
||||||
|
@ -979,7 +983,7 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
|
|
||||||
- (void) _thread
|
- (void) _thread
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
ENTER_POOL
|
||||||
|
|
||||||
[[[NSThread currentThread] threadDictionary] setObject: self
|
[[[NSThread currentThread] threadDictionary] setObject: self
|
||||||
forKey: threadKey];
|
forKey: threadKey];
|
||||||
|
@ -1022,11 +1026,10 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
{
|
{
|
||||||
NS_DURING
|
NS_DURING
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *opPool = [NSAutoreleasePool new];
|
ENTER_POOL
|
||||||
|
|
||||||
[NSThread setThreadPriority: [op threadPriority]];
|
[NSThread setThreadPriority: [op threadPriority]];
|
||||||
[op start];
|
[op start];
|
||||||
RELEASE(opPool);
|
LEAVE_POOL
|
||||||
}
|
}
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
{
|
{
|
||||||
|
@ -1043,7 +1046,7 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
[internal->lock lock];
|
[internal->lock lock];
|
||||||
internal->threadCount--;
|
internal->threadCount--;
|
||||||
[internal->lock unlock];
|
[internal->lock unlock];
|
||||||
RELEASE(pool);
|
LEAVE_POOL
|
||||||
[NSThread exit];
|
[NSThread exit];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,6 @@
|
||||||
Boston, MA 02111 USA.
|
Boston, MA 02111 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#define EXPOSE_NSFileHandle_IVARS 1
|
#define EXPOSE_NSFileHandle_IVARS 1
|
||||||
#define EXPOSE_GSFileHandle_IVARS 1
|
#define EXPOSE_GSFileHandle_IVARS 1
|
||||||
|
|
|
@ -19,9 +19,14 @@ int main()
|
||||||
|
|
||||||
NSAutoreleasePool *arp2 = [NSAutoreleasePool new];
|
NSAutoreleasePool *arp2 = [NSAutoreleasePool new];
|
||||||
|
|
||||||
id testObj = [[[NSObject alloc] init] autorelease];
|
id testObj1 = [[[NSObject alloc] init] autorelease];
|
||||||
[mapTable setObject:testObj forKey:@"test"];
|
id testObj2 = [[[NSObject alloc] init] autorelease];
|
||||||
PASS([mapTable objectForKey:@"test"] != nil, "Table retains active weak reference");
|
|
||||||
|
[mapTable setObject:testObj1 forKey:@"test"];
|
||||||
|
PASS([mapTable objectForKey:@"test"] == testObj1, "Table retains first active weak reference");
|
||||||
|
|
||||||
|
[mapTable setObject:testObj2 forKey:@"test"];
|
||||||
|
PASS([mapTable objectForKey:@"test"] == testObj2, "Table retains second active weak reference");
|
||||||
|
|
||||||
[arp2 release]; arp2 = nil;
|
[arp2 release]; arp2 = nil;
|
||||||
|
|
||||||
|
|
29
configure
vendored
29
configure
vendored
|
@ -10985,7 +10985,15 @@ if test $enable_iconv = yes; then
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking iconv support" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking iconv support" >&5
|
||||||
$as_echo_n "checking iconv support... " >&6; }
|
$as_echo_n "checking iconv support... " >&6; }
|
||||||
if test "$cross_compiling" = yes; then :
|
if test "$cross_compiling" = yes; then :
|
||||||
found_iconv="$cross_found_iconv_libc"
|
found_iconv="$cross_found_iconv_libc";
|
||||||
|
if test "$found_iconv" = "yes"; then
|
||||||
|
|
||||||
|
$as_echo "#define HAVE_ICONV 1" >>confdefs.h
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, in libc (via cross.config)" >&5
|
||||||
|
$as_echo "yes, in libc (via cross.config)" >&6; }
|
||||||
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
/* end confdefs.h. */
|
/* end confdefs.h. */
|
||||||
|
@ -11041,7 +11049,13 @@ esac
|
||||||
LIBS="-liconv $LIBS"
|
LIBS="-liconv $LIBS"
|
||||||
if test "$cross_compiling" = yes; then :
|
if test "$cross_compiling" = yes; then :
|
||||||
found_iconv="$cross_found_iconv_liconv";
|
found_iconv="$cross_found_iconv_liconv";
|
||||||
if test "$found_iconv" = "no"; then
|
if test "$found_iconv" = "yes"; then
|
||||||
|
|
||||||
|
$as_echo "#define HAVE_ICONV 1" >>confdefs.h
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, -liconv (via cross.config)" >&5
|
||||||
|
$as_echo "yes, -liconv (via cross.config)" >&6; }
|
||||||
|
else
|
||||||
LIBS="$old_LIBS"
|
LIBS="$old_LIBS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -11080,7 +11094,16 @@ if test $found_iconv = no ; then
|
||||||
LIBS="-lgiconv $LIBS"
|
LIBS="-lgiconv $LIBS"
|
||||||
if test "$cross_compiling" = yes; then :
|
if test "$cross_compiling" = yes; then :
|
||||||
found_iconv="$cross_found_iconv_lgiconv";
|
found_iconv="$cross_found_iconv_lgiconv";
|
||||||
if test "$found_iconv" = "no"; then
|
if test "$found_iconv" = "yes"; then
|
||||||
|
|
||||||
|
$as_echo "#define HAVE_ICONV 1" >>confdefs.h
|
||||||
|
|
||||||
|
|
||||||
|
$as_echo "#define HAVE_GICONV 1" >>confdefs.h
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, -lgiconv (via cross.config)" >&5
|
||||||
|
$as_echo "yes, -lgiconv (via cross.config)" >&6; }
|
||||||
|
else
|
||||||
LIBS="$old_LIBS"
|
LIBS="$old_LIBS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
17
configure.ac
17
configure.ac
|
@ -2996,7 +2996,11 @@ int main(int argc,char **argv)
|
||||||
,
|
,
|
||||||
found_iconv=no
|
found_iconv=no
|
||||||
,
|
,
|
||||||
found_iconv="$cross_found_iconv_libc",
|
found_iconv="$cross_found_iconv_libc";
|
||||||
|
if test "$found_iconv" = "yes"; then
|
||||||
|
AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
|
||||||
|
AC_MSG_RESULT([[yes, in libc (via cross.config)]])
|
||||||
|
fi
|
||||||
)
|
)
|
||||||
|
|
||||||
if test $found_iconv = no ; then
|
if test $found_iconv = no ; then
|
||||||
|
@ -3025,7 +3029,10 @@ if test $found_iconv = no ; then
|
||||||
LIBS="$old_LIBS"
|
LIBS="$old_LIBS"
|
||||||
,
|
,
|
||||||
found_iconv="$cross_found_iconv_liconv";
|
found_iconv="$cross_found_iconv_liconv";
|
||||||
if test "$found_iconv" = "no"; then
|
if test "$found_iconv" = "yes"; then
|
||||||
|
AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
|
||||||
|
AC_MSG_RESULT([[yes, -liconv (via cross.config)]])
|
||||||
|
else
|
||||||
LIBS="$old_LIBS"
|
LIBS="$old_LIBS"
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
@ -3049,7 +3056,11 @@ if test $found_iconv = no ; then
|
||||||
LIBS="$old_LIBS"
|
LIBS="$old_LIBS"
|
||||||
,
|
,
|
||||||
found_iconv="$cross_found_iconv_lgiconv";
|
found_iconv="$cross_found_iconv_lgiconv";
|
||||||
if test "$found_iconv" = "no"; then
|
if test "$found_iconv" = "yes"; then
|
||||||
|
AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
|
||||||
|
AC_DEFINE(HAVE_GICONV,1, [Define if you have this function])
|
||||||
|
AC_MSG_RESULT([[yes, -lgiconv (via cross.config)]])
|
||||||
|
else
|
||||||
LIBS="$old_LIBS"
|
LIBS="$old_LIBS"
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue