diff --git a/build/Xcode/FlatBuffers.xcodeproj/project.pbxproj b/build/Xcode/FlatBuffers.xcodeproj/project.pbxproj index b67ae95b5..dfa2962c7 100644 --- a/build/Xcode/FlatBuffers.xcodeproj/project.pbxproj +++ b/build/Xcode/FlatBuffers.xcodeproj/project.pbxproj @@ -12,8 +12,9 @@ 61823BBC53544106B6DBC38E /* idl_parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3709AC883348409592530AE6 /* idl_parser.cpp */; settings = {COMPILER_FLAGS = ""; }; }; 61FF3C34FBEC4819A1C30F92 /* sample_text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ECCEBFFA6977404F858F9739 /* sample_text.cpp */; settings = {COMPILER_FLAGS = ""; }; }; 8C303C591975D6A700D7C1C5 /* idl_gen_go.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C303C581975D6A700D7C1C5 /* idl_gen_go.cpp */; }; - 8C6905F819F835A900CB8866 /* idl_gen_fbs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C6905F119F835A900CB8866 /* idl_gen_fbs.cpp */; }; 8C6905FD19F835B400CB8866 /* idl_gen_fbs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C6905EC19F8357300CB8866 /* idl_gen_fbs.cpp */; }; + 8C8774631B703D4800E693F5 /* reflection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C8774621B703D4800E693F5 /* reflection.cpp */; }; + 8C8774641B703E1200E693F5 /* idl_gen_fbs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C6905EC19F8357300CB8866 /* idl_gen_fbs.cpp */; }; 8CA854B31B04244A00040A06 /* idl_gen_python.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CA854B21B04244A00040A06 /* idl_gen_python.cpp */; }; 8CD8717B19CB937D0012A827 /* idl_gen_general.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CD8717A19CB937D0012A827 /* idl_gen_general.cpp */; }; A9C9A99F719A4ED58DC2D2FC /* idl_parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3709AC883348409592530AE6 /* idl_parser.cpp */; settings = {COMPILER_FLAGS = ""; }; }; @@ -33,23 +34,15 @@ 3709AC883348409592530AE6 /* idl_parser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_parser.cpp; path = src/idl_parser.cpp; sourceTree = SOURCE_ROOT; }; 3863042BCEC64791BFB48625 /* flatsamplebinary */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; path = flatsamplebinary; sourceTree = BUILT_PRODUCTS_DIR; }; 420E3BC724ED4A008D79297F /* flatsampletext */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; path = flatsampletext; sourceTree = BUILT_PRODUCTS_DIR; }; - 423CA92401AE442B91546E63 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CMakeLists.txt; path = /Users/wvo/flatbuffers_snapshot9/CMakeLists.txt; sourceTree = ""; }; 5EE44BFFAF8E43F485859145 /* sample_binary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sample_binary.cpp; path = samples/sample_binary.cpp; sourceTree = SOURCE_ROOT; }; 6AD24EEB3D024825A37741FF /* test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = test.cpp; path = tests/test.cpp; sourceTree = SOURCE_ROOT; }; 8C303C581975D6A700D7C1C5 /* idl_gen_go.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_gen_go.cpp; path = src/idl_gen_go.cpp; sourceTree = ""; }; 8C6905EC19F8357300CB8866 /* idl_gen_fbs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_gen_fbs.cpp; path = src/idl_gen_fbs.cpp; sourceTree = ""; }; - 8C6905EF19F835A900CB8866 /* flatc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = flatc.cpp; sourceTree = ""; }; - 8C6905F019F835A900CB8866 /* idl_gen_cpp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = idl_gen_cpp.cpp; sourceTree = ""; }; - 8C6905F119F835A900CB8866 /* idl_gen_fbs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = idl_gen_fbs.cpp; sourceTree = ""; }; - 8C6905F219F835A900CB8866 /* idl_gen_general.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = idl_gen_general.cpp; sourceTree = ""; }; - 8C6905F319F835A900CB8866 /* idl_gen_go.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = idl_gen_go.cpp; sourceTree = ""; }; - 8C6905F419F835A900CB8866 /* idl_gen_text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = idl_gen_text.cpp; sourceTree = ""; }; - 8C6905F519F835A900CB8866 /* idl_parser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = idl_parser.cpp; sourceTree = ""; }; + 8C8774621B703D4800E693F5 /* reflection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = reflection.cpp; path = src/reflection.cpp; sourceTree = ""; }; 8CA854B21B04244A00040A06 /* idl_gen_python.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_gen_python.cpp; path = src/idl_gen_python.cpp; sourceTree = ""; }; 8CD8717A19CB937D0012A827 /* idl_gen_general.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_gen_general.cpp; path = src/idl_gen_general.cpp; sourceTree = ""; }; A13F25CDAD23435DA293690D /* flattests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; path = flattests; sourceTree = BUILT_PRODUCTS_DIR; }; AB70F1FBA50E4120BCF37C8D /* monster_test_generated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = monster_test_generated.h; path = tests/monster_test_generated.h; sourceTree = SOURCE_ROOT; }; - AD3682C6E1DD4EABB822C0CC /* monster_generated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = monster_generated.h; path = samples/monster_generated.h; sourceTree = SOURCE_ROOT; }; C0E7B66C3FF849A0AD9A7168 /* util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = util.h; path = include/flatbuffers/util.h; sourceTree = SOURCE_ROOT; }; CD90A7F6B2BE4D0384294DD1 /* idl_gen_cpp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = idl_gen_cpp.cpp; path = src/idl_gen_cpp.cpp; sourceTree = SOURCE_ROOT; }; DD8B353D4756412195777FBA /* flatbuffers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = flatbuffers.h; path = include/flatbuffers/flatbuffers.h; sourceTree = SOURCE_ROOT; }; @@ -58,13 +51,6 @@ /* End PBXFileReference section */ /* Begin PBXGroup section */ - 194905BCBB5C451DB092EB08 /* Resources */ = { - isa = PBXGroup; - children = ( - ); - name = Resources; - sourceTree = ""; - }; 28237E300FE042DEADA302D3 /* Source Files */ = { isa = PBXGroup; children = ( @@ -72,19 +58,10 @@ 8C6905EC19F8357300CB8866 /* idl_gen_fbs.cpp */, 8CD8717A19CB937D0012A827 /* idl_gen_general.cpp */, 8C303C581975D6A700D7C1C5 /* idl_gen_go.cpp */, - 0DFD29781D8E490284B06504 /* flatc.cpp */, - CD90A7F6B2BE4D0384294DD1 /* idl_gen_cpp.cpp */, - ); - name = "Source Files"; - sourceTree = ""; - }; - 355DCA17961E4B2FB2C71403 /* Source Files */ = { - isa = PBXGroup; - children = ( - 8C6905EE19F835A900CB8866 /* src */, F6C5D81DBF864365B12E269D /* idl_gen_text.cpp */, 3709AC883348409592530AE6 /* idl_parser.cpp */, - 6AD24EEB3D024825A37741FF /* test.cpp */, + CD90A7F6B2BE4D0384294DD1 /* idl_gen_cpp.cpp */, + 8C8774621B703D4800E693F5 /* reflection.cpp */, ); name = "Source Files"; sourceTree = ""; @@ -92,49 +69,17 @@ 378446B9D5EF46EF92B35E21 /* flatc */ = { isa = PBXGroup; children = ( - 5FEA84E7D39645988300317C /* Header Files */, - 28237E300FE042DEADA302D3 /* Source Files */, + 0DFD29781D8E490284B06504 /* flatc.cpp */, ); name = flatc; sourceTree = ""; }; - 40E30B8480BD493EA459E9B4 /* Header Files */ = { - isa = PBXGroup; - children = ( - AD3682C6E1DD4EABB822C0CC /* monster_generated.h */, - ); - name = "Header Files"; - sourceTree = ""; - }; - 4D1151F6FE594E40A1C177FF /* Header Files */ = { - isa = PBXGroup; - children = ( - ); - name = "Header Files"; - sourceTree = ""; - }; - 5235469653ED4BC88A6C504D /* Header Files */ = { - isa = PBXGroup; - children = ( - DD8B353D4756412195777FBA /* flatbuffers.h */, - 00154BD8654B4B5B9FF45FA6 /* idl.h */, - C0E7B66C3FF849A0AD9A7168 /* util.h */, - AB70F1FBA50E4120BCF37C8D /* monster_test_generated.h */, - ); - name = "Header Files"; - sourceTree = ""; - }; - 5648A71028E14478841372D3 /* Source Files */ = { - isa = PBXGroup; - children = ( - 5EE44BFFAF8E43F485859145 /* sample_binary.cpp */, - ); - name = "Source Files"; - sourceTree = ""; - }; 5FEA84E7D39645988300317C /* Header Files */ = { isa = PBXGroup; children = ( + DD8B353D4756412195777FBA /* flatbuffers.h */, + 00154BD8654B4B5B9FF45FA6 /* idl.h */, + C0E7B66C3FF849A0AD9A7168 /* util.h */, ); name = "Header Files"; sourceTree = ""; @@ -142,6 +87,8 @@ 866694F9F2F7451382D236B3 /* Sources */ = { isa = PBXGroup; children = ( + 28237E300FE042DEADA302D3 /* Source Files */, + 5FEA84E7D39645988300317C /* Header Files */, 378446B9D5EF46EF92B35E21 /* flatc */, DB9DE41C20F349F694A488F3 /* flatsamplebinary */, 8FA1F43C78914AE5AD04E24E /* flatsampletext */, @@ -153,31 +100,16 @@ 88421F5F87584EE3B67C979A /* flattests */ = { isa = PBXGroup; children = ( - 5235469653ED4BC88A6C504D /* Header Files */, - 355DCA17961E4B2FB2C71403 /* Source Files */, + AB70F1FBA50E4120BCF37C8D /* monster_test_generated.h */, + 6AD24EEB3D024825A37741FF /* test.cpp */, ); name = flattests; sourceTree = ""; }; - 8C6905EE19F835A900CB8866 /* src */ = { - isa = PBXGroup; - children = ( - 8C6905EF19F835A900CB8866 /* flatc.cpp */, - 8C6905F019F835A900CB8866 /* idl_gen_cpp.cpp */, - 8C6905F119F835A900CB8866 /* idl_gen_fbs.cpp */, - 8C6905F219F835A900CB8866 /* idl_gen_general.cpp */, - 8C6905F319F835A900CB8866 /* idl_gen_go.cpp */, - 8C6905F419F835A900CB8866 /* idl_gen_text.cpp */, - 8C6905F519F835A900CB8866 /* idl_parser.cpp */, - ); - path = src; - sourceTree = ""; - }; 8F5E926B72104F4194B3BD5A = { isa = PBXGroup; children = ( 866694F9F2F7451382D236B3 /* Sources */, - 194905BCBB5C451DB092EB08 /* Resources */, 99CC11E382B8420AA79A8A14 /* Products */, ); sourceTree = ""; @@ -185,8 +117,7 @@ 8FA1F43C78914AE5AD04E24E /* flatsampletext */ = { isa = PBXGroup; children = ( - 40E30B8480BD493EA459E9B4 /* Header Files */, - A1C826615F904FDE8F0CA154 /* Source Files */, + ECCEBFFA6977404F858F9739 /* sample_text.cpp */, ); name = flatsampletext; sourceTree = ""; @@ -202,20 +133,10 @@ name = Products; sourceTree = ""; }; - A1C826615F904FDE8F0CA154 /* Source Files */ = { - isa = PBXGroup; - children = ( - ECCEBFFA6977404F858F9739 /* sample_text.cpp */, - ); - name = "Source Files"; - sourceTree = ""; - }; DB9DE41C20F349F694A488F3 /* flatsamplebinary */ = { isa = PBXGroup; children = ( - 4D1151F6FE594E40A1C177FF /* Header Files */, - 5648A71028E14478841372D3 /* Source Files */, - 423CA92401AE442B91546E63 /* CMakeLists.txt */, + 5EE44BFFAF8E43F485859145 /* sample_binary.cpp */, ); name = flatsamplebinary; sourceTree = ""; @@ -338,8 +259,8 @@ AA9BACF55EB3456BA2F633BB /* flatc.cpp in Sources */, BE03D7B0C9584DD58B50ED34 /* idl_gen_cpp.cpp in Sources */, AD71FEBEE4E846529002C1F0 /* idl_gen_text.cpp in Sources */, + 8C8774641B703E1200E693F5 /* idl_gen_fbs.cpp in Sources */, A9C9A99F719A4ED58DC2D2FC /* idl_parser.cpp in Sources */, - 8C6905F819F835A900CB8866 /* idl_gen_fbs.cpp in Sources */, 8CA854B31B04244A00040A06 /* idl_gen_python.cpp in Sources */, 8CD8717B19CB937D0012A827 /* idl_gen_general.cpp in Sources */, ); @@ -349,6 +270,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 8C8774631B703D4800E693F5 /* reflection.cpp in Sources */, 5AC48C391ACA9A0A008132C5 /* idl_gen_general.cpp in Sources */, 8C6905FD19F835B400CB8866 /* idl_gen_fbs.cpp in Sources */, E0680D6B5BFD484BA9D88EE8 /* idl_gen_text.cpp in Sources */, diff --git a/src/reflection.cpp b/src/reflection.cpp index aa1ffaf36..b0a80e453 100644 --- a/src/reflection.cpp +++ b/src/reflection.cpp @@ -334,8 +334,7 @@ const uint8_t *AddFlatBuffer(std::vector &flatbuf, } auto insertion_point = static_cast(flatbuf.size()); // Insert the entire FlatBuffer minus the root pointer. - flatbuf.insert(flatbuf.end(), newbuf + sizeof(uoffset_t), - newbuf + newlen - sizeof(uoffset_t)); + flatbuf.insert(flatbuf.end(), newbuf + sizeof(uoffset_t), newbuf + newlen); auto root_offset = ReadScalar(newbuf) - sizeof(uoffset_t); return flatbuf.data() + insertion_point + root_offset; } diff --git a/tests/test.cpp b/tests/test.cpp index 984e1c620..116068edd 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -393,8 +393,8 @@ void ReflectionTest(uint8_t *flatbuf, size_t length) { // We do this last, so the pointer doesn't get invalidated (since it is // at the end of the buffer): auto string_ptr = flatbuffers::AddFlatBuffer(resizingbuf, - stringfbb.GetBufferPointer(), - stringfbb.GetSize()); + stringfbb.GetBufferPointer(), + stringfbb.GetSize()); // Finally, set the new value in the vector. rtestarrayofstring->MutateOffset(2, string_ptr); TEST_EQ_STR(rtestarrayofstring->Get(0)->c_str(), "bob");