Skip to content

Commit 18f4ffe

Browse files
committed
Change doc comment style
1 parent bceef54 commit 18f4ffe

File tree

1 file changed

+62
-78
lines changed

1 file changed

+62
-78
lines changed

stdlib/public/Darwin/Compression/Compression.swift

Lines changed: 62 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import Darwin
1414
import Foundation
1515
@_exported import Compression
1616

17-
/**
18-
Compression algorithms, wraps the C API constants.
19-
*/
17+
/// Compression algorithms, wraps the C API constants.
2018
public enum Algorithm: CaseIterable {
2119

2220
/// LZFSE
@@ -41,9 +39,7 @@ public enum Algorithm: CaseIterable {
4139
}
4240
}
4341

44-
/**
45-
Compression errors
46-
*/
42+
/// Compression errors
4743
public enum FilterError: Error {
4844
/// Filter failed to initialize
4945
case filterInitError
@@ -55,9 +51,7 @@ public enum FilterError: Error {
5551
case writeToFinalizedFilter
5652
}
5753

58-
/**
59-
Compression filter direction of operation, compress/decompress
60-
*/
54+
/// Compression filter direction of operation, compress/decompress
6155
public enum FilterOperation {
6256
/// Compress raw data to a compressed payload
6357
case compress
@@ -76,15 +70,15 @@ public enum FilterOperation {
7670
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
7771
extension compression_stream {
7872

79-
/**
80-
Initialize a compression_stream struct
81-
82-
- Parameter operation: direction of operation
83-
- Parameter algorithm: compression algorithm
84-
85-
- Throws: `FilterError.filterInitError` if `algorithm` is not supported by the Compression stream API
86-
*/
87-
init(operation: FilterOperation, algorithm: Algorithm) throws {
73+
/// Initialize a compression_stream struct
74+
///
75+
/// - Parameter operation: direction of operation
76+
/// - Parameter algorithm: compression algorithm
77+
///
78+
/// - Throws: `FilterError.filterInitError` if `algorithm` is not supported
79+
/// by the Compression stream API
80+
///
81+
internal init(operation: FilterOperation, algorithm: Algorithm) throws {
8882
self.init(dst_ptr: UnsafeMutablePointer<UInt8>.allocate(capacity:0),
8983
dst_size: 0,
9084
src_ptr: UnsafeMutablePointer<UInt8>.allocate(capacity:0),
@@ -93,7 +87,6 @@ extension compression_stream {
9387
let status = compression_stream_init(&self, operation.rawValue, algorithm.rawValue)
9488
guard status == COMPRESSION_STATUS_OK else { throw FilterError.filterInitError }
9589
}
96-
9790
}
9891

9992
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
@@ -104,17 +97,15 @@ public class OutputFilter {
10497
private let _writeFunc: (Data?) throws -> ()
10598
private var _finalized: Bool = false
10699

107-
/**
108-
Initialize an output filter
109-
110-
- Parameters:
111-
- operation: direction of operation
112-
- algorithm: compression algorithm
113-
- bufferCapacity: capacity of the internal data buffer
114-
- writeFunc: called to write the processed data
115-
116-
- Throws: `FilterError.StreamInitError` if stream initialization failed
117-
*/
100+
/// Initialize an output filter
101+
///
102+
/// - Parameters:
103+
/// - operation: direction of operation
104+
/// - algorithm: compression algorithm
105+
/// - bufferCapacity: capacity of the internal data buffer
106+
/// - writeFunc: called to write the processed data
107+
///
108+
/// - Throws: `FilterError.StreamInitError` if stream initialization failed
118109
public init(
119110
_ operation: FilterOperation,
120111
using algorithm: Algorithm,
@@ -127,19 +118,18 @@ public class OutputFilter {
127118
_writeFunc = writeFunc
128119
}
129120

130-
/**
131-
Send data to output filter
132-
133-
Processed output will be sent to the output closure.
134-
A call with empty/nil data is interpreted as finalize().
135-
Writing non empty/nil data to a finalized stream is an error.
136-
137-
- Parameter data: data to process
138-
139-
- Throws:
140-
`FilterError.filterProcessError` if an error occurs during processing
141-
`FilterError.writeToFinalizedFilter` if `data` is not empty/nil, and the filter is the finalized state
142-
*/
121+
/// Send data to output filter
122+
///
123+
/// Processed output will be sent to the output closure.
124+
/// A call with empty/nil data is interpreted as finalize().
125+
/// Writing non empty/nil data to a finalized stream is an error.
126+
///
127+
/// - Parameter data: data to process
128+
///
129+
/// - Throws:
130+
/// `FilterError.filterProcessError` if an error occurs during processing
131+
/// `FilterError.writeToFinalizedFilter` if `data` is not empty/nil, and the
132+
/// filter is the finalized state
143133
public func write(_ data: Data?) throws {
144134
// Finalize if data is empty/nil
145135
if data == nil || data!.isEmpty { try finalize() ; return }
@@ -155,15 +145,13 @@ public class OutputFilter {
155145
}
156146
}
157147

158-
/**
159-
Finalize the stream, i.e. flush all data remaining in the stream
160-
161-
Processed output will be sent to the output closure.
162-
When all output has been sent, the writingTo closure is called one last time with nil data.
163-
Once the stream is finalized, writing non empty/nil data to the stream will throw an exception.
164-
165-
- Throws: `FilterError.StreamProcessError` if an error occurs during processing
166-
*/
148+
/// Finalize the stream, i.e. flush all data remaining in the stream
149+
///
150+
/// Processed output will be sent to the output closure.
151+
/// When all output has been sent, the writingTo closure is called one last time with nil data.
152+
/// Once the stream is finalized, writing non empty/nil data to the stream will throw an exception.
153+
///
154+
/// - Throws: `FilterError.StreamProcessError` if an error occurs during processing
167155
public func finalize() throws {
168156
// Do nothing if already finalized
169157
if _finalized { return }
@@ -223,17 +211,15 @@ public class InputFilter {
223211
private var _eofReached: Bool = false // did we read end-of-file from the input?
224212
private var _endReached: Bool = false // did we reach end-of-file from the decoder stream?
225213

226-
/**
227-
Initialize an input filter
228-
229-
- Parameters:
230-
- operation: direction of operation
231-
- algorithm: compression algorithm
232-
- bufferCapacity: capacity of the internal data buffer
233-
- readFunc: called to read the input data
234-
235-
- Throws: `FilterError.filterInitError` if filter initialization failed
236-
*/
214+
/// Initialize an input filter
215+
///
216+
/// - Parameters:
217+
/// - operation: direction of operation
218+
/// - algorithm: compression algorithm
219+
/// - bufferCapacity: capacity of the internal data buffer
220+
/// - readFunc: called to read the input data
221+
///
222+
/// - Throws: `FilterError.filterInitError` if filter initialization failed
237223
public init(
238224
_ operation: FilterOperation,
239225
using algorithm: Algorithm,
@@ -245,21 +231,19 @@ public class InputFilter {
245231
_readFunc = readFunc
246232
}
247233

248-
/**
249-
Read processed data from the filter
250-
251-
Input data, when needed, is obtained from the input closure
252-
When the input closure returns a nil or empty Data object, the filter will be
253-
finalized, and after all processed data has been read, readData will return nil
254-
to signal end of input
255-
256-
- Parameter count: max number of bytes to read from the filter
257-
258-
- Returns: a new Data object containing at most `count` output bytes, or nil if no more data is available
259-
260-
- Throws:
261-
`FilterError.filterProcessError` if an error occurs during processing
262-
*/
234+
/// Read processed data from the filter
235+
///
236+
/// Input data, when needed, is obtained from the input closure
237+
/// When the input closure returns a nil or empty Data object, the filter will be
238+
/// finalized, and after all processed data has been read, readData will return nil
239+
/// to signal end of input
240+
///
241+
/// - Parameter count: max number of bytes to read from the filter
242+
///
243+
/// - Returns: a new Data object containing at most `count` output bytes, or nil if no more data is available
244+
///
245+
/// - Throws:
246+
/// `FilterError.filterProcessError` if an error occurs during processing
263247
public func readData(ofLength count: Int) throws -> Data? {
264248
// Sanity check
265249
precondition(count > 0, "number of bytes to read can't be 0")

0 commit comments

Comments
 (0)