90
90
///
91
91
/// The higher-level APIs will automatically ensure that `BitstreamWriter.data`
92
92
/// is valid. Once serialization has completed, simply emit this data to a file.
93
- @available ( * , deprecated, message: " moved to swift-driver " )
94
93
public final class BitstreamWriter {
95
94
/// The buffer of data being written to.
96
95
private( set) public var data : [ UInt8 ]
@@ -160,7 +159,6 @@ public final class BitstreamWriter {
160
159
161
160
extension BitstreamWriter {
162
161
/// Writes the provided UInt32 to the data stream directly.
163
- @available ( * , deprecated, message: " moved to swift-driver " )
164
162
public func write( _ int: UInt32 ) {
165
163
let index = data. count
166
164
@@ -179,7 +177,6 @@ extension BitstreamWriter {
179
177
/// - int: The integer containing the bits you'd like to write
180
178
/// - width: The number of low-bits of the integer you're writing to the
181
179
/// buffer
182
- @available ( * , deprecated, message: " moved to swift-driver " )
183
180
public func writeVBR< IntType> ( _ int: IntType , width: UInt8 )
184
181
where IntType: UnsignedInteger & ExpressibleByIntegerLiteral
185
182
{
@@ -202,7 +199,6 @@ extension BitstreamWriter {
202
199
/// - int: The integer containing the bits you'd like to write
203
200
/// - width: The number of low-bits of the integer you're writing to the
204
201
/// buffer
205
- @available ( * , deprecated, message: " moved to swift-driver " )
206
202
public func write< IntType> ( _ int: IntType , width: UInt8 )
207
203
where IntType: UnsignedInteger & ExpressibleByIntegerLiteral
208
204
{
@@ -249,7 +245,6 @@ extension BitstreamWriter {
249
245
currentBit = ( currentBit + width) & 31
250
246
}
251
247
252
- @available ( * , deprecated, message: " moved to swift-driver " )
253
248
public func alignIfNeeded( ) {
254
249
guard currentBit > 0 else { return }
255
250
write ( currentValue)
@@ -259,13 +254,11 @@ extension BitstreamWriter {
259
254
}
260
255
261
256
/// Writes a Bool as a 1-bit integer value.
262
- @available ( * , deprecated, message: " moved to swift-driver " )
263
257
public func write( _ bool: Bool ) {
264
258
write ( bool ? 1 as UInt : 0 , width: 1 )
265
259
}
266
260
267
261
/// Writes the provided BitCode Abbrev operand to the stream.
268
- @available ( * , deprecated, message: " moved to swift-driver " )
269
262
public func write( _ abbrevOp: Bitstream . Abbreviation . Operand ) {
270
263
write ( abbrevOp. isLiteral) // the Literal bit.
271
264
switch abbrevOp {
@@ -295,21 +288,18 @@ extension BitstreamWriter {
295
288
}
296
289
297
290
/// Writes the specified abbreviaion value to the stream, as a 32-bit quantity.
298
- @available ( * , deprecated, message: " moved to swift-driver " )
299
291
public func writeCode( _ code: Bitstream . AbbreviationID ) {
300
292
writeCode ( code. rawValue)
301
293
}
302
294
303
295
/// Writes the specified Code value to the stream, as a 32-bit quantity.
304
- @available ( * , deprecated, message: " moved to swift-driver " )
305
296
public func writeCode< IntType> ( _ code: IntType )
306
297
where IntType: UnsignedInteger & ExpressibleByIntegerLiteral
307
298
{
308
299
write ( code, width: codeBitWidth)
309
300
}
310
301
311
302
/// Writes an ASCII character to the stream, as an 8-bit ascii value.
312
- @available ( * , deprecated, message: " moved to swift-driver " )
313
303
public func writeASCII( _ character: Character ) {
314
304
precondition ( character. unicodeScalars. count == 1 , " character is not ASCII " )
315
305
let c = UInt8 ( ascii: character. unicodeScalars. first!)
@@ -322,7 +312,6 @@ extension BitstreamWriter {
322
312
extension BitstreamWriter {
323
313
/// Defines an abbreviation and returns the unique identifier for that
324
314
/// abbreviation.
325
- @available ( * , deprecated, message: " moved to swift-driver " )
326
315
public func defineAbbreviation( _ abbrev: Bitstream . Abbreviation ) -> Bitstream . AbbreviationID {
327
316
encodeAbbreviation ( abbrev)
328
317
currentAbbreviations. append ( abbrev)
@@ -332,7 +321,6 @@ extension BitstreamWriter {
332
321
}
333
322
334
323
/// Encodes the definition of an abbreviation to the stream.
335
- @available ( * , deprecated, message: " moved to swift-driver " )
336
324
private func encodeAbbreviation( _ abbrev: Bitstream . Abbreviation ) {
337
325
writeCode ( . defineAbbreviation)
338
326
writeVBR ( UInt ( abbrev. operands. count) , width: 5 )
@@ -345,7 +333,6 @@ extension BitstreamWriter {
345
333
// MARK: Writing Records
346
334
347
335
extension BitstreamWriter {
348
- @available ( * , deprecated, message: " moved to swift-driver " )
349
336
public struct RecordBuffer {
350
337
private( set) var values = [ UInt32] ( )
351
338
@@ -389,7 +376,6 @@ extension BitstreamWriter {
389
376
}
390
377
391
378
/// Writes an unabbreviated record to the stream.
392
- @available ( * , deprecated, message: " moved to swift-driver " )
393
379
public func writeRecord< CodeType> ( _ code: CodeType , _ composeRecord: ( inout RecordBuffer ) -> Void )
394
380
where CodeType: RawRepresentable , CodeType. RawValue == UInt8
395
381
{
@@ -406,7 +392,6 @@ extension BitstreamWriter {
406
392
/// Writes a record with the provided abbreviation ID and record contents.
407
393
/// Optionally, emits the provided blob if the abbreviation referenced
408
394
/// by that ID requires it.
409
- @available ( * , deprecated, message: " moved to swift-driver " )
410
395
public func writeRecord(
411
396
_ abbrevID: Bitstream . AbbreviationID ,
412
397
_ composeRecord: ( inout RecordBuffer ) -> Void ,
@@ -470,14 +455,12 @@ extension BitstreamWriter {
470
455
/// '0' .. '9' --- 52 .. 61
471
456
/// '.' --- 62
472
457
/// '_' --- 63
473
- @available ( * , deprecated, message: " moved to swift-driver " )
474
458
private static let char6Map =
475
459
Array ( zip ( " abcdefghijklmnopqrstuvwxyz " +
476
460
" ABCDEFGHIJKLMNOPQRSTUVWXYZ " +
477
461
" 0123456789._ " , ( 0 as UInt ) ... ) )
478
462
479
463
/// Writes a char6-encoded value.
480
- @available ( * , deprecated, message: " moved to swift-driver " )
481
464
public func writeChar6< IntType> ( _ value: IntType )
482
465
where IntType: UnsignedInteger & ExpressibleByIntegerLiteral
483
466
{
@@ -489,7 +472,6 @@ extension BitstreamWriter {
489
472
}
490
473
491
474
/// Writes a value with the provided abbreviation encoding.
492
- @available ( * , deprecated, message: " moved to swift-driver " )
493
475
public func writeAbbrevField( _ op: Bitstream . Abbreviation . Operand , value: UInt32 ) {
494
476
switch op {
495
477
case . literal( let literalValue) :
@@ -510,7 +492,6 @@ extension BitstreamWriter {
510
492
511
493
/// Writes a block, beginning with the provided block code and the
512
494
/// abbreviation width
513
- @available ( * , deprecated, message: " moved to swift-driver " )
514
495
public func writeBlock(
515
496
_ blockID: Bitstream . BlockID ,
516
497
newAbbrevWidth: UInt8 ? = nil ,
@@ -521,7 +502,6 @@ extension BitstreamWriter {
521
502
endBlock ( )
522
503
}
523
504
524
- @available ( * , deprecated, message: " moved to swift-driver " )
525
505
public func writeBlob< S> ( _ bytes: S , includeSize: Bool = true )
526
506
where S: Collection , S. Element == UInt8
527
507
{
@@ -547,7 +527,6 @@ extension BitstreamWriter {
547
527
548
528
/// Writes the blockinfo block and allows emitting abbreviations
549
529
/// and records in it.
550
- @available ( * , deprecated, message: " moved to swift-driver " )
551
530
public func writeBlockInfoBlock( emitRecords: ( ) -> Void ) {
552
531
writeBlock ( . blockInfo, newAbbrevWidth: 2 ) {
553
532
currentBlockID = nil
@@ -566,7 +545,6 @@ extension BitstreamWriter {
566
545
/// - blockID: The ID of the block to emit.
567
546
/// - abbreviationBitWidth: The width of the largest abbreviation ID in this block.
568
547
/// - defineSubBlock: A closure that is called to define the contents of the new block.
569
- @available ( * , deprecated, message: " moved to swift-driver " )
570
548
public func withSubBlock(
571
549
_ blockID: Bitstream . BlockID ,
572
550
abbreviationBitWidth: UInt8 ? = nil ,
@@ -588,7 +566,6 @@ extension BitstreamWriter {
588
566
/// - Parameters:
589
567
/// - blockID: The ID of the block to emit.
590
568
/// - abbreviationBitWidth: The width of the largest abbreviation ID in this block.
591
- @available ( * , deprecated, message: " moved to swift-driver " )
592
569
public func enterSubblock(
593
570
_ blockID: Bitstream . BlockID ,
594
571
abbreviationBitWidth: UInt8 ? = nil
@@ -622,7 +599,6 @@ extension BitstreamWriter {
622
599
}
623
600
624
601
/// Marks the end of a new block record.
625
- @available ( * , deprecated, message: " moved to swift-driver " )
626
602
public func endBlock( ) {
627
603
guard let block = blockScope. popLast ( ) else {
628
604
fatalError ( " endBlock() called with no block registered " )
@@ -645,7 +621,6 @@ extension BitstreamWriter {
645
621
646
622
/// Defines an abbreviation within the blockinfo block for the provided
647
623
/// block ID.
648
- @available ( * , deprecated, message: " moved to swift-driver " )
649
624
public func defineBlockInfoAbbreviation(
650
625
_ blockID: Bitstream . BlockID ,
651
626
_ abbrev: Bitstream . Abbreviation
@@ -659,7 +634,6 @@ extension BitstreamWriter {
659
634
}
660
635
661
636
662
- @available ( * , deprecated, message: " moved to swift-driver " )
663
637
private func overwriteBytes( _ int: UInt32 , byteIndex: Int ) {
664
638
let i = int. littleEndian
665
639
data. withUnsafeMutableBytes { ptr in
@@ -669,15 +643,13 @@ extension BitstreamWriter {
669
643
670
644
/// Gets the BlockInfo for the provided ID or creates it if it hasn't been
671
645
/// created already.
672
- @available ( * , deprecated, message: " moved to swift-driver " )
673
646
private func getOrCreateBlockInfo( _ id: UInt8 ) -> BlockInfo {
674
647
if let blockInfo = blockInfoRecords [ id] { return blockInfo }
675
648
let info = BlockInfo ( )
676
649
blockInfoRecords [ id] = info
677
650
return info
678
651
}
679
652
680
- @available ( * , deprecated, message: " moved to swift-driver " )
681
653
private func `switch`( to blockID: Bitstream . BlockID ) {
682
654
if currentBlockID == blockID { return }
683
655
writeRecord ( Bitstream . BlockInfoCode. setBID) {
0 commit comments