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