forked from blanu/Song
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:blanu/Song
- Loading branch information
Showing
18 changed files
with
638 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/.build | ||
/Packages | ||
/*.xcodeproj | ||
query |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11134" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11134"/> | ||
</dependencies> | ||
<objects> | ||
<customObject id="-2" userLabel="File's Owner"/> | ||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> | ||
<customObject id="-3" userLabel="Application" customClass="NSObject"/> | ||
</objects> | ||
</document> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import Foundation | ||
import Network | ||
import Datable | ||
|
||
public func remoteCall(code: String, callback: @escaping (Data) -> Void ) | ||
{ | ||
let queue = DispatchQueue(label: "network") | ||
|
||
let conn = NWConnection(host: NWEndpoint.Host("127.0.0.1"), port: NWEndpoint.Port(integerLiteral: 1234), using: .tcp) | ||
conn.start(queue: queue) | ||
|
||
let payload = code.data | ||
let length = payload.count | ||
let length16 = UInt16(length) | ||
let lengthBytes = length16.data | ||
let data = lengthBytes + payload | ||
|
||
conn.send(content: data, completion: NWConnection.SendCompletion.contentProcessed( | ||
{ | ||
maybeError in | ||
|
||
guard maybeError == nil else { return } | ||
|
||
conn.receive(minimumIncompleteLength: 2, maximumLength: 2) | ||
{ | ||
(maybeData, maybeContext, isComplete, maybeError) in | ||
|
||
print("received \(maybeData)") | ||
|
||
guard maybeError == nil else { return } | ||
guard let data = maybeData else { return } | ||
|
||
let length = Int(data.uint16) | ||
|
||
conn.receive(minimumIncompleteLength: length, maximumLength: length) | ||
{ | ||
(maybeData, maybeContext, isComplete, maybeError) in | ||
|
||
print("received.. \(maybeData)") | ||
|
||
guard maybeError == nil else { return } | ||
guard let data = maybeData else { return } | ||
|
||
callback(data) | ||
} | ||
} | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import Foundation | ||
|
||
public struct Package | ||
{ | ||
public let name: String | ||
public let type: PackageType | ||
|
||
public init(name: String, type: PackageType = .library) | ||
{ | ||
self.name = name | ||
self.type = type | ||
|
||
guard let _ = try? FileManager.default.createDirectory(atPath: self.name, withIntermediateDirectories: false, attributes: nil) else { return } | ||
|
||
let process = Process() | ||
process.currentDirectoryPath = self.name | ||
process.launchPath = "/usr/bin/swift" | ||
|
||
switch self.type | ||
{ | ||
case .library: | ||
process.arguments = ["package", "init", "--type", "library"] | ||
case .executable: | ||
process.arguments = ["package", "init", "--type", "executable"] | ||
} | ||
|
||
process.launch() | ||
process.waitUntilExit() | ||
} | ||
|
||
public func update() | ||
{ | ||
let process = Process() | ||
process.currentDirectoryPath = self.name | ||
process.launchPath = "/usr/bin/swift" | ||
|
||
process.arguments = ["package", "update"] | ||
|
||
process.launch() | ||
process.waitUntilExit() | ||
} | ||
|
||
public func build() | ||
{ | ||
let process = Process() | ||
process.currentDirectoryPath = self.name | ||
process.launchPath = "/usr/bin/swift" | ||
|
||
process.arguments = ["build", "-Xswiftc", "-target", "-Xswiftc", "x86_64-apple-macosx10.14"] | ||
|
||
process.launch() | ||
process.waitUntilExit() | ||
} | ||
|
||
public func run() -> Data | ||
{ | ||
let process = Process() | ||
process.currentDirectoryPath = self.name | ||
process.launchPath = "/usr/bin/swift" | ||
|
||
process.arguments = ["run"] | ||
let output = Pipe() | ||
process.standardOutput = output | ||
let handle = output.fileHandleForReading | ||
|
||
process.launch() | ||
process.waitUntilExit() | ||
|
||
let data = handle.readDataToEndOfFile() | ||
return data | ||
} | ||
} | ||
|
||
public enum PackageType | ||
{ | ||
case library | ||
case executable | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.