From e24afd838aedabb782b46091d33485360d176608 Mon Sep 17 00:00:00 2001 From: Maor Itzkovitch Date: Sat, 1 Aug 2015 19:07:10 +0300 Subject: [PATCH] extended scalar mutator support --- .gitignore | 6 ++++++ net/FlatBuffers/ByteBuffer.cs | 6 ++++++ src/idl_gen_general.cpp | 9 ++++++--- tests/JavaTest.java | 25 +++++++++++++++++++++++++ tests/MyGame/Example/Monster.cs | 26 +++++++++++++------------- tests/MyGame/Example/Monster.java | 26 +++++++++++++------------- tests/MyGame/Example/Stat.cs | 4 ++-- tests/MyGame/Example/Stat.java | 4 ++-- tests/MyGame/Example/Test.cs | 4 ++-- tests/MyGame/Example/Test.java | 4 ++-- tests/MyGame/Example/Vec3.cs | 10 +++++----- tests/MyGame/Example/Vec3.java | 10 +++++----- 12 files changed, 87 insertions(+), 47 deletions(-) diff --git a/.gitignore b/.gitignore index 5d7a885..c841551 100755 --- a/.gitignore +++ b/.gitignore @@ -31,10 +31,15 @@ proguard-project.txt linklint_results Makefile flatc +flatc.exe flathash +flathash.exe flattests +flattests.exe flatsamplebinary +flatsamplebinary.exe flatsampletext +flatsampletext.exe snapshot.sh tests/go_gen tests/monsterdata_java_wire.mon @@ -50,3 +55,4 @@ java/.idea java/*.iml java/target **/*.pyc +.idea \ No newline at end of file diff --git a/net/FlatBuffers/ByteBuffer.cs b/net/FlatBuffers/ByteBuffer.cs index aadd0ea..1ea0402 100755 --- a/net/FlatBuffers/ByteBuffer.cs +++ b/net/FlatBuffers/ByteBuffer.cs @@ -139,6 +139,12 @@ namespace FlatBuffers _pos = offset; } + // this method exists in order to conform with Java ByteBuffer standards + public void Put(int offset, byte value) + { + PutByte(offset, value); + } + #if UNSAFE_BYTEBUFFER // Unsafe but more efficient versions of Put*. public void PutShort(int offset, short value) diff --git a/src/idl_gen_general.cpp b/src/idl_gen_general.cpp index 0c733f3..9bc1f70 100644 --- a/src/idl_gen_general.cpp +++ b/src/idl_gen_general.cpp @@ -434,7 +434,8 @@ static std::string GenSetter(const LanguageParameters &lang, case BASE_TYPE_STRUCT: return ""; default: { std::string setter = "bb." + FunctionStart(lang, 'P') + "ut"; - if (GenTypeBasic(lang, type) != "byte") { + if (GenTypeBasic(lang, type) != "byte" && + type.base_type != BASE_TYPE_BOOL) { setter += MakeCamel(GenTypeGet(lang, type)); } return setter; @@ -716,6 +717,8 @@ static void GenStruct(const LanguageParameters &lang, const Parser &parser, // generate mutators for scalar fields if (opts.mutable_buffer) { + // boolean parameters have to be explicitly converted to byte representation + std::string setter_parameter = field.value.type.base_type == BASE_TYPE_BOOL ? "(byte)(" + field.name + " ? 1 : 0)" : field.name; std::string mutator_prefix = MakeCamel("mutate", lang.first_camel_upper); if (IsScalar(field.value.type.base_type)) { code += " public "; @@ -725,11 +728,11 @@ static void GenStruct(const LanguageParameters &lang, const Parser &parser, code += " " + field.name + ") { "; if (struct_def.fixed) { code += GenSetter(lang, field.value.type) + "(bb_pos + "; - code += NumToString(field.value.offset) + "); }\n"; + code += NumToString(field.value.offset) + ", " + setter_parameter + "); }\n"; } else { code += "int o = __offset(" + NumToString(field.value.offset) + ");"; code += " if (o != 0) { " + GenSetter(lang, field.value.type); - code += "(o + bb_pos); return true } else { return false } }\n"; + code += "(o + bb_pos, " + setter_parameter + "); return true; } else { return false; } }\n"; } } } diff --git a/tests/JavaTest.java b/tests/JavaTest.java index 75fb598..9e8c77b 100755 --- a/tests/JavaTest.java +++ b/tests/JavaTest.java @@ -110,6 +110,31 @@ class JavaTest { TestEnums(); + //Attempt to mutate Monster fields and check whether the buffer has been mutated properly + // revert to original values after testing + Monster monster = Monster.getRootAsMonster(fbb.dataBuffer()); + + // mana is optional and does not exist in the buffer so the mutation should fail + // it should retain its default value + TestEq(monster.mutateMana((short)10), false); + TestEq(monster.mana(), (short)150); + + // testType is an existing field and mutating it should succeed + TestEq(monster.testType(), (byte)Any.Monster); + TestEq(monster.mutateTestType(Any.NONE), true); + TestEq(monster.testType(), (byte)Any.NONE); + TestEq(monster.mutateTestType(Any.Monster), true); + TestEq(monster.testType(), (byte)Any.Monster); + + // get a struct field and edit one of its fields + // + Vec3 pos = monster.pos(); + TestEq(pos.x(), 1.0f); + pos.mutateX(55.0f); + TestEq(pos.x(), 55.0f); + pos.mutateX(1.0f); + TestEq(pos.x(), 1.0f); + System.out.println("FlatBuffers test: completed successfully"); } diff --git a/tests/MyGame/Example/Monster.cs b/tests/MyGame/Example/Monster.cs index a029b04..593210b 100644 --- a/tests/MyGame/Example/Monster.cs +++ b/tests/MyGame/Example/Monster.cs @@ -14,16 +14,16 @@ public sealed class Monster : Table { public Vec3 Pos { get { return GetPos(new Vec3()); } } public Vec3 GetPos(Vec3 obj) { int o = __offset(4); return o != 0 ? obj.__init(o + bb_pos, bb) : null; } public short Mana { get { int o = __offset(6); return o != 0 ? bb.GetShort(o + bb_pos) : (short)150; } } - public bool MutateMana(short mana) { int o = __offset(6); if (o != 0) { bb.PutShort(o + bb_pos); return true } else { return false } } + public bool MutateMana(short mana) { int o = __offset(6); if (o != 0) { bb.PutShort(o + bb_pos, mana); return true; } else { return false; } } public short Hp { get { int o = __offset(8); return o != 0 ? bb.GetShort(o + bb_pos) : (short)100; } } - public bool MutateHp(short hp) { int o = __offset(8); if (o != 0) { bb.PutShort(o + bb_pos); return true } else { return false } } + public bool MutateHp(short hp) { int o = __offset(8); if (o != 0) { bb.PutShort(o + bb_pos, hp); return true; } else { return false; } } public string Name { get { int o = __offset(10); return o != 0 ? __string(o + bb_pos) : null; } } public byte GetInventory(int j) { int o = __offset(14); return o != 0 ? bb.Get(__vector(o) + j * 1) : (byte)0; } public int InventoryLength { get { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; } } public Color Color { get { int o = __offset(16); return o != 0 ? (Color)bb.GetSbyte(o + bb_pos) : (Color)8; } } - public bool MutateColor(sbyte color) { int o = __offset(16); if (o != 0) { bb.PutSbyte(o + bb_pos); return true } else { return false } } + public bool MutateColor(sbyte color) { int o = __offset(16); if (o != 0) { bb.PutSbyte(o + bb_pos, color); return true; } else { return false; } } public Any TestType { get { int o = __offset(18); return o != 0 ? (Any)bb.Get(o + bb_pos) : (Any)0; } } - public bool MutateTestType(byte test_type) { int o = __offset(18); if (o != 0) { bb.Put(o + bb_pos); return true } else { return false } } + public bool MutateTestType(byte test_type) { int o = __offset(18); if (o != 0) { bb.Put(o + bb_pos, test_type); return true; } else { return false; } } public TTable GetTest(TTable obj) where TTable : Table { int o = __offset(20); return o != 0 ? __union(obj, o) : null; } public Test GetTest4(int j) { return GetTest4(new Test(), j); } public Test GetTest4(Test obj, int j) { int o = __offset(22); return o != 0 ? obj.__init(__vector(o) + j * 4, bb) : null; } @@ -42,23 +42,23 @@ public sealed class Monster : Table { public Stat Testempty { get { return GetTestempty(new Stat()); } } public Stat GetTestempty(Stat obj) { int o = __offset(32); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; } public bool Testbool { get { int o = __offset(34); return o != 0 ? 0!=bb.Get(o + bb_pos) : (bool)false; } } - public bool MutateTestbool(bool testbool) { int o = __offset(34); if (o != 0) { bb.PutBool(o + bb_pos); return true } else { return false } } + public bool MutateTestbool(bool testbool) { int o = __offset(34); if (o != 0) { bb.Put(o + bb_pos, (byte)(testbool ? 1 : 0)); return true; } else { return false; } } public int Testhashs32Fnv1 { get { int o = __offset(36); return o != 0 ? bb.GetInt(o + bb_pos) : (int)0; } } - public bool MutateTesthashs32Fnv1(int testhashs32_fnv1) { int o = __offset(36); if (o != 0) { bb.PutInt(o + bb_pos); return true } else { return false } } + public bool MutateTesthashs32Fnv1(int testhashs32_fnv1) { int o = __offset(36); if (o != 0) { bb.PutInt(o + bb_pos, testhashs32_fnv1); return true; } else { return false; } } public uint Testhashu32Fnv1 { get { int o = __offset(38); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } } - public bool MutateTesthashu32Fnv1(uint testhashu32_fnv1) { int o = __offset(38); if (o != 0) { bb.PutUint(o + bb_pos); return true } else { return false } } + public bool MutateTesthashu32Fnv1(uint testhashu32_fnv1) { int o = __offset(38); if (o != 0) { bb.PutUint(o + bb_pos, testhashu32_fnv1); return true; } else { return false; } } public long Testhashs64Fnv1 { get { int o = __offset(40); return o != 0 ? bb.GetLong(o + bb_pos) : (long)0; } } - public bool MutateTesthashs64Fnv1(long testhashs64_fnv1) { int o = __offset(40); if (o != 0) { bb.PutLong(o + bb_pos); return true } else { return false } } + public bool MutateTesthashs64Fnv1(long testhashs64_fnv1) { int o = __offset(40); if (o != 0) { bb.PutLong(o + bb_pos, testhashs64_fnv1); return true; } else { return false; } } public ulong Testhashu64Fnv1 { get { int o = __offset(42); return o != 0 ? bb.GetUlong(o + bb_pos) : (ulong)0; } } - public bool MutateTesthashu64Fnv1(ulong testhashu64_fnv1) { int o = __offset(42); if (o != 0) { bb.PutUlong(o + bb_pos); return true } else { return false } } + public bool MutateTesthashu64Fnv1(ulong testhashu64_fnv1) { int o = __offset(42); if (o != 0) { bb.PutUlong(o + bb_pos, testhashu64_fnv1); return true; } else { return false; } } public int Testhashs32Fnv1a { get { int o = __offset(44); return o != 0 ? bb.GetInt(o + bb_pos) : (int)0; } } - public bool MutateTesthashs32Fnv1a(int testhashs32_fnv1a) { int o = __offset(44); if (o != 0) { bb.PutInt(o + bb_pos); return true } else { return false } } + public bool MutateTesthashs32Fnv1a(int testhashs32_fnv1a) { int o = __offset(44); if (o != 0) { bb.PutInt(o + bb_pos, testhashs32_fnv1a); return true; } else { return false; } } public uint Testhashu32Fnv1a { get { int o = __offset(46); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } } - public bool MutateTesthashu32Fnv1a(uint testhashu32_fnv1a) { int o = __offset(46); if (o != 0) { bb.PutUint(o + bb_pos); return true } else { return false } } + public bool MutateTesthashu32Fnv1a(uint testhashu32_fnv1a) { int o = __offset(46); if (o != 0) { bb.PutUint(o + bb_pos, testhashu32_fnv1a); return true; } else { return false; } } public long Testhashs64Fnv1a { get { int o = __offset(48); return o != 0 ? bb.GetLong(o + bb_pos) : (long)0; } } - public bool MutateTesthashs64Fnv1a(long testhashs64_fnv1a) { int o = __offset(48); if (o != 0) { bb.PutLong(o + bb_pos); return true } else { return false } } + public bool MutateTesthashs64Fnv1a(long testhashs64_fnv1a) { int o = __offset(48); if (o != 0) { bb.PutLong(o + bb_pos, testhashs64_fnv1a); return true; } else { return false; } } public ulong Testhashu64Fnv1a { get { int o = __offset(50); return o != 0 ? bb.GetUlong(o + bb_pos) : (ulong)0; } } - public bool MutateTesthashu64Fnv1a(ulong testhashu64_fnv1a) { int o = __offset(50); if (o != 0) { bb.PutUlong(o + bb_pos); return true } else { return false } } + public bool MutateTesthashu64Fnv1a(ulong testhashu64_fnv1a) { int o = __offset(50); if (o != 0) { bb.PutUlong(o + bb_pos, testhashu64_fnv1a); return true; } else { return false; } } public static void StartMonster(FlatBufferBuilder builder) { builder.StartObject(24); } public static void AddPos(FlatBufferBuilder builder, int posOffset) { builder.AddStruct(0, posOffset, 0); } diff --git a/tests/MyGame/Example/Monster.java b/tests/MyGame/Example/Monster.java index 4b8bdac..0183a00 100644 --- a/tests/MyGame/Example/Monster.java +++ b/tests/MyGame/Example/Monster.java @@ -16,18 +16,18 @@ public final class Monster extends Table { public Vec3 pos() { return pos(new Vec3()); } public Vec3 pos(Vec3 obj) { int o = __offset(4); return o != 0 ? obj.__init(o + bb_pos, bb) : null; } public short mana() { int o = __offset(6); return o != 0 ? bb.getShort(o + bb_pos) : 150; } - public boolean mutateMana(short mana) { int o = __offset(6); if (o != 0) { bb.putShort(o + bb_pos); return true } else { return false } } + public boolean mutateMana(short mana) { int o = __offset(6); if (o != 0) { bb.putShort(o + bb_pos, mana); return true; } else { return false; } } public short hp() { int o = __offset(8); return o != 0 ? bb.getShort(o + bb_pos) : 100; } - public boolean mutateHp(short hp) { int o = __offset(8); if (o != 0) { bb.putShort(o + bb_pos); return true } else { return false } } + public boolean mutateHp(short hp) { int o = __offset(8); if (o != 0) { bb.putShort(o + bb_pos, hp); return true; } else { return false; } } public String name() { int o = __offset(10); return o != 0 ? __string(o + bb_pos) : null; } public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(10, 1); } public int inventory(int j) { int o = __offset(14); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; } public int inventoryLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; } public ByteBuffer inventoryAsByteBuffer() { return __vector_as_bytebuffer(14, 1); } public byte color() { int o = __offset(16); return o != 0 ? bb.get(o + bb_pos) : 8; } - public boolean mutateColor(byte color) { int o = __offset(16); if (o != 0) { bb.put(o + bb_pos); return true } else { return false } } + public boolean mutateColor(byte color) { int o = __offset(16); if (o != 0) { bb.put(o + bb_pos, color); return true; } else { return false; } } public byte testType() { int o = __offset(18); return o != 0 ? bb.get(o + bb_pos) : 0; } - public boolean mutateTestType(byte test_type) { int o = __offset(18); if (o != 0) { bb.put(o + bb_pos); return true } else { return false } } + public boolean mutateTestType(byte test_type) { int o = __offset(18); if (o != 0) { bb.put(o + bb_pos, test_type); return true; } else { return false; } } public Table test(Table obj) { int o = __offset(20); return o != 0 ? __union(obj, o) : null; } public Test test4(int j) { return test4(new Test(), j); } public Test test4(Test obj, int j) { int o = __offset(22); return o != 0 ? obj.__init(__vector(o) + j * 4, bb) : null; } @@ -49,23 +49,23 @@ public final 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 boolean mutateTestbool(boolean testbool) { int o = __offset(34); if (o != 0) { bb.putBoolean(o + bb_pos); return true } else { return false } } + public boolean mutateTestbool(boolean testbool) { int o = __offset(34); if (o != 0) { bb.put(o + bb_pos, (byte)(testbool ? 1 : 0)); return true; } else { return false; } } public int testhashs32Fnv1() { int o = __offset(36); return o != 0 ? bb.getInt(o + bb_pos) : 0; } - public boolean mutateTesthashs32Fnv1(int testhashs32_fnv1) { int o = __offset(36); if (o != 0) { bb.putInt(o + bb_pos); return true } else { return false } } + public boolean mutateTesthashs32Fnv1(int testhashs32_fnv1) { int o = __offset(36); if (o != 0) { bb.putInt(o + bb_pos, testhashs32_fnv1); return true; } else { return false; } } public long testhashu32Fnv1() { int o = __offset(38); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0; } - public boolean mutateTesthashu32Fnv1(int testhashu32_fnv1) { int o = __offset(38); if (o != 0) { bb.putInt(o + bb_pos); return true } else { return false } } + public boolean mutateTesthashu32Fnv1(int testhashu32_fnv1) { int o = __offset(38); if (o != 0) { bb.putInt(o + bb_pos, testhashu32_fnv1); return true; } else { return false; } } public long testhashs64Fnv1() { int o = __offset(40); return o != 0 ? bb.getLong(o + bb_pos) : 0; } - public boolean mutateTesthashs64Fnv1(long testhashs64_fnv1) { int o = __offset(40); if (o != 0) { bb.putLong(o + bb_pos); return true } else { return false } } + public boolean mutateTesthashs64Fnv1(long testhashs64_fnv1) { int o = __offset(40); if (o != 0) { bb.putLong(o + bb_pos, testhashs64_fnv1); return true; } else { return false; } } public long testhashu64Fnv1() { int o = __offset(42); return o != 0 ? bb.getLong(o + bb_pos) : 0; } - public boolean mutateTesthashu64Fnv1(long testhashu64_fnv1) { int o = __offset(42); if (o != 0) { bb.putLong(o + bb_pos); return true } else { return false } } + public boolean mutateTesthashu64Fnv1(long testhashu64_fnv1) { int o = __offset(42); if (o != 0) { bb.putLong(o + bb_pos, testhashu64_fnv1); return true; } else { return false; } } public int testhashs32Fnv1a() { int o = __offset(44); return o != 0 ? bb.getInt(o + bb_pos) : 0; } - public boolean mutateTesthashs32Fnv1a(int testhashs32_fnv1a) { int o = __offset(44); if (o != 0) { bb.putInt(o + bb_pos); return true } else { return false } } + public boolean mutateTesthashs32Fnv1a(int testhashs32_fnv1a) { int o = __offset(44); if (o != 0) { bb.putInt(o + bb_pos, testhashs32_fnv1a); return true; } else { return false; } } public long testhashu32Fnv1a() { int o = __offset(46); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0; } - public boolean mutateTesthashu32Fnv1a(int testhashu32_fnv1a) { int o = __offset(46); if (o != 0) { bb.putInt(o + bb_pos); return true } else { return false } } + public boolean mutateTesthashu32Fnv1a(int testhashu32_fnv1a) { int o = __offset(46); if (o != 0) { bb.putInt(o + bb_pos, testhashu32_fnv1a); return true; } else { return false; } } public long testhashs64Fnv1a() { int o = __offset(48); return o != 0 ? bb.getLong(o + bb_pos) : 0; } - public boolean mutateTesthashs64Fnv1a(long testhashs64_fnv1a) { int o = __offset(48); if (o != 0) { bb.putLong(o + bb_pos); return true } else { return false } } + public boolean mutateTesthashs64Fnv1a(long testhashs64_fnv1a) { int o = __offset(48); if (o != 0) { bb.putLong(o + bb_pos, testhashs64_fnv1a); return true; } else { return false; } } public long testhashu64Fnv1a() { int o = __offset(50); return o != 0 ? bb.getLong(o + bb_pos) : 0; } - public boolean mutateTesthashu64Fnv1a(long testhashu64_fnv1a) { int o = __offset(50); if (o != 0) { bb.putLong(o + bb_pos); return true } else { return false } } + public boolean mutateTesthashu64Fnv1a(long testhashu64_fnv1a) { int o = __offset(50); if (o != 0) { bb.putLong(o + bb_pos, testhashu64_fnv1a); return true; } else { return false; } } public static void startMonster(FlatBufferBuilder builder) { builder.startObject(24); } public static void addPos(FlatBufferBuilder builder, int posOffset) { builder.addStruct(0, posOffset, 0); } diff --git a/tests/MyGame/Example/Stat.cs b/tests/MyGame/Example/Stat.cs index b0ad134..a1f310e 100644 --- a/tests/MyGame/Example/Stat.cs +++ b/tests/MyGame/Example/Stat.cs @@ -12,9 +12,9 @@ public sealed class Stat : Table { public string Id { get { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; } } public long Val { get { int o = __offset(6); return o != 0 ? bb.GetLong(o + bb_pos) : (long)0; } } - public bool MutateVal(long val) { int o = __offset(6); if (o != 0) { bb.PutLong(o + bb_pos); return true } else { return false } } + public bool MutateVal(long val) { int o = __offset(6); if (o != 0) { bb.PutLong(o + bb_pos, val); return true; } else { return false; } } public ushort Count { get { int o = __offset(8); return o != 0 ? bb.GetUshort(o + bb_pos) : (ushort)0; } } - public bool MutateCount(ushort count) { int o = __offset(8); if (o != 0) { bb.PutUshort(o + bb_pos); return true } else { return false } } + public bool MutateCount(ushort count) { int o = __offset(8); if (o != 0) { bb.PutUshort(o + bb_pos, count); return true; } else { return false; } } public static int CreateStat(FlatBufferBuilder builder, int id = 0, diff --git a/tests/MyGame/Example/Stat.java b/tests/MyGame/Example/Stat.java index 7c78876..23cc42a 100644 --- a/tests/MyGame/Example/Stat.java +++ b/tests/MyGame/Example/Stat.java @@ -15,9 +15,9 @@ public final class Stat extends Table { public String id() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; } public ByteBuffer idAsByteBuffer() { return __vector_as_bytebuffer(4, 1); } public long val() { int o = __offset(6); return o != 0 ? bb.getLong(o + bb_pos) : 0; } - public boolean mutateVal(long val) { int o = __offset(6); if (o != 0) { bb.putLong(o + bb_pos); return true } else { return false } } + public boolean mutateVal(long val) { int o = __offset(6); if (o != 0) { bb.putLong(o + bb_pos, val); return true; } else { return false; } } public int count() { int o = __offset(8); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; } - public boolean mutateCount(short count) { int o = __offset(8); if (o != 0) { bb.putShort(o + bb_pos); return true } else { return false } } + public boolean mutateCount(short count) { int o = __offset(8); if (o != 0) { bb.putShort(o + bb_pos, count); return true; } else { return false; } } public static int createStat(FlatBufferBuilder builder, int id, diff --git a/tests/MyGame/Example/Test.cs b/tests/MyGame/Example/Test.cs index 4cddc36..ff81c45 100644 --- a/tests/MyGame/Example/Test.cs +++ b/tests/MyGame/Example/Test.cs @@ -9,9 +9,9 @@ public sealed class Test : Struct { public Test __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } public short A { get { return bb.GetShort(bb_pos + 0); } } - public void MutateA(short a) { bb.PutShort(bb_pos + 0); } + public void MutateA(short a) { bb.PutShort(bb_pos + 0, a); } public sbyte B { get { return bb.GetSbyte(bb_pos + 2); } } - public void MutateB(sbyte b) { bb.PutSbyte(bb_pos + 2); } + public void MutateB(sbyte b) { bb.PutSbyte(bb_pos + 2, b); } public static int CreateTest(FlatBufferBuilder builder, short A, sbyte B) { builder.Prep(2, 4); diff --git a/tests/MyGame/Example/Test.java b/tests/MyGame/Example/Test.java index 0dc72a7..c4cd6aa 100644 --- a/tests/MyGame/Example/Test.java +++ b/tests/MyGame/Example/Test.java @@ -11,9 +11,9 @@ public final class Test extends Struct { public Test __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } public short a() { return bb.getShort(bb_pos + 0); } - public void mutateA(short a) { bb.putShort(bb_pos + 0); } + public void mutateA(short a) { bb.putShort(bb_pos + 0, a); } public byte b() { return bb.get(bb_pos + 2); } - public void mutateB(byte b) { bb.put(bb_pos + 2); } + public void mutateB(byte b) { bb.put(bb_pos + 2, b); } public static int createTest(FlatBufferBuilder builder, short a, byte b) { builder.prep(2, 4); diff --git a/tests/MyGame/Example/Vec3.cs b/tests/MyGame/Example/Vec3.cs index 090dd19..3582c0d 100644 --- a/tests/MyGame/Example/Vec3.cs +++ b/tests/MyGame/Example/Vec3.cs @@ -9,15 +9,15 @@ public sealed class Vec3 : Struct { public Vec3 __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } public float X { get { return bb.GetFloat(bb_pos + 0); } } - public void MutateX(float x) { bb.PutFloat(bb_pos + 0); } + public void MutateX(float x) { bb.PutFloat(bb_pos + 0, x); } public float Y { get { return bb.GetFloat(bb_pos + 4); } } - public void MutateY(float y) { bb.PutFloat(bb_pos + 4); } + public void MutateY(float y) { bb.PutFloat(bb_pos + 4, y); } public float Z { get { return bb.GetFloat(bb_pos + 8); } } - public void MutateZ(float z) { bb.PutFloat(bb_pos + 8); } + public void MutateZ(float z) { bb.PutFloat(bb_pos + 8, z); } public double Test1 { get { return bb.GetDouble(bb_pos + 16); } } - public void MutateTest1(double test1) { bb.PutDouble(bb_pos + 16); } + public void MutateTest1(double test1) { bb.PutDouble(bb_pos + 16, test1); } public Color Test2 { get { return (Color)bb.GetSbyte(bb_pos + 24); } } - public void MutateTest2(sbyte test2) { bb.PutSbyte(bb_pos + 24); } + public void MutateTest2(sbyte test2) { bb.PutSbyte(bb_pos + 24, test2); } public Test Test3 { get { return GetTest3(new Test()); } } public Test GetTest3(Test obj) { return obj.__init(bb_pos + 26, bb); } diff --git a/tests/MyGame/Example/Vec3.java b/tests/MyGame/Example/Vec3.java index df62cc8..457f57d 100644 --- a/tests/MyGame/Example/Vec3.java +++ b/tests/MyGame/Example/Vec3.java @@ -11,15 +11,15 @@ public final class Vec3 extends Struct { public Vec3 __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } public float x() { return bb.getFloat(bb_pos + 0); } - public void mutateX(float x) { bb.putFloat(bb_pos + 0); } + public void mutateX(float x) { bb.putFloat(bb_pos + 0, x); } public float y() { return bb.getFloat(bb_pos + 4); } - public void mutateY(float y) { bb.putFloat(bb_pos + 4); } + public void mutateY(float y) { bb.putFloat(bb_pos + 4, y); } public float z() { return bb.getFloat(bb_pos + 8); } - public void mutateZ(float z) { bb.putFloat(bb_pos + 8); } + public void mutateZ(float z) { bb.putFloat(bb_pos + 8, z); } public double test1() { return bb.getDouble(bb_pos + 16); } - public void mutateTest1(double test1) { bb.putDouble(bb_pos + 16); } + public void mutateTest1(double test1) { bb.putDouble(bb_pos + 16, test1); } public byte test2() { return bb.get(bb_pos + 24); } - public void mutateTest2(byte test2) { bb.put(bb_pos + 24); } + public void mutateTest2(byte test2) { bb.put(bb_pos + 24, test2); } public Test test3() { return test3(new Test()); } public Test test3(Test obj) { return obj.__init(bb_pos + 26, bb); } -- 2.7.4