diff options
author | mustiikhalil <mustii@mmk.one> | 2020-01-13 23:34:06 +0300 |
---|---|---|
committer | Wouter van Oortmerssen <aardappel@gmail.com> | 2020-01-13 12:34:06 -0800 |
commit | a4b2884e4ed6116335d534af8f58a84678b74a17 (patch) | |
tree | 73a9fc0f7e747c3333e50f4523db42c49ccde881 /samples | |
parent | 04d80f255d1c2fa7a466e8465a119c0eaef26d59 (diff) | |
download | flatbuffers-a4b2884e4ed6116335d534af8f58a84678b74a17.tar.gz flatbuffers-a4b2884e4ed6116335d534af8f58a84678b74a17.tar.bz2 flatbuffers-a4b2884e4ed6116335d534af8f58a84678b74a17.zip |
Added create function for swift (#5707)
Fixed the create functions and updated the test cases in swift
Removes unneeded code
Updated documentation
Diffstat (limited to 'samples')
-rw-r--r-- | samples/sample_binary.swift | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/samples/sample_binary.swift b/samples/sample_binary.swift index e334fab7..3a6dc747 100644 --- a/samples/sample_binary.swift +++ b/samples/sample_binary.swift @@ -1,10 +1,10 @@ // THIS IS JUST TO SHOW THE CODE, PLEASE DO IMPORT FLATBUFFERS WITH SPM.. import Flatbuffers -typealias Monster = MyGame1.Sample.Monster -typealias Weapon = MyGame1.Sample.Weapon -typealias Color = MyGame1.Sample.Color -typealias Vec3 = MyGame1.Sample.Vec3 +typealias Monster = MyGame.Sample.Monster +typealias Weapon = MyGame.Sample.Weapon +typealias Color = MyGame.Sample.Color +typealias Vec3 = MyGame.Sample.Vec3 func main() { let expectedDMG: [Int16] = [3, 5] @@ -30,16 +30,16 @@ func main() { let weaponsOffset = builder.createVector(ofOffsets: [sword, axe]) let pos = builder.create(struct: MyGame.Sample.createVec3(x: 1, y: 2, z: 3), type: Vec3.self) - let start = Monster.startMonster(builder) - Monster.add(pos: pos, builder) - Monster.add(hp: 300, builder) - Monster.add(name: name, builder) - Monster.add(inventory: inventoryOffset, builder) - Monster.add(color: .red, builder) - Monster.add(weapons: weaponsOffset, builder) - Monster.add(equippedType: .weapon, builder) - Monster.add(equipped: axe, builder) - var orc = Monster.endMonster(builder, start: start) + + let orc = Monster.createMonster(builder, + offsetOfPos: pos, + hp: 300, + offsetOfName: name, + vectorOfInventory: inventoryOffset, + color: .red, + vectorOfWeapons: weaponsOffset, + equippedType: .weapon, + offsetOfEquipped: axe) builder.finish(offset: orc) var buf = builder.sizedByteArray @@ -48,7 +48,7 @@ func main() { assert(monster.mana == 150) assert(monster.hp == 300) assert(monster.name == "Orc") - assert(monster.color == MyGame1.Sample.Color.red) + assert(monster.color == MyGame.Sample.Color.red) assert(monster.pos != nil) for i in 0..<monster.inventoryCount { assert(i == monster.inventory(at: i)) |