removing zewo/core dependence

This commit is contained in:
badim 2016-10-09 13:31:04 +03:00
parent 0cc0c5332e
commit e888bdd8f0
2 changed files with 10 additions and 11 deletions

View File

@ -3,7 +3,6 @@ import PackageDescription
let package = Package( let package = Package(
name: "ZeroMQ", name: "ZeroMQ",
dependencies: [ dependencies: [
.Package(url: "https://github.com/Zewo/Core.git", majorVersion: 0, minor: 13),
.Package(url: "https://github.com/Zewo/CZeroMQ.git", majorVersion: 1, minor: 0), .Package(url: "https://github.com/Zewo/CZeroMQ.git", majorVersion: 1, minor: 0),
] ]
) )

View File

@ -23,7 +23,7 @@
// SOFTWARE. // SOFTWARE.
import CZeroMQ import CZeroMQ
import Core import struct Foundation.Data
public struct SendMode : OptionSet { public struct SendMode : OptionSet {
public let rawValue: Int public let rawValue: Int
@ -197,11 +197,11 @@ public struct SocketEvent : OptionSet {
extension Socket { extension Socket {
func setOption(_ option: Int32, _ value: Bool) throws { func setOption(_ option: Int32, _ value: Bool) throws {
var value = value ? 1 : 0 var value = value ? 1 : 0
try setOption(option, value: &value, length: strideof(Int32.self)) try setOption(option, value: &value, length: MemoryLayout<Int32>.stride)
} }
func setOption(_ option: Int32, _ value: Int32) throws { func setOption(_ option: Int32, _ value: Int32) throws {
var value = value var value = value
try setOption(option, value: &value, length: strideof(Int32.self)) try setOption(option, value: &value, length: MemoryLayout<Int32>.stride)
} }
func setOption(_ option: Int32, _ value: String) throws { func setOption(_ option: Int32, _ value: String) throws {
try value.withCString { v in try value.withCString { v in
@ -227,7 +227,7 @@ extension Socket {
extension Socket { extension Socket {
public func setAffinity(_ value: UInt64) throws { public func setAffinity(_ value: UInt64) throws {
var value = value var value = value
try setOption(ZMQ_AFFINITY, value: &value, length: strideof(UInt64.self)) try setOption(ZMQ_AFFINITY, value: &value, length: MemoryLayout<UInt64>.stride)
} }
public func setBacklog(_ value: Int32) throws { public func setBacklog(_ value: Int32) throws {
@ -316,7 +316,7 @@ extension Socket {
public func setMaxMessageSize(_ value: Int64) throws { public func setMaxMessageSize(_ value: Int64) throws {
var value = value var value = value
try setOption(ZMQ_MAXMSGSIZE, value: &value, length: strideof(Int64.self)) try setOption(ZMQ_MAXMSGSIZE, value: &value, length: MemoryLayout<Int64>.stride)
} }
public func setMulticastHops(_ value: Int32) throws { public func setMulticastHops(_ value: Int32) throws {
@ -463,7 +463,7 @@ extension Socket {
extension Socket { extension Socket {
func getOption(_ option: Int32) throws -> Int32 { func getOption(_ option: Int32) throws -> Int32 {
var value: Int32 = 0 var value: Int32 = 0
var length = strideof(Int32.self) var length = MemoryLayout<Int32>.stride
try getOption(option, value: &value, length: &length) try getOption(option, value: &value, length: &length)
return value return value
} }
@ -482,7 +482,7 @@ extension Socket {
extension Socket { extension Socket {
public func getAffinity() throws -> UInt64 { public func getAffinity() throws -> UInt64 {
var value: UInt64 = 0 var value: UInt64 = 0
var length = strideof(UInt64.self) var length = MemoryLayout<UInt64>.stride
try getOption(ZMQ_AFFINITY, value: &value, length: &length) try getOption(ZMQ_AFFINITY, value: &value, length: &length)
return value return value
} }
@ -566,7 +566,7 @@ extension Socket {
public func getMaxMessageSize() throws -> Int64 { public func getMaxMessageSize() throws -> Int64 {
var value: Int64 = 0 var value: Int64 = 0
var length = strideof(Int64.self) var length = MemoryLayout<Int64>.stride
try getOption(ZMQ_MAXMSGSIZE, value: &value, length: &length) try getOption(ZMQ_MAXMSGSIZE, value: &value, length: &length)
return value return value
} }
@ -696,13 +696,13 @@ extension SecurityMechanism {
extension Socket { extension Socket {
public func sendString(_ string: String, mode: SendMode = []) throws -> Bool { public func sendString(_ string: String, mode: SendMode = []) throws -> Bool {
return try send(Data(string), mode: mode) return try send(Data(string.utf8), mode: mode)
} }
public func receiveString(_ mode: ReceiveMode = []) throws -> String? { public func receiveString(_ mode: ReceiveMode = []) throws -> String? {
guard let buffer = try receive(mode: mode) else { guard let buffer = try receive(mode: mode) else {
return nil return nil
} }
return try? String(data: buffer) return String(data: buffer, encoding: String.Encoding.utf8)
} }
} }