From 3f53f73c6341a3ae49d4c5c98d8a74f6cb0f2875 Mon Sep 17 00:00:00 2001 From: Alex Ames Date: Mon, 21 Jul 2014 16:27:58 -0700 Subject: [PATCH] Corrected the order of the comments on namespace close parens Also removed the semicolon on the bracket. It makes -pedanic unhappy. Bug: 16399323 Change-Id: I16ec0d67af13c3ca0bc6285741f5a95658d262bd --- samples/monster_generated.h | 26 ++++++++++++++++---------- src/idl_gen_cpp.cpp | 6 +++--- tests/monster_test_generated.h | 4 ++-- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/samples/monster_generated.h b/samples/monster_generated.h index 50011b4..ebf7e62 100755 --- a/samples/monster_generated.h +++ b/samples/monster_generated.h @@ -63,14 +63,14 @@ struct Monster : private flatbuffers::Table { int8_t color() const { return GetField(16, 2); } bool Verify(const flatbuffers::Verifier &verifier) const { return VerifyTable(verifier) && - VerifyField(verifier, 4) && - VerifyField(verifier, 6) && - VerifyField(verifier, 8) && - VerifyField(verifier, 10) && + VerifyField(verifier, 4 /* pos */) && + VerifyField(verifier, 6 /* mana */) && + VerifyField(verifier, 8 /* hp */) && + VerifyField(verifier, 10 /* name */) && verifier.Verify(name()) && - VerifyField(verifier, 14) && + VerifyField(verifier, 14 /* inventory */) && verifier.Verify(inventory()) && - VerifyField(verifier, 16); + VerifyField(verifier, 16 /* color */); } }; @@ -88,7 +88,13 @@ struct MonsterBuilder { flatbuffers::Offset Finish() { return flatbuffers::Offset(fbb_.EndTable(start_, 7)); } }; -inline flatbuffers::Offset CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, const Vec3 *pos, int16_t mana, int16_t hp, flatbuffers::Offset name, flatbuffers::Offset> inventory, int8_t color) { +inline flatbuffers::Offset CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, + const Vec3 *pos = 0, + int16_t mana = 150, + int16_t hp = 100, + flatbuffers::Offset name = 0, + flatbuffers::Offset> inventory = 0, + int8_t color = 2) { MonsterBuilder builder_(_fbb); builder_.add_inventory(inventory); builder_.add_name(name); @@ -102,7 +108,7 @@ inline flatbuffers::Offset CreateMonster(flatbuffers::FlatBufferBuilder bool VerifyAny(const flatbuffers::Verifier &verifier, const void *union_obj, uint8_t type) { switch (type) { case Any_NONE: return true; - case Any_Monster: return reinterpret_cast(union_obj)->Verify(verifier); + case Any_Monster: return verifier.VerifyTable(reinterpret_cast(union_obj)); default: return false; } } @@ -111,7 +117,7 @@ inline const Monster *GetMonster(const void *buf) { return flatbuffers::GetRoot< inline bool VerifyMonsterBuffer(const flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer(); } -}; // namespace MyGame -}; // namespace Sample +} // namespace Sample +} // namespace MyGame #endif // FLATBUFFERS_GENERATED_MONSTER_MYGAME_SAMPLE_H_ diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index 8bb7551..d453f57 100644 --- a/src/idl_gen_cpp.cpp +++ b/src/idl_gen_cpp.cpp @@ -480,9 +480,9 @@ std::string GenerateCPP(const Parser &parser, const std::string &include_guard_i } // Close the namespaces. - for (auto it = parser.name_space_.begin(); - it != parser.name_space_.end(); ++it) { - code += "}; // namespace " + *it + "\n"; + for (auto it = parser.name_space_.rbegin(); + it != parser.name_space_.rend(); ++it) { + code += "} // namespace " + *it + "\n"; } // Close the include guard. diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h index e362bd5..c568dfe 100755 --- a/tests/monster_test_generated.h +++ b/tests/monster_test_generated.h @@ -187,7 +187,7 @@ inline const Monster *GetMonster(const void *buf) { return flatbuffers::GetRoot< inline bool VerifyMonsterBuffer(const flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer(); } -}; // namespace MyGame -}; // namespace Example +} // namespace Example +} // namespace MyGame #endif // FLATBUFFERS_GENERATED_MONSTER_TEST_MYGAME_EXAMPLE_H_ -- 2.7.4