Skip to content

NSData: Align methods with Darwin #1287

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 3 commits into from
Nov 18, 2017
Merged

Conversation

spevans
Copy link
Contributor

@spevans spevans commented Oct 28, 2017

  • Remove 'convenience' from:
    init()
    init(bytes:length:)
    init(bytesNoCopy:length:)
    init(bytesNoCopy:length:freeWhenDone:)
    init(bytesNoCopy:length:deallocator:)
    init(contentsOfFile:options:)
    init?(contentsOfFile:)
    init(data:)
    init(contentsOf:,options:)
    init?(base64Encoded base64String:options:)
    init?(base64Encoded base64Data:options:)

  • Add:
    init?(contentsOf:)
    (deprecated) base64Encoding()

  • Add (unimplemented):
    (deprecated) init?(contentsOfMappedFile:)
    (deprecated) class func dataWithContentsOfMappedFile()
    contains()
    contains(where:)

NSMutableData:

  • Remove 'convenience' from:
    init?(capacity:)
    init?(length:)

  • Add:
    init(bytes:length:)

  • Add description documentation to public methods.

  • Update tests.

- Remove 'convenience' from:
  init()
  init(bytes:length:)
  init(bytesNoCopy:length:)
  init(bytesNoCopy:length:freeWhenDone:)
  init(bytesNoCopy:length:deallocator:)
  init(contentsOfFile:options:)
  init?(contentsOfFile:)
  init(data:)
  init(contentsOf:,options:)
  init?(base64Encoded base64String:options:)
  init?(base64Encoded base64Data:options:)

- Add:
  init?(contentsOf:)
  (deprecated) base64Encoding()

- Add (unimplemented):
  (deprecated) init?(contentsOfMappedFile:)
  (deprecated) class func dataWithContentsOfMappedFile()
  contains()
  contains(where:)

NSMutableData:

- Remove 'convenience' from:
   init?(capacity:)
   init?(length:)

- Add:
  init(bytes:length:)

- Add description documentation to public methods.

- Update tests.
@spevans
Copy link
Contributor Author

spevans commented Oct 28, 2017

@swift-ci please test

@available(*, deprecated)
/// Initializes a data object with the contents of the mapped file specified by a given path.
public init?(contentsOfMappedFile path: String) {
NSUnimplemented()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We intentionally left out deprecated API from swift-corelibs-foundation.

@spevans
Copy link
Contributor Author

spevans commented Oct 31, 2017

@swift-ci please test

1 similar comment
@spevans
Copy link
Contributor Author

spevans commented Oct 31, 2017

@swift-ci please test

@ianpartridge
Copy link
Contributor

This looks good to me. @spevans are you happy?

@spevans
Copy link
Contributor Author

spevans commented Nov 13, 2017

@ianpartridge Yes I think this is ok to go now

@ianpartridge
Copy link
Contributor

@parkera any more thoughts on this? i've gone through it and compared with the docs, it looks good to me.

/// Returns a Boolean value indicating whether the sequence contains the given element.
func contains(_ element: UInt8) -> Bool {
NSUnimplemented()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did contains and contains(where) come from? As far as I know NSData doesn't conform to Sequence (struct Data does).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I based the missing methods on this documentation:

https://developer.apple.com/documentation/foundation/nsdata

Which has the 2 contains methods. Maybe the documentation is incorrect?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see them in the generated interface for NSData on Darwin. I'll file a bug for the documentation.

@spevans
Copy link
Contributor Author

spevans commented Nov 16, 2017

@swift-ci please test

@spevans
Copy link
Contributor Author

spevans commented Nov 17, 2017

@parkera I removed the two contains methods. Do you have any other concerns or does this look ok now?

@parkera
Copy link
Contributor

parkera commented Nov 17, 2017

Nope, thanks!

@ianpartridge
Copy link
Contributor

@swift-ci please test and merge

@swift-ci swift-ci merged commit 5d04589 into swiftlang:master Nov 18, 2017
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.

4 participants