Skip to content

Commit 1fab8aa

Browse files
committed
Hide functionality behind SPI init
1 parent cdcb44e commit 1fab8aa

File tree

7 files changed

+924
-473
lines changed

7 files changed

+924
-473
lines changed

Sources/RegexBuilder/Anchor.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ extension Anchor: RegexComponent {
5151
}
5252

5353
public var regex: Regex<Substring> {
54-
_RegexFactory.assertion(baseAssertion)
54+
_RegexFactory().assertion(baseAssertion)
5555
}
5656
}
5757

@@ -159,14 +159,14 @@ public struct Lookahead<Output>: _BuiltinRegexComponent {
159159
public init<R: RegexComponent>(
160160
_ component: R
161161
) where R.RegexOutput == Output {
162-
self.init(_RegexFactory.lookaheadNonCapturing(component))
162+
self.init(_RegexFactory().lookaheadNonCapturing(component))
163163
}
164164

165165
/// Creates a lookahead from the regex generated by the given builder closure.
166166
public init<R: RegexComponent>(
167167
@RegexComponentBuilder _ component: () -> R
168168
) where R.RegexOutput == Output {
169-
self.init(_RegexFactory.lookaheadNonCapturing(component()))
169+
self.init(_RegexFactory().lookaheadNonCapturing(component()))
170170
}
171171
}
172172

@@ -189,14 +189,14 @@ public struct NegativeLookahead<Output>: _BuiltinRegexComponent {
189189
public init<R: RegexComponent>(
190190
_ component: R
191191
) where R.RegexOutput == Output {
192-
self.init(_RegexFactory.negativeLookaheadNonCapturing(component))
192+
self.init(_RegexFactory().negativeLookaheadNonCapturing(component))
193193
}
194194

195195
/// Creates a negative lookahead from the regex generated by the given builder
196196
/// closure.
197197
public init<R: RegexComponent>(
198198
@RegexComponentBuilder _ component: () -> R
199199
) where R.RegexOutput == Output {
200-
self.init(_RegexFactory.negativeLookaheadNonCapturing(component()))
200+
self.init(_RegexFactory().negativeLookaheadNonCapturing(component()))
201201
}
202202
}

Sources/RegexBuilder/Builder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@resultBuilder
1616
public enum RegexComponentBuilder {
1717
public static func buildBlock() -> Regex<Substring> {
18-
_RegexFactory.empty()
18+
_RegexFactory().empty()
1919
}
2020

2121
public static func buildPartialBlock<R: RegexComponent>(

Sources/RegexBuilder/CharacterClass.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public struct CharacterClass {
3131
@available(SwiftStdlib 5.7, *)
3232
extension CharacterClass: RegexComponent {
3333
public var regex: Regex<Substring> {
34-
_RegexFactory.customCharacterClass(ccc)
34+
_RegexFactory().customCharacterClass(ccc)
3535
}
3636
}
3737

Sources/RegexBuilder/DSL.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ extension Character: RegexComponent {
4949
public typealias Output = Substring
5050

5151
public var regex: Regex<Output> {
52-
_RegexFactory.char(self)
52+
_RegexFactory().char(self)
5353
}
5454
}
5555

@@ -58,7 +58,7 @@ extension UnicodeScalar: RegexComponent {
5858
public typealias Output = Substring
5959

6060
public var regex: Regex<Output> {
61-
_RegexFactory.scalar(self)
61+
_RegexFactory().scalar(self)
6262
}
6363
}
6464

@@ -248,7 +248,7 @@ public struct Reference<Capture>: RegexComponent {
248248
}
249249

250250
public var regex: Regex<Capture> {
251-
_RegexFactory.symbolicReference(id)
251+
_RegexFactory().symbolicReference(id)
252252
}
253253
}
254254

@@ -258,3 +258,9 @@ extension Regex.Match {
258258
self[reference.id]
259259
}
260260
}
261+
262+
@available(SwiftStdlib 5.7, *)
263+
@usableFromInline
264+
internal func makeFactory() -> _RegexFactory {
265+
_RegexFactory()
266+
}

0 commit comments

Comments
 (0)