From 7ef2fc251735f019a21b5e0aa88053a1faffd7c7 Mon Sep 17 00:00:00 2001 From: Wouter van Oortmerssen Date: Fri, 13 Mar 2015 13:05:28 -0700 Subject: [PATCH] Regenerated test code + fixed typo in C# FlatBufferBuilder Change-Id: Ifa6d9459c53ae60b9bf936d9468ec971ee282f14 Tested: on Linux and Windows. --- .gitignore | 1 + net/FlatBuffers/FlatBufferBuilder.cs | 4 +- tests/MyGame/Example/Monster.cs | 18 ++++++- tests/MyGame/Example/Monster.go | 74 +++++++++++++++++++++++++++- tests/MyGame/Example/Monster.java | 18 ++++++- tests/monster_test_generated.h | 24 ++++++++- 6 files changed, 132 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index ff7fcbf18..d3e40d5d2 100755 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ flatsampletext snapshot.sh tests/go_gen tests/monsterdata_java_wire.mon +tests/monsterdata_go_wire.mon CMakeLists.txt.user CMakeScripts/** build/Xcode/FlatBuffers.xcodeproj/project.xcworkspace/** diff --git a/net/FlatBuffers/FlatBufferBuilder.cs b/net/FlatBuffers/FlatBufferBuilder.cs index d5e02b3f4..c46a77090 100644 --- a/net/FlatBuffers/FlatBufferBuilder.cs +++ b/net/FlatBuffers/FlatBufferBuilder.cs @@ -170,7 +170,7 @@ namespace FlatBuffers public void AddInt(int x) { Prep(sizeof(int), 0); PutInt(x); } public void AddUint(uint x) { Prep(sizeof(uint), 0); PutUint(x); } public void AddLong(long x) { Prep(sizeof(long), 0); PutLong(x); } - public void AddULong(ulong x) { Prep(sizeof(ulong), 0); PutUlong(x); } + public void AddUlong(ulong x) { Prep(sizeof(ulong), 0); PutUlong(x); } public void AddFloat(float x) { Prep(sizeof(float), 0); PutFloat(x); } public void AddDouble(double x) { Prep(sizeof(double), 0); PutDouble(x); } @@ -245,7 +245,7 @@ namespace FlatBuffers public void AddInt(int o, int x, int d) { if (x != d) { AddInt(x); Slot(o); } } public void AddUint(int o, uint x, uint d) { if (x != d) { AddUint(x); Slot(o); } } public void AddLong(int o, long x, long d) { if (x != d) { AddLong(x); Slot(o); } } - public void AddULong(int o, ulong x, ulong d) { if (x != d) { AddULong(x); Slot(o); } } + public void AddUlong(int o, ulong x, ulong d) { if (x != d) { AddUlong(x); Slot(o); } } public void AddFloat(int o, float x, double d) { if (x != d) { AddFloat(x); Slot(o); } } public void AddDouble(int o, double x, double d) { if (x != d) { AddDouble(x); Slot(o); } } public void AddOffset(int o, int x, int d) { if (x != d) { AddOffset(x); Slot(o); } } diff --git a/tests/MyGame/Example/Monster.cs b/tests/MyGame/Example/Monster.cs index 453e596fa..aca7972ed 100644 --- a/tests/MyGame/Example/Monster.cs +++ b/tests/MyGame/Example/Monster.cs @@ -38,8 +38,16 @@ public class Monster : Table { public Stat Testempty() { return Testempty(new Stat()); } public Stat Testempty(Stat obj) { int o = __offset(32); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; } public bool Testbool() { int o = __offset(34); return o != 0 ? 0!=bb.Get(o + bb_pos) : (bool)false; } + public int Testhashs32Fnv1() { int o = __offset(36); return o != 0 ? bb.GetInt(o + bb_pos) : (int)0; } + public uint Testhashu32Fnv1() { int o = __offset(38); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } + public long Testhashs64Fnv1() { int o = __offset(40); return o != 0 ? bb.GetLong(o + bb_pos) : (long)0; } + public ulong Testhashu64Fnv1() { int o = __offset(42); return o != 0 ? bb.GetUlong(o + bb_pos) : (ulong)0; } + public int Testhashs32Fnv1a() { int o = __offset(44); return o != 0 ? bb.GetInt(o + bb_pos) : (int)0; } + public uint Testhashu32Fnv1a() { int o = __offset(46); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } + public long Testhashs64Fnv1a() { int o = __offset(48); return o != 0 ? bb.GetLong(o + bb_pos) : (long)0; } + public ulong Testhashu64Fnv1a() { int o = __offset(50); return o != 0 ? bb.GetUlong(o + bb_pos) : (ulong)0; } - public static void StartMonster(FlatBufferBuilder builder) { builder.StartObject(16); } + public static void StartMonster(FlatBufferBuilder builder) { builder.StartObject(24); } public static void AddPos(FlatBufferBuilder builder, int posOffset) { builder.AddStruct(0, posOffset, 0); } public static void AddMana(FlatBufferBuilder builder, short mana) { builder.AddShort(1, mana, 150); } public static void AddHp(FlatBufferBuilder builder, short hp) { builder.AddShort(2, hp, 100); } @@ -64,6 +72,14 @@ public class Monster : Table { public static void StartTestnestedflatbufferVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); } public static void AddTestempty(FlatBufferBuilder builder, int testemptyOffset) { builder.AddOffset(14, testemptyOffset, 0); } public static void AddTestbool(FlatBufferBuilder builder, bool testbool) { builder.AddBool(15, testbool, false); } + public static void AddTesthashs32Fnv1(FlatBufferBuilder builder, int testhashs32Fnv1) { builder.AddInt(16, testhashs32Fnv1, 0); } + public static void AddTesthashu32Fnv1(FlatBufferBuilder builder, uint testhashu32Fnv1) { builder.AddUint(17, testhashu32Fnv1, 0); } + public static void AddTesthashs64Fnv1(FlatBufferBuilder builder, long testhashs64Fnv1) { builder.AddLong(18, testhashs64Fnv1, 0); } + public static void AddTesthashu64Fnv1(FlatBufferBuilder builder, ulong testhashu64Fnv1) { builder.AddUlong(19, testhashu64Fnv1, 0); } + public static void AddTesthashs32Fnv1a(FlatBufferBuilder builder, int testhashs32Fnv1a) { builder.AddInt(20, testhashs32Fnv1a, 0); } + public static void AddTesthashu32Fnv1a(FlatBufferBuilder builder, uint testhashu32Fnv1a) { builder.AddUint(21, testhashu32Fnv1a, 0); } + public static void AddTesthashs64Fnv1a(FlatBufferBuilder builder, long testhashs64Fnv1a) { builder.AddLong(22, testhashs64Fnv1a, 0); } + public static void AddTesthashu64Fnv1a(FlatBufferBuilder builder, ulong testhashu64Fnv1a) { builder.AddUlong(23, testhashu64Fnv1a, 0); } public static int EndMonster(FlatBufferBuilder builder) { int o = builder.EndObject(); builder.Required(o, 10); // name diff --git a/tests/MyGame/Example/Monster.go b/tests/MyGame/Example/Monster.go index a47f9ee3b..1abb902e6 100644 --- a/tests/MyGame/Example/Monster.go +++ b/tests/MyGame/Example/Monster.go @@ -215,7 +215,71 @@ func (rcv *Monster) Testbool() byte { return 0 } -func MonsterStart(builder *flatbuffers.Builder) { builder.StartObject(16) } +func (rcv *Monster) Testhashs32Fnv1() int32 { + o := flatbuffers.UOffsetT(rcv._tab.Offset(36)) + if o != 0 { + return rcv._tab.GetInt32(o + rcv._tab.Pos) + } + return 0 +} + +func (rcv *Monster) Testhashu32Fnv1() uint32 { + o := flatbuffers.UOffsetT(rcv._tab.Offset(38)) + if o != 0 { + return rcv._tab.GetUint32(o + rcv._tab.Pos) + } + return 0 +} + +func (rcv *Monster) Testhashs64Fnv1() int64 { + o := flatbuffers.UOffsetT(rcv._tab.Offset(40)) + if o != 0 { + return rcv._tab.GetInt64(o + rcv._tab.Pos) + } + return 0 +} + +func (rcv *Monster) Testhashu64Fnv1() uint64 { + o := flatbuffers.UOffsetT(rcv._tab.Offset(42)) + if o != 0 { + return rcv._tab.GetUint64(o + rcv._tab.Pos) + } + return 0 +} + +func (rcv *Monster) Testhashs32Fnv1a() int32 { + o := flatbuffers.UOffsetT(rcv._tab.Offset(44)) + if o != 0 { + return rcv._tab.GetInt32(o + rcv._tab.Pos) + } + return 0 +} + +func (rcv *Monster) Testhashu32Fnv1a() uint32 { + o := flatbuffers.UOffsetT(rcv._tab.Offset(46)) + if o != 0 { + return rcv._tab.GetUint32(o + rcv._tab.Pos) + } + return 0 +} + +func (rcv *Monster) Testhashs64Fnv1a() int64 { + o := flatbuffers.UOffsetT(rcv._tab.Offset(48)) + if o != 0 { + return rcv._tab.GetInt64(o + rcv._tab.Pos) + } + return 0 +} + +func (rcv *Monster) Testhashu64Fnv1a() uint64 { + o := flatbuffers.UOffsetT(rcv._tab.Offset(50)) + if o != 0 { + return rcv._tab.GetUint64(o + rcv._tab.Pos) + } + return 0 +} + +func MonsterStart(builder *flatbuffers.Builder) { builder.StartObject(24) } func MonsterAddPos(builder *flatbuffers.Builder, pos flatbuffers.UOffsetT) { builder.PrependStructSlot(0, flatbuffers.UOffsetT(pos), 0) } func MonsterAddMana(builder *flatbuffers.Builder, mana int16) { builder.PrependInt16Slot(1, mana, 150) } func MonsterAddHp(builder *flatbuffers.Builder, hp int16) { builder.PrependInt16Slot(2, hp, 100) } @@ -241,4 +305,12 @@ func MonsterStartTestnestedflatbufferVector(builder *flatbuffers.Builder, numEle } func MonsterAddTestempty(builder *flatbuffers.Builder, testempty flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(14, flatbuffers.UOffsetT(testempty), 0) } func MonsterAddTestbool(builder *flatbuffers.Builder, testbool byte) { builder.PrependByteSlot(15, testbool, 0) } +func MonsterAddTesthashs32Fnv1(builder *flatbuffers.Builder, testhashs32Fnv1 int32) { builder.PrependInt32Slot(16, testhashs32Fnv1, 0) } +func MonsterAddTesthashu32Fnv1(builder *flatbuffers.Builder, testhashu32Fnv1 uint32) { builder.PrependUint32Slot(17, testhashu32Fnv1, 0) } +func MonsterAddTesthashs64Fnv1(builder *flatbuffers.Builder, testhashs64Fnv1 int64) { builder.PrependInt64Slot(18, testhashs64Fnv1, 0) } +func MonsterAddTesthashu64Fnv1(builder *flatbuffers.Builder, testhashu64Fnv1 uint64) { builder.PrependUint64Slot(19, testhashu64Fnv1, 0) } +func MonsterAddTesthashs32Fnv1a(builder *flatbuffers.Builder, testhashs32Fnv1a int32) { builder.PrependInt32Slot(20, testhashs32Fnv1a, 0) } +func MonsterAddTesthashu32Fnv1a(builder *flatbuffers.Builder, testhashu32Fnv1a uint32) { builder.PrependUint32Slot(21, testhashu32Fnv1a, 0) } +func MonsterAddTesthashs64Fnv1a(builder *flatbuffers.Builder, testhashs64Fnv1a int64) { builder.PrependInt64Slot(22, testhashs64Fnv1a, 0) } +func MonsterAddTesthashu64Fnv1a(builder *flatbuffers.Builder, testhashu64Fnv1a uint64) { builder.PrependUint64Slot(23, testhashu64Fnv1a, 0) } func MonsterEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() } diff --git a/tests/MyGame/Example/Monster.java b/tests/MyGame/Example/Monster.java index b129908b9..03e6aeb31 100644 --- a/tests/MyGame/Example/Monster.java +++ b/tests/MyGame/Example/Monster.java @@ -43,8 +43,16 @@ public class Monster extends Table { public Stat testempty() { return testempty(new Stat()); } public Stat testempty(Stat obj) { int o = __offset(32); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; } public boolean testbool() { int o = __offset(34); return o != 0 ? 0!=bb.get(o + bb_pos) : false; } + public int testhashs32Fnv1() { int o = __offset(36); return o != 0 ? bb.getInt(o + bb_pos) : 0; } + public int testhashu32Fnv1() { int o = __offset(38); return o != 0 ? bb.getInt(o + bb_pos) : 0; } + public long testhashs64Fnv1() { int o = __offset(40); return o != 0 ? bb.getLong(o + bb_pos) : 0; } + public long testhashu64Fnv1() { int o = __offset(42); return o != 0 ? bb.getLong(o + bb_pos) : 0; } + public int testhashs32Fnv1a() { int o = __offset(44); return o != 0 ? bb.getInt(o + bb_pos) : 0; } + public int testhashu32Fnv1a() { int o = __offset(46); return o != 0 ? bb.getInt(o + bb_pos) : 0; } + public long testhashs64Fnv1a() { int o = __offset(48); return o != 0 ? bb.getLong(o + bb_pos) : 0; } + public long testhashu64Fnv1a() { int o = __offset(50); return o != 0 ? bb.getLong(o + bb_pos) : 0; } - public static void startMonster(FlatBufferBuilder builder) { builder.startObject(16); } + public static void startMonster(FlatBufferBuilder builder) { builder.startObject(24); } public static void addPos(FlatBufferBuilder builder, int posOffset) { builder.addStruct(0, posOffset, 0); } public static void addMana(FlatBufferBuilder builder, short mana) { builder.addShort(1, mana, 150); } public static void addHp(FlatBufferBuilder builder, short hp) { builder.addShort(2, hp, 100); } @@ -69,6 +77,14 @@ public class Monster extends Table { public static void startTestnestedflatbufferVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); } public static void addTestempty(FlatBufferBuilder builder, int testemptyOffset) { builder.addOffset(14, testemptyOffset, 0); } public static void addTestbool(FlatBufferBuilder builder, boolean testbool) { builder.addBoolean(15, testbool, false); } + public static void addTesthashs32Fnv1(FlatBufferBuilder builder, int testhashs32Fnv1) { builder.addInt(16, testhashs32Fnv1, 0); } + public static void addTesthashu32Fnv1(FlatBufferBuilder builder, int testhashu32Fnv1) { builder.addInt(17, testhashu32Fnv1, 0); } + public static void addTesthashs64Fnv1(FlatBufferBuilder builder, long testhashs64Fnv1) { builder.addLong(18, testhashs64Fnv1, 0); } + public static void addTesthashu64Fnv1(FlatBufferBuilder builder, long testhashu64Fnv1) { builder.addLong(19, testhashu64Fnv1, 0); } + public static void addTesthashs32Fnv1a(FlatBufferBuilder builder, int testhashs32Fnv1a) { builder.addInt(20, testhashs32Fnv1a, 0); } + public static void addTesthashu32Fnv1a(FlatBufferBuilder builder, int testhashu32Fnv1a) { builder.addInt(21, testhashu32Fnv1a, 0); } + public static void addTesthashs64Fnv1a(FlatBufferBuilder builder, long testhashs64Fnv1a) { builder.addLong(22, testhashs64Fnv1a, 0); } + public static void addTesthashu64Fnv1a(FlatBufferBuilder builder, long testhashu64Fnv1a) { builder.addLong(23, testhashu64Fnv1a, 0); } public static int endMonster(FlatBufferBuilder builder) { int o = builder.endObject(); builder.required(o, 10); // name diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h index 2364c01d7..55d8eb4be 100755 --- a/tests/monster_test_generated.h +++ b/tests/monster_test_generated.h @@ -145,6 +145,10 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { uint32_t testhashu32_fnv1() const { return GetField(38, 0); } int64_t testhashs64_fnv1() const { return GetField(40, 0); } uint64_t testhashu64_fnv1() const { return GetField(42, 0); } + int32_t testhashs32_fnv1a() const { return GetField(44, 0); } + uint32_t testhashu32_fnv1a() const { return GetField(46, 0); } + int64_t testhashs64_fnv1a() const { return GetField(48, 0); } + uint64_t testhashu64_fnv1a() const { return GetField(50, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* pos */) && @@ -177,6 +181,10 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { VerifyField(verifier, 38 /* testhashu32_fnv1 */) && VerifyField(verifier, 40 /* testhashs64_fnv1 */) && VerifyField(verifier, 42 /* testhashu64_fnv1 */) && + VerifyField(verifier, 44 /* testhashs32_fnv1a */) && + VerifyField(verifier, 46 /* testhashu32_fnv1a */) && + VerifyField(verifier, 48 /* testhashs64_fnv1a */) && + VerifyField(verifier, 50 /* testhashu64_fnv1a */) && verifier.EndTable(); } }; @@ -203,10 +211,14 @@ struct MonsterBuilder { void add_testhashu32_fnv1(uint32_t testhashu32_fnv1) { fbb_.AddElement(38, testhashu32_fnv1, 0); } void add_testhashs64_fnv1(int64_t testhashs64_fnv1) { fbb_.AddElement(40, testhashs64_fnv1, 0); } void add_testhashu64_fnv1(uint64_t testhashu64_fnv1) { fbb_.AddElement(42, testhashu64_fnv1, 0); } + void add_testhashs32_fnv1a(int32_t testhashs32_fnv1a) { fbb_.AddElement(44, testhashs32_fnv1a, 0); } + void add_testhashu32_fnv1a(uint32_t testhashu32_fnv1a) { fbb_.AddElement(46, testhashu32_fnv1a, 0); } + void add_testhashs64_fnv1a(int64_t testhashs64_fnv1a) { fbb_.AddElement(48, testhashs64_fnv1a, 0); } + void add_testhashu64_fnv1a(uint64_t testhashu64_fnv1a) { fbb_.AddElement(50, testhashu64_fnv1a, 0); } MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } MonsterBuilder &operator=(const MonsterBuilder &); flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 20)); + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 24)); fbb_.Required(o, 10); // name return o; } @@ -231,10 +243,18 @@ inline flatbuffers::Offset CreateMonster(flatbuffers::FlatBufferBuilder int32_t testhashs32_fnv1 = 0, uint32_t testhashu32_fnv1 = 0, int64_t testhashs64_fnv1 = 0, - uint64_t testhashu64_fnv1 = 0) { + uint64_t testhashu64_fnv1 = 0, + int32_t testhashs32_fnv1a = 0, + uint32_t testhashu32_fnv1a = 0, + int64_t testhashs64_fnv1a = 0, + uint64_t testhashu64_fnv1a = 0) { MonsterBuilder builder_(_fbb); + builder_.add_testhashu64_fnv1a(testhashu64_fnv1a); + builder_.add_testhashs64_fnv1a(testhashs64_fnv1a); builder_.add_testhashu64_fnv1(testhashu64_fnv1); builder_.add_testhashs64_fnv1(testhashs64_fnv1); + builder_.add_testhashu32_fnv1a(testhashu32_fnv1a); + builder_.add_testhashs32_fnv1a(testhashs32_fnv1a); builder_.add_testhashu32_fnv1(testhashu32_fnv1); builder_.add_testhashs32_fnv1(testhashs32_fnv1); builder_.add_testempty(testempty);