Skip to content

Commit

Permalink
Merge commit '75a75e53'
Browse files Browse the repository at this point in the history
  • Loading branch information
weswmsft committed May 3, 2016
2 parents 1e01b23 + 75a75e5 commit 748b8aa
Show file tree
Hide file tree
Showing 129 changed files with 2,795 additions and 1,618 deletions.
6 changes: 3 additions & 3 deletions Frameworks/AVFoundation/AVAudioPlayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

#include <UWP/WindowsUIXamlControls.h>

#import <COMIncludes.h>
#include <COMIncludes.h>
#import <RawBuffer.h>
#import <windows.storage.streams.h>
#import <COMIncludes_End.h>
#include <COMIncludes_End.h>
#import "AssertARCEnabled.h"

// 100 nanoseconds per tick
Expand Down Expand Up @@ -184,7 +184,7 @@ - (instancetype)initWithData:(NSData *)data fileTypeHint:(NSString*)utiString er

// TODO: subclassed IAsyncOperation<T>s don't get generated correctly in ObjCUWP yet, when that happens it'll
// open up StoreAsync.
IDataWriter* writer = (__bridge IDataWriter*)[rw internalObject];
IDataWriter* writer = (IDataWriter*)[rw comObj].Get();
ComPtr<IAsyncOperation<UInt32>> comp;
writer->WriteBuffer(buffer.Get());
writer->StoreAsync(&comp);
Expand Down
27 changes: 22 additions & 5 deletions Frameworks/CoreFoundationAdditions/CFMisc.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@

#import <CoreFoundation/CoreFoundation.h>

#include <mach/mach_time.h>

#include <algorithm>
#include <mach/mach_time.h>
#include "LoggingNative.h"

static const wchar_t* TAG = L"CFMisc";
Expand All @@ -48,12 +47,30 @@
static ComPtr<ABI::Windows::Security::Cryptography::ICryptographicBufferStatics> bufferStatics(GetBufferStatics());

UINT32 randResult = 0;
if (!SUCCEEDED(bufferStatics->GenerateRandomNumber(&randResult))) {
TraceVerbose(TAG, L"Unable to get random number!");
}
FAIL_FAST_IF(!SUCCEEDED(bufferStatics->GenerateRandomNumber(&randResult)));
return randResult;
}

extern "C" uint32_t arc4random_uniform(uint32_t upperbound) {
if (upperbound == 0) {
TraceError(TAG, L"arc4random_uniform: Invalid upper bound");
FAIL_FAST();
}

static ComPtr<ABI::Windows::Security::Cryptography::ICryptographicBufferStatics> bufferStatics(GetBufferStatics());

UINT32 randResult = 0;
UINT32 highestMultipleOfUpperBound = ULONG_MAX - (ULONG_MAX % upperbound);

// Constrict the result so it is < upperbound. In order to get a uniform result distribution, we generate a new random number
// when the result of GenerateRandomNumber falls within the range [highestMultipleOfUpperBound, ULONG_MAX]
do {
FAIL_FAST_IF(!SUCCEEDED(bufferStatics->GenerateRandomNumber(&randResult)));
} while (randResult >= highestMultipleOfUpperBound);

return randResult % upperbound;
}

extern "C" int sysctlbyname(const char* name, void* out, size_t* outSize, const void*, size_t) {
if (strcmp(name, "hw.machine") == 0) {
const int required = 8;
Expand Down
15 changes: 15 additions & 0 deletions Frameworks/CoreFoundationAdditions/CFUUID.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,23 @@ CFUUIDRef CFUUIDCreate(CFAllocatorRef allocator) {
return (CFUUIDRef)[[NSUUID alloc] init];
}

/**
@Status Interoperable
*/
CFUUIDRef CFUUIDCreateFromString(CFAllocatorRef allocator, CFStringRef string) {
return (CFUUIDRef)[[NSUUID alloc] initWithUUIDString:(NSString*)string];
}

/**
@Status Interoperable
*/
CFUUIDRef CFUUIDCreateFromUUIDBytes(CFAllocatorRef allocator, CFUUIDBytes bytes) {
return (CFUUIDRef)[[NSUUID alloc] initWithUUIDBytes:reinterpret_cast<unsigned char*>(&bytes)];
}

/**
@Status Interoperable
*/
CFUUIDRef CFUUIDCreateWithBytes(CFAllocatorRef allocator,
uint8_t byte0,
uint8_t byte1,
Expand All @@ -63,6 +72,9 @@ CFUUIDRef CFUUIDCreateWithBytes(CFAllocatorRef allocator,
return CFUUIDCreateFromUUIDBytes(allocator, bytes);
}

/**
@Status Interoperable
*/
CFUUIDRef CFUUIDGetConstantUUIDWithBytes(CFAllocatorRef allocator,
uint8_t byte0,
uint8_t byte1,
Expand Down Expand Up @@ -90,6 +102,9 @@ CFUUIDRef CFUUIDGetConstantUUIDWithBytes(CFAllocatorRef allocator,
return (CFUUIDRef)constantUUIDs[bytes];
}

/**
@Status Interoperable
*/
CFUUIDBytes CFUUIDGetUUIDBytes(CFUUIDRef self) {
CFUUIDBytes bytes;
[(NSUUID*)self getUUIDBytes:reinterpret_cast<unsigned char*>(&bytes)];
Expand Down
12 changes: 12 additions & 0 deletions Frameworks/CoreGraphics/CGContextCairo.mm
Original file line number Diff line number Diff line change
Expand Up @@ -753,14 +753,20 @@
states[curStateNum].curBlendMode = curState->curBlendMode;
states[curStateNum]._imgClip = NULL;
states[curStateNum]._imgMask = NULL;
states[curStateNum].shadowColor = NULL;

if (curState->_imgClip) {
states[curStateNum]._imgClip = curState->_imgClip->Backing()->Copy();
}

if (curState->_imgMask) {
states[curStateNum]._imgMask = curState->_imgMask->Backing()->Copy();
}

if (curState->shadowColor) {
states[curStateNum].shadowColor = CGColorCreateCopy(curState->shadowColor);
}

memcpy(&states[curStateNum].curTransform, &curState->curTransform, sizeof(curState->curTransform));

curState = &states[curStateNum];
Expand All @@ -777,9 +783,15 @@
if (curState->_imgClip) {
delete curState->_imgClip;
}

if (curState->_imgMask) {
delete curState->_imgMask;
}

if (curState->shadowColor) {
CGColorRelease(curState->shadowColor);
}

curStateNum--;
curState = &states[curStateNum];

Expand Down
9 changes: 0 additions & 9 deletions Frameworks/CoreGraphics/CGGeometry.mm
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,6 @@ bool CGRectMakeWithDictionaryRepresentation(CFDictionaryRef dict, CGRect* rect)
return StubReturn();
}

/**
@Status Stub
@Notes
*/
CGVector CGVectorMake(CGFloat dx, CGFloat dy) {
UNIMPLEMENTED();
return StubReturn();
}

/**
@Status Stub
@Notes
Expand Down
26 changes: 17 additions & 9 deletions Frameworks/CoreGraphics/CGPath.mm
Original file line number Diff line number Diff line change
Expand Up @@ -522,14 +522,22 @@ void CGPathAddQuadCurveToPoint(CGMutablePathRef path, const CGAffineTransform* m
}

/**
@Status Caveat
@Notes transform property not supported
@Status Interoperable
@Notes
*/
void CGPathAddCurveToPoint(
CGMutablePathRef path, const CGAffineTransform* m, CGFloat cp1x, CGFloat cp1y, CGFloat cp2x, CGFloat cp2y, CGFloat x, CGFloat y) {
CGPathRef pathObj = path;

assert(!m);
CGPoint cp1 = CGPointMake(cp1x, cp1y);
CGPoint cp2 = CGPointMake(cp2x, cp2y);
CGPoint end = CGPointMake(x, y);

if (m) {
cp1 = CGPointApplyAffineTransform(cp1, *m);
cp2 = CGPointApplyAffineTransform(cp2, *m);
end = CGPointApplyAffineTransform(end, *m);
}

if (pathObj->_count + 1 >= pathObj->_max) {
pathObj->_max += 32;
Expand All @@ -539,12 +547,12 @@ void CGPathAddCurveToPoint(
int count = pathObj->_count;

pathObj->_components[count].type = pathComponentCurve;
pathObj->_components[count].ctp.x1 = cp1x;
pathObj->_components[count].ctp.y1 = cp1y;
pathObj->_components[count].ctp.x2 = cp2x;
pathObj->_components[count].ctp.y2 = cp2y;
pathObj->_components[count].ctp.x = x;
pathObj->_components[count].ctp.y = y;
pathObj->_components[count].ctp.x1 = cp1.x;
pathObj->_components[count].ctp.y1 = cp1.y;
pathObj->_components[count].ctp.x2 = cp2.x;
pathObj->_components[count].ctp.y2 = cp2.y;
pathObj->_components[count].ctp.x = end.x;
pathObj->_components[count].ctp.y = end.y;

pathObj->_count++;
}
Expand Down
2 changes: 1 addition & 1 deletion Frameworks/CoreText/CTRun.mm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ CFIndex CTRunGetGlyphCount(CTRunRef run) {
}

/**
@Status Stub
@Status Interoperable
*/
CFDictionaryRef CTRunGetAttributes(CTRunRef run) {
if (run == nil) {
Expand Down
14 changes: 12 additions & 2 deletions Frameworks/Foundation/NSArray.mm
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,18 @@ - (void)encodeWithCoder:(NSCoder*)coder {
@Status Interoperable
*/
- (NSString*)description {
UNIMPLEMENTED();
return [super description];
NSMutableString* s = [NSMutableString string];
[s appendString:@"("];
for (id val in self) {
[s appendFormat:@"%@, ", val];
}

if ([self count] > 0) {
[s deleteCharactersInRange:{[s length] - 2, 2}];
}

[s appendString:@")"];
return s;
}

/**
Expand Down
18 changes: 9 additions & 9 deletions Frameworks/Foundation/NSBundle.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1159,14 +1159,14 @@ - (NSString*)resourcePath {
*/
- (NSString*)executablePath {
UNIMPLEMENTED();
return [_bundlePath stringByAppendingPathComponent:[NSString stringWithCString:g_globalExecutableName]];
return StubReturn();
}

/**
@Status Stub
@Status Caveat
@Notes Returns [en, Base, eng, English];
*/
- (NSArray*)preferredLocalizations {
UNIMPLEMENTED();
if (_preferredLocalizations == nil) {
_preferredLocalizations = [[NSMutableArray arrayWithObject:@"en"] retain];
[_preferredLocalizations addObject:@"Base"];
Expand All @@ -1186,10 +1186,10 @@ - (NSString*)pathForAuxiliaryExecutable:(NSString*)executable {
}

/**
@Status Stub
@Status Caveat
@Notes Adds only "en", "eng", and "English"
*/
+ (NSArray*)preferredLocalizationsFromArray:(NSArray*)localizations {
UNIMPLEMENTED();
NSMutableArray* ret = [NSMutableArray array];

if ([localizations containsObject:@"en"]) {
Expand All @@ -1206,10 +1206,10 @@ + (NSArray*)preferredLocalizationsFromArray:(NSArray*)localizations {
}

/**
@Status Stub
@Status Caveat
@Notes Adds only "en", "eng", and "English"
*/
+ (NSArray*)preferredLocalizationsFromArray:(NSArray*)localizations forPreferences:(NSArray*)preferences {
UNIMPLEMENTED();
NSMutableArray* ret = [NSMutableArray array];

if ([localizations containsObject:@"en"]) {
Expand Down Expand Up @@ -1267,10 +1267,10 @@ - (NSArray*)URLsForResourcesWithExtension:(NSString*)type subdirectory:(NSString
}

/**
@Status Stub
@Status Caveat
@Notes Ignores localization
*/
- (NSArray*)URLsForResourcesWithExtension:(NSString*)extension subdirectory:(NSString*)subpath localization:(NSString*)localizationName {
UNIMPLEMENTED();
return [self URLsForResourcesWithExtension:extension subdirectory:subpath];
}

Expand Down
31 changes: 3 additions & 28 deletions Frameworks/Foundation/NSCalendar.mm
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,9 @@ - (void)dealloc {
}

/**
@Status Stub
@Status Interoperable
*/
- (NSString*)calendarIdentifier {
UNIMPLEMENTED();
return _identifier;
}

Expand Down Expand Up @@ -410,11 +409,7 @@ - (NSDateComponents*)components:(NSUInteger)unitFlags fromDate:(NSDate*)fromDate
*/
- (BOOL)rangeOfUnit:(NSCalendarUnit)unit startDate:(NSDate* _Nullable*)datep interval:(NSTimeInterval*)timep forDate:(NSDate*)date {
UNIMPLEMENTED();
// HACK: implement me!
if (datep) {
*datep = [date retain];
}
return NO;
return StubReturn();
}

static UCalendarDateFields icuFieldFromUnit(NSCalendarUnit unit) {
Expand Down Expand Up @@ -454,27 +449,7 @@ static UCalendarDateFields icuFieldFromUnit(NSCalendarUnit unit) {
*/
- (NSRange)rangeOfUnit:(NSCalendarUnit)smaller inUnit:(NSCalendarUnit)larger forDate:(NSDate*)date {
UNIMPLEMENTED();
NSRange ret;

double time = [date timeIntervalSince1970];

UErrorCode status = U_ZERO_ERROR;
Calendar* copy = [self _getICUCalendar]->clone();
copy->setTime(time * 1000.0, status);

icu::TimeZone* tz = [_timeZone _createICUTimeZone];
copy->setTimeZone(*tz);
delete tz;

UCalendarDateFields icuSmaller = icuFieldFromUnit(smaller);
ret.location = copy->getActualMinimum(icuSmaller, status);
ret.length = copy->getActualMaximum(icuSmaller, status) - ret.location + 1;

if (smaller == NSMonthCalendarUnit) {
ret.location++;
}
delete copy;
return ret;
return StubReturn();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Frameworks/Foundation/NSData.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
#import "Foundation/NSValue.h"
#import <UWP/WindowsStorageStreams.h>
#import <UWP/WindowsSecurityCryptography.h>
#import <COMIncludes.h>
#include <COMIncludes.h>
#import "ErrorHandling.h"
#import "RawBuffer.h"
#import <wrl\wrappers\corewrappers.h>
#import <windows.security.cryptography.h>
#import <windows.storage.streams.h>
#import <COMIncludes_End.h>
#include <COMIncludes_End.h>
#import <string>
#import <sstream>
#import <iomanip>
Expand Down
2 changes: 0 additions & 2 deletions Frameworks/Foundation/NSDate.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
- (double)timeIntervalSinceDate:(id)ref;
- (NSDate*)dateByAddingTimeInterval:(double)interval;
- (NSDate*)initWithCoder:(NSCoder*)coder;
- (NSDate*)initWithString:(NSString*)string;
- (NSDate*)initWithTimeIntervalSince1970:(double)secondsSince1970;
- (NSDate*)initWithTimeIntervalSinceNow:(double)secondsSinceNow;
- (NSDate*)initWithTimeIntervalSinceReferenceDate:(double)ref;
Expand All @@ -43,7 +42,6 @@
- (NSObject*)init;
- (NSObject*)encodeWithCoder:(NSCoder*)coder;
- (NSString*)description;
+ (NSDate*)dateWithString:(NSString*)string;
+ (NSDate*)date;
+ (NSDate*)distantPast;
+ (NSDate*)distantFuture;
Expand Down
Loading

0 comments on commit 748b8aa

Please sign in to comment.