Skip to content

Commit

Permalink
2.0.0 (#15)
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Smallman <srsmallman@mac.com>
  • Loading branch information
sammysmallman authored Jun 4, 2024
1 parent 887328e commit 20581ab
Show file tree
Hide file tree
Showing 43 changed files with 593 additions and 394 deletions.
2 changes: 1 addition & 1 deletion .swiftpm/xcode/xcshareddata/xcschemes/CoreOSC.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1530"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.3
// swift-tools-version:5.9
import PackageDescription

let package = Package(
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ let message1 = try! OSCMessage(with: "/core/osc/1")
let message2 = try! OSCMessage(with: "/core/osc/2")
let message3 = try! OSCMessage(with: "/core/osc/3")

let bundle = OSCBundle([message1, message2, message3],
let bundle = OSCBundle([.message(message1), .message(message2), .message(message3)],
timetag: .immediate)
```

Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreOSC/CoreOSC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Foundation
public enum CoreOSC {

/// This package's semantic version number, mirrored also in git history as a `git tag`.
public static let version: String = "1.3.1"
public static let version: String = "2.0.0"

/// The license agreement this repository is licensed under.
public static let license: String = {
Expand Down
34 changes: 16 additions & 18 deletions Sources/CoreOSC/Extensions/Character.swift
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
//
// Characeter.swift
// Character.swift
// CoreOSC
//
// Created by Sam Smallman on 26/07/2021.
// Copyright © 2021 Sam Smallman. https://github.com/SammySmallman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// This file is part of CoreOSC
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// CoreOSC is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// CoreOSC is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//


import Foundation

public extension Character {

static let oscTypeTagString: Character = "s"
static let oscTypeTagInt: Character = "i"
static let oscTypeTagFloat: Character = "f"
static let oscTypeTagInt32: Character = "i"
static let oscTypeTagFloat32: Character = "f"
static let oscTypeTagBlob: Character = "b"
static let oscTypeTagTimeTag: Character = "t"
static let oscTypeTagTrue: Character = "T"
Expand Down
45 changes: 26 additions & 19 deletions Sources/CoreOSC/Extensions/Numeric.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,41 @@
// CoreOSC
//
// Created by Sam Smallman on 18/07/2021.
// Copyright © 2020 Sam Smallman. https://github.com/SammySmallman
// Copyright © 2021 Sam Smallman. https://github.com/SammySmallman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// This file is part of CoreOSC
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// CoreOSC is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// CoreOSC is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//


import Foundation

extension Numeric {
extension UInt32 {

var data: Data {
var source = self
return Data(bytes: &source, count: MemoryLayout<UInt32>.size)
}

}

extension Int32 {

internal var data: Data {
var data: Data {
var source = self
return Data(bytes: &source, count: MemoryLayout<Self>.size)
return Data(bytes: &source, count: MemoryLayout<Int32>.size)
}

}
30 changes: 14 additions & 16 deletions Sources/CoreOSC/Extensions/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@
// CoreOSC
//
// Created by Sam Smallman on 18/07/2021.
// Copyright © 2020 Sam Smallman. https://github.com/SammySmallman
// Copyright © 2021 Sam Smallman. https://github.com/SammySmallman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// This file is part of CoreOSC
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// CoreOSC is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// CoreOSC is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//


import Foundation

Expand Down
30 changes: 14 additions & 16 deletions Sources/CoreOSC/Extensions/UInt32.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@
// CoreOSC
//
// Created by Sam Smallman on 18/07/2021.
// Copyright © 2020 Sam Smallman. https://github.com/SammySmallman
// Copyright © 2021 Sam Smallman. https://github.com/SammySmallman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// This file is part of CoreOSC
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// CoreOSC is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// CoreOSC is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//


import Foundation

Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreOSC/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2023 Sam Smallman. https://github.com/SammySmallman
Copyright © 2021 Sam Smallman. https://github.com/SammySmallman

This file is part of CoreOSC

Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreOSC/OSCAddress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// CoreOSC
//
// Created by Sam Smallman on 26/07/2021.
// Copyright © 2022 Sam Smallman. https://github.com/SammySmallman
// Copyright © 2021 Sam Smallman. https://github.com/SammySmallman
//
// This file is part of CoreOSC
//
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreOSC/OSCAddressError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// CoreOSC
//
// Created by Sam Smallman on 29/07/2021.
// Copyright © 2022 Sam Smallman. https://github.com/SammySmallman
// Copyright © 2021 Sam Smallman. https://github.com/SammySmallman
//
// This file is part of CoreOSC
//
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreOSC/OSCAddressFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// CoreOSC
//
// Created by Sam Smallman on 13/08/2021.
// Copyright © 2022 Sam Smallman. https://github.com/SammySmallman
// Copyright © 2021 Sam Smallman. https://github.com/SammySmallman
//
// This file is part of CoreOSC
//
Expand Down
4 changes: 2 additions & 2 deletions Sources/CoreOSC/OSCAddressPattern.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// CoreOSC
//
// Created by Sam Smallman on 29/07/2021.
// Copyright © 2022 Sam Smallman. https://github.com/SammySmallman
// Copyright © 2021 Sam Smallman. https://github.com/SammySmallman
//
// This file is part of CoreOSC
//
Expand All @@ -24,7 +24,7 @@
import Foundation

/// An object that represents the full path to one or more OSC Methods through pattern matching.
public struct OSCAddressPattern: Hashable, Equatable {
public struct OSCAddressPattern: Hashable, Equatable, Sendable {

/// The full path to one or more OSC Methods.
public let fullPath: String
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreOSC/OSCAddressSpace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// CoreOSC
//
// Created by Sam Smallman on 10/08/2021.
// Copyright © 2022 Sam Smallman. https://github.com/SammySmallman
// Copyright © 2021 Sam Smallman. https://github.com/SammySmallman
//
// This file is part of CoreOSC
//
Expand Down
42 changes: 21 additions & 21 deletions Sources/CoreOSC/OSCAnnotation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// CoreOSC
//
// Created by Sam Smallman on 22/07/2021.
// Copyright © 2022 Sam Smallman. https://github.com/SammySmallman
// Copyright © 2021 Sam Smallman. https://github.com/SammySmallman
//
// This file is part of CoreOSC
//
Expand Down Expand Up @@ -88,7 +88,7 @@ public struct OSCAnnotation {
// There should only be one match. Range at index 1 will always be the address pattern.
// If there are arguments these will be found at index 2,
// prefaced with "=" and index 3 if there are more than one argument.
var arguments: [OSCArgumentProtocol] = []
var arguments: [OSCArgument] = []
guard let match = matches.first, match.range == annotation.nsrange,
let address = annotation.substring(with: match.range(at: 1)) else { return nil }
if var argumentString = annotation.substring(with: match.range(at: 2)) {
Expand All @@ -102,22 +102,22 @@ public struct OSCAnnotation {
if let decimal = Decimal(string: argument, locale: Locale(identifier: "en_US")) {
if decimal.isZero || (decimal.isNormal && decimal.exponent >= 0),
let int = Int32(argument) {
arguments.append(int)
arguments.append(.int32(int))
} else if let float = Float32(argument) {
arguments.append(float)
arguments.append(.float32(float))
} else {
arguments.append(argument)
arguments.append(.string(argument))
}
} else {
switch argument {
case "true":
arguments.append(true)
arguments.append(.true)
case "false":
arguments.append(false)
arguments.append(.false)
case "nil":
arguments.append(OSCArgument.nil)
arguments.append(.nil)
case "impulse":
arguments.append(OSCArgument.impulse)
arguments.append(.impulse)
default:
// If the argument is prefaced with quotation marks,
// the regex dictates the argument should close with them.
Expand All @@ -126,9 +126,9 @@ public struct OSCAnnotation {
var quoationMarkArgument = argument
quoationMarkArgument.removeFirst()
quoationMarkArgument.removeLast()
arguments.append(quoationMarkArgument)
arguments.append(.string(quoationMarkArgument))
} else {
arguments.append(argument)
arguments.append(.string(argument))
}
}

Expand All @@ -151,7 +151,7 @@ public struct OSCAnnotation {
range: annotation.nsrange)
// There should only be one match. Range at index 1 will always be the address pattern.
// Range at index 2 will be the argument string prefaced with " "
var arguments: [OSCArgumentProtocol] = []
var arguments: [OSCArgument] = []
guard let match = matches.first, match.range == annotation.nsrange,
let address = annotation.substring(with: match.range(at: 1)),
let argumentString = annotation.substring(with: match.range(at: 2)) else {
Expand All @@ -176,22 +176,22 @@ public struct OSCAnnotation {
if argument.quoted == false,
let decimal = Decimal(string: argument.string, locale: Locale(identifier: "en_US")) {
if decimal.isZero || (decimal.isNormal && decimal.exponent >= 0), let int = Int32(argument.string) {
arguments.append(int)
arguments.append(.int32(int))
} else if let float = Float32(argument.string) {
arguments.append(float)
arguments.append(.float32(float))
} else {
arguments.append(argument.string)
arguments.append(.string(argument.string))
}
} else {
switch argument.string {
case "true":
argument.quoted ? arguments.append("true") : arguments.append(true)
argument.quoted ? arguments.append(.string("true")) : arguments.append(.true)
case "false":
argument.quoted ? arguments.append("false") : arguments.append(false)
argument.quoted ? arguments.append(.string("false")) : arguments.append(.false)
case "nil":
argument.quoted ? arguments.append("nil") : arguments.append(OSCArgument.nil)
argument.quoted ? arguments.append(.string("nil")) : arguments.append(.nil)
case "impulse":
argument.quoted ? arguments.append("impulse") : arguments.append(OSCArgument.impulse)
argument.quoted ? arguments.append(.string("impulse")) : arguments.append(.impulse)
default:
// If the argument is prefaced with quotation marks,
// the regex dictates the argument should close with them.
Expand All @@ -200,9 +200,9 @@ public struct OSCAnnotation {
var quoationMarkArgument = argument.string
quoationMarkArgument.removeFirst()
quoationMarkArgument.removeLast()
arguments.append(quoationMarkArgument)
arguments.append(.string(quoationMarkArgument))
} else {
arguments.append(argument.string)
arguments.append(.string(argument.string))
}
}
}
Expand Down
Loading

0 comments on commit 20581ab

Please sign in to comment.