Improves documentation, and adding DocC (#6784)

Finished documenting flatbuffersbuilder

Replaces swift 5.5 with 5.2 packages

Starts building the tutorial for xcode 13

Finishes building the tutorial for xcode 13

Removes docc files from old swift versions

Updates swift style guide
This commit is contained in:
mustiikhalil
2021-09-27 20:59:19 +02:00
committed by GitHub
parent e2b26ee19b
commit f63c130c28
56 changed files with 1214 additions and 163 deletions

View File

@@ -51,7 +51,10 @@ final class FlatBuffersUnionTests: XCTestCase {
var builder = FlatBufferBuilder(initialSize: 20)
let sword = builder.create(string: "Sword")
let axe = builder.create(string: "Axe")
let weaponOne = Weapon.createWeapon(builder: &builder, offset: sword, dmg: 3)
let weaponOne = Weapon.createWeapon(
builder: &builder,
offset: sword,
dmg: 3)
let weaponTwo = Weapon.createWeapon(builder: &builder, offset: axe, dmg: 5)
let name = builder.create(string: "Orc")
let inventory: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
@@ -138,7 +141,9 @@ final class FlatBuffersUnionTests: XCTestCase {
2)
var objc: MovieT? = movie.unpack()
XCTAssertEqual(movie.charactersTypeCount, Int32(objc?.characters.count ?? 0))
XCTAssertEqual(
movie.charactersTypeCount,
Int32(objc?.characters.count ?? 0))
XCTAssertEqual(
movie.characters(at: 0, type: BookReader_Mutable.self)?.booksRead,
(objc?.characters[0]?.value as? BookReader)?.booksRead)
@@ -219,20 +224,32 @@ public enum ColorsNameSpace {
private var _accessor: Table
static func getRootAsMonster(bb: ByteBuffer) -> Monster { Monster(Table(
bb: bb,
position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
position: Int32(bb.read(def: UOffset.self, position: bb.reader)) +
Int32(bb.reader))) }
init(_ t: Table) { _accessor = t }
init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
public var colorsCount: Int32 { let o = _accessor.offset(4); return o == 0 ? 0 : _accessor.vector(count: o) }
public func colors(at index: Int32) -> ColorsNameSpace.RGB? { let o = _accessor.offset(4); return o == 0 ? ColorsNameSpace.RGB(rawValue: 0)! : ColorsNameSpace.RGB(rawValue: _accessor.directRead(
of: Int32.self,
offset: _accessor.vector(at: o) + index * 4)) }
static func startMonster(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
public var colorsCount: Int32 {
let o = _accessor.offset(4); return o == 0 ? 0 : _accessor
.vector(count: o) }
public func colors(at index: Int32) -> ColorsNameSpace
.RGB?
{ let o = _accessor.offset(4); return o == 0 ? ColorsNameSpace
.RGB(rawValue: 0)! : ColorsNameSpace.RGB(rawValue: _accessor.directRead(
of: Int32.self,
offset: _accessor.vector(at: o) + index * 4)) }
static func startMonster(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb
.startTable(with: 1) }
static func add(colors: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(
offset: colors,
at: 4) }
static func endMonster(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
static func endMonster(
_ fbb: inout FlatBufferBuilder,
start: UOffset)
-> Offset
{ let end = Offset(offset: fbb.endTable(at: start)); return end
}
}
}
@@ -280,9 +297,10 @@ struct LocalMonster {
init(_ fb: ByteBuffer, o: Int32) { __t = Table(bb: fb, position: o) }
init(_ t: Table) { __t = t }
func weapon(at index: Int32) -> Weapon? { let o = __t.offset(4); return o == 0 ? nil : Weapon.assign(
__t.indirect(__t.vector(at: o) + (index * 4)),
__t.bb) }
func weapon(at index: Int32) -> Weapon? { let o = __t
.offset(4); return o == 0 ? nil : Weapon.assign(
__t.indirect(__t.vector(at: o) + (index * 4)),
__t.bb) }
func equiped<T: FlatBufferObject>() -> T? {
let o = __t.offset(8); return o == 0 ? nil : __t.union(o)
@@ -304,7 +322,10 @@ struct LocalMonster {
let start = builder.startTable(with: 3)
builder.add(element: equippedOffset, def: 0, at: 8)
builder.add(offset: offset, at: 4)
builder.add(element: equipment.rawValue, def: Equipment.none.rawValue, at: 6)
builder.add(
element: equipment.rawValue,
def: Equipment.none.rawValue,
at: 6)
return Offset(offset: builder.endTable(at: start))
}
}
@@ -323,7 +344,8 @@ struct Weapon: FlatBufferObject {
of: Int16.self,
at: o) }
var nameVector: [UInt8]? { __t.getVector(at: 4) }
var name: String? { let o = __t.offset(4); return o == 0 ? nil : __t.string(at: o) }
var name: String? {
let o = __t.offset(4); return o == 0 ? nil : __t.string(at: o) }
static func assign(_ i: Int32, _ bb: ByteBuffer) -> Weapon { Weapon(Table(
bb: bb,
@@ -342,7 +364,10 @@ struct Weapon: FlatBufferObject {
}
@inlinable
static func end(builder: inout FlatBufferBuilder, startOffset: UOffset) -> Offset {
static func end(
builder: inout FlatBufferBuilder,
startOffset: UOffset) -> Offset
{
Offset(offset: builder.endTable(at: startOffset))
}