diff --git a/.gitignore b/.gitignore index 02c0875..119616e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /.build /Packages /*.xcodeproj +/Package.pins diff --git a/.swift-version b/.swift-version index d0b9234..8c50098 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -DEVELOPMENT-SNAPSHOT-2016-05-09-a +3.1 diff --git a/.travis.yml b/.travis.yml index e8bc901..6f34747 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,10 @@ -notifications: - slack: zewo:VjyVCCQvTOw9yrbzQysZezD1 os: - linux - - osx -language: generic -sudo: required dist: trusty -osx_image: xcode7.3 +sudo: required +language: generic install: - - eval "$(curl -sL https://raw.githubusercontent.com/Zewo/Zewo/5254525d9da56df29346fd76e99529c22034d61d/Scripts/install-swiftenv.sh)" + - eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)" script: - swift build - swift build -c release diff --git a/Package.swift b/Package.swift index c206339..d811a02 100644 --- a/Package.swift +++ b/Package.swift @@ -3,6 +3,6 @@ import PackageDescription let package = Package( name: "UUID", dependencies: [ - .Package(url: "https://github.com/Zewo/POSIX.git", majorVersion: 0, minor: 5) + .Package(url: "https://github.com/Zewo/POSIX.git", majorVersion: 0, minor: 15) ] ) diff --git a/README.md b/README.md index 8168b91..209d4eb 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ **UUID** allows your to easily create Universally Unique Identifiers. Pure Swift. + ## Installation ```swift @@ -10,12 +11,12 @@ import PackageDescription let package = Package( dependencies: [ - .Package(url: "https://github.com/Zewo/UUID.git", majorVersion: 0, minor: 7) + .Package(url: "https://github.com/Ponyboy47/UUID.git", majorVersion: 0, minor: 8) ] ) ``` -Compiles with the `05-09` snapshot. Compatibility with other versions of Swift is not guaranteed. +Compiles with swift 3.1. Compatibility with other versions of Swift is not guaranteed. ## Usage @@ -50,14 +51,14 @@ The entire Zewo code base is licensed under MIT. By contributing to Zewo you are [codebeat-url]: https://codebeat.co/projects/github-com-zewo-uuid [mit-badge]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat [mit-url]: https://tldrlegal.com/license/mit-license -[platform-badge]: https://img.shields.io/badge/Platforms-OS%20X%20--%20Linux-lightgray.svg?style=flat +[platform-badge]: https://img.shields.io/badge/Platform-%20Linux-lightgray.svg?style=flat [platform-url]: https://swift.org [slack-badge]: https://zewo-slackin.herokuapp.com/badge.svg [slack-image]: http://s13.postimg.org/ybwy92ktf/Slack.png [slack-url]: http://slack.zewo.io -[swift-badge]: https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat +[swift-badge]: https://img.shields.io/badge/Swift-3.1-orange.svg?style=flat [swift-url]: https://swift.org -[travis-badge]: https://travis-ci.org/Zewo/UUID.svg?branch=master -[travis-url]: https://travis-ci.org/Zewo/UUID +[travis-badge]: https://travis-ci.org/Ponyboy47/UUID.svg?branch=master +[travis-url]: https://travis-ci.org/Ponyboy47/UUID [zewo-badge]: https://img.shields.io/badge/Zewo-0.7-FF7565.svg?style=flat -[zewo-url]: http://zewo.io \ No newline at end of file +[zewo-url]: http://zewo.io diff --git a/Sources/UUID.swift b/Sources/UUID.swift index 69658ab..0d228c4 100644 --- a/Sources/UUID.swift +++ b/Sources/UUID.swift @@ -7,6 +7,11 @@ // import POSIX +#if os(Linux) +import Glibc +#else +import Darwin +#endif public struct UUID { @@ -19,7 +24,7 @@ public struct UUID { } deinit { - bytes.deallocateCapacity(UUID.size) + bytes.deallocate(capacity: UUID.size) } } @@ -43,7 +48,7 @@ public struct UUID { */ public init() { let bytes: UnsafeMutablePointer = { - let bytes = UnsafeMutablePointer(allocatingCapacity: UUID.size) + let bytes = UnsafeMutablePointer.allocate(capacity: UUID.size) let fd = open("/dev/urandom", O_RDONLY) read(fd, bytes, UUID.size) close(fd) @@ -94,10 +99,10 @@ extension UUID: CustomStringConvertible, RawRepresentable { return nil } - let bytes = UnsafeMutablePointer.init(allocatingCapacity: UUID.size) + let bytes = UnsafeMutablePointer.allocate(capacity: UUID.size) - let out = UnsafeMutablePointer(allocatingCapacity: 1) - defer { out.deallocateCapacity(1) } + let out = UnsafeMutablePointer.allocate(capacity: 1) + defer { out.deallocate(capacity: 1) } let result: Int32 = rawValue.withCString { cString in let list = (0..