From 9b3d8b318a3bc9d71d08b50d723996f556557c86 Mon Sep 17 00:00:00 2001 From: Wouter van Oortmerssen Date: Fri, 27 Jan 2017 15:28:57 -0800 Subject: Added tracking of order of types declared. Change-Id: Iade313c99f119dcf1619674260648a33f61dc030 --- include/flatbuffers/idl.h | 1 + src/idl_parser.cpp | 4 ++++ tests/union_vector/union_vector_generated.h | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/flatbuffers/idl.h b/include/flatbuffers/idl.h index aab4b8fa..898b4104 100644 --- a/include/flatbuffers/idl.h +++ b/include/flatbuffers/idl.h @@ -578,6 +578,7 @@ private: BaseType baseType); public: + SymbolTable types_; SymbolTable structs_; SymbolTable enums_; SymbolTable services_; diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp index fa7b98bf..5974d044 100644 --- a/src/idl_parser.cpp +++ b/src/idl_parser.cpp @@ -1314,6 +1314,8 @@ CheckedError Parser::ParseEnum(bool is_union, EnumDef **dest) { } } if (dest) *dest = &enum_def; + types_.Add(namespaces_.back()->GetFullyQualifiedName(enum_def.name), + new Type(BASE_TYPE_UNION, nullptr, &enum_def)); return NoError(); } @@ -1419,6 +1421,8 @@ CheckedError Parser::ParseDecl() { ECHECK(CheckClash(fields, struct_def, "_byte_vector", BASE_TYPE_STRING)); ECHECK(CheckClash(fields, struct_def, "ByteVector", BASE_TYPE_STRING)); EXPECT('}'); + types_.Add(namespaces_.back()->GetFullyQualifiedName(struct_def->name), + new Type(BASE_TYPE_STRUCT, struct_def, nullptr)); return NoError(); } diff --git a/tests/union_vector/union_vector_generated.h b/tests/union_vector/union_vector_generated.h index 180b3d99..560860c6 100644 --- a/tests/union_vector/union_vector_generated.h +++ b/tests/union_vector/union_vector_generated.h @@ -266,8 +266,8 @@ inline bool VerifyCharacterVector(flatbuffers::Verifier &verifier, const flatbuf if (values->size() != types->size()) return false; for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { if (!VerifyCharacter( - verifier, values->Get(i), types->GetEnum(i))) { - return false; + verifier, values->Get(i), types->GetEnum(i))) { + return false; } } return true; -- cgit v1.2.3