Skip to content

Commit 5b2ff18

Browse files
committed
Fixes bazel breaking due to new project structure
Address warnings within the library
1 parent 40708c5 commit 5b2ff18

18 files changed

+28
-18
lines changed

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import PackageDescription
2020
let package = Package(
2121
name: "FlatBuffers",
2222
platforms: [
23-
.iOS(.v11),
23+
.iOS(.v12),
2424
.macOS(.v10_14),
2525
],
2626
products: [

grpc/examples/swift/Greeter/Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import PackageDescription
2020
let package = Package(
2121
name: "Greeter",
2222
platforms: [
23-
.iOS(.v11),
23+
.iOS(.v12),
2424
.macOS(.v10_14),
2525
],
2626
dependencies: [

swift/BUILD.bazel

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
22

3+
swift_library(
4+
name = "FlexBuffers",
5+
srcs = glob([
6+
"Sources/FlexBuffers/**/*.swift",
7+
"Sources/Common/*.swift",
8+
]),
9+
module_name = "FlexBuffers",
10+
visibility = ["//visibility:public"],
11+
)
12+
313
swift_library(
414
name = "swift",
5-
srcs = glob(["Sources/FlatBuffers/*.swift"]),
15+
srcs = glob([
16+
"Sources/FlatBuffers/*.swift",
17+
"Sources/Common/*.swift",
18+
]),
619
module_name = "FlatBuffers",
720
visibility = ["//visibility:public"],
821
)

swift/Sources/FlatBuffers/ByteBuffer.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import Common
1817
import Foundation
1918

2019
/// `ByteBuffer` is the interface that stores the data for a `Flatbuffers` object
@@ -294,7 +293,7 @@ public struct ByteBuffer {
294293
}
295294
assert(index < _storage.capacity, "Write index is out of writing bound")
296295
assert(index >= 0, "Writer index should be above zero")
297-
_ = withUnsafePointer(to: value) { ptr in
296+
withUnsafePointer(to: value) { ptr in
298297
_storage.withUnsafeRawPointer {
299298
memcpy(
300299
$0.advanced(by: index),

swift/Sources/FlatBuffers/Constants.swift

+2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17+
#if canImport(Common)
1718
@_exported import Common
19+
#endif
1820
import Foundation
1921

2022
/// Type aliases

swift/Sources/FlatBuffers/FlatBufferBuilder.swift

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import Common
1817
import Foundation
1918

2019
/// ``FlatBufferBuilder`` builds a `FlatBuffer` through manipulating its internal state.

swift/Sources/FlatBuffers/Table.swift

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import Common
1817
import Foundation
1918

2019
/// `Table` is a Flatbuffers object that can read,

swift/Sources/FlatBuffers/_InternalByteBuffer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ struct _InternalByteBuffer {
253253
}
254254
assert(index < _storage.capacity, "Write index is out of writing bound")
255255
assert(index >= 0, "Writer index should be above zero")
256-
_ = withUnsafePointer(to: value) {
256+
withUnsafePointer(to: value) {
257257
memcpy(
258258
_storage.memory.advanced(by: index),
259259
$0,

swift/Sources/FlexBuffers/ByteBuffer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public struct ByteBuffer {
293293
}
294294
assert(index < _storage.capacity, "Write index is out of writing bound")
295295
assert(index >= 0, "Writer index should be above zero")
296-
_ = withUnsafePointer(to: value) { ptr in
296+
withUnsafePointer(to: value) { ptr in
297297
_storage.withUnsafeRawPointer {
298298
memcpy(
299299
$0.advanced(by: index),

swift/Sources/FlexBuffers/Reader/Map.swift

-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ public struct Map: Sized {
4040

4141
@inline(__always)
4242
public subscript(key: String) -> Reference? {
43-
let count = keys.count
44-
let mid = count / 2
4543
guard let position = binarySearch(vector: keys, target: key)
4644
else { return nil }
4745

swift/Sources/FlexBuffers/Reader/Reference.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public func getRoot(buffer: ByteBuffer) throws -> Reference? {
4141

4242
@inline(__always)
4343
public func getRootChecked(buffer: ByteBuffer) throws -> Reference? {
44-
#warning("TODO: Implement")
44+
// TODO(mustiikhalil): implement verifier
4545
return try getRoot(buffer: buffer)
4646
}
4747

swift/Sources/FlexBuffers/Utils/Constants.swift

+2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17+
#if canImport(Common)
1718
@_exported import Common
19+
#endif
1820
import Foundation
1921

2022
extension UInt64 {

swift/Sources/FlexBuffers/Utils/Value.swift

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import Common
1817
import Foundation
1918

2019
public struct Value: Equatable {

swift/Sources/FlexBuffers/Writer/FlexBuffersWriter.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -757,14 +757,14 @@ public struct FlexBuffersWriter {
757757
private mutating func write(offset: UInt64, byteWidth: Int) {
758758
let offset: UInt64 = numericCast(writerIndex) &- offset
759759
assert(byteWidth == 8 || offset < UInt64.one << (byteWidth * 8))
760-
_ = withUnsafePointer(to: offset) {
760+
withUnsafePointer(to: offset) {
761761
_bb.writeBytes($0, len: byteWidth)
762762
}
763763
}
764764

765765
@inline(__always)
766766
private mutating func write<T>(value: T, byteWidth: Int) where T: Scalar {
767-
_ = withUnsafePointer(to: value) {
767+
withUnsafePointer(to: value) {
768768
_bb.writeBytes($0, len: byteWidth)
769769
}
770770
}

swift/Sources/FlexBuffers/_InternalByteBuffer.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import Common
1817
import Foundation
1918

2019
/// `ByteBuffer` is the interface that stores the data for a `Flatbuffers` object
@@ -162,7 +161,7 @@ struct _InternalByteBuffer {
162161
}
163162

164163
mutating func write<T>(_ v: T, len: Int) {
165-
_ = withUnsafePointer(to: v) {
164+
withUnsafePointer(to: v) {
166165
memcpy(
167166
_storage.memory.advanced(by: writerIndex),
168167
$0,

tests/swift/tests/Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import PackageDescription
2020
let package = Package(
2121
name: "FlatBuffers.Test.Swift",
2222
platforms: [
23-
.iOS(.v11),
23+
.iOS(.v12),
2424
.macOS(.v10_14),
2525
],
2626
dependencies: [

0 commit comments

Comments
 (0)