Skip to content

Commit 833fc63

Browse files
committed
Merge branch 'develop'
2 parents e4c2ac2 + c7fc5c7 commit 833fc63

23 files changed

Lines changed: 230 additions & 172 deletions

.github/workflows/swift.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
image:
16-
- swift:5.0.3-xenial
17-
- swift:5.2.5-xenial
18-
- swift:5.3.2-bionic
19-
- swift:5.5.0-focal
16+
- swift:6.2-jammy
2017
container: ${{ matrix.image }}
2118
steps:
2219
- name: Checkout Repository
@@ -31,11 +28,11 @@ jobs:
3128
runs-on: macos-latest
3229
steps:
3330
- name: Select latest available Xcode
34-
uses: maxim-lobanov/setup-xcode@v1.2.1
31+
uses: maxim-lobanov/setup-xcode@v1.6.0
3532
with:
36-
xcode-version: 12.4
33+
xcode-version: latest
3734
- name: Checkout Repository
38-
uses: actions/checkout@v2
35+
uses: actions/checkout@v4
3936
- name: Build Swift Debug Package
4037
run: swift build -c debug
4138
- name: Build Swift Release Package

Makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
SWIFT_BUILD=swift build
55
SWIFT_CLEAN=swift package clean
66
SWIFT_BUILD_DIR=.build
7+
SWIFT_TEST=swift test
8+
CONFIGURATION=release
79

810
# docker config
9-
SWIFT_BUILD_IMAGE="helje5/swift-dev:5.2.0"
10-
CONFIGURATION=debug
11+
DOCKER_BUILD_DIR=.docker.build
12+
SWIFT_BUILD_IMAGE=swift:6.2
13+
#SWIFT_BUILD_IMAGE="helje5/swift-dev:6.2.3"
1114
DOCKER_BUILD_DIR=".docker.build"
12-
SWIFT_DOCKER_BUILD_DIR="$(DOCKER_BUILD_DIR)/x86_64-unknown-linux/$(CONFIGURATION)"
15+
SWIFT_DOCKER_BUILD_DIR="$(DOCKER_BUILD_DIR)/aarch64-unknown-linux/$(CONFIGURATION)"
16+
#SWIFT_DOCKER_BUILD_DIR="$(DOCKER_BUILD_DIR)/x86_64-unknown-linux/$(CONFIGURATION)"
1317
DOCKER_BUILD_PRODUCT="$(DOCKER_BUILD_DIR)/$(TOOL_NAME)"
1418

1519

@@ -36,6 +40,13 @@ $(DOCKER_BUILD_PRODUCT): $(SWIFT_SOURCES)
3640

3741
docker-all: $(DOCKER_BUILD_PRODUCT)
3842

43+
docker-tests: #docker-all # doesn't help, gets rebuilt anyways
44+
docker run --rm \
45+
-v "$(PWD):/src" \
46+
-v "$(PWD)/$(DOCKER_BUILD_DIR):/src/.build" \
47+
"$(SWIFT_BUILD_IMAGE)" \
48+
bash -c 'cd /src && swift test --enable-test-discovery -c $(CONFIGURATION)'
49+
3950
docker-clean:
4051
rm -rf $(DOCKER_BUILD_PRODUCT)
4152

Package.swift

Lines changed: 87 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,99 @@
1-
// swift-tools-version:5.0
1+
// swift-tools-version:6.2
22
//
33
// Package.swift
44
// SwiftObjects
55
//
66
// Created by Helge Hess on 11.05.18.
7-
// Copyright © 2018-2020 ZeeZide. All rights reserved.
7+
// Copyright © 2018-2026 ZeeZide. All rights reserved.
88
//
99
import PackageDescription
10+
import Foundation
11+
12+
let fm = FileManager.default
1013

1114
let package = Package(
12-
name: "SwiftObjects",
15+
name: "SwiftObjects",
16+
17+
platforms: [ .macOS(.v15), .iOS(.v18), .visionOS(.v2) ],
18+
19+
products: [
20+
.library(name: "SwiftObjects", targets: [ "SwiftObjects" ]),
21+
],
22+
23+
dependencies: [
24+
.package(url: "https://github.com/apple/swift-nio.git",
25+
from: "2.92.1"),
26+
.package(url: "https://github.com/wickwirew/Runtime.git",
27+
from: "2.2.7"),
1328

14-
products: [
15-
.library(name: "SwiftObjects", targets: [ "SwiftObjects" ]),
16-
],
17-
18-
dependencies: [
19-
.package(url: "https://github.com/apple/swift-nio.git",
20-
from: "2.25.1"),
21-
.package(url: "https://github.com/wickwirew/Runtime.git",
22-
from: "2.2.2"),
23-
24-
// just for the showcase
25-
.package(url: "https://github.com/SwiftWebResources/SemanticUI-Swift.git",
26-
from: "2.4.2"),
27-
.package(url: "https://github.com/SwiftWebResources/jQuery-Swift.git",
28-
from: "3.5.1"),
29-
],
29+
// just for the showcase
30+
.package(url: "https://github.com/SwiftWebResources/SemanticUI-Swift.git",
31+
from: "2.5.0"),
32+
.package(url: "https://github.com/SwiftWebResources/jQuery-Swift.git",
33+
from: "3.7.1"),
34+
],
35+
36+
targets: [
37+
.target(name: "SwiftObjects",
38+
dependencies: [
39+
.product(name: "NIO", package: "swift-nio"),
40+
.product(name: "NIOHTTP1", package: "swift-nio"),
41+
.product(name: "NIOFoundationCompat", package: "swift-nio"),
42+
.product(name: "Runtime", package: "Runtime"),
43+
],
44+
exclude:
45+
fm.filesWithExtension("api", at: targetURL("SwiftObjects")),
46+
swiftSettings: [ .swiftLanguageMode(.v5) ]),
47+
48+
.testTarget(name: "SwiftObjectsTests",
49+
dependencies: [ "SwiftObjects" ],
50+
swiftSettings: [ .swiftLanguageMode(.v5) ]),
51+
52+
.executableTarget(name: "WOShowcaseApp",
53+
dependencies: [
54+
"SwiftObjects",
55+
.product(name: "SemanticUI",
56+
package: "SemanticUI-Swift"),
57+
.product(name: "jQuery", package: "jQuery-Swift")
58+
],
59+
resources: [
60+
.copy("favicon.ico")
61+
]
62+
+ fm.filesWithExtension("html",
63+
at: targetURL("WOShowcaseApp"))
64+
.map { .copy($0) }
65+
+ fm.filesWithExtension("wod",
66+
at: targetURL("WOShowcaseApp"))
67+
.map { .copy($0) })
68+
]
69+
)
3070

31-
targets: [
32-
.target(name: "SwiftObjects",
33-
dependencies: [
34-
"NIO",
35-
"NIOHTTP1",
36-
"NIOFoundationCompat",
37-
"NIOConcurrencyHelpers",
38-
"Runtime"
39-
]),
40-
.testTarget(name: "SwiftObjectsTests",
41-
dependencies: [ "SwiftObjects" ]),
71+
fileprivate func targetURL(_ target: String) -> URL {
72+
URL(fileURLWithPath: #filePath)
73+
.deletingLastPathComponent()
74+
.appendingPathComponent("Sources")
75+
.appendingPathComponent(target)
76+
}
4277

43-
.target(name: "WOShowcaseApp",
44-
dependencies: [
45-
"SwiftObjects",
46-
"SemanticUI",
47-
"jQuery"
48-
]),
49-
]
50-
)
78+
fileprivate extension FileManager {
79+
80+
func filesWithExtension(_ extension: String, at url: URL) -> [ String ] {
81+
let url = url.standardizedFileURL
82+
guard let enumerator = FileManager.default
83+
.enumerator(at: url,
84+
includingPropertiesForKeys: [ .isRegularFileKey ],
85+
options: [ .skipsHiddenFiles ])
86+
else { return [] }
87+
88+
let baseParts = url.pathComponents.count
89+
var files = [ String ]()
90+
for case let url as URL in enumerator
91+
where url.pathExtension == `extension`
92+
{
93+
let relative = url.pathComponents.dropFirst(baseParts)
94+
.joined(separator: "/")
95+
files.append(relative)
96+
}
97+
return files
98+
}
99+
}

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h2>SwiftObjects
2-
<img src="http://zeezide.com/img/SoElementIcon.svg"
2+
<img src="https://zeezide.com/img/SoElementIcon.svg"
33
align="right" width="128" height="128" />
44
</h2>
55

@@ -24,14 +24,14 @@ Nor is it optimized, or fast at all, to the contrary.
2424
## Blog
2525

2626
This is part of a blog entry, called:
27-
[An Introduction to WebObjects, in Swift](http://www.alwaysrightinstitute.com/wo-intro/).
27+
[An Introduction to WebObjects, in Swift](https://www.alwaysrightinstitute.com/wo-intro/).
2828

2929
## Install
3030

3131
Note: Setup to work with Swift 5.0 aka Xcode 10.2 (can be changed manually to
3232
4.x). The SwiftXcode setup now requires Xcode 10.2.
3333

34-
<a href="https://swiftxcode.github.io" target="extlink"><img src="http://zeezide.com/img/SwiftXcodePkgIcon.svg"
34+
<a href="https://swiftxcode.github.io" target="extlink"><img src="https://zeezide.com/img/SwiftXcodePkgIcon.svg"
3535
align="right" width="86" height="86" style="padding: 0 0 0.5em 0.5em;" /></a>
3636
We use [Homebrew](https://brew.sh) to install the SwiftObjects
3737
development environment.
@@ -54,22 +54,22 @@ template, very much at the bottom of the inspector
5454
(pro tip: type "wo" in the filter field at the upper right):
5555

5656
<center><img src=
57-
"http://www.alwaysrightinstitute.com/images/swiftobjects/01-so-create-project-1.png"
57+
"https://www.alwaysrightinstitute.com/images/swiftobjects/01-so-create-project-1.png"
5858
/></center>
5959

6060
Give your project a name, say "HelloWOrld" create it somewhere, and you should
6161
end up with something like this:
6262

6363
<center><img src=
64-
"http://www.alwaysrightinstitute.com/images/swiftobjects/05-so-create-project-5.png"
64+
"https://www.alwaysrightinstitute.com/images/swiftobjects/05-so-create-project-5.png"
6565
/></center>
6666

6767
Press the Play/Run button to build and start the application. Open your
6868
favorite browser and navigate to
6969
[http://localhost:1337/](http://localhost:1337/):
7070

7171
<center><img src=
72-
"http://www.alwaysrightinstitute.com/images/swiftobjects/21-main-page.png"
72+
"https://www.alwaysrightinstitute.com/images/swiftobjects/21-main-page.png"
7373
/></center>
7474

7575
Yay. History is up and running!
@@ -79,9 +79,9 @@ Yay. History is up and running!
7979
### Who
8080

8181
**SwiftObjects** is brought to you by
82-
[ZeeZide](http://zeezide.de).
82+
[ZeeZide](https://zeezide.de).
8383
We like feedback, GitHub stars,
84-
cool [contract work](http://zeezide.com/en/services/services.html),
84+
cool [contract work](https://zeezide.com/en/services/services.html),
8585
presumably any form of praise you can think of.
8686

87-
There is a channel on the [Noze.io Slack](http://slack.noze.io).
87+
There is a channel on the [Noze.io Slack](https://slack.noze.io).

Sources/SwiftObjects/Core/WOApplication.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
// SwiftObjects
44
//
55
// Created by Helge Hess on 11.05.18.
6-
// Copyright © 2018-2020 ZeeZide. All rights reserved.
6+
// Copyright © 2018-2026 ZeeZide. All rights reserved.
77
//
88

99
import struct Foundation.Data
1010
import struct Foundation.Date
1111
import struct Foundation.TimeInterval
1212
import class Foundation.UserDefaults
13-
import NIOConcurrencyHelpers
13+
import Synchronization
1414
import Runtime
1515

1616
/**
@@ -70,8 +70,8 @@ open class WOApplication : WOLifecycle, WOResponder, WORequestDispatcher,
7070
public let log : WOLogger = WOPrintLogger(logLevel: .Log)
7171

7272
let properties = UserDefaults.standard
73-
var requestCounter = NIOAtomic.makeAtomic(value: 0)
74-
var activeDispatchCount = NIOAtomic.makeAtomic(value: 0)
73+
let requestCounter = Atomic<Int>(0)
74+
let activeDispatchCount = Atomic<Int>(0)
7575

7676
open var contextClass : WOContext.Type? = nil
7777
open var sessionClass : WOSession.Type? = nil
@@ -180,9 +180,9 @@ open class WOApplication : WOLifecycle, WOResponder, WORequestDispatcher,
180180
}()
181181

182182
open func dispatchRequest(_ request: WORequest) -> WOResponse {
183-
_ = requestCounter.add(1)
184-
_ = activeDispatchCount.add(1)
185-
defer { _ = activeDispatchCount.sub(1) }
183+
requestCounter.wrappingAdd(1, ordering: .relaxed)
184+
activeDispatchCount.wrappingAdd(1, ordering: .relaxed)
185+
defer { activeDispatchCount.wrappingAdd(-1, ordering: .relaxed) }
186186

187187
// TODO: port CORS stuff, OPTIONS
188188

@@ -677,7 +677,8 @@ open class WOApplication : WOLifecycle, WOResponder, WORequestDispatcher,
677677
open func appendToDescription(_ ms: inout String) {
678678
if let s = _name { ms += " '\(s)'" }
679679

680-
ms += " #req=\(requestCounter.load())/\(activeDispatchCount.load())"
680+
ms += " #req=\(requestCounter.load(ordering: .relaxed))"
681+
ms += "/\(activeDispatchCount.load(ordering: .relaxed))"
681682
ms += " rh=\(requestHandlerRegistry.keys.joined(separator:","))"
682683

683684
if refusesNewSessions { ms += " REFUSES-NEW" }

Sources/SwiftObjects/Core/WOCookie.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ import struct Foundation.Date
3636
* not what you want.
3737
*
3838
* Outdated iunfo:
39-
* http://www.ietf.org/rfc/rfc2109.txt
40-
* http://www.faqs.org/rfcs/rfc2965.html (only implemented by Opera?)
39+
* https://www.ietf.org/rfc/rfc2109.txt
40+
* https://www.faqs.org/rfcs/rfc2965.html (only implemented by Opera?)
4141
*/
4242
public struct WOCookie : SmartDescription {
4343

@@ -125,7 +125,7 @@ public struct WOCookie : SmartDescription {
125125
}
126126
else if timeout == nil {
127127
/* A convenience to improve browser compat, straight from:
128-
* http://wp.netscape.com/newsref/std/cookie_spec.html
128+
* https://wp.netscape.com/newsref/std/cookie_spec.html
129129
* This helps Safari3 forget cookies (Max-Age: 0 doesn't seem to affect
130130
* it).
131131
*/

Sources/SwiftObjects/Core/WOCoreContext.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88

99
import struct Foundation.Date
10-
import NIOConcurrencyHelpers
10+
import Synchronization
1111

1212
/**
1313
* WOCoreContext
@@ -77,15 +77,17 @@ open class WOCoreContextBase : WOCoreContext {
7777
open var closeAllElements = true // generate <br /> instead of <br>
7878
open var generateXMLStyleEmptyElements = false
7979

80-
private static var ctxIdCounter = NIOAtomic.makeAtomic(value: 0)
80+
private static let ctxIdCounter = Atomic<Int>(0)
8181

8282
public init(application: WOApplication, request: WORequest) {
8383
self.application = application
8484
self.request = request
8585
self.response = WOResponse(request: request)
86-
86+
8787
let stamp = Date().timeIntervalSince1970 - 1157999293 // magic
88-
self.contextID = "\(Int(stamp))x\(WOCoreContextBase.ctxIdCounter.add(1))"
88+
let count = WOCoreContextBase.ctxIdCounter
89+
.wrappingAdd(1, ordering: .relaxed).newValue
90+
self.contextID = "\(Int(stamp))x\(count)"
8991
}
9092

9193

Sources/SwiftObjects/Core/WODevResourceManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import struct Foundation.Data
1111

1212
/**
1313
* A basic resource manager, which supports class registration and looks up
14-
* resources relative to some source file (using the #filename trick).
14+
* resources relative to some source file (using the #filePath trick).
1515
*/
1616
open class WODevResourceManager : WOResourceManagerBase {
1717

@@ -42,7 +42,7 @@ open class WODevResourceManager : WOResourceManagerBase {
4242
var resourceMissCache = Set<String>()
4343
var memoryResources = [ String : InMemoryResource ]()
4444

45-
public init<T>(sourceFile: StaticString = #file, sourceType: T.Type,
45+
public init<T>(sourceFile: StaticString = #filePath, sourceType: T.Type,
4646
defaultFramework: String,
4747
_ classes : [ String : AnyClass ] = [:])
4848
{

Sources/SwiftObjects/Core/WORequest.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
// SwiftObjects
44
//
55
// Created by Helge Hess on 11.05.18.
6-
// Copyright © 2018 ZeeZide. All rights reserved.
6+
// Copyright © 2018-2026 ZeeZide. All rights reserved.
77
//
88

99
import struct Foundation.CharacterSet
1010
import struct Foundation.URLComponents
11+
import NIOHTTP1
1112

1213
open class WORequest : WOMessage {
1314

0 commit comments

Comments
 (0)