[Java] ObjectAPI implementation (#6521) (#6582)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)

* [Java] ObjectAPI implementation (#6521)
This commit is contained in:
ofirm93 2021-06-04 00:17:40 +03:00 committed by GitHub
parent baaffbaedd
commit 7c3e267e1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
77 changed files with 3538 additions and 238 deletions

View File

@ -1,5 +1,5 @@
#ifndef FLATBUFFERS_BASE_H_
#define FLATBUFFERS_BASE_H_
# define FLATBUFFERS_BASE_H_
// clang-format off

View File

@ -1397,10 +1397,12 @@ class Builder FLATBUFFERS_FINAL_CLASS {
template<typename T> static Type GetScalarType() {
static_assert(flatbuffers::is_scalar<T>::value, "Unrelated types");
return flatbuffers::is_floating_point<T>::value ? FBT_FLOAT
: flatbuffers::is_same<T, bool>::value
? FBT_BOOL
: (flatbuffers::is_unsigned<T>::value ? FBT_UINT : FBT_INT);
return flatbuffers::is_floating_point<T>::value
? FBT_FLOAT
: flatbuffers::is_same<T, bool>::value
? FBT_BOOL
: (flatbuffers::is_unsigned<T>::value ? FBT_UINT
: FBT_INT);
}
public:

View File

@ -667,9 +667,7 @@ class CppGenerator : public BaseGenerator {
}
case BASE_TYPE_UNION:
// fall through
default: {
return "void";
}
default: { return "void"; }
}
}
@ -1009,9 +1007,10 @@ class CppGenerator : public BaseGenerator {
? bt - BASE_TYPE_UTYPE + ET_UTYPE
: ET_SEQUENCE;
int ref_idx = -1;
std::string ref_name = type.struct_def ? WrapInNameSpace(*type.struct_def)
: type.enum_def ? WrapInNameSpace(*type.enum_def)
: "";
std::string ref_name =
type.struct_def
? WrapInNameSpace(*type.struct_def)
: type.enum_def ? WrapInNameSpace(*type.enum_def) : "";
if (!ref_name.empty()) {
auto rit = type_refs.begin();
for (; rit != type_refs.end(); ++rit) {
@ -1924,9 +1923,7 @@ class CppGenerator : public BaseGenerator {
}
break;
}
default: {
break;
}
default: { break; }
}
}

View File

@ -1515,10 +1515,11 @@ class CSharpGenerator : public BaseGenerator {
case BASE_TYPE_ARRAY: {
auto type_name = GenTypeGet_ObjectAPI(field.value.type, opts);
auto length_str = NumToString(field.value.type.fixed_length);
auto unpack_method = field.value.type.struct_def == nullptr ? ""
: field.value.type.struct_def->fixed
? ".UnPack()"
: "?.UnPack()";
auto unpack_method = field.value.type.struct_def == nullptr
? ""
: field.value.type.struct_def->fixed
? ".UnPack()"
: "?.UnPack()";
code += start + "new " + type_name.substr(0, type_name.length() - 1) +
length_str + "];\n";
code += " for (var _j = 0; _j < " + length_str + "; ++_j) { _o." +

File diff suppressed because it is too large Load Diff

View File

@ -130,9 +130,7 @@ std::string GenType(const Type &type) {
return union_type_string;
}
case BASE_TYPE_UTYPE: return GenTypeRef(type.enum_def);
default: {
return GenBaseType(type);
}
default: { return GenBaseType(type); }
}
}

View File

@ -303,15 +303,15 @@ class KotlinGenerator : public BaseGenerator {
}
writer += ")";
});
GenerateFunOneLine(
writer, "name", "e: Int", "String",
[&]() {
writer += "names[e\\";
if (enum_def.MinValue()->IsNonZero())
writer += " - " + enum_def.MinValue()->name + ".toInt()\\";
writer += "]";
},
parser_.opts.gen_jvmstatic);
GenerateFunOneLine(writer, "name", "e: Int", "String",
[&]() {
writer += "names[e\\";
if (enum_def.MinValue()->IsNonZero())
writer += " - " + enum_def.MinValue()->name +
".toInt()\\";
writer += "]";
},
parser_.opts.gen_jvmstatic);
}
});
writer.DecrementIdentLevel();
@ -625,10 +625,9 @@ class KotlinGenerator : public BaseGenerator {
auto id = identifier.length() > 0 ? ", \"" + identifier + "\"" : "";
auto params = "builder: FlatBufferBuilder, offset: Int";
auto method_name = "finish" + Esc(struct_def.name) + "Buffer";
GenerateFunOneLine(
writer, method_name, params, "",
[&]() { writer += "builder.finish(offset" + id + ")"; },
options.gen_jvmstatic);
GenerateFunOneLine(writer, method_name, params, "",
[&]() { writer += "builder.finish(offset" + id + ")"; },
options.gen_jvmstatic);
}
void GenerateEndStructMethod(StructDef &struct_def, CodeWriter &writer,
@ -639,21 +638,21 @@ class KotlinGenerator : public BaseGenerator {
auto returns = "Int";
auto field_vec = struct_def.fields.vec;
GenerateFun(
writer, name, params, returns,
[&]() {
writer += "val o = builder.endTable()";
writer.IncrementIdentLevel();
for (auto it = field_vec.begin(); it != field_vec.end(); ++it) {
auto &field = **it;
if (field.deprecated || !field.IsRequired()) { continue; }
writer.SetValue("offset", NumToString(field.value.offset));
writer += "builder.required(o, {{offset}})";
}
writer.DecrementIdentLevel();
writer += "return o";
},
options.gen_jvmstatic);
GenerateFun(writer, name, params, returns,
[&]() {
writer += "val o = builder.endTable()";
writer.IncrementIdentLevel();
for (auto it = field_vec.begin(); it != field_vec.end();
++it) {
auto &field = **it;
if (field.deprecated || !field.IsRequired()) { continue; }
writer.SetValue("offset", NumToString(field.value.offset));
writer += "builder.required(o, {{offset}})";
}
writer.DecrementIdentLevel();
writer += "return o";
},
options.gen_jvmstatic);
}
// Generate a method to create a vector from a Kotlin array.
@ -668,18 +667,18 @@ class KotlinGenerator : public BaseGenerator {
writer.SetValue("root", GenMethod(vector_type));
writer.SetValue("cast", CastToSigned(vector_type));
GenerateFun(
writer, method_name, params, "Int",
[&]() {
writer += "builder.startVector({{size}}, data.size, {{align}})";
writer += "for (i in data.size - 1 downTo 0) {";
writer.IncrementIdentLevel();
writer += "builder.add{{root}}(data[i]{{cast}})";
writer.DecrementIdentLevel();
writer += "}";
writer += "return builder.endVector()";
},
options.gen_jvmstatic);
GenerateFun(writer, method_name, params, "Int",
[&]() {
writer +=
"builder.startVector({{size}}, data.size, {{align}})";
writer += "for (i in data.size - 1 downTo 0) {";
writer.IncrementIdentLevel();
writer += "builder.add{{root}}(data[i]{{cast}})";
writer.DecrementIdentLevel();
writer += "}";
writer += "return builder.endVector()";
},
options.gen_jvmstatic);
}
void GenerateStartVectorField(FieldDef &field, CodeWriter &writer,
@ -705,21 +704,21 @@ class KotlinGenerator : public BaseGenerator {
auto field_type = GenTypeBasic(field.value.type.base_type);
auto secondArg = MakeCamel(Esc(field.name), false) + ": " + field_type;
GenerateFunOneLine(
writer, "add" + MakeCamel(Esc(field.name), true),
"builder: FlatBufferBuilder, " + secondArg, "",
[&]() {
auto method = GenMethod(field.value.type);
writer.SetValue("field_name", MakeCamel(Esc(field.name), false));
writer.SetValue("method_name", method);
writer.SetValue("pos", field_pos);
writer.SetValue("default", GenFBBDefaultValue(field));
writer.SetValue("cast", GenFBBValueCast(field));
GenerateFunOneLine(writer, "add" + MakeCamel(Esc(field.name), true),
"builder: FlatBufferBuilder, " + secondArg, "",
[&]() {
auto method = GenMethod(field.value.type);
writer.SetValue("field_name",
MakeCamel(Esc(field.name), false));
writer.SetValue("method_name", method);
writer.SetValue("pos", field_pos);
writer.SetValue("default", GenFBBDefaultValue(field));
writer.SetValue("cast", GenFBBValueCast(field));
writer += "builder.add{{method_name}}({{pos}}, \\";
writer += "{{field_name}}{{cast}}, {{default}})";
},
options.gen_jvmstatic);
writer += "builder.add{{method_name}}({{pos}}, \\";
writer += "{{field_name}}{{cast}}, {{default}})";
},
options.gen_jvmstatic);
}
static std::string ToSignedType(const Type &type) {
@ -1015,9 +1014,8 @@ class KotlinGenerator : public BaseGenerator {
break;
default: found = "{{bbgetter}}({{index}}){{ucast}}";
}
OffsetWrapper(
writer, offset_val, [&]() { writer += found; },
[&]() { writer += not_found; });
OffsetWrapper(writer, offset_val, [&]() { writer += found; },
[&]() { writer += not_found; });
});
break;
}
@ -1169,13 +1167,13 @@ class KotlinGenerator : public BaseGenerator {
if (struct_def.fixed) {
writer += "{{bbsetter}}({{index}}, {{params}}{{cast}})";
} else {
OffsetWrapper(
writer, offset_val,
[&]() {
writer += "{{bbsetter}}({{index}}, {{params}}{{cast}})";
writer += "true";
},
[&]() { writer += "false"; });
OffsetWrapper(writer, offset_val,
[&]() {
writer +=
"{{bbsetter}}({{index}}, {{params}}{{cast}})";
writer += "true";
},
[&]() { writer += "false"; });
}
};
@ -1318,13 +1316,12 @@ class KotlinGenerator : public BaseGenerator {
const IDLOptions options) {
// create a struct constructor function
auto params = StructConstructorParams(struct_def);
GenerateFun(
code, "create" + Esc(struct_def.name), params, "Int",
[&]() {
GenStructBody(struct_def, code, "");
code += "return builder.offset()";
},
options.gen_jvmstatic);
GenerateFun(code, "create" + Esc(struct_def.name), params, "Int",
[&]() {
GenStructBody(struct_def, code, "");
code += "return builder.offset()";
},
options.gen_jvmstatic);
}
static std::string StructConstructorParams(const StructDef &struct_def,

View File

@ -3757,9 +3757,7 @@ Offset<reflection::EnumVal> EnumVal::Serialize(FlatBufferBuilder *builder,
auto docs__ = parser.opts.binary_schema_comments
? builder->CreateVectorOfStrings(doc_comment)
: 0;
return reflection::CreateEnumVal(
*builder, name__, value,
type__, docs__);
return reflection::CreateEnumVal(*builder, name__, value, type__, docs__);
}
bool EnumVal::Deserialize(const Parser &parser,

View File

@ -109,6 +109,8 @@ class JavaTest {
TestScalarOptional();
TestPackUnpack(bb);
System.out.println("FlatBuffers test: completed successfully");
}
@ -1059,7 +1061,7 @@ class JavaTest {
FlexBuffersBuilder failBuilder = new FlexBuffersBuilder(ByteBuffer.allocate(1));
failBuilder.putString(someString);
}
public static void testFlexBuffersUtf8Map() {
FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(512),
FlexBuffersBuilder.BUILDER_FLAG_SHARE_KEYS_AND_STRINGS);
@ -1402,6 +1404,122 @@ class JavaTest {
TestEq(scalarStuff.hasMaybeEnum(), true);
}
static void TestObject(MonsterT monster) {
TestEq(monster.getHp(), (short) 80);
TestEq(monster.getMana(), (short) 150); // default
TestEq(monster.getName(), "MyMonster");
TestEq(monster.getColor(), Color.Blue);
// monster.friendly() // can't access, deprecated
Vec3T pos = monster.getPos();
TestEq(pos.getX(), 1.0f);
TestEq(pos.getY(), 2.0f);
TestEq(pos.getZ(), 3.0f);
TestEq(pos.getTest1(), 3.0);
// issue: int != byte
TestEq(pos.getTest2(), (int) Color.Green);
TestT t = pos.getTest3();
TestEq(t.getA(), (short) 5);
TestEq(t.getB(), (byte) 6);
TestEq(monster.getTest().getType(), (byte) Any.Monster);
MonsterT monster2 = (MonsterT) monster.getTest().getValue();
TestEq(monster2 != null, true);
TestEq(monster2.getName(), "Fred");
int[] inv = monster.getInventory();
TestEq(inv.length, 5);
int[] expInv = {0, 1, 2, 3, 4};
for (int i = 0; i < inv.length; i++)
TestEq(expInv[i], inv[i]);
TestT[] test4 = monster.getTest4();
TestT test_0 = test4[0];
TestT test_1 = test4[1];
TestEq(test4.length, 2);
TestEq(test_0.getA(), (short) 10);
TestEq(test_0.getB(), (byte) 20);
TestEq(test_1.getA(), (short) 30);
TestEq(test_1.getB(), (byte) 40);
String[] testarrayofstring = monster.getTestarrayofstring();
TestEq(testarrayofstring.length, 2);
TestEq(testarrayofstring[0], "test1");
TestEq(testarrayofstring[1], "test2");
MonsterT[] testarrayoftables = monster.getTestarrayoftables();
TestEq(testarrayoftables.length, 0);
MonsterT enemy = monster.getEnemy();
TestEq(enemy != null, true);
TestEq(enemy.getName(), "Fred");
int[] testnestedflatbuffer = monster.getTestnestedflatbuffer();
TestEq(testnestedflatbuffer.length, 0);
TestEq(monster.getTestempty() == null, true);
TestEq(monster.getTestbool(), true);
boolean[] testarrayofbools = monster.getTestarrayofbools();
TestEq(testarrayofbools.length, 3);
TestEq(testarrayofbools[0], true);
TestEq(testarrayofbools[1], false);
TestEq(testarrayofbools[2], true);
TestEq(monster.getTestf(), 3.14159f);
TestEq(monster.getTestf2(), 3.0f);
TestEq(monster.getTestf3(), 0.0f);
TestEq(monster.getTestf3(), 0.0f);
AbilityT[] testarrayofsortedstruct = monster.getTestarrayofsortedstruct();
TestEq(testarrayofsortedstruct.length, 3);
TestEq(testarrayofsortedstruct[0].getId(), (long) 0);
TestEq(testarrayofsortedstruct[1].getId(), (long) 1);
TestEq(testarrayofsortedstruct[2].getId(), (long) 5);
TestEq(testarrayofsortedstruct[0].getDistance(), (long) 45);
TestEq(testarrayofsortedstruct[1].getDistance(), (long) 21);
TestEq(testarrayofsortedstruct[2].getDistance(), (long) 12);
int[] flex = monster.getFlex();
TestEq(flex.length, 0);
long[] vectorOfLongs = monster.getVectorOfLongs();
TestEq(vectorOfLongs.length, 5);
long l = 1;
for (int i = 0; i < vectorOfLongs.length; i++) {
TestEq(vectorOfLongs[i], l);
l *= 100;
}
double[] vectorOfDoubles = monster.getVectorOfDoubles();
TestEq(vectorOfDoubles.length, 3);
TestEq(vectorOfDoubles[0], -1.7976931348623157E308);
TestEq(vectorOfDoubles[1], 0.0);
TestEq(vectorOfDoubles[2], 1.7976931348623157E308);
TestEq(monster.getParentNamespaceTest() == null, true);
ReferrableT[] vectorOfReferrables = monster.getVectorOfReferrables();
TestEq(vectorOfReferrables.length, 0);
TestEq(monster.getSignedEnum(), (byte) -1);
}
static void TestPackUnpack(ByteBuffer bb) {
Monster m = Monster.getRootAsMonster(bb);
MonsterT mObject = m.unpack();
TestObject(mObject);
FlatBufferBuilder fbb = new FlatBufferBuilder();
int monster = Monster.pack(fbb, mObject);
Monster.finishMonsterBuffer(fbb, monster);
TestBuffer(fbb.dataBuffer());
byte[] bytes = mObject.serializeToBinary();
MonsterT newMonsterT = MonsterT.deserializeFromBinary(bytes);
TestObject(newMonsterT);
}
static <T> void TestEq(T a, T b) {
if ((a == null && a != b) || (a != null && !a.equals(b))) {
System.out.println("" + a.getClass().getName() + " " + b.getClass().getName());

View File

@ -13,14 +13,14 @@ public final class Ability extends Struct {
public Ability __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public long id() { return (long)bb.getInt(bb_pos + 0) & 0xFFFFFFFFL; }
public void mutateId(long id) { bb.putInt(bb_pos + 0, (int)id); }
public void mutateId(long id) { bb.putInt(bb_pos + 0, (int) id); }
public long distance() { return (long)bb.getInt(bb_pos + 4) & 0xFFFFFFFFL; }
public void mutateDistance(long distance) { bb.putInt(bb_pos + 4, (int)distance); }
public void mutateDistance(long distance) { bb.putInt(bb_pos + 4, (int) distance); }
public static int createAbility(FlatBufferBuilder builder, long id, long distance) {
builder.prep(4, 8);
builder.putInt((int)distance);
builder.putInt((int)id);
builder.putInt((int) distance);
builder.putInt((int) id);
return builder.offset();
}
@ -30,5 +30,23 @@ public final class Ability extends Struct {
public Ability get(int j) { return get(new Ability(), j); }
public Ability get(Ability obj, int j) { return obj.__assign(__element(j), bb); }
}
public AbilityT unpack() {
AbilityT _o = new AbilityT();
unpackTo(_o);
return _o;
}
public void unpackTo(AbilityT _o) {
long _oId = id();
_o.setId(_oId);
long _oDistance = distance();
_o.setDistance(_oDistance);
}
public static int pack(FlatBufferBuilder builder, AbilityT _o) {
if (_o == null) return 0;
return createAbility(
builder,
_o.getId(),
_o.getDistance());
}
}

View File

@ -0,0 +1,28 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class AbilityT {
private long id;
private long distance;
public long getId() { return id; }
public void setId(long id) { this.id = id; }
public long getDistance() { return distance; }
public void setDistance(long distance) { this.distance = distance; }
public AbilityT() {
this.id = 0L;
this.distance = 0L;
}
}

View File

@ -2,6 +2,7 @@
package MyGame.Example;
@SuppressWarnings("unused")
public final class Any {
private Any() { }
public static final byte NONE = 0;

View File

@ -2,6 +2,7 @@
package MyGame.Example;
@SuppressWarnings("unused")
public final class AnyAmbiguousAliases {
private AnyAmbiguousAliases() { }
public static final byte NONE = 0;

View File

@ -0,0 +1,37 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example;
import com.google.flatbuffers.FlatBufferBuilder;
public class AnyAmbiguousAliasesUnion {
private byte type;
private Object value;
public byte getType() { return type; }
public void setType(byte type) { this.type = type; }
public Object getValue() { return value; }
public void setValue(Object value) { this.value = value; }
public AnyAmbiguousAliasesUnion() {
this.type = AnyAmbiguousAliases.NONE;
this.value = null;
}
public MyGame.Example.MonsterT asM1() { return (MyGame.Example.MonsterT) value; }
public MyGame.Example.MonsterT asM2() { return (MyGame.Example.MonsterT) value; }
public MyGame.Example.MonsterT asM3() { return (MyGame.Example.MonsterT) value; }
public static int pack(FlatBufferBuilder builder, AnyAmbiguousAliasesUnion _o) {
switch (_o.type) {
case AnyAmbiguousAliases.M1: return MyGame.Example.Monster.pack(builder, _o.asM1());
case AnyAmbiguousAliases.M2: return MyGame.Example.Monster.pack(builder, _o.asM2());
case AnyAmbiguousAliases.M3: return MyGame.Example.Monster.pack(builder, _o.asM3());
default: return 0;
}
}
}

View File

@ -0,0 +1,37 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example;
import com.google.flatbuffers.FlatBufferBuilder;
public class AnyUnion {
private byte type;
private Object value;
public byte getType() { return type; }
public void setType(byte type) { this.type = type; }
public Object getValue() { return value; }
public void setValue(Object value) { this.value = value; }
public AnyUnion() {
this.type = Any.NONE;
this.value = null;
}
public MyGame.Example.MonsterT asMonster() { return (MyGame.Example.MonsterT) value; }
MyGame.Example.TestSimpleTableWithEnumT asTestSimpleTableWithEnum() { return (MyGame.Example.TestSimpleTableWithEnumT) value; }
public MyGame.Example2.MonsterT asMyGame_Example2_Monster() { return (MyGame.Example2.MonsterT) value; }
public static int pack(FlatBufferBuilder builder, AnyUnion _o) {
switch (_o.type) {
case Any.Monster: return MyGame.Example.Monster.pack(builder, _o.asMonster());
case Any.TestSimpleTableWithEnum: return MyGame.Example.TestSimpleTableWithEnum.pack(builder, _o.asTestSimpleTableWithEnum());
case Any.MyGame_Example2_Monster: return MyGame.Example2.Monster.pack(builder, _o.asMyGame_Example2_Monster());
default: return 0;
}
}
}

View File

@ -2,6 +2,7 @@
package MyGame.Example;
@SuppressWarnings("unused")
public final class AnyUniqueAliases {
private AnyUniqueAliases() { }
public static final byte NONE = 0;

View File

@ -0,0 +1,37 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example;
import com.google.flatbuffers.FlatBufferBuilder;
public class AnyUniqueAliasesUnion {
private byte type;
private Object value;
public byte getType() { return type; }
public void setType(byte type) { this.type = type; }
public Object getValue() { return value; }
public void setValue(Object value) { this.value = value; }
public AnyUniqueAliasesUnion() {
this.type = AnyUniqueAliases.NONE;
this.value = null;
}
public MyGame.Example.MonsterT asM() { return (MyGame.Example.MonsterT) value; }
MyGame.Example.TestSimpleTableWithEnumT asTS() { return (MyGame.Example.TestSimpleTableWithEnumT) value; }
public MyGame.Example2.MonsterT asM2() { return (MyGame.Example2.MonsterT) value; }
public static int pack(FlatBufferBuilder builder, AnyUniqueAliasesUnion _o) {
switch (_o.type) {
case AnyUniqueAliases.M: return MyGame.Example.Monster.pack(builder, _o.asM());
case AnyUniqueAliases.TS: return MyGame.Example.TestSimpleTableWithEnum.pack(builder, _o.asTS());
case AnyUniqueAliases.M2: return MyGame.Example2.Monster.pack(builder, _o.asM2());
default: return 0;
}
}
}

View File

@ -18,6 +18,7 @@ public final class ArrayStruct extends Struct {
public void mutateB(int j, int b) { bb.putInt(bb_pos + 4 + j * 4, b); }
public byte c() { return bb.get(bb_pos + 64); }
public void mutateC(byte c) { bb.put(bb_pos + 64, c); }
public MyGame.Example.NestedStruct d(int j) { return d(new MyGame.Example.NestedStruct(), j); }
public MyGame.Example.NestedStruct d(MyGame.Example.NestedStruct obj, int j) { return obj.__assign(bb_pos + 72 + j * 32, bb); }
public int e() { return bb.getInt(bb_pos + 136); }
public void mutateE(int e) { bb.putInt(bb_pos + 136, e); }
@ -60,5 +61,48 @@ public final class ArrayStruct extends Struct {
public ArrayStruct get(int j) { return get(new ArrayStruct(), j); }
public ArrayStruct get(ArrayStruct obj, int j) { return obj.__assign(__element(j), bb); }
}
public ArrayStructT unpack() {
ArrayStructT _o = new ArrayStructT();
unpackTo(_o);
return _o;
}
public void unpackTo(ArrayStructT _o) {
float _oA = a();
_o.setA(_oA);
int[] _oB = _o.getB();
for (int _j = 0; _j < 15; ++_j) { _oB[_j] = b(_j); }
byte _oC = c();
_o.setC(_oC);
MyGame.Example.NestedStructT[] _oD = _o.getD();
for (int _j = 0; _j < 2; ++_j) { _oD[_j] = d(_j).unpack(); }
int _oE = e();
_o.setE(_oE);
long[] _oF = _o.getF();
for (int _j = 0; _j < 2; ++_j) { _oF[_j] = f(_j); }
}
public static int pack(FlatBufferBuilder builder, ArrayStructT _o) {
if (_o == null) return 0;
int[] _b = _o.getB();
int[][] _d_a = new int[2][2];
for (int idx0 = 0; idx0 < 2; ++idx0) {for (int idx1 = 0; idx1 < 2; ++idx1) {_d_a[idx0][idx1] = _o.getD()[idx0].getA()[idx1];}}
byte[] _d_b = new byte[2];
for (int idx0 = 0; idx0 < 2; ++idx0) {_d_b[idx0] = _o.getD()[idx0].getB();}
byte[][] _d_c = new byte[2][2];
for (int idx0 = 0; idx0 < 2; ++idx0) {for (int idx1 = 0; idx1 < 2; ++idx1) {_d_c[idx0][idx1] = _o.getD()[idx0].getC()[idx1];}}
long[][] _d_d = new long[2][2];
for (int idx0 = 0; idx0 < 2; ++idx0) {for (int idx1 = 0; idx1 < 2; ++idx1) {_d_d[idx0][idx1] = _o.getD()[idx0].getD()[idx1];}}
long[] _f = _o.getF();
return createArrayStruct(
builder,
_o.getA(),
_b,
_o.getC(),
_d_a,
_d_b,
_d_c,
_d_d,
_o.getE(),
_f);
}
}

View File

@ -0,0 +1,52 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class ArrayStructT {
private float a;
private int[] b;
private byte c;
private MyGame.Example.NestedStructT[] d;
private int e;
private long[] f;
public float getA() { return a; }
public void setA(float a) { this.a = a; }
public int[] getB() { return b; }
public void setB(int[] b) { if (b != null && b.length == 15) this.b = b; }
public byte getC() { return c; }
public void setC(byte c) { this.c = c; }
public MyGame.Example.NestedStructT[] getD() { return d; }
public void setD(MyGame.Example.NestedStructT[] d) { if (d != null && d.length == 2) this.d = d; }
public int getE() { return e; }
public void setE(int e) { this.e = e; }
public long[] getF() { return f; }
public void setF(long[] f) { if (f != null && f.length == 2) this.f = f; }
public ArrayStructT() {
this.a = 0.0f;
this.b = new int[15];
this.c = 0;
this.d = new MyGame.Example.NestedStructT[2];
this.e = 0;
this.f = new long[2];
}
}

View File

@ -34,5 +34,20 @@ public final class ArrayTable extends Table {
public ArrayTable get(int j) { return get(new ArrayTable(), j); }
public ArrayTable get(ArrayTable obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
public ArrayTableT unpack() {
ArrayTableT _o = new ArrayTableT();
unpackTo(_o);
return _o;
}
public void unpackTo(ArrayTableT _o) {
if (a() != null) a().unpackTo(_o.getA());
else _o.setA(null);
}
public static int pack(FlatBufferBuilder builder, ArrayTableT _o) {
if (_o == null) return 0;
startArrayTable(builder);
addA(builder, MyGame.Example.ArrayStruct.pack(builder, _o.getA()));
return endArrayTable(builder);
}
}

View File

@ -0,0 +1,30 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class ArrayTableT {
private MyGame.Example.ArrayStructT a;
public MyGame.Example.ArrayStructT getA() { return a; }
public void setA(MyGame.Example.ArrayStructT a) { this.a = a; }
public ArrayTableT() {
this.a = new MyGame.Example.ArrayStructT();
}
public static ArrayTableT deserializeFromBinary(byte[] fbBuffer) {
return ArrayTable.getRootAsArrayTable(ByteBuffer.wrap(fbBuffer)).unpack();
}
public byte[] serializeToBinary() {
FlatBufferBuilder fbb = new FlatBufferBuilder();
ArrayTable.finishArrayTableBuffer(fbb, ArrayTable.pack(fbb, this));
return fbb.sizedByteArray();
}
}

View File

@ -5,6 +5,7 @@ package MyGame.Example;
/**
* Composite components of Monster color.
*/
@SuppressWarnings("unused")
public final class Color {
private Color() { }
public static final int Red = 1;

View File

@ -34,9 +34,9 @@ public final class Monster extends Table {
public ByteVector inventoryVector(ByteVector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer inventoryAsByteBuffer() { return __vector_as_bytebuffer(14, 1); }
public ByteBuffer inventoryInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 14, 1); }
public boolean mutateInventory(int j, int inventory) { int o = __offset(14); if (o != 0) { bb.put(__vector(o) + j * 1, (byte)inventory); return true; } else { return false; } }
public boolean mutateInventory(int j, int inventory) { int o = __offset(14); if (o != 0) { bb.put(__vector(o) + j * 1, (byte) inventory); return true; } else { return false; } }
public int color() { int o = __offset(16); return o != 0 ? bb.get(o + bb_pos) & 0xFF : 8; }
public boolean mutateColor(int color) { int o = __offset(16); if (o != 0) { bb.put(o + bb_pos, (byte)color); return true; } else { return false; } }
public boolean mutateColor(int color) { int o = __offset(16); if (o != 0) { bb.put(o + bb_pos, (byte) color); return true; } else { return false; } }
public byte testType() { int o = __offset(18); return o != 0 ? bb.get(o + bb_pos) : 0; }
public Table test(Table obj) { int o = __offset(20); return o != 0 ? __union(obj, o + bb_pos) : null; }
public MyGame.Example.Test test4(int j) { return test4(new MyGame.Example.Test(), j); }
@ -69,7 +69,7 @@ public final class Monster extends Table {
public ByteBuffer testnestedflatbufferInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 30, 1); }
public MyGame.Example.Monster testnestedflatbufferAsMonster() { return testnestedflatbufferAsMonster(new MyGame.Example.Monster()); }
public MyGame.Example.Monster testnestedflatbufferAsMonster(MyGame.Example.Monster obj) { int o = __offset(30); return o != 0 ? obj.__assign(__indirect(__vector(o)), bb) : null; }
public boolean mutateTestnestedflatbuffer(int j, int testnestedflatbuffer) { int o = __offset(30); if (o != 0) { bb.put(__vector(o) + j * 1, (byte)testnestedflatbuffer); return true; } else { return false; } }
public boolean mutateTestnestedflatbuffer(int j, int testnestedflatbuffer) { int o = __offset(30); if (o != 0) { bb.put(__vector(o) + j * 1, (byte) testnestedflatbuffer); return true; } else { return false; } }
public MyGame.Example.Stat testempty() { return testempty(new MyGame.Example.Stat()); }
public MyGame.Example.Stat testempty(MyGame.Example.Stat obj) { int o = __offset(32); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
public boolean testbool() { int o = __offset(34); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
@ -77,7 +77,7 @@ public final class Monster extends Table {
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, testhashs32_fnv1); return true; } else { return false; } }
public long testhashu32Fnv1() { int o = __offset(38); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; }
public boolean mutateTesthashu32Fnv1(long testhashu32_fnv1) { int o = __offset(38); if (o != 0) { bb.putInt(o + bb_pos, (int)testhashu32_fnv1); return true; } else { return false; } }
public boolean mutateTesthashu32Fnv1(long testhashu32_fnv1) { int o = __offset(38); if (o != 0) { bb.putInt(o + bb_pos, (int) testhashu32_fnv1); return true; } else { return false; } }
public long testhashs64Fnv1() { int o = __offset(40); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
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) : 0L; }
@ -85,7 +85,7 @@ public final class Monster extends Table {
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, testhashs32_fnv1a); return true; } else { return false; } }
public long testhashu32Fnv1a() { int o = __offset(46); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; }
public boolean mutateTesthashu32Fnv1a(long testhashu32_fnv1a) { int o = __offset(46); if (o != 0) { bb.putInt(o + bb_pos, (int)testhashu32_fnv1a); return true; } else { return false; } }
public boolean mutateTesthashu32Fnv1a(long testhashu32_fnv1a) { int o = __offset(46); if (o != 0) { bb.putInt(o + bb_pos, (int) testhashu32_fnv1a); return true; } else { return false; } }
public long testhashs64Fnv1a() { int o = __offset(48); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
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) : 0L; }
@ -118,7 +118,7 @@ public final class Monster extends Table {
public ByteVector flexVector(ByteVector obj) { int o = __offset(64); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer flexAsByteBuffer() { return __vector_as_bytebuffer(64, 1); }
public ByteBuffer flexInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 64, 1); }
public boolean mutateFlex(int j, int flex) { int o = __offset(64); if (o != 0) { bb.put(__vector(o) + j * 1, (byte)flex); return true; } else { return false; } }
public boolean mutateFlex(int j, int flex) { int o = __offset(64); if (o != 0) { bb.put(__vector(o) + j * 1, (byte) flex); return true; } else { return false; } }
public MyGame.Example.Test test5(int j) { return test5(new MyGame.Example.Test(), j); }
public MyGame.Example.Test test5(MyGame.Example.Test obj, int j) { int o = __offset(66); return o != 0 ? obj.__assign(__vector(o) + j * 4, bb) : null; }
public int test5Length() { int o = __offset(66); return o != 0 ? __vector_len(o) : 0; }
@ -191,7 +191,7 @@ public final class Monster extends Table {
public ByteVector vectorOfEnumsVector(ByteVector obj) { int o = __offset(98); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer vectorOfEnumsAsByteBuffer() { return __vector_as_bytebuffer(98, 1); }
public ByteBuffer vectorOfEnumsInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 98, 1); }
public boolean mutateVectorOfEnums(int j, int vector_of_enums) { int o = __offset(98); if (o != 0) { bb.put(__vector(o) + j * 1, (byte)vector_of_enums); return true; } else { return false; } }
public boolean mutateVectorOfEnums(int j, int vector_of_enums) { int o = __offset(98); if (o != 0) { bb.put(__vector(o) + j * 1, (byte) vector_of_enums); return true; } else { return false; } }
public byte signedEnum() { int o = __offset(100); return o != 0 ? bb.get(o + bb_pos) : -1; }
public boolean mutateSignedEnum(byte signed_enum) { int o = __offset(100); if (o != 0) { bb.put(o + bb_pos, signed_enum); return true; } else { return false; } }
public int testrequirednestedflatbuffer(int j) { int o = __offset(102); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; }
@ -202,7 +202,7 @@ public final class Monster extends Table {
public ByteBuffer testrequirednestedflatbufferInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 102, 1); }
public MyGame.Example.Monster testrequirednestedflatbufferAsMonster() { return testrequirednestedflatbufferAsMonster(new MyGame.Example.Monster()); }
public MyGame.Example.Monster testrequirednestedflatbufferAsMonster(MyGame.Example.Monster obj) { int o = __offset(102); return o != 0 ? obj.__assign(__indirect(__vector(o)), bb) : null; }
public boolean mutateTestrequirednestedflatbuffer(int j, int testrequirednestedflatbuffer) { int o = __offset(102); if (o != 0) { bb.put(__vector(o) + j * 1, (byte)testrequirednestedflatbuffer); return true; } else { return false; } }
public boolean mutateTestrequirednestedflatbuffer(int j, int testrequirednestedflatbuffer) { int o = __offset(102); if (o != 0) { bb.put(__vector(o) + j * 1, (byte) testrequirednestedflatbuffer); return true; } else { return false; } }
public MyGame.Example.Stat scalarKeySortedTables(int j) { return scalarKeySortedTables(new MyGame.Example.Stat(), j); }
public MyGame.Example.Stat scalarKeySortedTables(MyGame.Example.Stat obj, int j) { int o = __offset(104); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
public int scalarKeySortedTablesLength() { int o = __offset(104); return o != 0 ? __vector_len(o) : 0; }
@ -220,7 +220,7 @@ public final class Monster extends Table {
public static int createInventoryVector(FlatBufferBuilder builder, byte[] data) { return builder.createByteVector(data); }
public static int createInventoryVector(FlatBufferBuilder builder, ByteBuffer data) { return builder.createByteVector(data); }
public static void startInventoryVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); }
public static void addColor(FlatBufferBuilder builder, int color) { builder.addByte(6, (byte)color, (byte)8); }
public static void addColor(FlatBufferBuilder builder, int color) { builder.addByte(6, (byte) color, (byte) 8); }
public static void addTestType(FlatBufferBuilder builder, byte testType) { builder.addByte(7, testType, 0); }
public static void addTest(FlatBufferBuilder builder, int testOffset) { builder.addOffset(8, testOffset, 0); }
public static void addTest4(FlatBufferBuilder builder, int test4Offset) { builder.addOffset(9, test4Offset, 0); }
@ -239,11 +239,11 @@ public final class Monster extends Table {
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, long testhashu32Fnv1) { builder.addInt(17, (int)testhashu32Fnv1, (int)0L); }
public static void addTesthashu32Fnv1(FlatBufferBuilder builder, long testhashu32Fnv1) { builder.addInt(17, (int) testhashu32Fnv1, (int) 0L); }
public static void addTesthashs64Fnv1(FlatBufferBuilder builder, long testhashs64Fnv1) { builder.addLong(18, testhashs64Fnv1, 0L); }
public static void addTesthashu64Fnv1(FlatBufferBuilder builder, long testhashu64Fnv1) { builder.addLong(19, testhashu64Fnv1, 0L); }
public static void addTesthashs32Fnv1a(FlatBufferBuilder builder, int testhashs32Fnv1a) { builder.addInt(20, testhashs32Fnv1a, 0); }
public static void addTesthashu32Fnv1a(FlatBufferBuilder builder, long testhashu32Fnv1a) { builder.addInt(21, (int)testhashu32Fnv1a, (int)0L); }
public static void addTesthashu32Fnv1a(FlatBufferBuilder builder, long testhashu32Fnv1a) { builder.addInt(21, (int) testhashu32Fnv1a, (int) 0L); }
public static void addTesthashs64Fnv1a(FlatBufferBuilder builder, long testhashs64Fnv1a) { builder.addLong(22, testhashs64Fnv1a, 0L); }
public static void addTesthashu64Fnv1a(FlatBufferBuilder builder, long testhashu64Fnv1a) { builder.addLong(23, testhashu64Fnv1a, 0L); }
public static void addTestarrayofbools(FlatBufferBuilder builder, int testarrayofboolsOffset) { builder.addOffset(24, testarrayofboolsOffset, 0); }
@ -344,5 +344,367 @@ public final class Monster extends Table {
public Monster getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
public Monster getByKey(Monster obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
}
public MonsterT unpack() {
MonsterT _o = new MonsterT();
unpackTo(_o);
return _o;
}
public void unpackTo(MonsterT _o) {
if (pos() != null) pos().unpackTo(_o.getPos());
else _o.setPos(null);
short _oMana = mana();
_o.setMana(_oMana);
short _oHp = hp();
_o.setHp(_oHp);
String _oName = name();
_o.setName(_oName);
int[] _oInventory = new int[inventoryLength()];
for (int _j = 0; _j < inventoryLength(); ++_j) {_oInventory[_j] = inventory(_j);}
_o.setInventory(_oInventory);
int _oColor = color();
_o.setColor(_oColor);
MyGame.Example.AnyUnion _oTest = new MyGame.Example.AnyUnion();
byte _oTestType = testType();
_oTest.setType(_oTestType);
Table _oTestValue;
switch (_oTestType) {
case MyGame.Example.Any.Monster:
_oTestValue = test(new MyGame.Example.Monster());
_oTest.setValue(_oTestValue != null ? ((MyGame.Example.Monster) _oTestValue).unpack() : null);
break;
case MyGame.Example.Any.TestSimpleTableWithEnum:
_oTestValue = test(new MyGame.Example.TestSimpleTableWithEnum());
_oTest.setValue(_oTestValue != null ? ((MyGame.Example.TestSimpleTableWithEnum) _oTestValue).unpack() : null);
break;
case MyGame.Example.Any.MyGame_Example2_Monster:
_oTestValue = test(new MyGame.Example2.Monster());
_oTest.setValue(_oTestValue != null ? ((MyGame.Example2.Monster) _oTestValue).unpack() : null);
break;
default: break;
}
_o.setTest(_oTest);
MyGame.Example.TestT[] _oTest4 = new MyGame.Example.TestT[test4Length()];
for (int _j = 0; _j < test4Length(); ++_j) {_oTest4[_j] = (test4(_j) != null ? test4(_j).unpack() : null);}
_o.setTest4(_oTest4);
String[] _oTestarrayofstring = new String[testarrayofstringLength()];
for (int _j = 0; _j < testarrayofstringLength(); ++_j) {_oTestarrayofstring[_j] = testarrayofstring(_j);}
_o.setTestarrayofstring(_oTestarrayofstring);
MyGame.Example.MonsterT[] _oTestarrayoftables = new MyGame.Example.MonsterT[testarrayoftablesLength()];
for (int _j = 0; _j < testarrayoftablesLength(); ++_j) {_oTestarrayoftables[_j] = (testarrayoftables(_j) != null ? testarrayoftables(_j).unpack() : null);}
_o.setTestarrayoftables(_oTestarrayoftables);
if (enemy() != null) _o.setEnemy(enemy().unpack());
else _o.setEnemy(null);
int[] _oTestnestedflatbuffer = new int[testnestedflatbufferLength()];
for (int _j = 0; _j < testnestedflatbufferLength(); ++_j) {_oTestnestedflatbuffer[_j] = testnestedflatbuffer(_j);}
_o.setTestnestedflatbuffer(_oTestnestedflatbuffer);
if (testempty() != null) _o.setTestempty(testempty().unpack());
else _o.setTestempty(null);
boolean _oTestbool = testbool();
_o.setTestbool(_oTestbool);
int _oTesthashs32Fnv1 = testhashs32Fnv1();
_o.setTesthashs32Fnv1(_oTesthashs32Fnv1);
long _oTesthashu32Fnv1 = testhashu32Fnv1();
_o.setTesthashu32Fnv1(_oTesthashu32Fnv1);
long _oTesthashs64Fnv1 = testhashs64Fnv1();
_o.setTesthashs64Fnv1(_oTesthashs64Fnv1);
long _oTesthashu64Fnv1 = testhashu64Fnv1();
_o.setTesthashu64Fnv1(_oTesthashu64Fnv1);
int _oTesthashs32Fnv1a = testhashs32Fnv1a();
_o.setTesthashs32Fnv1a(_oTesthashs32Fnv1a);
long _oTesthashu32Fnv1a = testhashu32Fnv1a();
_o.setTesthashu32Fnv1a(_oTesthashu32Fnv1a);
long _oTesthashs64Fnv1a = testhashs64Fnv1a();
_o.setTesthashs64Fnv1a(_oTesthashs64Fnv1a);
long _oTesthashu64Fnv1a = testhashu64Fnv1a();
_o.setTesthashu64Fnv1a(_oTesthashu64Fnv1a);
boolean[] _oTestarrayofbools = new boolean[testarrayofboolsLength()];
for (int _j = 0; _j < testarrayofboolsLength(); ++_j) {_oTestarrayofbools[_j] = testarrayofbools(_j);}
_o.setTestarrayofbools(_oTestarrayofbools);
float _oTestf = testf();
_o.setTestf(_oTestf);
float _oTestf2 = testf2();
_o.setTestf2(_oTestf2);
float _oTestf3 = testf3();
_o.setTestf3(_oTestf3);
String[] _oTestarrayofstring2 = new String[testarrayofstring2Length()];
for (int _j = 0; _j < testarrayofstring2Length(); ++_j) {_oTestarrayofstring2[_j] = testarrayofstring2(_j);}
_o.setTestarrayofstring2(_oTestarrayofstring2);
MyGame.Example.AbilityT[] _oTestarrayofsortedstruct = new MyGame.Example.AbilityT[testarrayofsortedstructLength()];
for (int _j = 0; _j < testarrayofsortedstructLength(); ++_j) {_oTestarrayofsortedstruct[_j] = (testarrayofsortedstruct(_j) != null ? testarrayofsortedstruct(_j).unpack() : null);}
_o.setTestarrayofsortedstruct(_oTestarrayofsortedstruct);
int[] _oFlex = new int[flexLength()];
for (int _j = 0; _j < flexLength(); ++_j) {_oFlex[_j] = flex(_j);}
_o.setFlex(_oFlex);
MyGame.Example.TestT[] _oTest5 = new MyGame.Example.TestT[test5Length()];
for (int _j = 0; _j < test5Length(); ++_j) {_oTest5[_j] = (test5(_j) != null ? test5(_j).unpack() : null);}
_o.setTest5(_oTest5);
long[] _oVectorOfLongs = new long[vectorOfLongsLength()];
for (int _j = 0; _j < vectorOfLongsLength(); ++_j) {_oVectorOfLongs[_j] = vectorOfLongs(_j);}
_o.setVectorOfLongs(_oVectorOfLongs);
double[] _oVectorOfDoubles = new double[vectorOfDoublesLength()];
for (int _j = 0; _j < vectorOfDoublesLength(); ++_j) {_oVectorOfDoubles[_j] = vectorOfDoubles(_j);}
_o.setVectorOfDoubles(_oVectorOfDoubles);
if (parentNamespaceTest() != null) _o.setParentNamespaceTest(parentNamespaceTest().unpack());
else _o.setParentNamespaceTest(null);
MyGame.Example.ReferrableT[] _oVectorOfReferrables = new MyGame.Example.ReferrableT[vectorOfReferrablesLength()];
for (int _j = 0; _j < vectorOfReferrablesLength(); ++_j) {_oVectorOfReferrables[_j] = (vectorOfReferrables(_j) != null ? vectorOfReferrables(_j).unpack() : null);}
_o.setVectorOfReferrables(_oVectorOfReferrables);
long _oSingleWeakReference = singleWeakReference();
_o.setSingleWeakReference(_oSingleWeakReference);
long[] _oVectorOfWeakReferences = new long[vectorOfWeakReferencesLength()];
for (int _j = 0; _j < vectorOfWeakReferencesLength(); ++_j) {_oVectorOfWeakReferences[_j] = vectorOfWeakReferences(_j);}
_o.setVectorOfWeakReferences(_oVectorOfWeakReferences);
MyGame.Example.ReferrableT[] _oVectorOfStrongReferrables = new MyGame.Example.ReferrableT[vectorOfStrongReferrablesLength()];
for (int _j = 0; _j < vectorOfStrongReferrablesLength(); ++_j) {_oVectorOfStrongReferrables[_j] = (vectorOfStrongReferrables(_j) != null ? vectorOfStrongReferrables(_j).unpack() : null);}
_o.setVectorOfStrongReferrables(_oVectorOfStrongReferrables);
long _oCoOwningReference = coOwningReference();
_o.setCoOwningReference(_oCoOwningReference);
long[] _oVectorOfCoOwningReferences = new long[vectorOfCoOwningReferencesLength()];
for (int _j = 0; _j < vectorOfCoOwningReferencesLength(); ++_j) {_oVectorOfCoOwningReferences[_j] = vectorOfCoOwningReferences(_j);}
_o.setVectorOfCoOwningReferences(_oVectorOfCoOwningReferences);
long _oNonOwningReference = nonOwningReference();
_o.setNonOwningReference(_oNonOwningReference);
long[] _oVectorOfNonOwningReferences = new long[vectorOfNonOwningReferencesLength()];
for (int _j = 0; _j < vectorOfNonOwningReferencesLength(); ++_j) {_oVectorOfNonOwningReferences[_j] = vectorOfNonOwningReferences(_j);}
_o.setVectorOfNonOwningReferences(_oVectorOfNonOwningReferences);
MyGame.Example.AnyUniqueAliasesUnion _oAnyUnique = new MyGame.Example.AnyUniqueAliasesUnion();
byte _oAnyUniqueType = anyUniqueType();
_oAnyUnique.setType(_oAnyUniqueType);
Table _oAnyUniqueValue;
switch (_oAnyUniqueType) {
case MyGame.Example.AnyUniqueAliases.M:
_oAnyUniqueValue = anyUnique(new MyGame.Example.Monster());
_oAnyUnique.setValue(_oAnyUniqueValue != null ? ((MyGame.Example.Monster) _oAnyUniqueValue).unpack() : null);
break;
case MyGame.Example.AnyUniqueAliases.TS:
_oAnyUniqueValue = anyUnique(new MyGame.Example.TestSimpleTableWithEnum());
_oAnyUnique.setValue(_oAnyUniqueValue != null ? ((MyGame.Example.TestSimpleTableWithEnum) _oAnyUniqueValue).unpack() : null);
break;
case MyGame.Example.AnyUniqueAliases.M2:
_oAnyUniqueValue = anyUnique(new MyGame.Example2.Monster());
_oAnyUnique.setValue(_oAnyUniqueValue != null ? ((MyGame.Example2.Monster) _oAnyUniqueValue).unpack() : null);
break;
default: break;
}
_o.setAnyUnique(_oAnyUnique);
MyGame.Example.AnyAmbiguousAliasesUnion _oAnyAmbiguous = new MyGame.Example.AnyAmbiguousAliasesUnion();
byte _oAnyAmbiguousType = anyAmbiguousType();
_oAnyAmbiguous.setType(_oAnyAmbiguousType);
Table _oAnyAmbiguousValue;
switch (_oAnyAmbiguousType) {
case MyGame.Example.AnyAmbiguousAliases.M1:
_oAnyAmbiguousValue = anyAmbiguous(new MyGame.Example.Monster());
_oAnyAmbiguous.setValue(_oAnyAmbiguousValue != null ? ((MyGame.Example.Monster) _oAnyAmbiguousValue).unpack() : null);
break;
case MyGame.Example.AnyAmbiguousAliases.M2:
_oAnyAmbiguousValue = anyAmbiguous(new MyGame.Example.Monster());
_oAnyAmbiguous.setValue(_oAnyAmbiguousValue != null ? ((MyGame.Example.Monster) _oAnyAmbiguousValue).unpack() : null);
break;
case MyGame.Example.AnyAmbiguousAliases.M3:
_oAnyAmbiguousValue = anyAmbiguous(new MyGame.Example.Monster());
_oAnyAmbiguous.setValue(_oAnyAmbiguousValue != null ? ((MyGame.Example.Monster) _oAnyAmbiguousValue).unpack() : null);
break;
default: break;
}
_o.setAnyAmbiguous(_oAnyAmbiguous);
int[] _oVectorOfEnums = new int[vectorOfEnumsLength()];
for (int _j = 0; _j < vectorOfEnumsLength(); ++_j) {_oVectorOfEnums[_j] = vectorOfEnums(_j);}
_o.setVectorOfEnums(_oVectorOfEnums);
byte _oSignedEnum = signedEnum();
_o.setSignedEnum(_oSignedEnum);
int[] _oTestrequirednestedflatbuffer = new int[testrequirednestedflatbufferLength()];
for (int _j = 0; _j < testrequirednestedflatbufferLength(); ++_j) {_oTestrequirednestedflatbuffer[_j] = testrequirednestedflatbuffer(_j);}
_o.setTestrequirednestedflatbuffer(_oTestrequirednestedflatbuffer);
MyGame.Example.StatT[] _oScalarKeySortedTables = new MyGame.Example.StatT[scalarKeySortedTablesLength()];
for (int _j = 0; _j < scalarKeySortedTablesLength(); ++_j) {_oScalarKeySortedTables[_j] = (scalarKeySortedTables(_j) != null ? scalarKeySortedTables(_j).unpack() : null);}
_o.setScalarKeySortedTables(_oScalarKeySortedTables);
}
public static int pack(FlatBufferBuilder builder, MonsterT _o) {
if (_o == null) return 0;
int _name = _o.getName() == null ? 0 : builder.createString(_o.getName());
int _inventory = 0;
if (_o.getInventory() != null) {
byte[] __inventory = new byte[_o.getInventory().length];
int _j = 0;
for (int _e : _o.getInventory()) { __inventory[_j] = (byte) _e; _j++;}
_inventory = createInventoryVector(builder, __inventory);
}
byte _testType = _o.getTest() == null ? MyGame.Example.Any.NONE : _o.getTest().getType();
int _test = _o.getTest() == null ? 0 : MyGame.Example.AnyUnion.pack(builder, _o.getTest());
int _test4 = 0;
MyGame.Example.TestT[] _oTest4 = _o.getTest4();
if (_oTest4 != null) {
startTest4Vector(builder, _oTest4.length);
for (int _j = _oTest4.length - 1; _j >=0; _j--) { MyGame.Example.Test.pack(builder, _oTest4[_j]);}
_test4 = builder.endVector();
}
int _testarrayofstring = 0;
if (_o.getTestarrayofstring() != null) {
int[] __testarrayofstring = new int[_o.getTestarrayofstring().length];
int _j = 0;
for (String _e : _o.getTestarrayofstring()) { __testarrayofstring[_j] = builder.createString(_e); _j++;}
_testarrayofstring = createTestarrayofstringVector(builder, __testarrayofstring);
}
int _testarrayoftables = 0;
if (_o.getTestarrayoftables() != null) {
int[] __testarrayoftables = new int[_o.getTestarrayoftables().length];
int _j = 0;
for (MyGame.Example.MonsterT _e : _o.getTestarrayoftables()) { __testarrayoftables[_j] = MyGame.Example.Monster.pack(builder, _e); _j++;}
_testarrayoftables = createTestarrayoftablesVector(builder, __testarrayoftables);
}
int _enemy = _o.getEnemy() == null ? 0 : MyGame.Example.Monster.pack(builder, _o.getEnemy());
int _testnestedflatbuffer = 0;
if (_o.getTestnestedflatbuffer() != null) {
byte[] __testnestedflatbuffer = new byte[_o.getTestnestedflatbuffer().length];
int _j = 0;
for (int _e : _o.getTestnestedflatbuffer()) { __testnestedflatbuffer[_j] = (byte) _e; _j++;}
_testnestedflatbuffer = createTestnestedflatbufferVector(builder, __testnestedflatbuffer);
}
int _testempty = _o.getTestempty() == null ? 0 : MyGame.Example.Stat.pack(builder, _o.getTestempty());
int _testarrayofbools = 0;
if (_o.getTestarrayofbools() != null) {
_testarrayofbools = createTestarrayofboolsVector(builder, _o.getTestarrayofbools());
}
int _testarrayofstring2 = 0;
if (_o.getTestarrayofstring2() != null) {
int[] __testarrayofstring2 = new int[_o.getTestarrayofstring2().length];
int _j = 0;
for (String _e : _o.getTestarrayofstring2()) { __testarrayofstring2[_j] = builder.createString(_e); _j++;}
_testarrayofstring2 = createTestarrayofstring2Vector(builder, __testarrayofstring2);
}
int _testarrayofsortedstruct = 0;
MyGame.Example.AbilityT[] _oTestarrayofsortedstruct = _o.getTestarrayofsortedstruct();
if (_oTestarrayofsortedstruct != null) {
startTestarrayofsortedstructVector(builder, _oTestarrayofsortedstruct.length);
for (int _j = _oTestarrayofsortedstruct.length - 1; _j >=0; _j--) { MyGame.Example.Ability.pack(builder, _oTestarrayofsortedstruct[_j]);}
_testarrayofsortedstruct = builder.endVector();
}
int _flex = 0;
if (_o.getFlex() != null) {
byte[] __flex = new byte[_o.getFlex().length];
int _j = 0;
for (int _e : _o.getFlex()) { __flex[_j] = (byte) _e; _j++;}
_flex = createFlexVector(builder, __flex);
}
int _test5 = 0;
MyGame.Example.TestT[] _oTest5 = _o.getTest5();
if (_oTest5 != null) {
startTest5Vector(builder, _oTest5.length);
for (int _j = _oTest5.length - 1; _j >=0; _j--) { MyGame.Example.Test.pack(builder, _oTest5[_j]);}
_test5 = builder.endVector();
}
int _vectorOfLongs = 0;
if (_o.getVectorOfLongs() != null) {
_vectorOfLongs = createVectorOfLongsVector(builder, _o.getVectorOfLongs());
}
int _vectorOfDoubles = 0;
if (_o.getVectorOfDoubles() != null) {
_vectorOfDoubles = createVectorOfDoublesVector(builder, _o.getVectorOfDoubles());
}
int _parent_namespace_test = _o.getParentNamespaceTest() == null ? 0 : MyGame.InParentNamespace.pack(builder, _o.getParentNamespaceTest());
int _vectorOfReferrables = 0;
if (_o.getVectorOfReferrables() != null) {
int[] __vectorOfReferrables = new int[_o.getVectorOfReferrables().length];
int _j = 0;
for (MyGame.Example.ReferrableT _e : _o.getVectorOfReferrables()) { __vectorOfReferrables[_j] = MyGame.Example.Referrable.pack(builder, _e); _j++;}
_vectorOfReferrables = createVectorOfReferrablesVector(builder, __vectorOfReferrables);
}
int _vectorOfWeakReferences = 0;
if (_o.getVectorOfWeakReferences() != null) {
_vectorOfWeakReferences = createVectorOfWeakReferencesVector(builder, _o.getVectorOfWeakReferences());
}
int _vectorOfStrongReferrables = 0;
if (_o.getVectorOfStrongReferrables() != null) {
int[] __vectorOfStrongReferrables = new int[_o.getVectorOfStrongReferrables().length];
int _j = 0;
for (MyGame.Example.ReferrableT _e : _o.getVectorOfStrongReferrables()) { __vectorOfStrongReferrables[_j] = MyGame.Example.Referrable.pack(builder, _e); _j++;}
_vectorOfStrongReferrables = createVectorOfStrongReferrablesVector(builder, __vectorOfStrongReferrables);
}
int _vectorOfCoOwningReferences = 0;
if (_o.getVectorOfCoOwningReferences() != null) {
_vectorOfCoOwningReferences = createVectorOfCoOwningReferencesVector(builder, _o.getVectorOfCoOwningReferences());
}
int _vectorOfNonOwningReferences = 0;
if (_o.getVectorOfNonOwningReferences() != null) {
_vectorOfNonOwningReferences = createVectorOfNonOwningReferencesVector(builder, _o.getVectorOfNonOwningReferences());
}
byte _anyUniqueType = _o.getAnyUnique() == null ? MyGame.Example.AnyUniqueAliases.NONE : _o.getAnyUnique().getType();
int _anyUnique = _o.getAnyUnique() == null ? 0 : MyGame.Example.AnyUniqueAliasesUnion.pack(builder, _o.getAnyUnique());
byte _anyAmbiguousType = _o.getAnyAmbiguous() == null ? MyGame.Example.AnyAmbiguousAliases.NONE : _o.getAnyAmbiguous().getType();
int _anyAmbiguous = _o.getAnyAmbiguous() == null ? 0 : MyGame.Example.AnyAmbiguousAliasesUnion.pack(builder, _o.getAnyAmbiguous());
int _vectorOfEnums = 0;
if (_o.getVectorOfEnums() != null) {
byte[] __vectorOfEnums = new byte[_o.getVectorOfEnums().length];
int _j = 0;
for (int _e : _o.getVectorOfEnums()) { __vectorOfEnums[_j] = (byte) _e; _j++;}
_vectorOfEnums = createVectorOfEnumsVector(builder, __vectorOfEnums);
}
int _testrequirednestedflatbuffer = 0;
if (_o.getTestrequirednestedflatbuffer() != null) {
byte[] __testrequirednestedflatbuffer = new byte[_o.getTestrequirednestedflatbuffer().length];
int _j = 0;
for (int _e : _o.getTestrequirednestedflatbuffer()) { __testrequirednestedflatbuffer[_j] = (byte) _e; _j++;}
_testrequirednestedflatbuffer = createTestrequirednestedflatbufferVector(builder, __testrequirednestedflatbuffer);
}
int _scalarKeySortedTables = 0;
if (_o.getScalarKeySortedTables() != null) {
int[] __scalarKeySortedTables = new int[_o.getScalarKeySortedTables().length];
int _j = 0;
for (MyGame.Example.StatT _e : _o.getScalarKeySortedTables()) { __scalarKeySortedTables[_j] = MyGame.Example.Stat.pack(builder, _e); _j++;}
_scalarKeySortedTables = createScalarKeySortedTablesVector(builder, __scalarKeySortedTables);
}
startMonster(builder);
addPos(builder, MyGame.Example.Vec3.pack(builder, _o.getPos()));
addMana(builder, _o.getMana());
addHp(builder, _o.getHp());
addName(builder, _name);
addInventory(builder, _inventory);
addColor(builder, _o.getColor());
addTestType(builder, _testType);
addTest(builder, _test);
addTest4(builder, _test4);
addTestarrayofstring(builder, _testarrayofstring);
addTestarrayoftables(builder, _testarrayoftables);
addEnemy(builder, _enemy);
addTestnestedflatbuffer(builder, _testnestedflatbuffer);
addTestempty(builder, _testempty);
addTestbool(builder, _o.getTestbool());
addTesthashs32Fnv1(builder, _o.getTesthashs32Fnv1());
addTesthashu32Fnv1(builder, _o.getTesthashu32Fnv1());
addTesthashs64Fnv1(builder, _o.getTesthashs64Fnv1());
addTesthashu64Fnv1(builder, _o.getTesthashu64Fnv1());
addTesthashs32Fnv1a(builder, _o.getTesthashs32Fnv1a());
addTesthashu32Fnv1a(builder, _o.getTesthashu32Fnv1a());
addTesthashs64Fnv1a(builder, _o.getTesthashs64Fnv1a());
addTesthashu64Fnv1a(builder, _o.getTesthashu64Fnv1a());
addTestarrayofbools(builder, _testarrayofbools);
addTestf(builder, _o.getTestf());
addTestf2(builder, _o.getTestf2());
addTestf3(builder, _o.getTestf3());
addTestarrayofstring2(builder, _testarrayofstring2);
addTestarrayofsortedstruct(builder, _testarrayofsortedstruct);
addFlex(builder, _flex);
addTest5(builder, _test5);
addVectorOfLongs(builder, _vectorOfLongs);
addVectorOfDoubles(builder, _vectorOfDoubles);
addParentNamespaceTest(builder, _parent_namespace_test);
addVectorOfReferrables(builder, _vectorOfReferrables);
addSingleWeakReference(builder, _o.getSingleWeakReference());
addVectorOfWeakReferences(builder, _vectorOfWeakReferences);
addVectorOfStrongReferrables(builder, _vectorOfStrongReferrables);
addCoOwningReference(builder, _o.getCoOwningReference());
addVectorOfCoOwningReferences(builder, _vectorOfCoOwningReferences);
addNonOwningReference(builder, _o.getNonOwningReference());
addVectorOfNonOwningReferences(builder, _vectorOfNonOwningReferences);
addAnyUniqueType(builder, _anyUniqueType);
addAnyUnique(builder, _anyUnique);
addAnyAmbiguousType(builder, _anyAmbiguousType);
addAnyAmbiguous(builder, _anyAmbiguous);
addVectorOfEnums(builder, _vectorOfEnums);
addSignedEnum(builder, _o.getSignedEnum());
addTestrequirednestedflatbuffer(builder, _testrequirednestedflatbuffer);
addScalarKeySortedTables(builder, _scalarKeySortedTables);
return endMonster(builder);
}
}

View File

@ -0,0 +1,306 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class MonsterT {
private MyGame.Example.Vec3T pos;
private short mana;
private short hp;
private String name;
private int[] inventory;
private int color;
private MyGame.Example.AnyUnion test;
private MyGame.Example.TestT[] test4;
private String[] testarrayofstring;
private MyGame.Example.MonsterT[] testarrayoftables;
private MyGame.Example.MonsterT enemy;
private int[] testnestedflatbuffer;
private MyGame.Example.StatT testempty;
private boolean testbool;
private int testhashs32Fnv1;
private long testhashu32Fnv1;
private long testhashs64Fnv1;
private long testhashu64Fnv1;
private int testhashs32Fnv1a;
private long testhashu32Fnv1a;
private long testhashs64Fnv1a;
private long testhashu64Fnv1a;
private boolean[] testarrayofbools;
private float testf;
private float testf2;
private float testf3;
private String[] testarrayofstring2;
private MyGame.Example.AbilityT[] testarrayofsortedstruct;
private int[] flex;
private MyGame.Example.TestT[] test5;
private long[] vectorOfLongs;
private double[] vectorOfDoubles;
private MyGame.InParentNamespaceT parentNamespaceTest;
private MyGame.Example.ReferrableT[] vectorOfReferrables;
private long singleWeakReference;
private long[] vectorOfWeakReferences;
private MyGame.Example.ReferrableT[] vectorOfStrongReferrables;
private long coOwningReference;
private long[] vectorOfCoOwningReferences;
private long nonOwningReference;
private long[] vectorOfNonOwningReferences;
private MyGame.Example.AnyUniqueAliasesUnion anyUnique;
private MyGame.Example.AnyAmbiguousAliasesUnion anyAmbiguous;
private int[] vectorOfEnums;
private byte signedEnum;
private int[] testrequirednestedflatbuffer;
private MyGame.Example.StatT[] scalarKeySortedTables;
public MyGame.Example.Vec3T getPos() { return pos; }
public void setPos(MyGame.Example.Vec3T pos) { this.pos = pos; }
public short getMana() { return mana; }
public void setMana(short mana) { this.mana = mana; }
public short getHp() { return hp; }
public void setHp(short hp) { this.hp = hp; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public int[] getInventory() { return inventory; }
public void setInventory(int[] inventory) { this.inventory = inventory; }
public int getColor() { return color; }
public void setColor(int color) { this.color = color; }
public MyGame.Example.AnyUnion getTest() { return test; }
public void setTest(MyGame.Example.AnyUnion test) { this.test = test; }
public MyGame.Example.TestT[] getTest4() { return test4; }
public void setTest4(MyGame.Example.TestT[] test4) { this.test4 = test4; }
public String[] getTestarrayofstring() { return testarrayofstring; }
public void setTestarrayofstring(String[] testarrayofstring) { this.testarrayofstring = testarrayofstring; }
public MyGame.Example.MonsterT[] getTestarrayoftables() { return testarrayoftables; }
public void setTestarrayoftables(MyGame.Example.MonsterT[] testarrayoftables) { this.testarrayoftables = testarrayoftables; }
public MyGame.Example.MonsterT getEnemy() { return enemy; }
public void setEnemy(MyGame.Example.MonsterT enemy) { this.enemy = enemy; }
public int[] getTestnestedflatbuffer() { return testnestedflatbuffer; }
public void setTestnestedflatbuffer(int[] testnestedflatbuffer) { this.testnestedflatbuffer = testnestedflatbuffer; }
public MyGame.Example.StatT getTestempty() { return testempty; }
public void setTestempty(MyGame.Example.StatT testempty) { this.testempty = testempty; }
public boolean getTestbool() { return testbool; }
public void setTestbool(boolean testbool) { this.testbool = testbool; }
public int getTesthashs32Fnv1() { return testhashs32Fnv1; }
public void setTesthashs32Fnv1(int testhashs32Fnv1) { this.testhashs32Fnv1 = testhashs32Fnv1; }
public long getTesthashu32Fnv1() { return testhashu32Fnv1; }
public void setTesthashu32Fnv1(long testhashu32Fnv1) { this.testhashu32Fnv1 = testhashu32Fnv1; }
public long getTesthashs64Fnv1() { return testhashs64Fnv1; }
public void setTesthashs64Fnv1(long testhashs64Fnv1) { this.testhashs64Fnv1 = testhashs64Fnv1; }
public long getTesthashu64Fnv1() { return testhashu64Fnv1; }
public void setTesthashu64Fnv1(long testhashu64Fnv1) { this.testhashu64Fnv1 = testhashu64Fnv1; }
public int getTesthashs32Fnv1a() { return testhashs32Fnv1a; }
public void setTesthashs32Fnv1a(int testhashs32Fnv1a) { this.testhashs32Fnv1a = testhashs32Fnv1a; }
public long getTesthashu32Fnv1a() { return testhashu32Fnv1a; }
public void setTesthashu32Fnv1a(long testhashu32Fnv1a) { this.testhashu32Fnv1a = testhashu32Fnv1a; }
public long getTesthashs64Fnv1a() { return testhashs64Fnv1a; }
public void setTesthashs64Fnv1a(long testhashs64Fnv1a) { this.testhashs64Fnv1a = testhashs64Fnv1a; }
public long getTesthashu64Fnv1a() { return testhashu64Fnv1a; }
public void setTesthashu64Fnv1a(long testhashu64Fnv1a) { this.testhashu64Fnv1a = testhashu64Fnv1a; }
public boolean[] getTestarrayofbools() { return testarrayofbools; }
public void setTestarrayofbools(boolean[] testarrayofbools) { this.testarrayofbools = testarrayofbools; }
public float getTestf() { return testf; }
public void setTestf(float testf) { this.testf = testf; }
public float getTestf2() { return testf2; }
public void setTestf2(float testf2) { this.testf2 = testf2; }
public float getTestf3() { return testf3; }
public void setTestf3(float testf3) { this.testf3 = testf3; }
public String[] getTestarrayofstring2() { return testarrayofstring2; }
public void setTestarrayofstring2(String[] testarrayofstring2) { this.testarrayofstring2 = testarrayofstring2; }
public MyGame.Example.AbilityT[] getTestarrayofsortedstruct() { return testarrayofsortedstruct; }
public void setTestarrayofsortedstruct(MyGame.Example.AbilityT[] testarrayofsortedstruct) { this.testarrayofsortedstruct = testarrayofsortedstruct; }
public int[] getFlex() { return flex; }
public void setFlex(int[] flex) { this.flex = flex; }
public MyGame.Example.TestT[] getTest5() { return test5; }
public void setTest5(MyGame.Example.TestT[] test5) { this.test5 = test5; }
public long[] getVectorOfLongs() { return vectorOfLongs; }
public void setVectorOfLongs(long[] vectorOfLongs) { this.vectorOfLongs = vectorOfLongs; }
public double[] getVectorOfDoubles() { return vectorOfDoubles; }
public void setVectorOfDoubles(double[] vectorOfDoubles) { this.vectorOfDoubles = vectorOfDoubles; }
public MyGame.InParentNamespaceT getParentNamespaceTest() { return parentNamespaceTest; }
public void setParentNamespaceTest(MyGame.InParentNamespaceT parentNamespaceTest) { this.parentNamespaceTest = parentNamespaceTest; }
public MyGame.Example.ReferrableT[] getVectorOfReferrables() { return vectorOfReferrables; }
public void setVectorOfReferrables(MyGame.Example.ReferrableT[] vectorOfReferrables) { this.vectorOfReferrables = vectorOfReferrables; }
public long getSingleWeakReference() { return singleWeakReference; }
public void setSingleWeakReference(long singleWeakReference) { this.singleWeakReference = singleWeakReference; }
public long[] getVectorOfWeakReferences() { return vectorOfWeakReferences; }
public void setVectorOfWeakReferences(long[] vectorOfWeakReferences) { this.vectorOfWeakReferences = vectorOfWeakReferences; }
public MyGame.Example.ReferrableT[] getVectorOfStrongReferrables() { return vectorOfStrongReferrables; }
public void setVectorOfStrongReferrables(MyGame.Example.ReferrableT[] vectorOfStrongReferrables) { this.vectorOfStrongReferrables = vectorOfStrongReferrables; }
public long getCoOwningReference() { return coOwningReference; }
public void setCoOwningReference(long coOwningReference) { this.coOwningReference = coOwningReference; }
public long[] getVectorOfCoOwningReferences() { return vectorOfCoOwningReferences; }
public void setVectorOfCoOwningReferences(long[] vectorOfCoOwningReferences) { this.vectorOfCoOwningReferences = vectorOfCoOwningReferences; }
public long getNonOwningReference() { return nonOwningReference; }
public void setNonOwningReference(long nonOwningReference) { this.nonOwningReference = nonOwningReference; }
public long[] getVectorOfNonOwningReferences() { return vectorOfNonOwningReferences; }
public void setVectorOfNonOwningReferences(long[] vectorOfNonOwningReferences) { this.vectorOfNonOwningReferences = vectorOfNonOwningReferences; }
public MyGame.Example.AnyUniqueAliasesUnion getAnyUnique() { return anyUnique; }
public void setAnyUnique(MyGame.Example.AnyUniqueAliasesUnion anyUnique) { this.anyUnique = anyUnique; }
public MyGame.Example.AnyAmbiguousAliasesUnion getAnyAmbiguous() { return anyAmbiguous; }
public void setAnyAmbiguous(MyGame.Example.AnyAmbiguousAliasesUnion anyAmbiguous) { this.anyAmbiguous = anyAmbiguous; }
public int[] getVectorOfEnums() { return vectorOfEnums; }
public void setVectorOfEnums(int[] vectorOfEnums) { this.vectorOfEnums = vectorOfEnums; }
public byte getSignedEnum() { return signedEnum; }
public void setSignedEnum(byte signedEnum) { this.signedEnum = signedEnum; }
public int[] getTestrequirednestedflatbuffer() { return testrequirednestedflatbuffer; }
public void setTestrequirednestedflatbuffer(int[] testrequirednestedflatbuffer) { this.testrequirednestedflatbuffer = testrequirednestedflatbuffer; }
public MyGame.Example.StatT[] getScalarKeySortedTables() { return scalarKeySortedTables; }
public void setScalarKeySortedTables(MyGame.Example.StatT[] scalarKeySortedTables) { this.scalarKeySortedTables = scalarKeySortedTables; }
public MonsterT() {
this.pos = new MyGame.Example.Vec3T();
this.mana = 150;
this.hp = 100;
this.name = null;
this.inventory = null;
this.color = 8;
this.test = null;
this.test4 = null;
this.testarrayofstring = null;
this.testarrayoftables = null;
this.enemy = null;
this.testnestedflatbuffer = null;
this.testempty = null;
this.testbool = false;
this.testhashs32Fnv1 = 0;
this.testhashu32Fnv1 = 0L;
this.testhashs64Fnv1 = 0L;
this.testhashu64Fnv1 = 0L;
this.testhashs32Fnv1a = 0;
this.testhashu32Fnv1a = 0L;
this.testhashs64Fnv1a = 0L;
this.testhashu64Fnv1a = 0L;
this.testarrayofbools = null;
this.testf = 3.14159f;
this.testf2 = 3.0f;
this.testf3 = 0.0f;
this.testarrayofstring2 = null;
this.testarrayofsortedstruct = null;
this.flex = null;
this.test5 = null;
this.vectorOfLongs = null;
this.vectorOfDoubles = null;
this.parentNamespaceTest = null;
this.vectorOfReferrables = null;
this.singleWeakReference = 0L;
this.vectorOfWeakReferences = null;
this.vectorOfStrongReferrables = null;
this.coOwningReference = 0L;
this.vectorOfCoOwningReferences = null;
this.nonOwningReference = 0L;
this.vectorOfNonOwningReferences = null;
this.anyUnique = null;
this.anyAmbiguous = null;
this.vectorOfEnums = null;
this.signedEnum = -1;
this.testrequirednestedflatbuffer = null;
this.scalarKeySortedTables = null;
}
public static MonsterT deserializeFromBinary(byte[] fbBuffer) {
return Monster.getRootAsMonster(ByteBuffer.wrap(fbBuffer)).unpack();
}
public byte[] serializeToBinary() {
FlatBufferBuilder fbb = new FlatBufferBuilder();
Monster.finishMonsterBuffer(fbb, Monster.pack(fbb, this));
return fbb.sizedByteArray();
}
}

View File

@ -43,5 +43,32 @@ public final class NestedStruct extends Struct {
public NestedStruct get(int j) { return get(new NestedStruct(), j); }
public NestedStruct get(NestedStruct obj, int j) { return obj.__assign(__element(j), bb); }
}
public NestedStructT unpack() {
NestedStructT _o = new NestedStructT();
unpackTo(_o);
return _o;
}
public void unpackTo(NestedStructT _o) {
int[] _oA = _o.getA();
for (int _j = 0; _j < 2; ++_j) { _oA[_j] = a(_j); }
byte _oB = b();
_o.setB(_oB);
byte[] _oC = _o.getC();
for (int _j = 0; _j < 2; ++_j) { _oC[_j] = c(_j); }
long[] _oD = _o.getD();
for (int _j = 0; _j < 2; ++_j) { _oD[_j] = d(_j); }
}
public static int pack(FlatBufferBuilder builder, NestedStructT _o) {
if (_o == null) return 0;
int[] _a = _o.getA();
byte[] _c = _o.getC();
long[] _d = _o.getD();
return createNestedStruct(
builder,
_a,
_o.getB(),
_c,
_d);
}
}

View File

@ -0,0 +1,40 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class NestedStructT {
private int[] a;
private byte b;
private byte[] c;
private long[] d;
public int[] getA() { return a; }
public void setA(int[] a) { if (a != null && a.length == 2) this.a = a; }
public byte getB() { return b; }
public void setB(byte b) { this.b = b; }
public byte[] getC() { return c; }
public void setC(byte[] c) { if (c != null && c.length == 2) this.c = c; }
public long[] getD() { return d; }
public void setD(long[] d) { if (d != null && d.length == 2) this.d = d; }
public NestedStructT() {
this.a = new int[2];
this.b = 0;
this.c = new byte[2];
this.d = new long[2];
}
}

View File

@ -2,6 +2,7 @@
package MyGame.Example;
@SuppressWarnings("unused")
public final class Race {
private Race() { }
public static final byte None = -1;

View File

@ -68,5 +68,20 @@ public final class Referrable extends Table {
public Referrable getByKey(long key) { return __lookup_by_key(null, __vector(), key, bb); }
public Referrable getByKey(Referrable obj, long key) { return __lookup_by_key(obj, __vector(), key, bb); }
}
public ReferrableT unpack() {
ReferrableT _o = new ReferrableT();
unpackTo(_o);
return _o;
}
public void unpackTo(ReferrableT _o) {
long _oId = id();
_o.setId(_oId);
}
public static int pack(FlatBufferBuilder builder, ReferrableT _o) {
if (_o == null) return 0;
return createReferrable(
builder,
_o.getId());
}
}

View File

@ -0,0 +1,22 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class ReferrableT {
private long id;
public long getId() { return id; }
public void setId(long id) { this.id = id; }
public ReferrableT() {
this.id = 0L;
}
}

View File

@ -21,7 +21,7 @@ public final class Stat extends Table {
public long val() { int o = __offset(6); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
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(int count) { int o = __offset(8); if (o != 0) { bb.putShort(o + bb_pos, (short)count); return true; } else { return false; } }
public boolean mutateCount(int count) { int o = __offset(8); if (o != 0) { bb.putShort(o + bb_pos, (short) count); return true; } else { return false; } }
public static int createStat(FlatBufferBuilder builder,
int idOffset,
@ -37,7 +37,7 @@ public final class Stat extends Table {
public static void startStat(FlatBufferBuilder builder) { builder.startTable(3); }
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, 0L); }
public static void addCount(FlatBufferBuilder builder, int count) { builder.addShort(2, (short)count, (short)0); }
public static void addCount(FlatBufferBuilder builder, int count) { builder.addShort(2, (short) count, (short) 0); }
public static int endStat(FlatBufferBuilder builder) {
int o = builder.endTable();
return o;
@ -79,5 +79,27 @@ public final class Stat extends Table {
public Stat getByKey(int key) { return __lookup_by_key(null, __vector(), key, bb); }
public Stat getByKey(Stat obj, int key) { return __lookup_by_key(obj, __vector(), key, bb); }
}
public StatT unpack() {
StatT _o = new StatT();
unpackTo(_o);
return _o;
}
public void unpackTo(StatT _o) {
String _oId = id();
_o.setId(_oId);
long _oVal = val();
_o.setVal(_oVal);
int _oCount = count();
_o.setCount(_oCount);
}
public static int pack(FlatBufferBuilder builder, StatT _o) {
if (_o == null) return 0;
int _id = _o.getId() == null ? 0 : builder.createString(_o.getId());
return createStat(
builder,
_id,
_o.getVal(),
_o.getCount());
}
}

View File

@ -0,0 +1,34 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class StatT {
private String id;
private long val;
private int count;
public String getId() { return id; }
public void setId(String id) { this.id = id; }
public long getVal() { return val; }
public void setVal(long val) { this.val = val; }
public int getCount() { return count; }
public void setCount(int count) { this.count = count; }
public StatT() {
this.id = null;
this.val = 0L;
this.count = 0;
}
}

View File

@ -22,15 +22,15 @@ public final class StructOfStructs extends Struct {
public static int createStructOfStructs(FlatBufferBuilder builder, long a_id, long a_distance, short b_a, byte b_b, long c_id, long c_distance) {
builder.prep(4, 20);
builder.prep(4, 8);
builder.putInt((int)c_distance);
builder.putInt((int)c_id);
builder.putInt((int) c_distance);
builder.putInt((int) c_id);
builder.prep(2, 4);
builder.pad(1);
builder.putByte(b_b);
builder.putShort(b_a);
builder.prep(4, 8);
builder.putInt((int)a_distance);
builder.putInt((int)a_id);
builder.putInt((int) a_distance);
builder.putInt((int) a_id);
return builder.offset();
}
@ -40,5 +40,32 @@ public final class StructOfStructs extends Struct {
public StructOfStructs get(int j) { return get(new StructOfStructs(), j); }
public StructOfStructs get(StructOfStructs obj, int j) { return obj.__assign(__element(j), bb); }
}
public StructOfStructsT unpack() {
StructOfStructsT _o = new StructOfStructsT();
unpackTo(_o);
return _o;
}
public void unpackTo(StructOfStructsT _o) {
a().unpackTo(_o.getA());
b().unpackTo(_o.getB());
c().unpackTo(_o.getC());
}
public static int pack(FlatBufferBuilder builder, StructOfStructsT _o) {
if (_o == null) return 0;
int _a_id = _o.getA().getId();
int _a_distance = _o.getA().getDistance();
short _b_a = _o.getB().getA();
byte _b_b = _o.getB().getB();
int _c_id = _o.getC().getId();
int _c_distance = _o.getC().getDistance();
return createStructOfStructs(
builder,
_a_id,
_a_distance,
_b_a,
_b_b,
_c_id,
_c_distance);
}
}

View File

@ -0,0 +1,34 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class StructOfStructsT {
private MyGame.Example.AbilityT a;
private MyGame.Example.TestT b;
private MyGame.Example.AbilityT c;
public MyGame.Example.AbilityT getA() { return a; }
public void setA(MyGame.Example.AbilityT a) { this.a = a; }
public MyGame.Example.TestT getB() { return b; }
public void setB(MyGame.Example.TestT b) { this.b = b; }
public MyGame.Example.AbilityT getC() { return c; }
public void setC(MyGame.Example.AbilityT c) { this.c = c; }
public StructOfStructsT() {
this.a = new MyGame.Example.AbilityT();
this.b = new MyGame.Example.TestT();
this.c = new MyGame.Example.AbilityT();
}
}

View File

@ -31,5 +31,23 @@ public final class Test extends Struct {
public Test get(int j) { return get(new Test(), j); }
public Test get(Test obj, int j) { return obj.__assign(__element(j), bb); }
}
public TestT unpack() {
TestT _o = new TestT();
unpackTo(_o);
return _o;
}
public void unpackTo(TestT _o) {
short _oA = a();
_o.setA(_oA);
byte _oB = b();
_o.setB(_oB);
}
public static int pack(FlatBufferBuilder builder, TestT _o) {
if (_o == null) return 0;
return createTest(
builder,
_o.getA(),
_o.getB());
}
}

View File

@ -2,6 +2,7 @@
package MyGame.Example;
@SuppressWarnings("unused")
public final class TestEnum {
private TestEnum() { }
public static final byte A = 0;

View File

@ -16,7 +16,7 @@ final class TestSimpleTableWithEnum extends Table {
public TestSimpleTableWithEnum __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public int color() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) & 0xFF : 2; }
public boolean mutateColor(int color) { int o = __offset(4); if (o != 0) { bb.put(o + bb_pos, (byte)color); return true; } else { return false; } }
public boolean mutateColor(int color) { int o = __offset(4); if (o != 0) { bb.put(o + bb_pos, (byte) color); return true; } else { return false; } }
public static int createTestSimpleTableWithEnum(FlatBufferBuilder builder,
int color) {
@ -26,7 +26,7 @@ final class TestSimpleTableWithEnum extends Table {
}
public static void startTestSimpleTableWithEnum(FlatBufferBuilder builder) { builder.startTable(1); }
public static void addColor(FlatBufferBuilder builder, int color) { builder.addByte(0, (byte)color, (byte)2); }
public static void addColor(FlatBufferBuilder builder, int color) { builder.addByte(0, (byte) color, (byte) 2); }
public static int endTestSimpleTableWithEnum(FlatBufferBuilder builder) {
int o = builder.endTable();
return o;
@ -38,5 +38,20 @@ final class TestSimpleTableWithEnum extends Table {
public TestSimpleTableWithEnum get(int j) { return get(new TestSimpleTableWithEnum(), j); }
public TestSimpleTableWithEnum get(TestSimpleTableWithEnum obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
public TestSimpleTableWithEnumT unpack() {
TestSimpleTableWithEnumT _o = new TestSimpleTableWithEnumT();
unpackTo(_o);
return _o;
}
public void unpackTo(TestSimpleTableWithEnumT _o) {
int _oColor = color();
_o.setColor(_oColor);
}
public static int pack(FlatBufferBuilder builder, TestSimpleTableWithEnumT _o) {
if (_o == null) return 0;
return createTestSimpleTableWithEnum(
builder,
_o.getColor());
}
}

View File

@ -0,0 +1,22 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
class TestSimpleTableWithEnumT {
private int color;
public int getColor() { return color; }
public void setColor(int color) { this.color = color; }
public TestSimpleTableWithEnumT() {
this.color = 2;
}
}

View File

@ -0,0 +1,28 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class TestT {
private short a;
private byte b;
public short getA() { return a; }
public void setA(short a) { this.a = a; }
public byte getB() { return b; }
public void setB(byte b) { this.b = b; }
public TestT() {
this.a = 0;
this.b = 0;
}
}

View File

@ -18,15 +18,15 @@ public final class TypeAliases extends Table {
public byte i8() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; }
public boolean mutateI8(byte i8) { int o = __offset(4); if (o != 0) { bb.put(o + bb_pos, i8); return true; } else { return false; } }
public int u8() { int o = __offset(6); return o != 0 ? bb.get(o + bb_pos) & 0xFF : 0; }
public boolean mutateU8(int u8) { int o = __offset(6); if (o != 0) { bb.put(o + bb_pos, (byte)u8); return true; } else { return false; } }
public boolean mutateU8(int u8) { int o = __offset(6); if (o != 0) { bb.put(o + bb_pos, (byte) u8); return true; } else { return false; } }
public short i16() { int o = __offset(8); return o != 0 ? bb.getShort(o + bb_pos) : 0; }
public boolean mutateI16(short i16) { int o = __offset(8); if (o != 0) { bb.putShort(o + bb_pos, i16); return true; } else { return false; } }
public int u16() { int o = __offset(10); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
public boolean mutateU16(int u16) { int o = __offset(10); if (o != 0) { bb.putShort(o + bb_pos, (short)u16); return true; } else { return false; } }
public boolean mutateU16(int u16) { int o = __offset(10); if (o != 0) { bb.putShort(o + bb_pos, (short) u16); return true; } else { return false; } }
public int i32() { int o = __offset(12); return o != 0 ? bb.getInt(o + bb_pos) : 0; }
public boolean mutateI32(int i32) { int o = __offset(12); if (o != 0) { bb.putInt(o + bb_pos, i32); return true; } else { return false; } }
public long u32() { int o = __offset(14); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; }
public boolean mutateU32(long u32) { int o = __offset(14); if (o != 0) { bb.putInt(o + bb_pos, (int)u32); return true; } else { return false; } }
public boolean mutateU32(long u32) { int o = __offset(14); if (o != 0) { bb.putInt(o + bb_pos, (int) u32); return true; } else { return false; } }
public long i64() { int o = __offset(16); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
public boolean mutateI64(long i64) { int o = __offset(16); if (o != 0) { bb.putLong(o + bb_pos, i64); return true; } else { return false; } }
public long u64() { int o = __offset(18); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
@ -81,11 +81,11 @@ public final class TypeAliases extends Table {
public static void startTypeAliases(FlatBufferBuilder builder) { builder.startTable(12); }
public static void addI8(FlatBufferBuilder builder, byte i8) { builder.addByte(0, i8, 0); }
public static void addU8(FlatBufferBuilder builder, int u8) { builder.addByte(1, (byte)u8, (byte)0); }
public static void addU8(FlatBufferBuilder builder, int u8) { builder.addByte(1, (byte) u8, (byte) 0); }
public static void addI16(FlatBufferBuilder builder, short i16) { builder.addShort(2, i16, 0); }
public static void addU16(FlatBufferBuilder builder, int u16) { builder.addShort(3, (short)u16, (short)0); }
public static void addU16(FlatBufferBuilder builder, int u16) { builder.addShort(3, (short) u16, (short) 0); }
public static void addI32(FlatBufferBuilder builder, int i32) { builder.addInt(4, i32, 0); }
public static void addU32(FlatBufferBuilder builder, long u32) { builder.addInt(5, (int)u32, (int)0L); }
public static void addU32(FlatBufferBuilder builder, long u32) { builder.addInt(5, (int) u32, (int) 0L); }
public static void addI64(FlatBufferBuilder builder, long i64) { builder.addLong(6, i64, 0L); }
public static void addU64(FlatBufferBuilder builder, long u64) { builder.addLong(7, u64, 0L); }
public static void addF32(FlatBufferBuilder builder, float f32) { builder.addFloat(8, f32, 0.0f); }
@ -108,5 +108,63 @@ public final class TypeAliases extends Table {
public TypeAliases get(int j) { return get(new TypeAliases(), j); }
public TypeAliases get(TypeAliases obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
public TypeAliasesT unpack() {
TypeAliasesT _o = new TypeAliasesT();
unpackTo(_o);
return _o;
}
public void unpackTo(TypeAliasesT _o) {
byte _oI8 = i8();
_o.setI8(_oI8);
int _oU8 = u8();
_o.setU8(_oU8);
short _oI16 = i16();
_o.setI16(_oI16);
int _oU16 = u16();
_o.setU16(_oU16);
int _oI32 = i32();
_o.setI32(_oI32);
long _oU32 = u32();
_o.setU32(_oU32);
long _oI64 = i64();
_o.setI64(_oI64);
long _oU64 = u64();
_o.setU64(_oU64);
float _oF32 = f32();
_o.setF32(_oF32);
double _oF64 = f64();
_o.setF64(_oF64);
byte[] _oV8 = new byte[v8Length()];
for (int _j = 0; _j < v8Length(); ++_j) {_oV8[_j] = v8(_j);}
_o.setV8(_oV8);
double[] _oVf64 = new double[vf64Length()];
for (int _j = 0; _j < vf64Length(); ++_j) {_oVf64[_j] = vf64(_j);}
_o.setVf64(_oVf64);
}
public static int pack(FlatBufferBuilder builder, TypeAliasesT _o) {
if (_o == null) return 0;
int _v8 = 0;
if (_o.getV8() != null) {
_v8 = createV8Vector(builder, _o.getV8());
}
int _vf64 = 0;
if (_o.getVf64() != null) {
_vf64 = createVf64Vector(builder, _o.getVf64());
}
return createTypeAliases(
builder,
_o.getI8(),
_o.getU8(),
_o.getI16(),
_o.getU16(),
_o.getI32(),
_o.getU32(),
_o.getI64(),
_o.getU64(),
_o.getF32(),
_o.getF64(),
_v8,
_vf64);
}
}

View File

@ -0,0 +1,88 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class TypeAliasesT {
private byte i8;
private int u8;
private short i16;
private int u16;
private int i32;
private long u32;
private long i64;
private long u64;
private float f32;
private double f64;
private byte[] v8;
private double[] vf64;
public byte getI8() { return i8; }
public void setI8(byte i8) { this.i8 = i8; }
public int getU8() { return u8; }
public void setU8(int u8) { this.u8 = u8; }
public short getI16() { return i16; }
public void setI16(short i16) { this.i16 = i16; }
public int getU16() { return u16; }
public void setU16(int u16) { this.u16 = u16; }
public int getI32() { return i32; }
public void setI32(int i32) { this.i32 = i32; }
public long getU32() { return u32; }
public void setU32(long u32) { this.u32 = u32; }
public long getI64() { return i64; }
public void setI64(long i64) { this.i64 = i64; }
public long getU64() { return u64; }
public void setU64(long u64) { this.u64 = u64; }
public float getF32() { return f32; }
public void setF32(float f32) { this.f32 = f32; }
public double getF64() { return f64; }
public void setF64(double f64) { this.f64 = f64; }
public byte[] getV8() { return v8; }
public void setV8(byte[] v8) { this.v8 = v8; }
public double[] getVf64() { return vf64; }
public void setVf64(double[] vf64) { this.vf64 = vf64; }
public TypeAliasesT() {
this.i8 = 0;
this.u8 = 0;
this.i16 = 0;
this.u16 = 0;
this.i32 = 0;
this.u32 = 0L;
this.i64 = 0L;
this.u64 = 0L;
this.f32 = 0.0f;
this.f64 = 0.0;
this.v8 = null;
this.vf64 = null;
}
}

View File

@ -21,7 +21,7 @@ public final class Vec3 extends Struct {
public double test1() { return bb.getDouble(bb_pos + 16); }
public void mutateTest1(double test1) { bb.putDouble(bb_pos + 16, test1); }
public int test2() { return bb.get(bb_pos + 24) & 0xFF; }
public void mutateTest2(int test2) { bb.put(bb_pos + 24, (byte)test2); }
public void mutateTest2(int test2) { bb.put(bb_pos + 24, (byte) test2); }
public MyGame.Example.Test test3() { return test3(new MyGame.Example.Test()); }
public MyGame.Example.Test test3(MyGame.Example.Test obj) { return obj.__assign(bb_pos + 26, bb); }
@ -33,7 +33,7 @@ public final class Vec3 extends Struct {
builder.putByte(test3_b);
builder.putShort(test3_a);
builder.pad(1);
builder.putByte((byte)test2);
builder.putByte((byte) test2);
builder.putDouble(test1);
builder.pad(4);
builder.putFloat(z);
@ -48,5 +48,37 @@ public final class Vec3 extends Struct {
public Vec3 get(int j) { return get(new Vec3(), j); }
public Vec3 get(Vec3 obj, int j) { return obj.__assign(__element(j), bb); }
}
public Vec3T unpack() {
Vec3T _o = new Vec3T();
unpackTo(_o);
return _o;
}
public void unpackTo(Vec3T _o) {
float _oX = x();
_o.setX(_oX);
float _oY = y();
_o.setY(_oY);
float _oZ = z();
_o.setZ(_oZ);
double _oTest1 = test1();
_o.setTest1(_oTest1);
int _oTest2 = test2();
_o.setTest2(_oTest2);
test3().unpackTo(_o.getTest3());
}
public static int pack(FlatBufferBuilder builder, Vec3T _o) {
if (_o == null) return 0;
short _test3_a = _o.getTest3().getA();
byte _test3_b = _o.getTest3().getB();
return createVec3(
builder,
_o.getX(),
_o.getY(),
_o.getZ(),
_o.getTest1(),
_o.getTest2(),
_test3_a,
_test3_b);
}
}

View File

@ -0,0 +1,52 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class Vec3T {
private float x;
private float y;
private float z;
private double test1;
private int test2;
private MyGame.Example.TestT test3;
public float getX() { return x; }
public void setX(float x) { this.x = x; }
public float getY() { return y; }
public void setY(float y) { this.y = y; }
public float getZ() { return z; }
public void setZ(float z) { this.z = z; }
public double getTest1() { return test1; }
public void setTest1(double test1) { this.test1 = test1; }
public int getTest2() { return test2; }
public void setTest2(int test2) { this.test2 = test2; }
public MyGame.Example.TestT getTest3() { return test3; }
public void setTest3(MyGame.Example.TestT test3) { this.test3 = test3; }
public Vec3T() {
this.x = 0.0f;
this.y = 0.0f;
this.z = 0.0f;
this.test1 = 0.0;
this.test2 = 0;
this.test3 = new MyGame.Example.TestT();
}
}

View File

@ -28,5 +28,17 @@ public final class Monster extends Table {
public Monster get(int j) { return get(new Monster(), j); }
public Monster get(Monster obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
public MonsterT unpack() {
MonsterT _o = new MonsterT();
unpackTo(_o);
return _o;
}
public void unpackTo(MonsterT _o) {
}
public static int pack(FlatBufferBuilder builder, MonsterT _o) {
if (_o == null) return 0;
startMonster(builder);
return endMonster(builder);
}
}

View File

@ -0,0 +1,16 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Example2;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class MonsterT {
public MonsterT() {
}
}

View File

@ -28,5 +28,17 @@ public final class InParentNamespace extends Table {
public InParentNamespace get(int j) { return get(new InParentNamespace(), j); }
public InParentNamespace get(InParentNamespace obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
public InParentNamespaceT unpack() {
InParentNamespaceT _o = new InParentNamespaceT();
unpackTo(_o);
return _o;
}
public void unpackTo(InParentNamespaceT _o) {
}
public static int pack(FlatBufferBuilder builder, InParentNamespaceT _o) {
if (_o == null) return 0;
startInParentNamespace(builder);
return endInParentNamespace(builder);
}
}

View File

@ -0,0 +1,16 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class InParentNamespaceT {
public InParentNamespaceT() {
}
}

View File

@ -100,5 +100,57 @@ public final class MonsterExtra extends Table {
public MonsterExtra get(int j) { return get(new MonsterExtra(), j); }
public MonsterExtra get(MonsterExtra obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
public MonsterExtraT unpack() {
MonsterExtraT _o = new MonsterExtraT();
unpackTo(_o);
return _o;
}
public void unpackTo(MonsterExtraT _o) {
double _oD0 = d0();
_o.setD0(_oD0);
double _oD1 = d1();
_o.setD1(_oD1);
double _oD2 = d2();
_o.setD2(_oD2);
double _oD3 = d3();
_o.setD3(_oD3);
float _oF0 = f0();
_o.setF0(_oF0);
float _oF1 = f1();
_o.setF1(_oF1);
float _oF2 = f2();
_o.setF2(_oF2);
float _oF3 = f3();
_o.setF3(_oF3);
double[] _oDvec = new double[dvecLength()];
for (int _j = 0; _j < dvecLength(); ++_j) {_oDvec[_j] = dvec(_j);}
_o.setDvec(_oDvec);
float[] _oFvec = new float[fvecLength()];
for (int _j = 0; _j < fvecLength(); ++_j) {_oFvec[_j] = fvec(_j);}
_o.setFvec(_oFvec);
}
public static int pack(FlatBufferBuilder builder, MonsterExtraT _o) {
if (_o == null) return 0;
int _dvec = 0;
if (_o.getDvec() != null) {
_dvec = createDvecVector(builder, _o.getDvec());
}
int _fvec = 0;
if (_o.getFvec() != null) {
_fvec = createFvecVector(builder, _o.getFvec());
}
return createMonsterExtra(
builder,
_o.getD0(),
_o.getD1(),
_o.getD2(),
_o.getD3(),
_o.getF0(),
_o.getF1(),
_o.getF2(),
_o.getF3(),
_dvec,
_fvec);
}
}

View File

@ -0,0 +1,84 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class MonsterExtraT {
private double d0;
private double d1;
private double d2;
private double d3;
private float f0;
private float f1;
private float f2;
private float f3;
private double[] dvec;
private float[] fvec;
public double getD0() { return d0; }
public void setD0(double d0) { this.d0 = d0; }
public double getD1() { return d1; }
public void setD1(double d1) { this.d1 = d1; }
public double getD2() { return d2; }
public void setD2(double d2) { this.d2 = d2; }
public double getD3() { return d3; }
public void setD3(double d3) { this.d3 = d3; }
public float getF0() { return f0; }
public void setF0(float f0) { this.f0 = f0; }
public float getF1() { return f1; }
public void setF1(float f1) { this.f1 = f1; }
public float getF2() { return f2; }
public void setF2(float f2) { this.f2 = f2; }
public float getF3() { return f3; }
public void setF3(float f3) { this.f3 = f3; }
public double[] getDvec() { return dvec; }
public void setDvec(double[] dvec) { this.dvec = dvec; }
public float[] getFvec() { return fvec; }
public void setFvec(float[] fvec) { this.fvec = fvec; }
public MonsterExtraT() {
this.d0 = Double.NaN;
this.d1 = Double.NaN;
this.d2 = Double.POSITIVE_INFINITY;
this.d3 = Double.NEGATIVE_INFINITY;
this.f0 = Float.NaN;
this.f1 = Float.NaN;
this.f2 = Float.POSITIVE_INFINITY;
this.f3 = Float.NEGATIVE_INFINITY;
this.dvec = null;
this.fvec = null;
}
public static MonsterExtraT deserializeFromBinary(byte[] fbBuffer) {
return MonsterExtra.getRootAsMonsterExtra(ByteBuffer.wrap(fbBuffer)).unpack();
}
public byte[] serializeToBinary() {
FlatBufferBuilder fbb = new FlatBufferBuilder();
MonsterExtra.finishMonsterExtraBuffer(fbb, MonsterExtra.pack(fbb, this));
return fbb.sizedByteArray();
}
}

View File

@ -0,0 +1,22 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.OtherNameSpace;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class TableBT {
private TableAT a;
public TableAT getA() { return a; }
public void setA(TableAT a) { this.a = a; }
public TableBT() {
this.a = null;
}
}

View File

@ -0,0 +1,22 @@
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.OtherNameSpace;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class UnusedT {
private int a;
public int getA() { return a; }
public void setA(int a) { this.a = a; }
public UnusedT() {
this.a = 0;
}
}

20
tests/TableAT.java Normal file
View File

@ -0,0 +1,20 @@
// automatically generated by the FlatBuffers compiler, do not modify
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class TableAT {
private MyGame.OtherNameSpace.TableBT b;
public MyGame.OtherNameSpace.TableBT getB() { return b; }
public void setB(MyGame.OtherNameSpace.TableBT b) { this.b = b; }
public TableAT() {
this.b = null;
}
}

View File

@ -2,6 +2,7 @@
package NamespaceA.NamespaceB;
@SuppressWarnings("unused")
public final class EnumInNestedNS {
private EnumInNestedNS() { }
public static final byte A = 0;

View File

@ -30,5 +30,23 @@ public final class StructInNestedNS extends Struct {
public StructInNestedNS get(int j) { return get(new StructInNestedNS(), j); }
public StructInNestedNS get(StructInNestedNS obj, int j) { return obj.__assign(__element(j), bb); }
}
public StructInNestedNST unpack() {
StructInNestedNST _o = new StructInNestedNST();
unpackTo(_o);
return _o;
}
public void unpackTo(StructInNestedNST _o) {
int _oA = a();
_o.setA(_oA);
int _oB = b();
_o.setB(_oB);
}
public static int pack(FlatBufferBuilder builder, StructInNestedNST _o) {
if (_o == null) return 0;
return createStructInNestedNS(
builder,
_o.getA(),
_o.getB());
}
}

View File

@ -0,0 +1,28 @@
// automatically generated by the FlatBuffers compiler, do not modify
package NamespaceA.NamespaceB;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class StructInNestedNST {
private int a;
private int b;
public int getA() { return a; }
public void setA(int a) { this.a = a; }
public int getB() { return b; }
public void setB(int b) { this.b = b; }
public StructInNestedNST() {
this.a = 0;
this.b = 0;
}
}

View File

@ -38,5 +38,20 @@ public final class TableInNestedNS extends Table {
public TableInNestedNS get(int j) { return get(new TableInNestedNS(), j); }
public TableInNestedNS get(TableInNestedNS obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
public TableInNestedNST unpack() {
TableInNestedNST _o = new TableInNestedNST();
unpackTo(_o);
return _o;
}
public void unpackTo(TableInNestedNST _o) {
int _oFoo = foo();
_o.setFoo(_oFoo);
}
public static int pack(FlatBufferBuilder builder, TableInNestedNST _o) {
if (_o == null) return 0;
return createTableInNestedNS(
builder,
_o.getFoo());
}
}

View File

@ -0,0 +1,22 @@
// automatically generated by the FlatBuffers compiler, do not modify
package NamespaceA.NamespaceB;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class TableInNestedNST {
private int foo;
public int getFoo() { return foo; }
public void setFoo(int foo) { this.foo = foo; }
public TableInNestedNST() {
this.foo = 0;
}
}

View File

@ -2,6 +2,7 @@
package NamespaceA.NamespaceB;
@SuppressWarnings("unused")
public final class UnionInNestedNS {
private UnionInNestedNS() { }
public static final byte NONE = 0;

View File

@ -0,0 +1,33 @@
// automatically generated by the FlatBuffers compiler, do not modify
package NamespaceA.NamespaceB;
import com.google.flatbuffers.FlatBufferBuilder;
public class UnionInNestedNSUnion {
private byte type;
private Object value;
public byte getType() { return type; }
public void setType(byte type) { this.type = type; }
public Object getValue() { return value; }
public void setValue(Object value) { this.value = value; }
public UnionInNestedNSUnion() {
this.type = UnionInNestedNS.NONE;
this.value = null;
}
public NamespaceA.NamespaceB.TableInNestedNST asTableInNestedNS() { return (NamespaceA.NamespaceB.TableInNestedNST) value; }
public static int pack(FlatBufferBuilder builder, UnionInNestedNSUnion _o) {
switch (_o.type) {
case UnionInNestedNS.TableInNestedNS: return NamespaceA.NamespaceB.TableInNestedNS.pack(builder, _o.asTableInNestedNS());
default: return 0;
}
}
}

View File

@ -19,9 +19,9 @@ public final class SecondTableInA extends Table {
public NamespaceC.TableInC referToC(NamespaceC.TableInC obj) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
public static int createSecondTableInA(FlatBufferBuilder builder,
int refer_to_cOffset) {
int referToCOffset) {
builder.startTable(1);
SecondTableInA.addReferToC(builder, refer_to_cOffset);
SecondTableInA.addReferToC(builder, referToCOffset);
return SecondTableInA.endSecondTableInA(builder);
}
@ -38,5 +38,21 @@ public final class SecondTableInA extends Table {
public SecondTableInA get(int j) { return get(new SecondTableInA(), j); }
public SecondTableInA get(SecondTableInA obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
public SecondTableInAT unpack() {
SecondTableInAT _o = new SecondTableInAT();
unpackTo(_o);
return _o;
}
public void unpackTo(SecondTableInAT _o) {
if (referToC() != null) _o.setReferToC(referToC().unpack());
else _o.setReferToC(null);
}
public static int pack(FlatBufferBuilder builder, SecondTableInAT _o) {
if (_o == null) return 0;
int _refer_to_c = _o.getReferToC() == null ? 0 : NamespaceC.TableInC.pack(builder, _o.getReferToC());
return createSecondTableInA(
builder,
_refer_to_c);
}
}

View File

@ -0,0 +1,22 @@
// automatically generated by the FlatBuffers compiler, do not modify
package NamespaceA;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class SecondTableInAT {
private NamespaceC.TableInCT referToC;
public NamespaceC.TableInCT getReferToC() { return referToC; }
public void setReferToC(NamespaceC.TableInCT referToC) { this.referToC = referToC; }
public SecondTableInAT() {
this.referToC = null;
}
}

View File

@ -41,5 +41,43 @@ public final class TableInFirstNS extends Table {
public TableInFirstNS get(int j) { return get(new TableInFirstNS(), j); }
public TableInFirstNS get(TableInFirstNS obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
public TableInFirstNST unpack() {
TableInFirstNST _o = new TableInFirstNST();
unpackTo(_o);
return _o;
}
public void unpackTo(TableInFirstNST _o) {
if (fooTable() != null) _o.setFooTable(fooTable().unpack());
else _o.setFooTable(null);
byte _oFooEnum = fooEnum();
_o.setFooEnum(_oFooEnum);
NamespaceA.NamespaceB.UnionInNestedNSUnion _oFooUnion = new NamespaceA.NamespaceB.UnionInNestedNSUnion();
byte _oFooUnionType = fooUnionType();
_oFooUnion.setType(_oFooUnionType);
Table _oFooUnionValue;
switch (_oFooUnionType) {
case NamespaceA.NamespaceB.UnionInNestedNS.TableInNestedNS:
_oFooUnionValue = fooUnion(new NamespaceA.NamespaceB.TableInNestedNS());
_oFooUnion.setValue(_oFooUnionValue != null ? ((NamespaceA.NamespaceB.TableInNestedNS) _oFooUnionValue).unpack() : null);
break;
default: break;
}
_o.setFooUnion(_oFooUnion);
if (fooStruct() != null) fooStruct().unpackTo(_o.getFooStruct());
else _o.setFooStruct(null);
}
public static int pack(FlatBufferBuilder builder, TableInFirstNST _o) {
if (_o == null) return 0;
int _foo_table = _o.getFooTable() == null ? 0 : NamespaceA.NamespaceB.TableInNestedNS.pack(builder, _o.getFooTable());
byte _fooUnionType = _o.getFooUnion() == null ? NamespaceA.NamespaceB.UnionInNestedNS.NONE : _o.getFooUnion().getType();
int _fooUnion = _o.getFooUnion() == null ? 0 : NamespaceA.NamespaceB.UnionInNestedNSUnion.pack(builder, _o.getFooUnion());
startTableInFirstNS(builder);
addFooTable(builder, _foo_table);
addFooEnum(builder, _o.getFooEnum());
addFooUnionType(builder, _fooUnionType);
addFooUnion(builder, _fooUnion);
addFooStruct(builder, NamespaceA.NamespaceB.StructInNestedNS.pack(builder, _o.getFooStruct()));
return endTableInFirstNS(builder);
}
}

View File

@ -0,0 +1,40 @@
// automatically generated by the FlatBuffers compiler, do not modify
package NamespaceA;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class TableInFirstNST {
private NamespaceA.NamespaceB.TableInNestedNST fooTable;
private byte fooEnum;
private NamespaceA.NamespaceB.UnionInNestedNSUnion fooUnion;
private NamespaceA.NamespaceB.StructInNestedNST fooStruct;
public NamespaceA.NamespaceB.TableInNestedNST getFooTable() { return fooTable; }
public void setFooTable(NamespaceA.NamespaceB.TableInNestedNST fooTable) { this.fooTable = fooTable; }
public byte getFooEnum() { return fooEnum; }
public void setFooEnum(byte fooEnum) { this.fooEnum = fooEnum; }
public NamespaceA.NamespaceB.UnionInNestedNSUnion getFooUnion() { return fooUnion; }
public void setFooUnion(NamespaceA.NamespaceB.UnionInNestedNSUnion fooUnion) { this.fooUnion = fooUnion; }
public NamespaceA.NamespaceB.StructInNestedNST getFooStruct() { return fooStruct; }
public void setFooStruct(NamespaceA.NamespaceB.StructInNestedNST fooStruct) { this.fooStruct = fooStruct; }
public TableInFirstNST() {
this.fooTable = null;
this.fooEnum = 0;
this.fooUnion = null;
this.fooStruct = new NamespaceA.NamespaceB.StructInNestedNST();
}
}

View File

@ -21,11 +21,11 @@ public final class TableInC extends Table {
public NamespaceA.SecondTableInA referToA2(NamespaceA.SecondTableInA obj) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
public static int createTableInC(FlatBufferBuilder builder,
int refer_to_a1Offset,
int refer_to_a2Offset) {
int referToA1Offset,
int referToA2Offset) {
builder.startTable(2);
TableInC.addReferToA2(builder, refer_to_a2Offset);
TableInC.addReferToA1(builder, refer_to_a1Offset);
TableInC.addReferToA2(builder, referToA2Offset);
TableInC.addReferToA1(builder, referToA1Offset);
return TableInC.endTableInC(builder);
}
@ -43,5 +43,25 @@ public final class TableInC extends Table {
public TableInC get(int j) { return get(new TableInC(), j); }
public TableInC get(TableInC obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
public TableInCT unpack() {
TableInCT _o = new TableInCT();
unpackTo(_o);
return _o;
}
public void unpackTo(TableInCT _o) {
if (referToA1() != null) _o.setReferToA1(referToA1().unpack());
else _o.setReferToA1(null);
if (referToA2() != null) _o.setReferToA2(referToA2().unpack());
else _o.setReferToA2(null);
}
public static int pack(FlatBufferBuilder builder, TableInCT _o) {
if (_o == null) return 0;
int _refer_to_a1 = _o.getReferToA1() == null ? 0 : NamespaceA.TableInFirstNS.pack(builder, _o.getReferToA1());
int _refer_to_a2 = _o.getReferToA2() == null ? 0 : NamespaceA.SecondTableInA.pack(builder, _o.getReferToA2());
return createTableInC(
builder,
_refer_to_a1,
_refer_to_a2);
}
}

View File

@ -0,0 +1,28 @@
// automatically generated by the FlatBuffers compiler, do not modify
package NamespaceC;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class TableInCT {
private NamespaceA.TableInFirstNST referToA1;
private NamespaceA.SecondTableInAT referToA2;
public NamespaceA.TableInFirstNST getReferToA1() { return referToA1; }
public void setReferToA1(NamespaceA.TableInFirstNST referToA1) { this.referToA1 = referToA1; }
public NamespaceA.SecondTableInAT getReferToA2() { return referToA2; }
public void setReferToA2(NamespaceA.SecondTableInAT referToA2) { this.referToA2 = referToA2; }
public TableInCT() {
this.referToA1 = null;
this.referToA2 = null;
}
}

View File

@ -2,6 +2,7 @@
package optional_scalars;
@SuppressWarnings("unused")
public final class OptionalByte {
private OptionalByte() { }
public static final byte None = 0;

View File

@ -66,79 +66,79 @@ public final class ScalarStuff extends Table {
public byte defaultEnum() { int o = __offset(74); return o != 0 ? bb.get(o + bb_pos) : 1; }
public static int createScalarStuff(FlatBufferBuilder builder,
byte just_i8,
byte maybe_i8,
byte default_i8,
int just_u8,
int maybe_u8,
int default_u8,
short just_i16,
short maybe_i16,
short default_i16,
int just_u16,
int maybe_u16,
int default_u16,
int just_i32,
int maybe_i32,
int default_i32,
long just_u32,
long maybe_u32,
long default_u32,
long just_i64,
long maybe_i64,
long default_i64,
long just_u64,
long maybe_u64,
long default_u64,
float just_f32,
float maybe_f32,
float default_f32,
double just_f64,
double maybe_f64,
double default_f64,
boolean just_bool,
boolean maybe_bool,
boolean default_bool,
byte just_enum,
byte maybe_enum,
byte default_enum) {
byte justI8,
byte maybeI8,
byte defaultI8,
int justU8,
int maybeU8,
int defaultU8,
short justI16,
short maybeI16,
short defaultI16,
int justU16,
int maybeU16,
int defaultU16,
int justI32,
int maybeI32,
int defaultI32,
long justU32,
long maybeU32,
long defaultU32,
long justI64,
long maybeI64,
long defaultI64,
long justU64,
long maybeU64,
long defaultU64,
float justF32,
float maybeF32,
float defaultF32,
double justF64,
double maybeF64,
double defaultF64,
boolean justBool,
boolean maybeBool,
boolean defaultBool,
byte justEnum,
byte maybeEnum,
byte defaultEnum) {
builder.startTable(36);
ScalarStuff.addDefaultF64(builder, default_f64);
ScalarStuff.addMaybeF64(builder, maybe_f64);
ScalarStuff.addJustF64(builder, just_f64);
ScalarStuff.addDefaultU64(builder, default_u64);
ScalarStuff.addMaybeU64(builder, maybe_u64);
ScalarStuff.addJustU64(builder, just_u64);
ScalarStuff.addDefaultI64(builder, default_i64);
ScalarStuff.addMaybeI64(builder, maybe_i64);
ScalarStuff.addJustI64(builder, just_i64);
ScalarStuff.addDefaultF32(builder, default_f32);
ScalarStuff.addMaybeF32(builder, maybe_f32);
ScalarStuff.addJustF32(builder, just_f32);
ScalarStuff.addDefaultU32(builder, default_u32);
ScalarStuff.addMaybeU32(builder, maybe_u32);
ScalarStuff.addJustU32(builder, just_u32);
ScalarStuff.addDefaultI32(builder, default_i32);
ScalarStuff.addMaybeI32(builder, maybe_i32);
ScalarStuff.addJustI32(builder, just_i32);
ScalarStuff.addDefaultU16(builder, default_u16);
ScalarStuff.addMaybeU16(builder, maybe_u16);
ScalarStuff.addJustU16(builder, just_u16);
ScalarStuff.addDefaultI16(builder, default_i16);
ScalarStuff.addMaybeI16(builder, maybe_i16);
ScalarStuff.addJustI16(builder, just_i16);
ScalarStuff.addDefaultEnum(builder, default_enum);
ScalarStuff.addMaybeEnum(builder, maybe_enum);
ScalarStuff.addJustEnum(builder, just_enum);
ScalarStuff.addDefaultBool(builder, default_bool);
ScalarStuff.addMaybeBool(builder, maybe_bool);
ScalarStuff.addJustBool(builder, just_bool);
ScalarStuff.addDefaultU8(builder, default_u8);
ScalarStuff.addMaybeU8(builder, maybe_u8);
ScalarStuff.addJustU8(builder, just_u8);
ScalarStuff.addDefaultI8(builder, default_i8);
ScalarStuff.addMaybeI8(builder, maybe_i8);
ScalarStuff.addJustI8(builder, just_i8);
ScalarStuff.addDefaultF64(builder, defaultF64);
ScalarStuff.addMaybeF64(builder, maybeF64);
ScalarStuff.addJustF64(builder, justF64);
ScalarStuff.addDefaultU64(builder, defaultU64);
ScalarStuff.addMaybeU64(builder, maybeU64);
ScalarStuff.addJustU64(builder, justU64);
ScalarStuff.addDefaultI64(builder, defaultI64);
ScalarStuff.addMaybeI64(builder, maybeI64);
ScalarStuff.addJustI64(builder, justI64);
ScalarStuff.addDefaultF32(builder, defaultF32);
ScalarStuff.addMaybeF32(builder, maybeF32);
ScalarStuff.addJustF32(builder, justF32);
ScalarStuff.addDefaultU32(builder, defaultU32);
ScalarStuff.addMaybeU32(builder, maybeU32);
ScalarStuff.addJustU32(builder, justU32);
ScalarStuff.addDefaultI32(builder, defaultI32);
ScalarStuff.addMaybeI32(builder, maybeI32);
ScalarStuff.addJustI32(builder, justI32);
ScalarStuff.addDefaultU16(builder, defaultU16);
ScalarStuff.addMaybeU16(builder, maybeU16);
ScalarStuff.addJustU16(builder, justU16);
ScalarStuff.addDefaultI16(builder, defaultI16);
ScalarStuff.addMaybeI16(builder, maybeI16);
ScalarStuff.addJustI16(builder, justI16);
ScalarStuff.addDefaultEnum(builder, defaultEnum);
ScalarStuff.addMaybeEnum(builder, maybeEnum);
ScalarStuff.addJustEnum(builder, justEnum);
ScalarStuff.addDefaultBool(builder, defaultBool);
ScalarStuff.addMaybeBool(builder, maybeBool);
ScalarStuff.addJustBool(builder, justBool);
ScalarStuff.addDefaultU8(builder, defaultU8);
ScalarStuff.addMaybeU8(builder, maybeU8);
ScalarStuff.addJustU8(builder, justU8);
ScalarStuff.addDefaultI8(builder, defaultI8);
ScalarStuff.addMaybeI8(builder, maybeI8);
ScalarStuff.addJustI8(builder, justI8);
return ScalarStuff.endScalarStuff(builder);
}
@ -146,21 +146,21 @@ public final class ScalarStuff extends Table {
public static void addJustI8(FlatBufferBuilder builder, byte justI8) { builder.addByte(0, justI8, 0); }
public static void addMaybeI8(FlatBufferBuilder builder, byte maybeI8) { builder.addByte(1, maybeI8, 0); }
public static void addDefaultI8(FlatBufferBuilder builder, byte defaultI8) { builder.addByte(2, defaultI8, 42); }
public static void addJustU8(FlatBufferBuilder builder, int justU8) { builder.addByte(3, (byte)justU8, (byte)0); }
public static void addMaybeU8(FlatBufferBuilder builder, int maybeU8) { builder.addByte(4, (byte)maybeU8, (byte)0); }
public static void addDefaultU8(FlatBufferBuilder builder, int defaultU8) { builder.addByte(5, (byte)defaultU8, (byte)42); }
public static void addJustU8(FlatBufferBuilder builder, int justU8) { builder.addByte(3, (byte) justU8, (byte) 0); }
public static void addMaybeU8(FlatBufferBuilder builder, int maybeU8) { builder.addByte(4, (byte) maybeU8, (byte) 0); }
public static void addDefaultU8(FlatBufferBuilder builder, int defaultU8) { builder.addByte(5, (byte) defaultU8, (byte) 42); }
public static void addJustI16(FlatBufferBuilder builder, short justI16) { builder.addShort(6, justI16, 0); }
public static void addMaybeI16(FlatBufferBuilder builder, short maybeI16) { builder.addShort(7, maybeI16, 0); }
public static void addDefaultI16(FlatBufferBuilder builder, short defaultI16) { builder.addShort(8, defaultI16, 42); }
public static void addJustU16(FlatBufferBuilder builder, int justU16) { builder.addShort(9, (short)justU16, (short)0); }
public static void addMaybeU16(FlatBufferBuilder builder, int maybeU16) { builder.addShort(10, (short)maybeU16, (short)0); }
public static void addDefaultU16(FlatBufferBuilder builder, int defaultU16) { builder.addShort(11, (short)defaultU16, (short)42); }
public static void addJustU16(FlatBufferBuilder builder, int justU16) { builder.addShort(9, (short) justU16, (short) 0); }
public static void addMaybeU16(FlatBufferBuilder builder, int maybeU16) { builder.addShort(10, (short) maybeU16, (short) 0); }
public static void addDefaultU16(FlatBufferBuilder builder, int defaultU16) { builder.addShort(11, (short) defaultU16, (short) 42); }
public static void addJustI32(FlatBufferBuilder builder, int justI32) { builder.addInt(12, justI32, 0); }
public static void addMaybeI32(FlatBufferBuilder builder, int maybeI32) { builder.addInt(13, maybeI32, 0); }
public static void addDefaultI32(FlatBufferBuilder builder, int defaultI32) { builder.addInt(14, defaultI32, 42); }
public static void addJustU32(FlatBufferBuilder builder, long justU32) { builder.addInt(15, (int)justU32, (int)0L); }
public static void addMaybeU32(FlatBufferBuilder builder, long maybeU32) { builder.addInt(16, (int)maybeU32, (int)0L); }
public static void addDefaultU32(FlatBufferBuilder builder, long defaultU32) { builder.addInt(17, (int)defaultU32, (int)42L); }
public static void addJustU32(FlatBufferBuilder builder, long justU32) { builder.addInt(15, (int) justU32, (int) 0L); }
public static void addMaybeU32(FlatBufferBuilder builder, long maybeU32) { builder.addInt(16, (int) maybeU32, (int) 0L); }
public static void addDefaultU32(FlatBufferBuilder builder, long defaultU32) { builder.addInt(17, (int) defaultU32, (int) 42L); }
public static void addJustI64(FlatBufferBuilder builder, long justI64) { builder.addLong(18, justI64, 0L); }
public static void addMaybeI64(FlatBufferBuilder builder, long maybeI64) { builder.addLong(19, maybeI64, 0L); }
public static void addDefaultI64(FlatBufferBuilder builder, long defaultI64) { builder.addLong(20, defaultI64, 42L); }

View File

@ -1554,9 +1554,7 @@ void FuzzTest2() {
}
}
AddToSchemaAndInstances(deprecated ? "(deprecated);\n" : ";\n",
deprecated ? ""
: is_last_field ? "\n"
: ",\n");
deprecated ? "" : is_last_field ? "\n" : ",\n");
}
AddToSchemaAndInstances("}\n\n", "}");
}

View File

@ -17,9 +17,9 @@ public final class Attacker extends Table {
public boolean mutateSwordAttackDamage(int sword_attack_damage) { int o = __offset(4); if (o != 0) { bb.putInt(o + bb_pos, sword_attack_damage); return true; } else { return false; } }
public static int createAttacker(FlatBufferBuilder builder,
int sword_attack_damage) {
int swordAttackDamage) {
builder.startTable(1);
Attacker.addSwordAttackDamage(builder, sword_attack_damage);
Attacker.addSwordAttackDamage(builder, swordAttackDamage);
return Attacker.endAttacker(builder);
}
@ -36,5 +36,20 @@ public final class Attacker extends Table {
public Attacker get(int j) { return get(new Attacker(), j); }
public Attacker get(Attacker obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
public AttackerT unpack() {
AttackerT _o = new AttackerT();
unpackTo(_o);
return _o;
}
public void unpackTo(AttackerT _o) {
int _oSwordAttackDamage = swordAttackDamage();
_o.setSwordAttackDamage(_oSwordAttackDamage);
}
public static int pack(FlatBufferBuilder builder, AttackerT _o) {
if (_o == null) return 0;
return createAttacker(
builder,
_o.getSwordAttackDamage());
}
}

View File

@ -0,0 +1,20 @@
// automatically generated by the FlatBuffers compiler, do not modify
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class AttackerT {
private int swordAttackDamage;
public int getSwordAttackDamage() { return swordAttackDamage; }
public void setSwordAttackDamage(int swordAttackDamage) { this.swordAttackDamage = swordAttackDamage; }
public AttackerT() {
this.swordAttackDamage = 0;
}
}

View File

@ -25,5 +25,20 @@ public final class BookReader extends Struct {
public BookReader get(int j) { return get(new BookReader(), j); }
public BookReader get(BookReader obj, int j) { return obj.__assign(__element(j), bb); }
}
public BookReaderT unpack() {
BookReaderT _o = new BookReaderT();
unpackTo(_o);
return _o;
}
public void unpackTo(BookReaderT _o) {
int _oBooksRead = booksRead();
_o.setBooksRead(_oBooksRead);
}
public static int pack(FlatBufferBuilder builder, BookReaderT _o) {
if (_o == null) return 0;
return createBookReader(
builder,
_o.getBooksRead());
}
}

View File

@ -0,0 +1,20 @@
// automatically generated by the FlatBuffers compiler, do not modify
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class BookReaderT {
private int booksRead;
public int getBooksRead() { return booksRead; }
public void setBooksRead(int booksRead) { this.booksRead = booksRead; }
public BookReaderT() {
this.booksRead = 0;
}
}

View File

@ -1,5 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
@SuppressWarnings("unused")
public final class Character {
private Character() { }
public static final byte NONE = 0;

View File

@ -0,0 +1,41 @@
// automatically generated by the FlatBuffers compiler, do not modify
import com.google.flatbuffers.FlatBufferBuilder;
public class CharacterUnion {
private byte type;
private Object value;
public byte getType() { return type; }
public void setType(byte type) { this.type = type; }
public Object getValue() { return value; }
public void setValue(Object value) { this.value = value; }
public CharacterUnion() {
this.type = Character.NONE;
this.value = null;
}
public AttackerT asMuLan() { return (AttackerT) value; }
public RapunzelT asRapunzel() { return (RapunzelT) value; }
public BookReaderT asBelle() { return (BookReaderT) value; }
public BookReaderT asBookFan() { return (BookReaderT) value; }
public String asOther() { return (String) value; }
public String asUnused() { return (String) value; }
public static int pack(FlatBufferBuilder builder, CharacterUnion _o) {
switch (_o.type) {
case Character.MuLan: return Attacker.pack(builder, _o.asMuLan());
case Character.Rapunzel: return Rapunzel.pack(builder, _o.asRapunzel());
case Character.Belle: return BookReader.pack(builder, _o.asBelle());
case Character.BookFan: return BookReader.pack(builder, _o.asBookFan());
case Character.Other: return builder.createString(_o.asOther());
case Character.Unused: return builder.createString(_o.asUnused());
default: return 0;
}
}
}

View File

@ -28,15 +28,15 @@ public final class Movie extends Table {
public UnionVector charactersVector(UnionVector obj) { int o = __offset(10); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
public static int createMovie(FlatBufferBuilder builder,
byte main_character_type,
int main_characterOffset,
int characters_typeOffset,
byte mainCharacterType,
int mainCharacterOffset,
int charactersTypeOffset,
int charactersOffset) {
builder.startTable(4);
Movie.addCharacters(builder, charactersOffset);
Movie.addCharactersType(builder, characters_typeOffset);
Movie.addMainCharacter(builder, main_characterOffset);
Movie.addMainCharacterType(builder, main_character_type);
Movie.addCharactersType(builder, charactersTypeOffset);
Movie.addMainCharacter(builder, mainCharacterOffset);
Movie.addMainCharacterType(builder, mainCharacterType);
return Movie.endMovie(builder);
}
@ -62,5 +62,65 @@ public final class Movie extends Table {
public Movie get(int j) { return get(new Movie(), j); }
public Movie get(Movie obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
public MovieT unpack() {
MovieT _o = new MovieT();
unpackTo(_o);
return _o;
}
public void unpackTo(MovieT _o) {
CharacterUnion _oMainCharacter = new CharacterUnion();
byte _oMainCharacterType = mainCharacterType();
_oMainCharacter.setType(_oMainCharacterType);
Table _oMainCharacterValue;
switch (_oMainCharacterType) {
case Character.MuLan:
_oMainCharacterValue = mainCharacter(new Attacker());
_oMainCharacter.setValue(_oMainCharacterValue != null ? ((Attacker) _oMainCharacterValue).unpack() : null);
break;
default: break;
}
_o.setMainCharacter(_oMainCharacter);
CharacterUnion[] _oCharacters = new CharacterUnion[charactersLength()];
for (int _j = 0; _j < charactersLength(); ++_j) {
CharacterUnion _oCharactersElement = new CharacterUnion();
byte _oCharactersElementType = charactersType(_j);
_oCharactersElement.setType(_oCharactersElementType);
Table _oCharactersElementValue;
switch (_oCharactersElementType) {
case Character.MuLan:
_oCharactersElementValue = characters(new Attacker(), _j);
_oCharactersElement.setValue(_oCharactersElementValue != null ? ((Attacker) _oCharactersElementValue).unpack() : null);
break;
default: break;
}
_oCharacters[_j] = _oCharactersElement;
}
_o.setCharacters(_oCharacters);
}
public static int pack(FlatBufferBuilder builder, MovieT _o) {
if (_o == null) return 0;
byte _mainCharacterType = _o.getMainCharacter() == null ? Character.NONE : _o.getMainCharacter().getType();
int _mainCharacter = _o.getMainCharacter() == null ? 0 : CharacterUnion.pack(builder, _o.getMainCharacter());
int _charactersType = 0;
if (_o.getCharacters() != null) {
byte[] __charactersType = new byte[_o.getCharacters().length];
int _j = 0;
for (CharacterUnion _e : _o.getCharacters()) { __charactersType[_j] = _o.getCharacters()[_j].getType(); _j++;}
_charactersType = createCharactersTypeVector(builder, __charactersType);
}
int _characters = 0;
if (_o.getCharacters() != null) {
int[] __characters = new int[_o.getCharacters().length];
int _j = 0;
for (CharacterUnion _e : _o.getCharacters()) { __characters[_j] = CharacterUnion.pack(builder, _o.getCharacters()[_j]); _j++;}
_characters = createCharactersVector(builder, __characters);
}
return createMovie(
builder,
_mainCharacterType,
_mainCharacter,
_charactersType,
_characters);
}
}

View File

@ -0,0 +1,34 @@
// automatically generated by the FlatBuffers compiler, do not modify
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class MovieT {
private CharacterUnion mainCharacter;
private CharacterUnion[] characters;
public CharacterUnion getMainCharacter() { return mainCharacter; }
public void setMainCharacter(CharacterUnion mainCharacter) { this.mainCharacter = mainCharacter; }
public CharacterUnion[] getCharacters() { return characters; }
public void setCharacters(CharacterUnion[] characters) { this.characters = characters; }
public MovieT() {
this.mainCharacter = null;
this.characters = null;
}
public static MovieT deserializeFromBinary(byte[] fbBuffer) {
return Movie.getRootAsMovie(ByteBuffer.wrap(fbBuffer)).unpack();
}
public byte[] serializeToBinary() {
FlatBufferBuilder fbb = new FlatBufferBuilder();
Movie.finishMovieBuffer(fbb, Movie.pack(fbb, this));
return fbb.sizedByteArray();
}
}

View File

@ -25,5 +25,20 @@ public final class Rapunzel extends Struct {
public Rapunzel get(int j) { return get(new Rapunzel(), j); }
public Rapunzel get(Rapunzel obj, int j) { return obj.__assign(__element(j), bb); }
}
public RapunzelT unpack() {
RapunzelT _o = new RapunzelT();
unpackTo(_o);
return _o;
}
public void unpackTo(RapunzelT _o) {
int _oHairLength = hairLength();
_o.setHairLength(_oHairLength);
}
public static int pack(FlatBufferBuilder builder, RapunzelT _o) {
if (_o == null) return 0;
return createRapunzel(
builder,
_o.getHairLength());
}
}

View File

@ -0,0 +1,20 @@
// automatically generated by the FlatBuffers compiler, do not modify
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
public class RapunzelT {
private int hairLength;
public int getHairLength() { return hairLength; }
public void setHairLength(int hairLength) { this.hairLength = hairLength; }
public RapunzelT() {
this.hairLength = 0;
}
}