Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into github_master
Browse files Browse the repository at this point in the history
  • Loading branch information
weswmsft committed Jun 9, 2016
2 parents 1200687 + 6fb1ecf commit 8e5b55d
Show file tree
Hide file tree
Showing 179 changed files with 9,678 additions and 836 deletions.
6 changes: 6 additions & 0 deletions Frameworks/CoreFoundation/Base.subproj/CFRuntime.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,12 @@ extern CFAllocatorRef __CFAllocatorGetAllocator(CFTypeRef);

CFAllocatorRef CFGetAllocator(CFTypeRef cf) {
if (NULL == cf) return kCFAllocatorSystemDefault;

// WINOBJC: Return something reasonable for ObjC objects
if (!__CF_IsCFObject(cf)) {
return kCFAllocatorDefault;
}

if (__kCFAllocatorTypeID_CONST == __CFGenericTypeID_inline(cf)) {
return __CFAllocatorGetAllocator(cf);
}
Expand Down
5 changes: 3 additions & 2 deletions Frameworks/Foundation/NSArray.mm
Original file line number Diff line number Diff line change
Expand Up @@ -597,12 +597,13 @@ - (NSArray*)arrayByAddingObject:(NSObject*)obj {
*/
- (NSArray*)arrayByAddingObjectsFromArray:(NSArray*)arr {
std::vector<id> objects([self count] + [arr count]);
NSUInteger currentIndex = 0;
for (NSUInteger i = 0; i < [self count]; i++) {
objects[i] = [self objectAtIndex:i];
objects[currentIndex++] = [self objectAtIndex:i];
}

for (NSUInteger i = 0; i < [arr count]; i++) {
objects[i] = [arr objectAtIndex:i];
objects[currentIndex++] = [arr objectAtIndex:i];
}

return [NSArray arrayWithObjects:objects.data() count:objects.size()];
Expand Down
5 changes: 5 additions & 0 deletions Frameworks/Foundation/NSBundle.mm
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ - (instancetype)initWithURL:(NSURL*)url {
@Status Interoperable
*/
- (instancetype)initWithPath:(NSString*)path {
if (path == nil) {
[self release];
return nil;
}

return [self initWithURL:[NSURL fileURLWithPath:path]];
}

Expand Down
12 changes: 11 additions & 1 deletion Frameworks/Foundation/NSKVOSupport.mm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ - (void)dealloc {
#pragma region Keypath Observer
@interface _NSKVOKeypathObserver () {
long _changeDepth;
void* _rawObserver;
}
@property (nonatomic, readonly) void* _rawObserver;
@end

@implementation _NSKVOKeypathObserver
Expand All @@ -78,6 +80,7 @@ - (instancetype)initWithObject:(id)object
if (self = [super init]) {
_object = object;
objc_storeWeak(&_observer, observer);
_rawObserver = _observer;
_keypath = [keypath copy];
_options = options;
_context = context;
Expand All @@ -96,6 +99,13 @@ - (id)observer {
return objc_loadWeak(&_observer);
}

- (void*)_rawObserver {
// We might need to remove an observer during its own deallocation;
// We therefore need the ability to grab the raw observer pointer during
// deregistration.
return _rawObserver;
}

- (bool)pushWillChange {
return InterlockedIncrementNoFence(&_changeDepth) == 1;
}
Expand Down Expand Up @@ -374,7 +384,7 @@ static void _removeKeypathObserver(id object, NSString* keypath, id observer, vo
_NSKVOObservationInfo* observationInfo = (_NSKVOObservationInfo*)[object observationInfo];
for (_NSKVOKeyObserver* keyObserver in [observationInfo observersForKey:key]) {
_NSKVOKeypathObserver* keypathObserver = keyObserver.keypathObserver;
if ([keypathObserver.keypath isEqual:keypath] && keypathObserver.object == object &&
if (keypathObserver._rawObserver == observer && keypathObserver.object == object && [keypathObserver.keypath isEqual:keypath] &&
(!context || keypathObserver.context == context)) {
_removeKeyObserver(keyObserver);
return;
Expand Down
5 changes: 0 additions & 5 deletions Frameworks/Foundation/NSString.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2362,11 +2362,6 @@ - (Boolean)_getCString:(char*)buffer maxLength:(NSUInteger)bufferSize encoding:(
return [self getCString:buffer maxLength:bufferSize encoding:encoding];
}

- (const wchar_t*)rawCharacters {
// TODO 7143070 This is only here for compatibility with projections. remove once we get a new projections.
return (const wchar_t*)[self cStringUsingEncoding:NSUTF16StringEncoding];
}

- (int)_versionStringCompare:(NSString*)compStrAddr {
TraceWarning(TAG, L"Warning: versionStringCompare not implemented");
char* str = (char*)[self UTF8String];
Expand Down
5 changes: 4 additions & 1 deletion Frameworks/Foundation/NSXMLPropertyList.mm
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ static id propertyListFromElement(xml_node<>* elem) {
return dataFromElement(elem);
} else if (strncmp(elem->name(), "date", elem->name_size()) == 0) {
Str numStr(elem->value(), elem->value_size());
return [NSDate dateWithTimeIntervalSinceReferenceDate:atof(numStr.cstr())];
// YYYY '-' MM '-' DD 'T' hh ':' mm ':' ss 'Z'
NSDateFormatter* formatter = [[NSDateFormatter new] autorelease];
[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
return [formatter dateFromString:@(numStr.cstr())];
} else {
TraceVerbose(TAG, L"Unrecognized element type!");
}
Expand Down
17 changes: 9 additions & 8 deletions Frameworks/UIKit/NSCoder+UIKitAdditions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#import "NSRaise.h"
#include <StubReturn.h>
#import <UIKit/NSValue+UIKitAdditions.h>
#import <UIKit/UIGeometry.h>

@implementation NSCoder (UIGeometryKeyedCoding)
Expand Down Expand Up @@ -147,28 +148,28 @@ - (void)encodeCGSize:(CGSize)size forKey:(NSString*)aKey {
@Status Interoperable
*/
- (void)encodeCGVector:(CGVector)vector forKey:(NSString*)key {
[self encodeObject:[NSValue valueWithBytes:&vector objCType:@encode(CGVector)] forKey:key];
[self encodeObject:[NSValue valueWithCGVector:vector] forKey:key];
}

/**
@Status Interoperable
*/
- (void)encodeUIEdgeInsets:(UIEdgeInsets)insets forKey:(NSString*)key {
[self encodeObject:[NSValue valueWithBytes:&insets objCType:@encode(UIEdgeInsets)] forKey:key];
[self encodeObject:[NSValue valueWithUIEdgeInsets:insets] forKey:key];
}

/**
@Status Interoperable
*/
- (void)encodeUIOffset:(UIOffset)offset forKey:(NSString*)key {
[self encodeObject:[NSValue valueWithBytes:&offset objCType:@encode(UIOffset)] forKey:key];
[self encodeObject:[NSValue valueWithUIOffset:offset] forKey:key];
}

/**
@Status Interoperable
*/
- (void)encodeCGAffineTransform:(CGAffineTransform)transform forKey:(NSString*)key {
[self encodeObject:[NSValue valueWithBytes:&transform objCType:@encode(CGAffineTransform)] forKey:key];
[self encodeObject:[NSValue valueWithCGAffineTransform:transform] forKey:key];
}
@end

Expand Down Expand Up @@ -224,7 +225,7 @@ - (CGVector)decodeCGVectorForKey:(NSString*)key {
id value = [self decodeObjectForKey:key];

if (value != nil) {
[value getValue:&ret];
ret = [value CGVectorValue];
}
return ret;
}
Expand All @@ -237,7 +238,7 @@ - (UIEdgeInsets)decodeUIEdgeInsetsForKey:(NSString*)key {
id value = [self decodeObjectForKey:key];

if (value != nil) {
[value getValue:&ret];
ret = [value UIEdgeInsetsValue];
}
return ret;
}
Expand All @@ -250,7 +251,7 @@ - (UIOffset)decodeUIOffsetForKey:(NSString*)key {
id value = [self decodeObjectForKey:key];

if (value != nil) {
[value getValue:&ret];
ret = [value UIOffsetValue];
}
return ret;
}
Expand All @@ -263,7 +264,7 @@ - (CGAffineTransform)decodeCGAffineTransformForKey:(NSString*)key {
id value = [self decodeObjectForKey:key];

if (value != nil) {
[value getValue:&ret];
ret = [value CGAffineTransformValue];
}
return ret;
}
Expand Down
41 changes: 41 additions & 0 deletions Frameworks/UIKit/NSValue+UIKitAdditions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ - (id)initWithCGSize:(CGSize)value {
return [self initWithBytes:(void*)&value objCType:@encode(CGSize)];
}

- (id)initWithCGVector:(CGVector)value {
return [self initWithBytes:(void*)&value objCType:@encode(CGVector)];
}

- (id)initWithCGPoint:(CGPoint)value {
return [self initWithBytes:(void*)&value objCType:@encode(CGPoint)];
}
Expand All @@ -42,10 +46,18 @@ - (id)initWithCGAffineTransform:(CGAffineTransform)value {
return [self initWithBytes:(void*)&value objCType:@encode(CGAffineTransform)];
}

- (id)initWithUIEdgeInsets:(UIEdgeInsets)value {
return [self initWithBytes:(void*)&value objCType:@encode(UIEdgeInsets)];
}

+ (NSValue*)valueWithCGSize:(CGSize)value {
return [[[self alloc] initWithCGSize:value] autorelease];
}

+ (NSValue*)valueWithCGVector:(CGVector)value {
return [[[self alloc] initWithCGVector:value] autorelease];
}

+ (NSValue*)valueWithCGPoint:(CGPoint)value {
return [[[self alloc] initWithCGPoint:value] autorelease];
}
Expand All @@ -66,6 +78,10 @@ + (NSValue*)valueWithCGAffineTransform:(CGAffineTransform)value {
return [[[self alloc] initWithCGAffineTransform:value] autorelease];
}

+ (NSValue*)valueWithUIEdgeInsets:(UIEdgeInsets)value {
return [[[self alloc] initWithUIEdgeInsets:value] autorelease];
}

- (CGSize)sizeValue {
CGSize val;
[self getValue:&val];
Expand All @@ -77,6 +93,19 @@ - (CGSize)CGSizeValue {
[self getValue:&val];
return val;
}

- (CGVector)vectorValue {
CGVector val;
[self getValue:&val];
return val;
}

- (CGVector)CGVectorValue {
CGVector val;
[self getValue:&val];
return val;
}

- (CGPoint)pointValue {
CGPoint val;
[self getValue:&val];
Expand Down Expand Up @@ -125,6 +154,18 @@ - (CGAffineTransform)CGAffineTransformValue {
return val;
}

- (UIEdgeInsets)edgeInsetsValue {
UIEdgeInsets val;
[self getValue:&val];
return val;
}

- (UIEdgeInsets)UIEdgeInsetsValue {
UIEdgeInsets val;
[self getValue:&val];
return val;
}

@end

void NSValueForceinclude() {
Expand Down
39 changes: 12 additions & 27 deletions Frameworks/UIKit/StarboardXaml/ApplicationCompositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ using namespace Windows::Foundation;
using namespace Windows::UI::Core;
using namespace Windows::System::Threading;

struct StartParameters {
int argc;
char** argv;
std::string principalClassName;
std::string delegateClassName;
float windowWidth, windowHeight;
};

StartParameters g_startParams = { 0, nullptr, std::string(), std::string(), 0.0f, 0.0f };

void InitializeApp() {
// Only init once.
// No lock needed as this is only called from the UI thread.
Expand All @@ -64,27 +54,22 @@ void InitializeApp() {
}

extern "C" void RunApplicationMain(Platform::String^ principalClassName,
Platform::String^ delegateClassName,
float windowWidth,
float windowHeight) {
Platform::String^ delegateClassName,
float windowWidth,
float windowHeight,
ActivationType activationType,
Platform::String^ activationArg) {
// Perform initialization
InitializeApp();

// Store the start parameters to hand off to the run loop
g_startParams.argc = 0;
g_startParams.argv = nullptr;
g_startParams.principalClassName = Strings::WideToNarrow(principalClassName->Data());
g_startParams.delegateClassName = Strings::WideToNarrow(delegateClassName->Data());
g_startParams.windowWidth = windowWidth;
g_startParams.windowHeight = windowHeight;

// Kick off iOS application main startup
ApplicationMainStart(g_startParams.argc,
g_startParams.argv,
g_startParams.principalClassName.c_str(),
g_startParams.delegateClassName.c_str(),
g_startParams.windowWidth,
g_startParams.windowHeight);
ApplicationMainStart(
Strings::WideToNarrow(principalClassName->Data()).c_str(),
Strings::WideToNarrow(delegateClassName->Data()).c_str(),
windowWidth,
windowHeight,
activationType,
Strings::WideToNarrow(activationArg->Data()).c_str());
}

// clang-format off
16 changes: 12 additions & 4 deletions Frameworks/UIKit/StarboardXaml/ApplicationCompositor.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@
// THE SOFTWARE.
//
//******************************************************************************
// clang-format does not seem to like C++/CX
// clang-format off
#pragma once

#include "StarboardXaml.h"

#ifdef __cplusplus_winrt
extern "C" void RunApplicationMain(Platform::String ^ principalClassName,
Platform::String ^ delegateClassName,
extern "C" void RunApplicationMain(Platform::String^ principalClassName,
Platform::String^ delegateClassName,
float windowWidth,
float windowHeight);
#endif
float windowHeight,
ActivationType type,
Platform::String^ activationArg);
#endif

// clang-format on
11 changes: 8 additions & 3 deletions Frameworks/UIKit/StarboardXaml/ApplicationMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@
//******************************************************************************
#pragma once

// IOS application main startup path
extern "C" int ApplicationMainStart(
int argc, char* argv[], const char* principalName, const char* delegateName, float windowWidth, float windowHeight);
#include "StarboardXaml.h"

// IOS application main startup path
extern "C" int ApplicationMainStart(const char* principalName,
const char* delegateName,
float windowWidth,
float windowHeight,
ActivationType activationType,
const char* activationArg);
void SetTemporaryFolder(const char* folder);
Loading

0 comments on commit 8e5b55d

Please sign in to comment.