Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/.build
/Packages
/*.xcodeproj
/Package.pins
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DEVELOPMENT-SNAPSHOT-2016-05-09-a
3.1
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]
)
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@

**UUID** allows your to easily create Universally Unique Identifiers. Pure Swift.


## Installation

```swift
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

Expand Down Expand Up @@ -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
[zewo-url]: http://zewo.io
15 changes: 10 additions & 5 deletions Sources/UUID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
//

import POSIX
#if os(Linux)
import Glibc
#else
import Darwin
#endif

public struct UUID {

Expand All @@ -19,7 +24,7 @@ public struct UUID {
}

deinit {
bytes.deallocateCapacity(UUID.size)
bytes.deallocate(capacity: UUID.size)
}
}

Expand All @@ -43,7 +48,7 @@ public struct UUID {
*/
public init() {
let bytes: UnsafeMutablePointer<UInt8> = {
let bytes = UnsafeMutablePointer<UInt8>(allocatingCapacity: UUID.size)
let bytes = UnsafeMutablePointer<UInt8>.allocate(capacity: UUID.size)
let fd = open("/dev/urandom", O_RDONLY)
read(fd, bytes, UUID.size)
close(fd)
Expand Down Expand Up @@ -94,10 +99,10 @@ extension UUID: CustomStringConvertible, RawRepresentable {
return nil
}

let bytes = UnsafeMutablePointer<UInt8>.init(allocatingCapacity: UUID.size)
let bytes = UnsafeMutablePointer<UInt8>.allocate(capacity: UUID.size)

let out = UnsafeMutablePointer<Int32>(allocatingCapacity: 1)
defer { out.deallocateCapacity(1) }
let out = UnsafeMutablePointer<Int32>.allocate(capacity: 1)
defer { out.deallocate(capacity: 1) }

let result: Int32 = rawValue.withCString { cString in
let list = (0..<UUID.size).map { bytes.advanced(by: $0) as CVarArg }
Expand Down
File renamed without changes.