Changes for verifying a buffer dynamically using reflection. (#4102)
* Changes for verifying a buffer dynamically using reflection.
* Fixing build issues on linux and applied code reformatting.
* Fixing the file order in cmake file that was messing up the macro based code inclusion.
Added tests for reflection based verification.
* Changes for verifying a buffer dynamically using reflection.
Fixing build issues on linux and applied code reformatting.
Fixing the file order in cmake file that was messing up the macro based code inclusion.
Added tests for reflection based verification.
* Incorporated the code review changes that were requested:
1. Changed the Verify function signature.
2. Changed the variable names to use snake_case.
3. Added better comments.
4. Refactored duplicate code.
5. Changed the verifier class so that it has the same size when compiled with or without FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE macro.
* Setting FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE and FLATBUFFERS_DEBUG_VERIFICATION_FAILURE through cmake for flattests so that it gets propagted to all translation units of flattests.
* Making the Verifier struct fields the same in all cases. Also reverting the target_compile_definitions change in cmake file because build machine on travis does not have cmake version 3.0 or higher which was the version when target_compile_definitions was added in cmake.
* Defining macros through cmake in a portable way using functions that are available in cmake 2.8.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7a6b370..7834f7a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -203,6 +203,9 @@
compile_flatbuffers_schema_to_cpp(tests/monster_test.fbs)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests)
add_executable(flattests ${FlatBuffers_Tests_SRCS})
+ set_property(TARGET flattests
+ PROPERTY COMPILE_DEFINITIONS FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
+ FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1)
compile_flatbuffers_schema_to_cpp(samples/monster.fbs)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/samples)