Skip to content

Commit 9022878

Browse files
committed
Merge branch 'develop'
2 parents b6dbc8a + 19d951c commit 9022878

File tree

17 files changed

+514
-99
lines changed

17 files changed

+514
-99
lines changed

.github/workflows/swift.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
image:
16-
- swift:5.5.3-xenial
17-
- swift:5.6.1-bionic
18-
- swift:5.7.2-focal
1916
- swift:5.8-jammy
17+
- swift:6.0-noble
2018
container: ${{ matrix.image }}
2119
steps:
2220
- name: Checkout Repository
23-
uses: actions/checkout@v3
21+
uses: actions/checkout@v4
2422
- name: Build Swift Debug Package
2523
run: swift build -c debug
2624
- name: Build Swift Release Package
@@ -33,9 +31,9 @@ jobs:
3331
- name: Select latest available Xcode
3432
uses: maxim-lobanov/setup-xcode@v1.5.1
3533
with:
36-
xcode-version: 13.2.1
34+
xcode-version: latest
3735
- name: Checkout Repository
38-
uses: actions/checkout@v3
36+
uses: actions/checkout@v4
3937
- name: Build Swift Debug Package
4038
run: swift build -c debug
4139
- name: Build Swift Release Package

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,6 @@ xcuserdata
9595
.docker.build
9696
.swiftpm
9797
.vscode
98+
.DS_Store
99+
*.swp
98100

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,8 @@ would require custom executors. Which are not yet available.
8585
### Who
8686

8787
**Macro** is brought to you by
88-
the
89-
[Always Right Institute](http://www.alwaysrightinstitute.com)
90-
and
91-
[ZeeZide](http://zeezide.de).
92-
We like
93-
[feedback](https://twitter.com/ar_institute),
94-
GitHub stars,
95-
cool [contract work](http://zeezide.com/en/services/services.html),
88+
[Helge Heß](https://github.com/helje5/) / [ZeeZide](https://zeezide.de).
89+
We like feedback, GitHub stars, cool contract work,
9690
presumably any form of praise you can think of.
9791

9892
There is a `#microexpress` channel on the

Sources/MacroCore/Events/ErrorEmitter.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Macro
44
//
55
// Created by Helge Hess.
6-
// Copyright © 2020 ZeeZide GmbH. All rights reserved.
6+
// Copyright © 2020-2023 ZeeZide GmbH. All rights reserved.
77
//
88

99
public protocol ErrorEmitterType {
@@ -42,7 +42,8 @@ open class ErrorEmitter : ErrorEmitterType, ErrorEmitterTarget {
4242
@inlinable
4343
open func emit(error: Error) {
4444
if errorListeners.isEmpty {
45-
let objectInfo = "\(type(of: self)):\(ObjectIdentifier(self))"
45+
let id = String(Int(bitPattern: ObjectIdentifier(self)), radix: 16)
46+
let objectInfo = "\(type(of: self)):0x\(id)"
4647
errorLog.error("[\(objectInfo)] Error not handled: \(error)")
4748
}
4849
else {

Sources/MacroCore/Process/DetectXcode.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ public extension process {
2222
#else
2323
static let isRunningInXCode : Bool = {
2424
// TBD: is there a better way?
25-
guard let s = xsys.getenv("XPC_SERVICE_NAME") else { return false }
26-
return strstr(s, "Xcode") != nil
25+
if let s = xsys.getenv("XPC_SERVICE_NAME") { // not in Xcode 16 anymore
26+
if strstr(s, "Xcode") != nil { return true }
27+
}
28+
if xsys.getenv("__XCODE_BUILT_PRODUCTS_DIR_PATHS") != nil { // Xcode 16
29+
return true
30+
}
31+
return false
2732
}()
2833
#endif
2934
}

Sources/MacroCore/Streams/Concat.swift

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Macro
44
//
55
// Created by Helge Hess.
6-
// Copyright © 2020 ZeeZide GmbH. All rights reserved.
6+
// Copyright © 2020-2023 ZeeZide GmbH. All rights reserved.
77
//
88

99
/**
@@ -13,6 +13,20 @@
1313
*
1414
* Be careful w/ using that. You don't want to baloon payloads in memory!
1515
*
16+
* Usage:
17+
* ```
18+
* request | concat { buffer in
19+
* console.log("The size of the request body is:", buffer.count)
20+
* }
21+
* ```
22+
*
23+
* Pushes a ``ConcatError`` if the maximum size was exceeded.
24+
*
25+
* - Parameters:
26+
* - maximumSize: The maximum size of the request body. Can be configured
27+
* using the `macro.concat.maxsize` environment variable.
28+
* - yield: A closure called with the loaded data (a ``Buffer``).
29+
* - Returns: The ``ConcatByteStream``.
1630
*/
1731
@inlinable
1832
public func concat(maximumSize: Int = _defaultConcatMaximumSize,
@@ -33,6 +47,20 @@ public func concat(maximumSize: Int = _defaultConcatMaximumSize,
3347
*
3448
* Be careful w/ using that. You don't want to baloon payloads in memory!
3549
*
50+
* Usage:
51+
* ```
52+
* request | concat { buffer in
53+
* console.log("The size of the request body is:", buffer.count)
54+
* }
55+
* ```
56+
*
57+
* Pushes a ``ConcatError`` if the maximum size was exceeded.
58+
*
59+
* - Parameters:
60+
* - maximumSize: The maximum size of the request body. Can be configured
61+
* using the `macro.concat.maxsize` environment variable.
62+
* - yield: A closure called with the loaded data (a ``Buffer``).
63+
* - Returns: The ``ConcatByteStream``.
3664
*/
3765
@inlinable
3866
public func concat(maximumSize: Int = _defaultConcatMaximumSize,
@@ -124,7 +152,8 @@ public class ConcatByteStream: WritableByteStream,
124152
// MARK: - CustomStringConvertible
125153

126154
open var description: String {
127-
var ms = "<Concat[\(ObjectIdentifier(self))]:"
155+
let id = String(Int(bitPattern: ObjectIdentifier(self)), radix: 16)
156+
var ms = "<Concat[0x\(id)]:"
128157
defer { ms += ">" }
129158

130159
let count = writableBuffer.count
@@ -146,10 +175,20 @@ public class ConcatByteStream: WritableByteStream,
146175
}
147176
}
148177

178+
/**
179+
* The ``concat`` middleware failed.
180+
*/
149181
public enum ConcatError: Swift.Error {
182+
/// The maximum allowed size was exceeded.
150183
case maximumSizeExceeded(maximumSize: Int, availableSize: Int)
151184
}
152185

186+
/**
187+
* The default maximum request size for the ``concat`` middleware.
188+
*
189+
* Can be set using the `macro.concat.maxsize` environment variable (in bytes),
190+
* and defaults to 1MB.
191+
*/
153192
public let _defaultConcatMaximumSize =
154193
process.getenv("macro.concat.maxsize",
155194
defaultValue : 1024 * 1024, // 1MB

Sources/MacroCore/Streams/ReadableStreamBase.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Macro
44
//
55
// Created by Helge Hess.
6-
// Copyright © 2020 ZeeZide GmbH. All rights reserved.
6+
// Copyright © 2020-2023 ZeeZide GmbH. All rights reserved.
77
//
88

99
/**
@@ -37,10 +37,12 @@ open class ReadableStreamBase<ReadablePayload>: ErrorEmitter {
3737
#if DEBUG && false // cycle debugging
3838
public override init() {
3939
super.init()
40-
print("INIT:\(ObjectIdentifier(self)) \(type(of:self))")
40+
let id = String(Int(bitPattern: ObjectIdentifier(self)), radix: 16)
41+
print("INIT:0x\(id) \(type(of:self))")
4142
}
4243
deinit {
43-
print("DEINIT:\(ObjectIdentifier(self)) \(type(of:self))")
44+
let id = String(Int(bitPattern: ObjectIdentifier(self)), radix: 16)
45+
print("DEINIT:0x\(id) \(type(of:self))")
4446
}
4547
#else
4648
public override init() {

Sources/MacroCore/Streams/WritableStreamBase.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Macro
44
//
55
// Created by Helge Hess.
6-
// Copyright © 2020 ZeeZide GmbH. All rights reserved.
6+
// Copyright © 2020-2023 ZeeZide GmbH. All rights reserved.
77
//
88

99
/**
@@ -43,10 +43,12 @@ open class WritableStreamBase<WritablePayload>: ErrorEmitter {
4343
#if DEBUG && false // cycle debugging
4444
public override init() {
4545
super.init()
46-
print("INIT:\(ObjectIdentifier(self)) \(type(of:self))")
46+
let id = String(Int(bitPattern: ObjectIdentifier(self)), radix: 16)
47+
print("INIT:0x\(id) \(type(of:self))")
4748
}
4849
deinit {
49-
print("DEINIT:\(ObjectIdentifier(self)) \(type(of:self))")
50+
let id = String(Int(bitPattern: ObjectIdentifier(self)), radix: 16)
51+
print("DEINIT:0x\(id) \(type(of:self))")
5052
}
5153
#endif
5254

Sources/MacroTestUtilities/TestServerResponse.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Macro
44
//
55
// Created by Helge Hess.
6-
// Copyright © 2020 ZeeZide GmbH. All rights reserved.
6+
// Copyright © 2020-2023 ZeeZide GmbH. All rights reserved.
77
//
88

99
import struct Logging.Logger
@@ -155,7 +155,8 @@ open class TestServerResponse: ServerResponse {
155155
// MARK: - CustomStringConvertible
156156

157157
override open var description: String {
158-
var ms = "<TestResponse[\(ObjectIdentifier(self))]:"
158+
let id = String(Int(bitPattern: ObjectIdentifier(self)), radix: 16)
159+
var ms = "<TestResponse[0x\(id)]:"
159160
defer { ms += ">" }
160161

161162
ms += " \(statusCode)"

0 commit comments

Comments
 (0)