mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-16 17:22:21 +00:00
Fixed bug in convenient constructors for Java/C#
Also fixed Go unit tests not being up to date with recent schema changes. Change-Id: I42e619f9c5ea05f6f937c68a5c8a92462c46bce3 Tested: on Linux and Windows.
This commit is contained in:
@@ -34,8 +34,8 @@ public class Monster : Table {
|
||||
public Monster Enemy(Monster obj) { int o = __offset(28); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; }
|
||||
public byte Testnestedflatbuffer(int j) { int o = __offset(30); return o != 0 ? bb.Get(__vector(o) + j * 1) : (byte)0; }
|
||||
public int TestnestedflatbufferLength() { int o = __offset(30); return o != 0 ? __vector_len(o) : 0; }
|
||||
public Monster Testempty() { return Testempty(new Monster()); }
|
||||
public Monster Testempty(Monster obj) { int o = __offset(32); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; }
|
||||
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 static void StartMonster(FlatBufferBuilder builder) { builder.StartObject(15); }
|
||||
public static void AddPos(FlatBufferBuilder builder, int posOffset) { builder.AddStruct(0, posOffset, 0); }
|
||||
|
||||
@@ -139,8 +139,7 @@ func (rcv *Monster) TestarrayofstringLength() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
/// an example documentation comment: this will end up in the generated code
|
||||
/// multiline too
|
||||
/// an example documentation comment: this will end up in the generated code multiline too
|
||||
func (rcv *Monster) Testarrayoftables(obj *Monster, j int) bool {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(26))
|
||||
if o != 0 {
|
||||
@@ -194,12 +193,12 @@ func (rcv *Monster) TestnestedflatbufferLength() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (rcv *Monster) Testempty(obj *Monster) *Monster {
|
||||
func (rcv *Monster) Testempty(obj *Stat) *Stat {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(32))
|
||||
if o != 0 {
|
||||
x := rcv._tab.Indirect(o + rcv._tab.Pos)
|
||||
if obj == nil {
|
||||
obj = new(Monster)
|
||||
obj = new(Stat)
|
||||
}
|
||||
obj.Init(rcv._tab.Bytes, x)
|
||||
return obj
|
||||
|
||||
@@ -42,8 +42,8 @@ public class Monster extends Table {
|
||||
public byte testnestedflatbuffer(int j) { int o = __offset(30); return o != 0 ? bb.get(__vector(o) + j * 1) : 0; }
|
||||
public int testnestedflatbufferLength() { int o = __offset(30); return o != 0 ? __vector_len(o) : 0; }
|
||||
public ByteBuffer testnestedflatbufferAsByteBuffer() { return __vector_as_bytebuffer(30, 1); }
|
||||
public Monster testempty() { return testempty(new Monster()); }
|
||||
public Monster testempty(Monster obj) { int o = __offset(32); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; }
|
||||
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 static void startMonster(FlatBufferBuilder builder) { builder.startObject(15); }
|
||||
public static void addPos(FlatBufferBuilder builder, int posOffset) { builder.addStruct(0, posOffset, 0); }
|
||||
|
||||
34
tests/MyGame/Example/Stat.cs
Normal file
34
tests/MyGame/Example/Stat.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
// automatically generated, do not modify
|
||||
|
||||
namespace MyGame.Example
|
||||
{
|
||||
|
||||
using FlatBuffers;
|
||||
|
||||
public class Stat : Table {
|
||||
public static Stat GetRootAsStat(ByteBuffer _bb) { return (new Stat()).__init(_bb.GetInt(_bb.position()) + _bb.position(), _bb); }
|
||||
public Stat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
public string Id() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public long Val() { int o = __offset(6); return o != 0 ? bb.GetLong(o + bb_pos) : (long)0; }
|
||||
|
||||
public static int CreateStat(FlatBufferBuilder builder,
|
||||
int id = 0,
|
||||
long val = 0) {
|
||||
builder.StartObject(2);
|
||||
Stat.AddVal(builder, val);
|
||||
Stat.AddId(builder, id);
|
||||
return Stat.EndStat(builder);
|
||||
}
|
||||
|
||||
public static void StartStat(FlatBufferBuilder builder) { builder.StartObject(2); }
|
||||
public static void AddId(FlatBufferBuilder builder, int idOffset) { builder.AddOffset(0, idOffset, 0); }
|
||||
public static void AddVal(FlatBufferBuilder builder, long val) { builder.AddLong(1, val, 0); }
|
||||
public static int EndStat(FlatBufferBuilder builder) {
|
||||
int o = builder.EndObject();
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
36
tests/MyGame/Example/Stat.go
Normal file
36
tests/MyGame/Example/Stat.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// automatically generated, do not modify
|
||||
|
||||
package Example
|
||||
|
||||
import (
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
)
|
||||
type Stat struct {
|
||||
_tab flatbuffers.Table
|
||||
}
|
||||
|
||||
func (rcv *Stat) Init(buf []byte, i flatbuffers.UOffsetT) {
|
||||
rcv._tab.Bytes = buf
|
||||
rcv._tab.Pos = i
|
||||
}
|
||||
|
||||
func (rcv *Stat) Id() string {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
|
||||
if o != 0 {
|
||||
return rcv._tab.String(o + rcv._tab.Pos)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (rcv *Stat) Val() int64 {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
|
||||
if o != 0 {
|
||||
return rcv._tab.GetInt64(o + rcv._tab.Pos)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func StatStart(builder *flatbuffers.Builder) { builder.StartObject(2) }
|
||||
func StatAddId(builder *flatbuffers.Builder, id flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(id), 0) }
|
||||
func StatAddVal(builder *flatbuffers.Builder, val int64) { builder.PrependInt64Slot(1, val, 0) }
|
||||
func StatEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() }
|
||||
35
tests/MyGame/Example/Stat.java
Normal file
35
tests/MyGame/Example/Stat.java
Normal file
@@ -0,0 +1,35 @@
|
||||
// automatically generated, do not modify
|
||||
|
||||
package MyGame.Example;
|
||||
|
||||
import java.nio.*;
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import com.google.flatbuffers.*;
|
||||
|
||||
public class Stat extends Table {
|
||||
public static Stat getRootAsStat(ByteBuffer _bb) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (new Stat()).__init(_bb.getInt(_bb.position()) + _bb.position(), _bb); }
|
||||
public Stat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
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 static int createStat(FlatBufferBuilder builder,
|
||||
int id,
|
||||
long val) {
|
||||
builder.startObject(2);
|
||||
Stat.addVal(builder, val);
|
||||
Stat.addId(builder, id);
|
||||
return Stat.endStat(builder);
|
||||
}
|
||||
|
||||
public static void startStat(FlatBufferBuilder builder) { builder.startObject(2); }
|
||||
public static void addId(FlatBufferBuilder builder, int idOffset) { builder.addOffset(0, idOffset, 0); }
|
||||
public static void addVal(FlatBufferBuilder builder, long val) { builder.addLong(1, val, 0); }
|
||||
public static int endStat(FlatBufferBuilder builder) {
|
||||
int o = builder.endObject();
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user