Skip to content

Commit

Permalink
Merge commit '83446999'
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvarma committed Apr 27, 2016
2 parents b25297b + 8344699 commit 07f72cc
Show file tree
Hide file tree
Showing 109 changed files with 1,784 additions and 991 deletions.
2 changes: 1 addition & 1 deletion Frameworks/CoreFoundationAdditions/CFArray.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "CFArrayInternal.h"

#include <Foundation/NSMutableArray.h>
#include "../Foundation/NSMutableArrayInternal.h"
#include "NSMutableArrayInternal.h"

#include <sys/stat.h>

Expand Down
127 changes: 15 additions & 112 deletions Frameworks/CoreFoundationAdditions/CFType.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//******************************************************************************

#include "Starboard.h"
#include "StubReturn.h"
#include "CoreFoundation/CFType.h"
#include "Foundation/NSString.h"

Expand All @@ -37,8 +38,8 @@ void CFRelease(CFTypeRef obj) {
/**
@Status Interoperable
*/
void CFAutorelease(CFTypeRef obj) {
objc_autorelease(static_cast<id>(obj));
CFTypeRef CFAutorelease(CFTypeRef obj) {
return objc_autorelease(static_cast<id>(obj));
}

/**
Expand Down Expand Up @@ -119,119 +120,21 @@ DWORD _NSSetLogCStringFunction(DWORD func) {
return 0;
}

#if 0
enum {
CFUnknownType,
CFStringType,
CFDictionaryType,
CFArrayType,
CFNumberType,
CFBooleanType,
CGLayerType,
CFBundleType,
CFBinaryHeap,
} CFTypeIDs;

DWORD CFGetTypeID(id cfobj)
{
id objType = cfobj;
if ( [objType isKindOfClass:[NSString class]] ) {
return CFStringType;
}
if ( [objType isKindOfClass:[NSDictionary class]] ) {
return CFDictionaryType;
}
if ( [objType isKindOfClass:[CFBinaryHeap class]] ) {
return CFBinaryHeap;
}
if ( [objType isKindOfClass:[NSArray class]] ) {
return CFArrayType;
}
if ( [objType isKindOfClass:[NSNumber class]] ) {
if ( [objType _isBool] ) {
return CFBooleanType;
}

return CFNumberType;
}
if ( [objType isKindOfClass:[CGLayer class]] ) {
return CGLayerType;
}
if ( [objType isKindOfClass:[NSBundle class]] ) {
return CFBundleType;
}
assert(0);

return 0;
}

DWORD CFBinaryHeapGetTypeID()
{
return CFBinaryHeap;
}

DWORD CFDictionaryGetTypeID()
{
return CFDictionaryType;
}

DWORD CFArrayGetTypeID()
{
return CFArrayType;
}

DWORD CFStringGetTypeID()
{
return CFStringType;
}

DWORD CFBooleanGetTypeID()
{
return CFBooleanType;
}

DWORD CFNumberGetTypeID()
{
return CFNumberType;
}

DWORD CGLayerGetTypeID()
{
return CGLayerType;
}

DWORD CFBundleGetTypeID()
{
return CFBundleType;
}

DWORD CFDateCreate(id allocator, double abstime)
{
id ret = [[NSDate alloc] initWithTimeIntervalSinceReferenceDate:abstime];

return ret;
}

static id defaultZone = nil;

DWORD NSDefaultMallocZone()
{
if ( defaultZone == nil ) {
defaultZone = [NSObject new];
}

return defaultZone;
}

DWORD NSZoneFromPointer(void *ptr)
{
if ( defaultZone == nil ) {
defaultZone = [NSObject new];
/**
@Status Stub
*/
CFTypeID CFGetTypeID(CFTypeRef cfobj) {
UNIMPLEMENTED();
return StubReturn();
}

return defaultZone;
/**
@Status Stub
*/
CFTypeID CFDataGetTypeID() {
UNIMPLEMENTED();
return StubReturn();
}
#endif

id CFNSRetain(id allocator, id obj) {
return [obj retain];
Expand Down
16 changes: 7 additions & 9 deletions Frameworks/Foundation/NSDate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ + (NSDate*)dateWithTimeIntervalSinceReferenceDate:(double)secondsSinceRef {
}

/**
@Status Stub
@Status Interoperable
*/
- (NSDate*)initWithCoder:(NSCoder*)coder {
UNIMPLEMENTED();
return StubReturn();
double time = [coder decodeDoubleForKey:@"NS.time"];
return [self initWithTimeIntervalSinceReferenceDate:time];
}

/**
Expand Down Expand Up @@ -313,10 +313,10 @@ - (NSObject*)init {
}

/**
@Status Stub
@Status Interoperable
*/
- (void)encodeWithCoder:(NSCoder*)coder {
UNIMPLEMENTED();
[coder encodeDouble:_curTime forKey:@"NS.time"];
}

/**
Expand Down Expand Up @@ -358,12 +358,10 @@ - (NSString*)descriptionWithLocale:(id)locale {
}

/**
@Status Stub
@Notes
@Status Interoperable
*/
+ (BOOL)supportsSecureCoding {
UNIMPLEMENTED();
return StubReturn();
return YES;
}

@end
8 changes: 6 additions & 2 deletions Frameworks/Foundation/NSDelayedPerform.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
//
//******************************************************************************

#pragma once

#import <Foundation/NSObject.h>

@interface NSDelayedPerform : NSObject {
@public
idt(NSObject) _object;
NSObject* _object;
SEL _selector;
idt(NSObject) _argument;
NSObject* _argument;
BOOL _releaseObjects;
}
- (NSDelayedPerform*)initWithObject:(NSObject*)object selector:(SEL)selector argument:(NSObject*)argument;
Expand Down
2 changes: 1 addition & 1 deletion Frameworks/Foundation/NSDictionary.mm
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ - (NSEnumerator*)keyEnumerator {
/**
@Status Interoperable
*/
- (uint64_t)fileSize {
- (unsigned long long)fileSize {
__int64 ret = [[self objectForKey:NSFileSize] intValue];

return ret;
Expand Down
2 changes: 1 addition & 1 deletion Frameworks/Foundation/NSDirectoryEnumerator.mm
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ - (void)skipDescendants {
return nil;
}

NSDictionary* ret = [NSMutableDictionary dictionary];
NSMutableDictionary* ret = [NSMutableDictionary dictionary];
[ret setValue:[NSNumber numberWithInt:st.st_size] forKey:NSFileSize];
[ret setValue:NSFileTypeRegular forKey:NSFileType];
[ret setValue:[NSDate dateWithTimeIntervalSince1970:st.st_ctime] forKey:NSFileCreationDate];
Expand Down
28 changes: 15 additions & 13 deletions Frameworks/Foundation/NSIndexSet.mm
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,6 @@ - (NSUInteger)countOfIndexesInRange:(NSRange)range {
@Notes NSEnumerationReverse not implemented.
*/
- (void)enumerateIndexesWithOptions:(NSEnumerationOptions)options usingBlock:(void (^)(NSUInteger, BOOL*))block {
if (options & NSEnumerationReverse) {
UNIMPLEMENTED();
return;
}

dispatch_queue_t queue;
dispatch_group_t group;

Expand All @@ -240,22 +235,29 @@ - (void)enumerateIndexesWithOptions:(NSEnumerationOptions)options usingBlock:(vo
}

__block BOOL stop = NO;
for (unsigned long i = 0; i < [(NSMutableIndexSet*)self _count] && !stop; i++) {
NSRange cur = [(NSMutableIndexSet*)self _itemAtIndex:i];

for (__block unsigned long j = cur.location; j < cur.location + cur.length && !stop; j++) {
BOOL reverse = options & NSEnumerationReverse;
unsigned long count = [(NSMutableIndexSet*)self _count];
unsigned long start = (reverse) ? count : 1;
unsigned long end = (reverse) ? 0 : count + 1;
long step = (reverse) ? -1 : 1;
for (unsigned long i = start; i != end && !stop; i += step) {
NSRange cur = [(NSMutableIndexSet*)self _itemAtIndex:(i - 1)];
__block unsigned long j;
unsigned long innerStart = (reverse) ? NSMaxRange(cur) - 1 : cur.location;
for (j = innerStart; NSLocationInRange(j, cur) && !stop; j += step) {
if (options & NSEnumerationConcurrent) {
dispatch_group_async(group,
queue,
^() {
block(j, &stop);
});
queue,
^() {
block(j, &stop);
});
} else {
block(j, &stop);
}
}
}

// Wait for dispatch queue to execute
if (options & NSEnumerationConcurrent) {
dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
dispatch_release(group);
Expand Down
Loading

0 comments on commit 07f72cc

Please sign in to comment.