-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Added NSPipe
implementation
#38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In `init(indexes:length:)`, initialize `_indexes` to an `Array` constructed with an `UnsafeBufferPointer` built from `indexes`, instead of initializing it to an empty array and adding each `idx` in `indexes` to it in a loop.
Fixed whitespacing issues Merge timeZone assignment into more clear single operation
Experiment tag added to attributesOfItemAtPath(path: String) function
… as part of Swift 3 naming changes.
Clarify GettingStarted.md
Added missing keys for NSURLError
|
||
let text = "test-pipe" | ||
|
||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)) { () -> Void in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the swift corelibs dispatch is not yet available for linux unfortunately so a thread or some other mechanism would have to be used to asynchronously read.
I've updated the test to remove the libdispatch requirement. |
Clarify where NSCalendar timezone is set and return values
…removeIndex: and addIndex:. The bounds checking is already done at removeIndexesinRange: and addIndexesInRange:, which removeIndex: and addIndex: call through to respectively.
During initalization store the number type in the CFInfo bitfield in the same way that CFNumberCreate does. NSNumber/CFNumber stores its value in a UInt64 (_pad) with associated type information as part of the CFInfo bitfield. NSNUmber Initialization is performed through _CFNumberInit which copies the value bytes into _pad but does not store the type information. This leads to broken behaviour when converting between type repesentations. i.e. Double -> NSNumber -> Integer.
[SR-71] Repair NSNumber behaviour
Remove some TODOs
Verify contents of the file attributes dictionary
Simplify implementation of `init(indexes:length:)`.
…nage dependencies
…on directory is part of the unit test build phase
These were category methods that were not properly imported during the first pass at NSData
These methods were initially missed during the first imports of NSData's interface
Update NSIndexSet enumeration snippets to Swift
Check only for the existence of file owner's account (user) identifier instead of comparing its numeric value because - user identifier of `0` are assigned to the superuser in linux - negative value are valid account identifier. e.g. `nobody` is `-2` (See https://en.wikipedia.org/wiki/User_identifier) - There's an assumption made here that account identifier are numeric which is reasonable for most system but there's a slim chance that this might not be the case. Thanks to @lxcid
Add string constants for NSDecimalNumber Add more string constants Add more string constants
Fixes test case TestNSFileManger.test_fileAttributes
Add string constants
Add NSProgress string constants
|
||
|
||
class TestNSPipe : XCTestCase { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a method for allTests
public var allTests: [(String, () -> ())] {
return [
("test_NSPipe", test_NSPipe)
]
}
Thanks for these comments! I've updated the test and I've also included an additional assertion for the initial string to nsdata conversion. |
One other minor thing it needs is the TestNSPipe.swift added to build.py (or rebase from master which now globs; which is preferable) and in TestFoundation/main.swift add the test to the XCTMain |
The implementation itself is very simple. In the unlikely event that the `pipe` system call fails, this implementation will stop with a fatalError. This seems to be the canon way of doing it based on my cursory reading of the rest of foundation.
The test currently only makes sure that writes into the pipe can be read correctly out of the pipe.
Since pipes can buffer the bytes just fine the asynchronous call was not really necessary for such a simple test anyway.
- Added `bridge()` to not rely on implicit bridging - Added `allTests` property - Updated Comments - Added assert for string to NSData conversion
I did a rebase so that the |
Builds correctly now; running the tests on linux fail due to missing functionality in NSString; but overall the implementation looks good to me, I am going to merge this in and just disable the test until NSString implementations get up to par to deal with this. |
Awesome, thanks! |
Prefer Void over ().
The implementation itself is very simple. In the unlikely event that the
pipe
system call fails, this implementation will stop with a fatalError.This seems to be the canonical way of doing it based on my cursory reading of
the rest of foundation.
I've also added a first, simple, unit test to make sure the pipe works as expected.