File tree 2 files changed +20
-2
lines changed
2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -291,10 +291,14 @@ extension ProtobufEncoder {
291
291
}
292
292
293
293
func binaryPlistData< T> ( for value: T ) throws -> Data where T: Encodable {
294
+ #if os(WASI)
295
+ fatalError ( " PropertyListEncoder is not avaiable on WASI " )
296
+ #else
294
297
let encoder = PropertyListEncoder ( )
295
298
encoder. outputFormat = . binary
296
299
encoder. userInfo = userInfo
297
300
return try encoder. encode ( [ value] )
301
+ #endif
298
302
}
299
303
300
304
@inline ( __always)
@@ -467,6 +471,7 @@ extension ProtobufEncoder {
467
471
encodeVarintZZ ( Int ( value) )
468
472
}
469
473
474
+ #if compiler(>=6.0)
470
475
@inline ( __always)
471
476
private mutating func encodeBitwiseCopyable< T> ( _ value: T ) where T: BitwiseCopyable {
472
477
let oldSize = size
@@ -478,6 +483,19 @@ extension ProtobufEncoder {
478
483
buffer. advanced ( by: oldSize) . storeBytes ( of: value, as: T . self)
479
484
}
480
485
}
486
+ #else // FIXME: Remove this after we drop WASI 5.10 support
487
+ @inline ( __always)
488
+ private mutating func encodeBitwiseCopyable< T> ( _ value: T ) {
489
+ let oldSize = size
490
+ let newSize = oldSize + MemoryLayout< T> . size
491
+ if capacity < newSize {
492
+ growBufferSlow ( to: newSize) . storeBytes ( of: value, as: T . self)
493
+ } else {
494
+ size = newSize
495
+ buffer. advanced ( by: oldSize) . storeBytes ( of: value, as: T . self)
496
+ }
497
+ }
498
+ #endif
481
499
482
500
package mutating func encodeBool( _ value: Bool ) {
483
501
encodeBitwiseCopyable ( value)
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ extension UnsafePointer {
15
15
16
16
@_transparent
17
17
package static var null : UnsafePointer < Pointee > {
18
- UnsafePointer ( bitPattern: Int ( bitPattern: 0xffff_ffff_ffff_ff00 ) | ( - MemoryLayout < Pointee > . alignment) ) !
18
+ UnsafePointer ( bitPattern: Int ( bitPattern: UInt . max - 0xff ) | ( - MemoryLayout < Pointee > . alignment) ) !
19
19
}
20
20
}
21
21
@@ -29,7 +29,7 @@ extension UnsafeMutablePointer {
29
29
30
30
@_transparent
31
31
package static var null : UnsafeMutablePointer < Pointee > {
32
- UnsafeMutablePointer ( bitPattern: Int ( bitPattern: 0xffff_ffff_ffff_ff00 ) | ( - MemoryLayout < Pointee > . alignment) ) !
32
+ UnsafeMutablePointer ( bitPattern: Int ( bitPattern: UInt . max - 0xff ) | ( - MemoryLayout < Pointee > . alignment) ) !
33
33
}
34
34
}
35
35
You can’t perform that action at this time.
0 commit comments