Merge "Added the hash attribute to ints and longs." into ub-games-master

This commit is contained in:
Alex Ames
2015-02-17 22:58:04 +00:00
committed by Android (Google) Code Review
11 changed files with 333 additions and 6 deletions

View File

@@ -44,6 +44,14 @@ table Monster {
testnestedflatbuffer:[ubyte] (id:13, nested_flatbuffer: "Monster");
testempty:Stat (id:14);
testbool:bool (id:15);
testhashs32_fnv1:int (id:16, hash:"fnv1_32");
testhashu32_fnv1:uint (id:17, hash:"fnv1_32");
testhashs64_fnv1:long (id:18, hash:"fnv1_64");
testhashu64_fnv1:ulong (id:19, hash:"fnv1_64");
testhashs32_fnv1a:int (id:20, hash:"fnv1a_32");
testhashu32_fnv1a:uint (id:21, hash:"fnv1a_32");
testhashs64_fnv1a:long (id:22, hash:"fnv1a_64");
testhashu64_fnv1a:ulong (id:23, hash:"fnv1a_64");
}
root_type Monster;

View File

@@ -141,6 +141,10 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
const Monster *testnestedflatbuffer_nested_root() const { return flatbuffers::GetRoot<Monster>(testnestedflatbuffer()->Data()); }
const Stat *testempty() const { return GetPointer<const Stat *>(32); }
uint8_t testbool() const { return GetField<uint8_t>(34, 0); }
int32_t testhashs32_fnv1() const { return GetField<int32_t>(36, 0); }
uint32_t testhashu32_fnv1() const { return GetField<uint32_t>(38, 0); }
int64_t testhashs64_fnv1() const { return GetField<int64_t>(40, 0); }
uint64_t testhashu64_fnv1() const { return GetField<uint64_t>(42, 0); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<Vec3>(verifier, 4 /* pos */) &&
@@ -169,6 +173,10 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VerifyField<flatbuffers::uoffset_t>(verifier, 32 /* testempty */) &&
verifier.VerifyTable(testempty()) &&
VerifyField<uint8_t>(verifier, 34 /* testbool */) &&
VerifyField<int32_t>(verifier, 36 /* testhashs32_fnv1 */) &&
VerifyField<uint32_t>(verifier, 38 /* testhashu32_fnv1 */) &&
VerifyField<int64_t>(verifier, 40 /* testhashs64_fnv1 */) &&
VerifyField<uint64_t>(verifier, 42 /* testhashu64_fnv1 */) &&
verifier.EndTable();
}
};
@@ -191,10 +199,14 @@ struct MonsterBuilder {
void add_testnestedflatbuffer(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testnestedflatbuffer) { fbb_.AddOffset(30, testnestedflatbuffer); }
void add_testempty(flatbuffers::Offset<Stat> testempty) { fbb_.AddOffset(32, testempty); }
void add_testbool(uint8_t testbool) { fbb_.AddElement<uint8_t>(34, testbool, 0); }
void add_testhashs32_fnv1(int32_t testhashs32_fnv1) { fbb_.AddElement<int32_t>(36, testhashs32_fnv1, 0); }
void add_testhashu32_fnv1(uint32_t testhashu32_fnv1) { fbb_.AddElement<uint32_t>(38, testhashu32_fnv1, 0); }
void add_testhashs64_fnv1(int64_t testhashs64_fnv1) { fbb_.AddElement<int64_t>(40, testhashs64_fnv1, 0); }
void add_testhashu64_fnv1(uint64_t testhashu64_fnv1) { fbb_.AddElement<uint64_t>(42, testhashu64_fnv1, 0); }
MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
MonsterBuilder &operator=(const MonsterBuilder &);
flatbuffers::Offset<Monster> Finish() {
auto o = flatbuffers::Offset<Monster>(fbb_.EndTable(start_, 16));
auto o = flatbuffers::Offset<Monster>(fbb_.EndTable(start_, 20));
fbb_.Required(o, 10); // name
return o;
}
@@ -215,8 +227,16 @@ inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder
flatbuffers::Offset<Monster> enemy = 0,
flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testnestedflatbuffer = 0,
flatbuffers::Offset<Stat> testempty = 0,
uint8_t testbool = 0) {
uint8_t testbool = 0,
int32_t testhashs32_fnv1 = 0,
uint32_t testhashu32_fnv1 = 0,
int64_t testhashs64_fnv1 = 0,
uint64_t testhashu64_fnv1 = 0) {
MonsterBuilder builder_(_fbb);
builder_.add_testhashu64_fnv1(testhashu64_fnv1);
builder_.add_testhashs64_fnv1(testhashs64_fnv1);
builder_.add_testhashu32_fnv1(testhashu32_fnv1);
builder_.add_testhashs32_fnv1(testhashs32_fnv1);
builder_.add_testempty(testempty);
builder_.add_testnestedflatbuffer(testnestedflatbuffer);
builder_.add_enemy(enemy);

View File

@@ -36,5 +36,13 @@
testarrayofstring: [
"test1",
"test2"
]
],
testhashs32_fnv1: -579221183,
testhashu32_fnv1: 3715746113,
testhashs64_fnv1: 7930699090847568257,
testhashu64_fnv1: 7930699090847568257,
testhashs32_fnv1a: -1904106383,
testhashu32_fnv1a: 2390860913,
testhashs64_fnv1a: 4898026182817603057,
testhashu64_fnv1a: 4898026182817603057
}

View File

@@ -36,5 +36,13 @@
testarrayofstring: [
"test1",
"test2"
]
],
testhashs32_fnv1: "This string is being hashed!",
testhashu32_fnv1: "This string is being hashed!",
testhashs64_fnv1: "This string is being hashed!",
testhashu64_fnv1: "This string is being hashed!",
testhashs32_fnv1a: "This string is being hashed!",
testhashu32_fnv1a: "This string is being hashed!",
testhashs64_fnv1a: "This string is being hashed!",
testhashu64_fnv1a: "This string is being hashed!",
}

Binary file not shown.