Merge branch 'master' of github.com:gnustep/libs-base into NSSecureCoding_branch2

This commit is contained in:
Gregory John Casamento 2020-06-08 04:12:45 -04:00
commit 3b315b9d21
11 changed files with 150 additions and 57 deletions

View file

@ -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>
* Source/NSUserDefaults.m:

View file

@ -39,11 +39,16 @@ DEFINE_BLOCK_TYPE(GSFilePresentedItemChangesWithCompletionHandler, void, NSError
@protocol NSFilePresenter <NSObject>
// @required
- (NSURL *) presentedItemURL;
- (NSOperationQueue *) presentedItemOperationQueue;
// @optional
#if GS_PROTOCOLS_HAVE_OPTIONAL
@optional
#else
@end
@interface NSObject (NSFilePresenter)
#endif
- (NSURL *) primaryPresentedItemURL;
- (NSString *) observedPresentedItemUbiquityAttributes;

View file

@ -306,8 +306,18 @@ typedef struct {
#define WINVER Windows2000
#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 <windows.h>
#endif
#undef __OBJC_BOOL
#undef BOOL

View file

@ -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;
}

View file

@ -1392,7 +1392,7 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
if (GSI_MAP_READ_VALUE(self, &node->value).obj != anObject)
{
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);
version++;
}

View file

@ -1877,13 +1877,22 @@ static NSStringEncoding defaultEncoding;
}
#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];
if (asset)
{
AAsset_close(asset);
return YES;
}
AAssetDir *assetDir = [NSBundle assetDirForPath: path];
if (assetDir)
{
AAssetDir_close(assetDir);
return YES;
}
#endif
return NO;

View file

@ -97,7 +97,7 @@ static NSArray *empty = nil;
+ (void) initialize
{
empty = [NSArray new];
[[NSObject leakAt: &empty] release];
RELEASE([NSObject leakAt: &empty]);
}
- (void) addDependency: (NSOperation *)op
@ -430,7 +430,8 @@ static NSArray *empty = nil;
- (void) start
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
ENTER_POOL
double prio = [NSThread threadPriority];
AUTORELEASE(RETAIN(self)); // Make sure we exist while running.
@ -486,7 +487,7 @@ static NSArray *empty = nil;
NS_ENDHANDLER;
[self _finish];
[pool release];
LEAVE_POOL
}
- (double) threadPriority
@ -507,7 +508,7 @@ static NSArray *empty = nil;
/* retain while finishing so that we don't get deallocated when our
* queue removes and releases us.
*/
[self retain];
RETAIN(self);
[internal->lock lock];
if (NO == internal->finished)
{
@ -532,7 +533,7 @@ static NSArray *empty = nil;
}
}
[internal->lock unlock];
[self release];
RELEASE(self);
}
@end
@ -540,7 +541,33 @@ static NSArray *empty = nil;
@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
{
self = [super init];
@ -551,34 +578,11 @@ static NSArray *empty = nil;
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
{
NSEnumerator *en = [[self executionBlocks] objectEnumerator];
GSBlockOperationBlock theBlock;
while ((theBlock = [en nextObject]) != NULL)
{
CALL_BLOCK_NO_ARGS(theBlock);
@ -836,9 +840,9 @@ static NSOperationQueue *mainQueue = nil;
internal->name
= [[NSString alloc] initWithFormat: @"NSOperation %p", self];
}
s = [internal->name retain];
s = RETAIN(internal->name);
[internal->lock unlock];
return [s autorelease];
return AUTORELEASE(s);
}
- (NSUInteger) operationCount
@ -888,7 +892,7 @@ static NSOperationQueue *mainQueue = nil;
if (NO == [internal->name isEqual: s])
{
[self willChangeValueForKey: @"name"];
[internal->name release];
RELEASE(internal->name);
internal->name = [s copy];
[self didChangeValueForKey: @"name"];
}
@ -915,10 +919,10 @@ static NSOperationQueue *mainQueue = nil;
[internal->lock lock];
while ((op = [internal->operations lastObject]) != nil)
{
[op retain];
RETAIN(op);
[internal->lock unlock];
[op waitUntilFinished];
[op release];
RELEASE(op);
[internal->lock lock];
}
[internal->lock unlock];
@ -979,7 +983,7 @@ static NSOperationQueue *mainQueue = nil;
- (void) _thread
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
ENTER_POOL
[[[NSThread currentThread] threadDictionary] setObject: self
forKey: threadKey];
@ -1022,11 +1026,10 @@ static NSOperationQueue *mainQueue = nil;
{
NS_DURING
{
NSAutoreleasePool *opPool = [NSAutoreleasePool new];
ENTER_POOL
[NSThread setThreadPriority: [op threadPriority]];
[op start];
RELEASE(opPool);
LEAVE_POOL
}
NS_HANDLER
{
@ -1043,7 +1046,7 @@ static NSOperationQueue *mainQueue = nil;
[internal->lock lock];
internal->threadCount--;
[internal->lock unlock];
RELEASE(pool);
LEAVE_POOL
[NSThread exit];
}

View file

@ -22,9 +22,6 @@
Boston, MA 02111 USA.
*/
#include <winsock2.h>
#include <windows.h>
#include "common.h"
#define EXPOSE_NSFileHandle_IVARS 1
#define EXPOSE_GSFileHandle_IVARS 1

View file

@ -19,9 +19,14 @@ int main()
NSAutoreleasePool *arp2 = [NSAutoreleasePool new];
id testObj = [[[NSObject alloc] init] autorelease];
[mapTable setObject:testObj forKey:@"test"];
PASS([mapTable objectForKey:@"test"] != nil, "Table retains active weak reference");
id testObj1 = [[[NSObject alloc] init] autorelease];
id testObj2 = [[[NSObject alloc] init] autorelease];
[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;

29
configure vendored
View file

@ -10985,7 +10985,15 @@ if test $enable_iconv = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking iconv support" >&5
$as_echo_n "checking iconv support... " >&6; }
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
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@ -11041,7 +11049,13 @@ esac
LIBS="-liconv $LIBS"
if test "$cross_compiling" = yes; then :
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"
fi
@ -11080,7 +11094,16 @@ if test $found_iconv = no ; then
LIBS="-lgiconv $LIBS"
if test "$cross_compiling" = yes; then :
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"
fi

View file

@ -2996,7 +2996,11 @@ int main(int argc,char **argv)
,
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
@ -3025,7 +3029,10 @@ if test $found_iconv = no ; then
LIBS="$old_LIBS"
,
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"
fi
)
@ -3049,7 +3056,11 @@ if test $found_iconv = no ; then
LIBS="$old_LIBS"
,
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"
fi
)