Skip to content

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

Merged
merged 39 commits into from
Dec 7, 2015
Merged

Added NSPipe implementation #38

merged 39 commits into from
Dec 7, 2015

Conversation

terhechte
Copy link
Contributor

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.

BryanHoke and others added 8 commits December 4, 2015 02:31
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

let text = "test-pipe"

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)) { () -> Void in
Copy link
Contributor

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.

@terhechte
Copy link
Contributor Author

I've updated the test to remove the libdispatch requirement.

parkera and others added 18 commits December 5, 2015 13:41
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.
Verify contents of the file attributes dictionary
Simplify implementation of `init(indexes:length:)`.
…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


class TestNSPipe : XCTestCase {

Copy link
Contributor

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)
    ]
 }

@terhechte
Copy link
Contributor Author

Thanks for these comments! I've updated the test and I've also included an additional assertion for the initial string to nsdata conversion.

@phausler
Copy link
Contributor

phausler commented Dec 7, 2015

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
@terhechte
Copy link
Contributor Author

I did a rebase so that the glob in build.py could be used and added to main.swift.

@phausler
Copy link
Contributor

phausler commented Dec 7, 2015

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.

@terhechte
Copy link
Contributor Author

Awesome, thanks!

@phausler phausler merged commit 37e4160 into swiftlang:master Dec 7, 2015
atrick pushed a commit to atrick/swift-corelibs-foundation that referenced this pull request Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.