Skip to content

[SE-0101] Migration #571

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

Closed
wants to merge 1 commit into from
Closed

[SE-0101] Migration #571

wants to merge 1 commit into from

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jul 29, 2016

Depends on swiftlang/swift#3854

SE-0101 removes sizeof, sizeofValue and related functions from the stdlib.
This PR is migrating them to newly introduced MemoryLayout<T> values.

@@ -38,7 +38,7 @@ class ReaddirTests: XCTestCase {

do {
var s = dirent()
let n = sizeof(s.d_name.dynamicType)
let n = MemoryLayout.of(s.d_name).size
Copy link
Member Author

@rintaro rintaro Jul 29, 2016

Choose a reason for hiding this comment

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

@gribozavr the type of s is platform dependent and something like (Int8, Int8, Int8, ...)
Is there any way without using ._ofInstance(_:) here?

#if os(Linux)
let n = MemoryLayout<(Int8, Int8, Int8, Int8... * 245)>.size
#elif of(macOS)
let n = MemoryLayout<(Int8, Int8, Int8, Int8, Int8... * 1024)>.size
...
#end

is not reasonable to me :(

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the least damaging thing we can do here is copying our _ofInstance implementation into this file (maybe under a non-underscored name):

extension MemoryLayout {
  fileprivate static func ofInstance(_: @autoclosure () -> T) -> MemoryLayout<T>.Type {
    return MemoryLayout<T>.self
  }
}

@gribozavr gribozavr changed the title [Do not merge yet][SE-0101] Migration [SE-0101] Migration Jul 29, 2016
@gribozavr
Copy link
Contributor

gribozavr commented Jul 30, 2016

I'll take care of this. Continuing in #578.

@gribozavr gribozavr closed this Jul 30, 2016
@rintaro rintaro deleted the SE-0101 branch August 1, 2016 07:05
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.

2 participants