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

@@ -35,7 +35,8 @@ class FlatBuffersMonsterWriterTests: XCTestCase {
func testReadFromOtherLanguages() {
let path = FileManager.default.currentDirectoryPath
let url = URL(fileURLWithPath: path, isDirectory: true).appendingPathComponent("monsterdata_test").appendingPathExtension("mon")
let url = URL(fileURLWithPath: path, isDirectory: true)
.appendingPathComponent("monsterdata_test").appendingPathExtension("mon")
guard let data = try? Data(contentsOf: url) else { return }
let _data = ByteBuffer(data: data)
readVerifiedMonster(fb: _data)
@@ -108,15 +109,16 @@ class FlatBuffersMonsterWriterTests: XCTestCase {
// swiftformat:disable all
var array: [UInt8] = [48, 0, 0, 0, 77, 79, 78, 83, 0, 0, 0, 0, 36, 0, 72, 0, 40, 0, 0, 0, 38, 0, 32, 0, 0, 0, 28, 0, 0, 0, 27, 0, 20, 0, 16, 0, 12, 0, 4, 0, 0, 0, 0, 0, 0, 0, 11, 0, 36, 0, 0, 0, 164, 0, 0, 0, 0, 0, 0, 1, 60, 0, 0, 0, 68, 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 1, 88, 0, 0, 0, 120, 0, 0, 0, 0, 0, 80, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 64, 2, 0, 5, 0, 6, 0, 0, 0, 2, 0, 0, 0, 64, 0, 0, 0, 48, 0, 0, 0, 2, 0, 0, 0, 30, 0, 40, 0, 10, 0, 20, 0, 152, 255, 255, 255, 4, 0, 0, 0, 4, 0, 0, 0, 70, 114, 101, 100, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 5, 0, 0, 0, 116, 101, 115, 116, 50, 0, 0, 0, 5, 0, 0, 0, 116, 101, 115, 116, 49, 0, 0, 0, 9, 0, 0, 0, 77, 121, 77, 111, 110, 115, 116, 101, 114, 0, 0, 0, 3, 0, 0, 0, 20, 0, 0, 0, 36, 0, 0, 0, 4, 0, 0, 0, 240, 255, 255, 255, 32, 0, 0, 0, 248, 255, 255, 255, 36, 0, 0, 0, 12, 0, 8, 0, 0, 0, 0, 0, 0, 0, 4, 0, 12, 0, 0, 0, 28, 0, 0, 0, 5, 0, 0, 0, 87, 105, 108, 109, 97, 0, 0, 0, 6, 0, 0, 0, 66, 97, 114, 110, 101, 121, 0, 0, 5, 0, 0, 0, 70, 114, 111, 100, 111, 0, 0, 0]
// swiftformat:enable all
let unpacked = array.withUnsafeMutableBytes { (memory) -> MyGame_Example_MonsterT in
let bytes = ByteBuffer(
assumingMemoryBound: memory.baseAddress!,
capacity: memory.count)
var monster = Monster.getRootAsMonster(bb: bytes)
readFlatbufferMonster(monster: &monster)
let unpacked = monster.unpack()
return unpacked
}
let unpacked = array
.withUnsafeMutableBytes { (memory) -> MyGame_Example_MonsterT in
let bytes = ByteBuffer(
assumingMemoryBound: memory.baseAddress!,
capacity: memory.count)
var monster = Monster.getRootAsMonster(bb: bytes)
readFlatbufferMonster(monster: &monster)
let unpacked = monster.unpack()
return unpacked
}
readObjectApi(monster: unpacked)
}
@@ -143,7 +145,10 @@ class FlatBuffersMonsterWriterTests: XCTestCase {
func readVerifiedMonster(fb: ByteBuffer) {
var byteBuffer = fb
XCTAssertNoThrow(try readMonster(monster: getCheckedRoot(byteBuffer: &byteBuffer) as MyGame_Example_Monster))
XCTAssertNoThrow(
try readMonster(
monster: getCheckedRoot(
byteBuffer: &byteBuffer) as MyGame_Example_Monster))
}
func readMonster(monster: Monster) {
@@ -151,7 +156,8 @@ class FlatBuffersMonsterWriterTests: XCTestCase {
readFlatbufferMonster(monster: &monster)
let unpacked: MyGame_Example_MonsterT? = monster.unpack()
readObjectApi(monster: unpacked!)
guard let buffer = unpacked?.serialize() else { fatalError("Couldnt generate bytebuffer") }
guard let buffer = unpacked?.serialize()
else { fatalError("Couldnt generate bytebuffer") }
var newMonster = Monster.getRootAsMonster(bb: buffer)
readFlatbufferMonster(monster: &newMonster)
}