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
Ramu-msft committed Nov 5, 2015
2 parents 9a25692 + 338708c commit 346c325
Show file tree
Hide file tree
Showing 19 changed files with 1,901 additions and 399 deletions.
1,195 changes: 1,195 additions & 0 deletions Coding_Standards.md

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions Contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Contributing to WinObjC

There are many ways that you can contribute to the WinObjC project:

- File a bug/issue
- Verify fixes for bugs/issues
- Submit a bug fix or feature implementation
- Submit a feature request
- Submit additional tests
- Tell others about the WinObjC project
- Submit feedback on the project

## Code Conventions
Be sure to familiarize yourself with our [coding standards](Coding_Standards.md) before contributing code fixes.

## Automated Tests

### Running Tests

1. Build the entire solution (<root>\build\build.sln)

2. Run runall.bat under <Root>\WinObjC\tests\unittests

### Authoring UnitTests
1. The UnitTest project is in under build\UnitTests

2. Add test code under tests\unittests and include it into the UnitTest project

3. For more info on writing the tests, see [googletest samples](https://code.google.com/p/googletest/wiki/V1_7_Samples)

## Commit Guidance

Squash your change into 1 commit on top of the master branch.

For the commit message, follow the guide below:

```
The title is a ~50 character summary of the change.
After one blank line, add more detail about the change wrapped to ~80
characters. If there is a github issue that is resolved by the change,
it can be added as below, with one blank line above it.
Fix #42
```

## Contribution License Agreement

You will need to sign a [Contribution License Agreement](https://cla.microsoft.com/) (CLA) before submitting your pull request. To complete the CLA, you will need to submit the request via the form and then electronically sign the CLA when you receive an email containing a link to the document.

This process needs to only be done once for any Microsoft open source project.

### Contributing to README and Wiki

You *do not* need to sign a Contribution License Agreement if you are just contributing to the README or the Wiki. However, by submitting a contribution to the README or the Wiki, you are contributing it under the [Creative Commons CC0 1.0 Universal Public Domain Dedication](http://creativecommons.org/publicdomain/zero/1.0/).

## Directory structure

- bin/ : Various prebuilt tools
- build/ : Projects/solutions to build the SDK
- deps/ : Open source dependencies
- prebuilt/ : Prebuilt binaries for various architectures
- Frameworks/ : Implementation of iOS-style Frameworks
- include/ : SDK headers (including headers for iOS-style Frameworks)
- Platform/ : Headers for Windows Objective-C bindings for various OS versions
- msvc/ : Visual Studio integration files
- samples/ : Assorted samples
- tools/ : Source code to tools

## Pull Request Flow

### Pre-request checklist

Please ensure the following before submitting a pull request for your changes:

- You have signed the [CLA](#contribution-license-agreement) and adhered to it.
- The entire solution (<root>\build\build.sln) builds with no errors for all flavors.
- The changed code follows our [code conventions](Coding_Standards.md).
- New tests have been added for all new features.
- All of the [automated tests](#automated-tests) pass with no failures.

### After submitting a request

What happens after a pull request is submitted?

- WinObjC team reviews the change, and checks for code convention or any other issues.
- WinObjC team verifies the change passes build and automated tests with no errors.

- If the above looks good, the pull request will be accepted, and the change will be merged into the master branch. Otherwise, we will iterate over the changes with the contributor to work through any issues before accepting the pull request.
168 changes: 0 additions & 168 deletions Frameworks/Foundation/NSArray.h

This file was deleted.

25 changes: 18 additions & 7 deletions Frameworks/Foundation/NSArray.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
#include "CoreFoundation/CFType.h"
#include "Foundation/NSIndexSet.h"
#include "Foundation/NSNull.h"
#include "NSArrayInternal.h"

__declspec(dllimport) extern "C" int CFNSBlockCompare(id obj1, id obj2, void* block);

@class NSXMLPropertyList, NSPropertyListReader, NSArrayConcrete, NSMutableArrayConcrete, NSPropertyListWriter_Binary;

@implementation NSArray : NSObject
@implementation NSArray
+ (NSArray*)arrayWithObjects:(NSObject*)first, ... {
va_list pReader;
va_start(pReader, first);
Expand Down Expand Up @@ -280,8 +281,12 @@ - (NSUInteger)indexOfObjectIdenticalTo:(id)obj {
return NSNotFound;
}

+ (BOOL)supportsSecureCoding {
return YES;
}

- (NSArray*)initWithCoder:(NSCoder*)coder {
id array = [coder decodeObjectForKey:@"NS.objects"];
id array = [coder decodeObjectOfClasses:coder.allowedClasses forKey:@"NS.objects"];

[self initWithArray:array];
return self;
Expand Down Expand Up @@ -787,18 +792,24 @@ - (NSArray*)objectsAtIndexes:(NSIndexSet*)indexes {

@end

@implementation NSArrayConcrete : NSArray
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState*)state objects:(id*)stackBuf count:(NSUInteger)maxCount {
DWORD count = CFArrayGetCount((CFArrayRef)self);
NSUInteger _NSArrayConcreteCountByEnumeratingWithState(NSArray* self, NSFastEnumerationState* state) {
auto count = CFArrayGetCount((CFArrayRef)self);

if (state->state >= count) {
return 0;
}

state->itemsPtr = (id*)_CFArrayGetPtr((CFArrayRef)self);
auto internalPointer = reinterpret_cast<id*>(_CFArrayGetPtr(static_cast<CFArrayRef>(self)));
state->itemsPtr = internalPointer;
state->state = count;
state->mutationsPtr = (unsigned long*)self;
state->mutationsPtr = reinterpret_cast<unsigned long*>(self);

return count;
}

@implementation NSArrayConcrete
// NSArrayConcrete ignores the passed-in stackbuf+size, as it has its own contiguous storage for its internal object pointers.
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState*)state objects:(id*)stackBuf count:(NSUInteger)maxCount {
return _NSArrayConcreteCountByEnumeratingWithState(self, state);
}
@end
19 changes: 19 additions & 0 deletions Frameworks/Foundation/NSArrayInternal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//******************************************************************************
//
// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
//******************************************************************************

#pragma once

NSUInteger _NSArrayConcreteCountByEnumeratingWithState(NSArray* self, NSFastEnumerationState* state);
10 changes: 7 additions & 3 deletions Frameworks/Foundation/NSDictionary.mm
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,13 @@ - (instancetype)initWithObject:(id)val forKey:(id)key {
return self;
}

- (id)initWithCoder:(id)coder {
NSArray* keys = [coder decodeObjectForKey:@"NS.keys"];
NSArray* values = [coder decodeObjectForKey:@"NS.objects"];
+ (BOOL)supportsSecureCoding {
return YES;
}

- (id)initWithCoder:(NSCoder*)coder {
NSArray* keys = [coder decodeObjectOfClasses:coder.allowedClasses forKey:@"NS.keys"];
NSArray* values = [coder decodeObjectOfClasses:coder.allowedClasses forKey:@"NS.objects"];

[self initWithObjects:values forKeys:keys];

Expand Down
Loading

0 comments on commit 346c325

Please sign in to comment.