Skip to content

Commit 993b61a

Browse files
committed
Fix review
1 parent 9450e3d commit 993b61a

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

Sources/BinaryParseKit/BinaryParseKit.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ public macro parseRest(endianness: Endianness) = #externalMacro(
255255
/// - Proper error handling for parsing failures
256256
/// - A ``Printable`` conformance
257257
///
258+
/// - Parameters:
259+
/// - parsingAccessor: The accessor level for the generated `Parsable` conformance (default is `.follow`)
260+
/// - printingAccessor: The accessor level for the generated `Printable` conformance (default is `.follow`)
261+
///
258262
/// - Note: All fields except those with accessors (`get` and `set`) must be parsed must be marked with `@parse`
259263
/// variants.
260264
///
@@ -298,6 +302,10 @@ public macro ParseStruct(
298302
/// - A ``Parsable`` conformance
299303
/// - A ``Printable`` conformance
300304
///
305+
/// - Parameters:
306+
/// - parsingAccessor: The accessor level for the generated `Parsable` conformance (default is `.follow`)
307+
/// - printingAccessor: The accessor level for the generated `Printable` conformance (default is `.follow`)
308+
///
301309
/// - Note: All enum cases must be marked with `@match` variants, which is intentional by design, which I don't think is
302310
/// necessary and is possible to be lifted int the future.
303311
/// - Note: Only one `@matchDefault` case is allowed per enum, and has to be declared at the end of all other cases.

Sources/BinaryParseKitCommons/ExtensionAccessor.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,33 @@
55
// Created by Larry Zeng on 11/26/25.
66
//
77

8+
/// This enum represents the access level of an extension in Swift, with a few extra cases
89
public enum ExtensionAccessor: ExpressibleByUnicodeScalarLiteral, Sendable, Codable {
910
public typealias UnicodeScalarLiteralType = String
1011

12+
/// Same as public keyword
1113
case `public`
14+
/// Same as package keyword
1215
case package
16+
/// Same as internal keyword
1317
case `internal`
18+
/// Same as fileprivate keyword
1419
case `fileprivate`
20+
/// Same as private keyword
1521
case `private`
22+
/// This specifier indicates that the extension should follow the access level of the type it extends
1623
case follow
24+
/// Represents an unknown or unsupported access level, which will be raised as macro error.
1725
case unknown(String)
1826

27+
/// All allowed cases for ExtensionAccessor
28+
///
29+
/// This includes all the defined access levels except for the ``ExtensionAccessor/unknown(_:)`` case.
1930
public static var allowedCases: [ExtensionAccessor] {
2031
[.public, .package, .internal, .fileprivate, .private, .follow]
2132
}
2233

34+
/// A textual representation of the access level.
2335
public var description: String {
2436
switch self {
2537
case .public: "public"
@@ -32,6 +44,10 @@ public enum ExtensionAccessor: ExpressibleByUnicodeScalarLiteral, Sendable, Coda
3244
}
3345
}
3446

47+
/// Initializes an `ExtensionAccessor` from a unicode scalar literal.
48+
///
49+
/// - Note: It tries to match the provided string with valid levels specified in ``ExtensionAccessor/allowedCases``,
50+
/// or default to ``ExtensionAccessor/unknown(_:)``.
3551
public init(unicodeScalarLiteral value: String) {
3652
self = ExtensionAccessor
3753
.allowedCases

Tests/BinaryParseKitMacroTests/BinaryParseKitStructTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ extension BinaryParseKitMacroTests {
761761
}
762762
763763
@Test
764-
func `enum bad accessor`() {
764+
func `struct bad accessor`() {
765765
assertMacro {
766766
"""
767767
@ParseStruct(parsingAccessor: "invalid", printingAccessor: .invalid)

0 commit comments

Comments
 (0)