Sets Swift minimum version to 5.8 (#8228)

Updates copyright from 2023 to 2024 & formats code - updates formatting rules

Updates CI to run with swift 5.8

Adds wasmer & updates command to run carton as a swift plugin

Update bazelci to also accept swift 5.8

Adds swift 5.10 to the test matrix
This commit is contained in:
mustiikhalil
2024-05-29 22:07:54 +02:00
committed by GitHub
parent 3b27f5396e
commit 75f05d6389
44 changed files with 89 additions and 192 deletions

View File

@@ -5,7 +5,7 @@ platforms:
ubuntu1804: ubuntu1804:
environment: environment:
CC: clang CC: clang
SWIFT_VERSION: "5.5.3" SWIFT_VERSION: "5.8"
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION" SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
PATH: "$PATH:$SWIFT_HOME/usr/bin" PATH: "$PATH:$SWIFT_HOME/usr/bin"
shell_commands: shell_commands:
@@ -19,7 +19,7 @@ platforms:
ubuntu2004: ubuntu2004:
environment: environment:
CC: clang CC: clang
SWIFT_VERSION: "5.5.3" SWIFT_VERSION: "5.8"
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION" SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
PATH: "$PATH:$SWIFT_HOME/usr/bin" PATH: "$PATH:$SWIFT_HOME/usr/bin"
shell_commands: shell_commands:

View File

@@ -486,10 +486,18 @@ jobs:
build-swift: build-swift:
name: Build Swift name: Build Swift
strategy:
matrix:
swift: ["5.8", "5.9", "5.10"]
# Only 22.04 has swift at the moment https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md?plain=1#L30 # Only 22.04 has swift at the moment https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md?plain=1#L30
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ matrix.swift }}
- name: Get swift version
run: swift --version
- name: test - name: test
working-directory: tests/swift/tests working-directory: tests/swift/tests
run: | run: |
@@ -505,9 +513,12 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Setup Wasmer - name: Setup Wasmer
uses: wasmerio/setup-wasmer@v2 uses: wasmerio/setup-wasmer@v2
- uses: swiftwasm/setup-swiftwasm@v1
with:
swift-version: "wasm-5.9.2-RELEASE"
- name: Test - name: Test
working-directory: tests/swift/Wasm.tests working-directory: tests/swift/Wasm.tests
run: carton test run: swift run carton test
build-ts: build-ts:
name: Build TS name: Build TS

View File

@@ -1,4 +1,4 @@
// swift-tools-version:5.6 // swift-tools-version:5.8
/* /*
* Copyright 2020 Google Inc. All rights reserved. * Copyright 2020 Google Inc. All rights reserved.
* *

View File

@@ -1,37 +0,0 @@
// swift-tools-version:5.5
/*
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import PackageDescription
let package = Package(
name: "FlatBuffers",
platforms: [
.iOS(.v11),
.macOS(.v10_14),
],
products: [
.library(
name: "FlatBuffers",
targets: ["FlatBuffers"]),
],
targets: [
.target(
name: "FlatBuffers",
dependencies: [],
path: "swift/Sources"),
])

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -6,7 +6,7 @@
# options # options
--self remove # redundantSelf --self remove # redundantSelf
--importgrouping testable-bottom # sortedImports --importgrouping testable-bottom # sortImports
--trimwhitespace always --trimwhitespace always
--indentcase false --indentcase false
--ifdef no-indent #indent --ifdef no-indent #indent
@@ -17,7 +17,7 @@
--typeattributes prev-line # wrapAttributes --typeattributes prev-line # wrapAttributes
# rules # rules
--rules wrap,todos,anyObjectProtocol,redundantParens,redundantReturn,redundantSelf,sortedImports,strongifiedSelf,trailingCommas,trailingSpace,wrapArguments,wrapMultilineStatementBraces,indent,wrapAttributes,void,fileHeader --rules wrap,todos,anyObjectProtocol,redundantParens,redundantReturn,redundantSelf,sortImports,strongifiedSelf,trailingCommas,trailingSpace,wrapArguments,wrapMultilineStatementBraces,indent,wrapAttributes,void,fileHeader
--disable trailingclosures --disable trailingclosures
--exclude **/*_generated.swift --exclude **/*_generated.swift

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// `ByteBuffer` is the interface that stores the data for a `Flatbuffers` object /// `ByteBuffer` is the interface that stores the data for a `Flatbuffers` object
/// it allows users to write and read data directly from memory thus the use of its /// it allows users to write and read data directly from memory thus the use of its
@@ -121,11 +117,11 @@ public struct ByteBuffer {
public let allowReadingUnalignedBuffers: Bool public let allowReadingUnalignedBuffers: Bool
/// Constructor that creates a Flatbuffer object from a UInt8 /// Constructor that creates a Flatbuffer object from a UInt8
/// - Parameter /// - Parameter
/// - bytes: Array of UInt8 /// - bytes: Array of UInt8
/// - allowReadingUnalignedBuffers: allow reading from unaligned buffer /// - allowReadingUnalignedBuffers: allow reading from unaligned buffer
public init( public init(
bytes: [UInt8], bytes: [UInt8],
allowReadingUnalignedBuffers allowUnalignedBuffers: Bool = false) allowReadingUnalignedBuffers allowUnalignedBuffers: Bool = false)
{ {
var b = bytes var b = bytes
@@ -133,17 +129,17 @@ public struct ByteBuffer {
_writerSize = _storage.capacity _writerSize = _storage.capacity
allowReadingUnalignedBuffers = allowUnalignedBuffers allowReadingUnalignedBuffers = allowUnalignedBuffers
b.withUnsafeMutableBytes { bufferPointer in b.withUnsafeMutableBytes { bufferPointer in
self._storage.copy(from: bufferPointer.baseAddress!, count: bytes.count) _storage.copy(from: bufferPointer.baseAddress!, count: bytes.count)
} }
} }
#if !os(WASI) #if !os(WASI)
/// Constructor that creates a Flatbuffer from the Swift Data type object /// Constructor that creates a Flatbuffer from the Swift Data type object
/// - Parameter /// - Parameter
/// - data: Swift data Object /// - data: Swift data Object
/// - allowReadingUnalignedBuffers: allow reading from unaligned buffer /// - allowReadingUnalignedBuffers: allow reading from unaligned buffer
public init( public init(
data: Data, data: Data,
allowReadingUnalignedBuffers allowUnalignedBuffers: Bool = false) allowReadingUnalignedBuffers allowUnalignedBuffers: Bool = false)
{ {
var b = data var b = data
@@ -151,7 +147,7 @@ public struct ByteBuffer {
_writerSize = _storage.capacity _writerSize = _storage.capacity
allowReadingUnalignedBuffers = allowUnalignedBuffers allowReadingUnalignedBuffers = allowUnalignedBuffers
b.withUnsafeMutableBytes { bufferPointer in b.withUnsafeMutableBytes { bufferPointer in
self._storage.copy(from: bufferPointer.baseAddress!, count: data.count) _storage.copy(from: bufferPointer.baseAddress!, count: data.count)
} }
} }
#endif #endif
@@ -175,7 +171,7 @@ public struct ByteBuffer {
/// - allowReadingUnalignedBuffers: allow reading from unaligned buffer /// - allowReadingUnalignedBuffers: allow reading from unaligned buffer
public init<Bytes: ContiguousBytes>( public init<Bytes: ContiguousBytes>(
contiguousBytes: Bytes, contiguousBytes: Bytes,
count: Int, count: Int,
allowReadingUnalignedBuffers allowUnalignedBuffers: Bool = false) allowReadingUnalignedBuffers allowUnalignedBuffers: Bool = false)
{ {
_storage = Storage(count: count, alignment: alignment) _storage = Storage(count: count, alignment: alignment)
@@ -208,7 +204,7 @@ public struct ByteBuffer {
/// - count: count of bytes /// - count: count of bytes
/// - allowReadingUnalignedBuffers: allow reading from unaligned buffer /// - allowReadingUnalignedBuffers: allow reading from unaligned buffer
init( init(
memory: UnsafeMutableRawPointer, memory: UnsafeMutableRawPointer,
count: Int, count: Int,
allowReadingUnalignedBuffers allowUnalignedBuffers: Bool = false) allowReadingUnalignedBuffers allowUnalignedBuffers: Bool = false)
{ {
@@ -228,7 +224,7 @@ public struct ByteBuffer {
memory: UnsafeMutableRawPointer, memory: UnsafeMutableRawPointer,
count: Int, count: Int,
removing removeBytes: Int, removing removeBytes: Int,
allowReadingUnalignedBuffers allowUnalignedBuffers: Bool = false) allowReadingUnalignedBuffers allowUnalignedBuffers: Bool = false)
{ {
_storage = Storage(count: count, alignment: alignment) _storage = Storage(count: count, alignment: alignment)
_storage.copy(from: memory, count: count) _storage.copy(from: memory, count: count)
@@ -257,7 +253,7 @@ public struct ByteBuffer {
_storage.memory.advanced(by: writerIndex &- ptr.count), _storage.memory.advanced(by: writerIndex &- ptr.count),
UnsafeRawPointer(ptr.baseAddress!), UnsafeRawPointer(ptr.baseAddress!),
ptr.count) ptr.count)
self._writerSize = self._writerSize &+ ptr.count _writerSize = _writerSize &+ ptr.count
} }
} }
@@ -271,7 +267,7 @@ public struct ByteBuffer {
_storage.memory _storage.memory
.advanced(by: writerIndex &- ptr.count) .advanced(by: writerIndex &- ptr.count)
.copyMemory(from: ptr.baseAddress!, byteCount: ptr.count) .copyMemory(from: ptr.baseAddress!, byteCount: ptr.count)
self._writerSize = self._writerSize &+ ptr.count _writerSize = _writerSize &+ ptr.count
} }
} }
@@ -287,7 +283,7 @@ public struct ByteBuffer {
_storage.memory.advanced(by: writerIndex &- ptr.count), _storage.memory.advanced(by: writerIndex &- ptr.count),
UnsafeRawPointer(ptr.baseAddress!), UnsafeRawPointer(ptr.baseAddress!),
ptr.count) ptr.count)
self._writerSize = self._writerSize &+ ptr.count _writerSize = _writerSize &+ ptr.count
} }
} }
#endif #endif
@@ -306,7 +302,7 @@ public struct ByteBuffer {
_storage.memory.advanced(by: writerIndex &- size), _storage.memory.advanced(by: writerIndex &- size),
$0.baseAddress!, $0.baseAddress!,
size) size)
self._writerSize = self._writerSize &+ size _writerSize = _writerSize &+ size
} }
} }
@@ -324,7 +320,7 @@ public struct ByteBuffer {
_storage.memory.advanced(by: writerIndex &- len), _storage.memory.advanced(by: writerIndex &- len),
$0.baseAddress!, $0.baseAddress!,
len) len)
self._writerSize = self._writerSize &+ len _writerSize = _writerSize &+ len
} }
} }
@@ -429,11 +425,9 @@ public struct ByteBuffer {
/// - position: the index of the object in the buffer /// - position: the index of the object in the buffer
@inline(__always) @inline(__always)
public func read<T>(def: T.Type, position: Int) -> T { public func read<T>(def: T.Type, position: Int) -> T {
#if swift(>=5.7)
if allowReadingUnalignedBuffers { if allowReadingUnalignedBuffers {
return _storage.memory.advanced(by: position).loadUnaligned(as: T.self) return _storage.memory.advanced(by: position).loadUnaligned(as: T.self)
} }
#endif
return _storage.memory.advanced(by: position).load(as: T.self) return _storage.memory.advanced(by: position).load(as: T.self)
} }
@@ -538,7 +532,8 @@ extension ByteBuffer: CustomDebugStringConvertible {
public var debugDescription: String { public var debugDescription: String {
""" """
buffer located at: \(_storage.memory), with capacity of \(_storage.capacity) buffer located at: \(_storage.memory), with capacity of \(_storage.capacity)
{ writerSize: \(_writerSize), readerSize: \(reader), writerIndex: \(writerIndex) } { writerSize: \(_writerSize), readerSize: \(reader), writerIndex: \(
writerIndex) }
""" """
} }
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,15 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
#if os(Linux)
import CoreFoundation
#else
import Foundation import Foundation
#endif
#else
import SwiftOverlayShims
#endif
/// A boolean to see if the system is littleEndian /// A boolean to see if the system is littleEndian
let isLitteEndian: Bool = { let isLitteEndian: Bool = {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// Enum is a protocol that all flatbuffers enums should conform to /// Enum is a protocol that all flatbuffers enums should conform to
/// Since it allows us to get the actual `ByteSize` and `Value` from /// Since it allows us to get the actual `ByteSize` and `Value` from

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// ``FlatBufferBuilder`` builds a `FlatBuffer` through manipulating its internal state. /// ``FlatBufferBuilder`` builds a `FlatBuffer` through manipulating its internal state.
/// ///
@@ -836,7 +832,8 @@ extension FlatBufferBuilder: CustomDebugStringConvertible {
buffer debug: buffer debug:
\(_bb) \(_bb)
builder debug: builder debug:
{ finished: \(finished), serializeDefaults: \(serializeDefaults), isNested: \(isNested) } { finished: \(finished), serializeDefaults: \(
serializeDefaults), isNested: \(isNested) }
""" """
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// NativeStruct is a protocol that indicates if the struct is a native `swift` struct /// NativeStruct is a protocol that indicates if the struct is a native `swift` struct
/// since now we will be serializing native structs into the buffer. /// since now we will be serializing native structs into the buffer.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// FlatBuffersUtils hosts some utility functions that might be useful /// FlatBuffersUtils hosts some utility functions that might be useful
public enum FlatBuffersUtils { public enum FlatBuffersUtils {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// Collection of thrown from the Flatbuffer verifier /// Collection of thrown from the Flatbuffer verifier
public enum FlatbuffersErrors: Error, Equatable { public enum FlatbuffersErrors: Error, Equatable {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
extension Int { extension Int {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// FlatBufferGRPCMessage protocol that should allow us to invoke /// FlatBufferGRPCMessage protocol that should allow us to invoke
/// initializers directly from the GRPC generated code /// initializers directly from the GRPC generated code

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,17 +14,13 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// Mutable is a protocol that allows us to mutate Scalar values within a ``ByteBuffer`` /// Mutable is a protocol that allows us to mutate Scalar values within a ``ByteBuffer``
public protocol Mutable { public protocol Mutable {
/// makes Flatbuffer accessed within the Protocol /// makes Flatbuffer accessed within the Protocol
var bb: ByteBuffer { get } var bb: ByteBuffer { get }
/// makes position of the ``Table``/``struct`` accessed within the Protocol /// makes position of the ``Table``/``Struct`` accessed within the Protocol
var postion: Int32 { get } var postion: Int32 { get }
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// NativeObject is a protocol that all of the `Object-API` generated code should be /// NativeObject is a protocol that all of the `Object-API` generated code should be
/// conforming to since it allows developers the ease of use to pack and unpack their /// conforming to since it allows developers the ease of use to pack and unpack their

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// Offset object for all the Objects that are written into the buffer /// Offset object for all the Objects that are written into the buffer
public struct Offset { public struct Offset {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// Takes in a prefixed sized buffer, where the prefixed size would be skipped. /// Takes in a prefixed sized buffer, where the prefixed size would be skipped.
/// And would verify that the buffer passed is a valid `Flatbuffers` Object. /// And would verify that the buffer passed is a valid `Flatbuffers` Object.
@@ -74,7 +70,8 @@ public func getCheckedPrefixedSizeRoot<T: FlatBufferObject & Verifiable>(
/// ///
/// ``getPrefixedSizeCheckedRoot(byteBuffer:options:)`` would skip the first Bytes in /// ``getPrefixedSizeCheckedRoot(byteBuffer:options:)`` would skip the first Bytes in
/// the ``ByteBuffer`` and then calls ``getRoot(byteBuffer:)`` /// the ``ByteBuffer`` and then calls ``getRoot(byteBuffer:)``
public func getPrefixedSizeRoot<T: FlatBufferObject>(byteBuffer: inout ByteBuffer) public func getPrefixedSizeRoot<T: FlatBufferObject>(
byteBuffer: inout ByteBuffer)
-> T -> T
{ {
byteBuffer.skipPrefix() byteBuffer.skipPrefix()

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
extension String: Verifiable { extension String: Verifiable {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// Struct is a representation of a mutable `Flatbuffers` struct /// Struct is a representation of a mutable `Flatbuffers` struct
/// since native structs are value types and cant be mutated /// since native structs are value types and cant be mutated

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// `Table` is a Flatbuffers object that can read, /// `Table` is a Flatbuffers object that can read,
/// mutate scalar fields within a valid flatbuffers buffer /// mutate scalar fields within a valid flatbuffers buffer

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// `TableVerifier` verifies a table object is within a provided memory. /// `TableVerifier` verifies a table object is within a provided memory.
/// It checks if all the objects for a specific generated table, are within /// It checks if all the objects for a specific generated table, are within

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// `VerifierOptions` is a set of options to verify a flatbuffer /// `VerifierOptions` is a set of options to verify a flatbuffer
public struct VerifierOptions { public struct VerifierOptions {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// Verifiable is a protocol all swift flatbuffers object should conform to, /// Verifiable is a protocol all swift flatbuffers object should conform to,
/// since swift is similar to `cpp` and `rust` where the data is read directly /// since swift is similar to `cpp` and `rust` where the data is read directly

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if !os(WASI)
import Foundation import Foundation
#else
import SwiftOverlayShims
#endif
/// Verifier that check if the buffer passed into it is a valid, /// Verifier that check if the buffer passed into it is a valid,
/// safe, aligned Flatbuffers object since swift read from `unsafeMemory` /// safe, aligned Flatbuffers object since swift read from `unsafeMemory`

View File

@@ -1 +0,0 @@
wasm-5.7-SNAPSHOT-2022-09-24-a

View File

@@ -1,4 +1,4 @@
// swift-tools-version:5.1 // swift-tools-version:5.9
/* /*
* Copyright 2020 Google Inc. All rights reserved. * Copyright 2020 Google Inc. All rights reserved.
* *
@@ -24,11 +24,13 @@ let package = Package(
], ],
dependencies: [ dependencies: [
.package(path: "../../.."), .package(path: "../../.."),
.package(url: "https://github.com/swiftwasm/carton", exact: "1.0.1"),
], ],
targets: [ targets: [
.target( .target(name: "Wasm"),
name: "Wasm"),
.testTarget( .testTarget(
name: "FlatBuffers.Test.Swift.WasmTests", name: "FlatBuffers.Test.Swift.WasmTests",
dependencies: ["FlatBuffers"]), dependencies: [
.product(name: "FlatBuffers", package: "flatbuffers"),
]),
]) ])

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -1,4 +1,4 @@
// swift-tools-version:5.1 // swift-tools-version:5.8
/* /*
* Copyright 2020 Google Inc. All rights reserved. * Copyright 2020 Google Inc. All rights reserved.
* *
@@ -28,10 +28,15 @@ let package = Package(
.package(url: "https://github.com/grpc/grpc-swift.git", from: "1.4.1"), .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.4.1"),
], ],
targets: [ targets: [
.target( .executableTarget(
name: "SwiftFlatBuffers", name: "SwiftFlatBuffers",
dependencies: ["FlatBuffers"]), dependencies: [
.product(name: "FlatBuffers", package: "flatbuffers"),
]),
.testTarget( .testTarget(
name: "FlatBuffers.Test.SwiftTests", name: "FlatBuffers.Test.SwiftTests",
dependencies: ["FlatBuffers", "GRPC"]), dependencies: [
.product(name: "FlatBuffers", package: "flatbuffers"),
.product(name: "GRPC", package: "grpc-swift"),
]),
]) ])

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2023 Google Inc. All rights reserved. * Copyright 2024 Google Inc. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.