diff options
-rw-r--r-- | CMakeLists.txt | 170 | ||||
-rw-r--r-- | samples/monster_generated.h | 18 | ||||
-rwxr-xr-x | scripts/generate_code.py | 58 | ||||
-rw-r--r-- | tests/alignment_test_generated.h | 16 | ||||
-rw-r--r-- | tests/arrays_test_generated.h | 12 | ||||
-rw-r--r-- | tests/monster_extra_generated.h | 8 | ||||
-rw-r--r-- | tests/monster_test_generated.h | 50 | ||||
-rw-r--r-- | tests/monster_test_suffix/ext_only/monster_test_generated.hpp | 50 | ||||
-rw-r--r-- | tests/monster_test_suffix/filesuffix_only/monster_test_suffix.h | 50 | ||||
-rw-r--r-- | tests/monster_test_suffix/monster_test_suffix.hpp | 50 | ||||
-rw-r--r-- | tests/namespace_test/namespace_test2_generated.h | 20 | ||||
-rw-r--r-- | tests/native_inline_table_test_generated.h | 2 | ||||
-rw-r--r-- | tests/native_type_test_generated.h | 8 | ||||
-rw-r--r-- | tests/optional_scalars_generated.h | 8 | ||||
-rw-r--r-- | tests/union_vector/union_vector_generated.h | 8 |
15 files changed, 222 insertions, 306 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 53f79db5..885984db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler" ON) option(FLATBUFFERS_STATIC_FLATC "Build flatbuffers compiler with -static flag" OFF) -option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" ON) +option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" OFF) option(FLATBUFFERS_BUILD_BENCHMARKS "Enable the build of flatbenchmark." OFF) option(FLATBUFFERS_BUILD_GRPCTEST "Enable the build of grpctest" OFF) @@ -243,32 +243,21 @@ set(FlatBuffers_Tests_CPP17_SRCS tests/test_assert.h tests/test_assert.cpp tests/cpp17/test_cpp17.cpp - # file generate by running compiler on tests/monster_test.fbs - ${CMAKE_CURRENT_BINARY_DIR}/tests/cpp17/generated_cpp17/monster_test_generated.h - ${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h - ${CMAKE_CURRENT_BINARY_DIR}/tests/cpp17/generated_cpp17/optional_scalars_generated.h - ${CMAKE_CURRENT_BINARY_DIR}/tests/optional_scalars_generated.h ) set(FlatBuffers_Sample_Binary_SRCS include/flatbuffers/flatbuffers.h samples/sample_binary.cpp - # file generated by running compiler on samples/monster.fbs - ${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h ) set(FlatBuffers_Sample_Text_SRCS ${FlatBuffers_Library_SRCS} samples/sample_text.cpp - # file generated by running compiler on samples/monster.fbs - ${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h ) set(FlatBuffers_Sample_BFBS_SRCS ${FlatBuffers_Library_SRCS} samples/sample_bfbs.cpp - # file generated by running compiler on samples/monster.fbs - ${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h ) set(FlatBuffers_GRPCTest_SRCS @@ -284,8 +273,6 @@ set(FlatBuffers_GRPCTest_SRCS tests/test_builder.cpp grpc/tests/grpctest.cpp grpc/tests/message_builder_test.cpp - # file generate by running compiler on tests/monster_test.fbs - ${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h ) # TODO(dbaileychess): Figure out how this would now work. I posted a question on @@ -500,144 +487,64 @@ if(FLATBUFFERS_BUILD_SHAREDLIB) endif() endif() -# Global list of generated files. -# Use the global property to be independent of PARENT_SCOPE. -set_property(GLOBAL PROPERTY FBS_GENERATED_OUTPUTS) - -function(get_generated_output generated_files) - get_property(tmp GLOBAL PROPERTY FBS_GENERATED_OUTPUTS) - set(${generated_files} ${tmp} PARENT_SCOPE) -endfunction(get_generated_output) - -function(register_generated_output file_name) - get_property(tmp GLOBAL PROPERTY FBS_GENERATED_OUTPUTS) - list(APPEND tmp ${file_name}) - set_property(GLOBAL PROPERTY FBS_GENERATED_OUTPUTS ${tmp}) -endfunction(register_generated_output) - -function(compile_flatbuffers_schema_to_cpp_opt SRC_FBS OPT) - if(FLATBUFFERS_BUILD_LEGACY) - set(OPT ${OPT};--cpp-std c++0x) - else() - # --cpp-std is defined by flatc default settings. - endif() - message(STATUS "`${SRC_FBS}`: add generation of C++ code with '${OPT}'") +function(compile_schema SRC_FBS OPT OUT_GEN_FILE) get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH) string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS}) - add_custom_command( - OUTPUT ${GEN_HEADER} - COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" - --cpp --gen-mutable --gen-object-api --reflect-names - --cpp-ptr-type flatbuffers::unique_ptr # Used to test with C++98 STLs - ${OPT} - -I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test" - -o "${SRC_FBS_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}" - DEPENDS flatc - COMMENT "Run generation: '${GEN_HEADER}'") - register_generated_output(${GEN_HEADER}) -endfunction() - -function(compile_flatbuffers_schema_to_cpp SRC_FBS) - compile_flatbuffers_schema_to_cpp_opt(${SRC_FBS} "--no-includes;--gen-compare") + add_custom_command(TARGET flatc POST_BUILD + COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" + ${OPT} + -o "${SRC_FBS_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}" + BYPRODUCTS ${GEN_HEADER} + COMMENT "flatc generation: `${SRC_FBS}` -> `${GEN_HEADER}`" + ) + set(${OUT_GEN_FILE} ${GEN_HEADER} PARENT_SCOPE) endfunction() -function(compile_flatbuffers_schema_to_binary SRC_FBS) - message(STATUS "`${SRC_FBS}`: add generation of binary (.bfbs) schema") - get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH) - string(REGEX REPLACE "\\.fbs$" ".bfbs" GEN_BINARY_SCHEMA ${SRC_FBS}) - # For details about flags see generate_code.py - add_custom_command( - OUTPUT ${GEN_BINARY_SCHEMA} - COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" - -b --schema --bfbs-comments --bfbs-builtins - --bfbs-filenames "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS_DIR}" - -I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test" - -o "${SRC_FBS_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}" - DEPENDS flatc - COMMENT "Run generation: '${GEN_BINARY_SCHEMA}'") - register_generated_output(${GEN_BINARY_SCHEMA}) +function(compile_schema_for_test SRC_FBS OPT) + compile_schema("${SRC_FBS}" "${OPT}" GEN_FILE) + target_sources(flattests PRIVATE ${GEN_FILE}) endfunction() -function(compile_flatbuffers_schema_to_embedded_binary SRC_FBS OPT) - if(FLATBUFFERS_BUILD_LEGACY) - set(OPT ${OPT};--cpp-std c++0x) - else() - # --cpp-std is defined by flatc default settings. - endif() - message(STATUS "`${SRC_FBS}`: add generation of C++ embedded binary schema code with '${OPT}'") - get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH) - string(REGEX REPLACE "\\.fbs$" "_bfbs_generated.h" GEN_BFBS_HEADER ${SRC_FBS}) - # For details about flags see generate_code.py - add_custom_command( - OUTPUT ${GEN_BFBS_HEADER} - COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" - --cpp --gen-mutable --gen-object-api --reflect-names - --cpp-ptr-type flatbuffers::unique_ptr # Used to test with C++98 STLs - ${OPT} - --bfbs-comments --bfbs-builtins --bfbs-gen-embed - --bfbs-filenames ${SRC_FBS_DIR} - -I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test" - -o "${SRC_FBS_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}" - DEPENDS flatc - COMMENT "Run generation: '${GEN_BFBS_HEADER}'") - register_generated_output(${GEN_BFBS_HEADER}) +function(compile_schema_for_samples SRC_FBS OPT) + compile_schema("${SRC_FBS}" "${OPT}" GEN_FILE) + target_sources(flatsamplebinary PRIVATE ${GEN_FILE}) + target_sources(flatsampletext PRIVATE ${GEN_FILE}) + target_sources(flatsamplebfbs PRIVATE ${GEN_FILE}) endfunction() if(FLATBUFFERS_BUILD_TESTS) - file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") - file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/samples" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") - - # TODO Add (monster_test.fbs monsterdata_test.json)->monsterdata_test.mon - compile_flatbuffers_schema_to_binary(tests/monster_test.fbs) - compile_flatbuffers_schema_to_cpp_opt(tests/namespace_test/namespace_test1.fbs "--no-includes;--gen-compare;--gen-name-strings") - compile_flatbuffers_schema_to_cpp_opt(tests/namespace_test/namespace_test2.fbs "--no-includes;--gen-compare;--gen-name-strings") - compile_flatbuffers_schema_to_cpp_opt(tests/union_vector/union_vector.fbs "--no-includes;--gen-compare;") - compile_flatbuffers_schema_to_cpp(tests/optional_scalars.fbs) - compile_flatbuffers_schema_to_cpp_opt(tests/native_type_test.fbs "") - compile_flatbuffers_schema_to_cpp_opt(tests/arrays_test.fbs "--scoped-enums;--gen-compare") - compile_flatbuffers_schema_to_binary(tests/arrays_test.fbs) - compile_flatbuffers_schema_to_embedded_binary(tests/monster_test.fbs "--no-includes;--gen-compare") - compile_flatbuffers_schema_to_cpp(tests/native_inline_table_test.fbs "--gen-compare") - compile_flatbuffers_schema_to_cpp(tests/alignment_test.fbs "--gen-compare") - compile_flatbuffers_schema_to_cpp(tests/key_field/key_field_sample.fbs) - if(NOT (MSVC AND (MSVC_VERSION LESS 1900))) - compile_flatbuffers_schema_to_cpp(tests/monster_extra.fbs) # Test floating-point NAN/INF. - endif() include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests) add_executable(flattests ${FlatBuffers_Tests_SRCS}) target_link_libraries(flattests PRIVATE $<BUILD_INTERFACE:ProjectConfig>) - target_include_directories(flattests PUBLIC src) - add_dependencies(flattests generated_code) + + # The flattest target needs some generated files + SET(FLATC_OPT --cpp --gen-mutable --gen-object-api --reflect-names) + SET(FLATC_OPT_COMP ${FLATC_OPT};--gen-compare) + + compile_schema_for_test(tests/alignment_test.fbs "${FLATC_OPT_COMP}") + compile_schema_for_test(tests/native_inline_table_test.fbs "${FLATC_OPT_COMP}") + compile_schema_for_test(tests/native_type_test.fbs "${FLATC_OPT}") if(FLATBUFFERS_CODE_SANITIZE) add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE}) endif() - - compile_flatbuffers_schema_to_cpp(samples/monster.fbs) - compile_flatbuffers_schema_to_binary(samples/monster.fbs) + include_directories(${CMAKE_CURRENT_BINARY_DIR}/samples) add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS}) - target_link_libraries(flatsamplebinary PRIVATE $<BUILD_INTERFACE:ProjectConfig>) - add_dependencies(flatsamplebinary generated_code) - add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS}) - target_link_libraries(flatsampletext PRIVATE $<BUILD_INTERFACE:ProjectConfig>) - add_dependencies(flatsampletext generated_code) - add_executable(flatsamplebfbs ${FlatBuffers_Sample_BFBS_SRCS}) + + target_link_libraries(flatsamplebinary PRIVATE $<BUILD_INTERFACE:ProjectConfig>) + target_link_libraries(flatsampletext PRIVATE $<BUILD_INTERFACE:ProjectConfig>) target_link_libraries(flatsamplebfbs PRIVATE $<BUILD_INTERFACE:ProjectConfig>) - add_dependencies(flatsamplebfbs generated_code) + + compile_schema_for_samples(samples/monster.fbs "${FLATC_OPT_COMP}") if(FLATBUFFERS_BUILD_CPP17) - # Don't generate header for flattests_cpp17 target. - # This target uses "generated_cpp17/monster_test_generated.h" add_executable(flattests_cpp17 ${FlatBuffers_Tests_CPP17_SRCS}) - add_dependencies(flattests_cpp17 generated_code) target_link_libraries(flattests_cpp17 PRIVATE $<BUILD_INTERFACE:ProjectConfig>) target_compile_features(flattests_cpp17 PRIVATE cxx_std_17) # requires cmake 3.8 @@ -662,7 +569,6 @@ if(FLATBUFFERS_BUILD_GRPCTEST) find_package(protobuf CONFIG REQUIRED) find_package(gRPC CONFIG REQUIRED) add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS}) - add_dependencies(grpctest generated_code) target_link_libraries(grpctext PRIVATE $<BUILD_INTERFACE:ProjectConfig> @@ -755,16 +661,6 @@ if(FLATBUFFERS_BUILD_TESTS) endif() endif() -# This target is sync-barrier. -# Other generate-dependent targets can depend on 'generated_code' only. -get_generated_output(fbs_generated) -if(fbs_generated) - # message(STATUS "Add generated_code target with files:${fbs_generated}") - add_custom_target(generated_code - DEPENDS ${fbs_generated} - COMMENT "All generated files were updated.") -endif() - include(CMake/BuildFlatBuffers.cmake) if(UNIX) diff --git a/samples/monster_generated.h b/samples/monster_generated.h index 7682e191..34d1a67b 100644 --- a/samples/monster_generated.h +++ b/samples/monster_generated.h @@ -237,13 +237,13 @@ inline bool operator!=(const Vec3 &lhs, const Vec3 &rhs) { struct MonsterT : public ::flatbuffers::NativeTable { typedef Monster TableType; - flatbuffers::unique_ptr<MyGame::Sample::Vec3> pos{}; + std::unique_ptr<MyGame::Sample::Vec3> pos{}; int16_t mana = 150; int16_t hp = 100; std::string name{}; std::vector<uint8_t> inventory{}; MyGame::Sample::Color color = MyGame::Sample::Color_Blue; - std::vector<flatbuffers::unique_ptr<MyGame::Sample::WeaponT>> weapons{}; + std::vector<std::unique_ptr<MyGame::Sample::WeaponT>> weapons{}; MyGame::Sample::EquipmentUnion equipped{}; std::vector<MyGame::Sample::Vec3> path{}; MonsterT() = default; @@ -556,7 +556,7 @@ inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) { (lhs.name == rhs.name) && (lhs.inventory == rhs.inventory) && (lhs.color == rhs.color) && - (lhs.weapons.size() == rhs.weapons.size() && std::equal(lhs.weapons.cbegin(), lhs.weapons.cend(), rhs.weapons.cbegin(), [](flatbuffers::unique_ptr<MyGame::Sample::WeaponT> const &a, flatbuffers::unique_ptr<MyGame::Sample::WeaponT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.weapons.size() == rhs.weapons.size() && std::equal(lhs.weapons.cbegin(), lhs.weapons.cend(), rhs.weapons.cbegin(), [](std::unique_ptr<MyGame::Sample::WeaponT> const &a, std::unique_ptr<MyGame::Sample::WeaponT> const &b) { return (a == b) || (a && b && *a == *b); })) && (lhs.equipped == rhs.equipped) && (lhs.path == rhs.path); } @@ -601,13 +601,13 @@ inline MonsterT *Monster::UnPack(const ::flatbuffers::resolver_function_t *_reso inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = pos(); if (_e) _o->pos = flatbuffers::unique_ptr<MyGame::Sample::Vec3>(new MyGame::Sample::Vec3(*_e)); } + { auto _e = pos(); if (_e) _o->pos = std::unique_ptr<MyGame::Sample::Vec3>(new MyGame::Sample::Vec3(*_e)); } { auto _e = mana(); _o->mana = _e; } { auto _e = hp(); _o->hp = _e; } { auto _e = name(); if (_e) _o->name = _e->str(); } { auto _e = inventory(); if (_e) { _o->inventory.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->inventory.begin()); } } { auto _e = color(); _o->color = _e; } - { auto _e = weapons(); if (_e) { _o->weapons.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->weapons[_i]) { _e->Get(_i)->UnPackTo(_o->weapons[_i].get(), _resolver); } else { _o->weapons[_i] = flatbuffers::unique_ptr<MyGame::Sample::WeaponT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->weapons.resize(0); } } + { auto _e = weapons(); if (_e) { _o->weapons.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->weapons[_i]) { _e->Get(_i)->UnPackTo(_o->weapons[_i].get(), _resolver); } else { _o->weapons[_i] = std::unique_ptr<MyGame::Sample::WeaponT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->weapons.resize(0); } } { auto _e = equipped_type(); _o->equipped.type = _e; } { auto _e = equipped(); if (_e) _o->equipped.value = MyGame::Sample::EquipmentUnion::UnPack(_e, equipped_type(), _resolver); } { auto _e = path(); if (_e) { _o->path.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->path[_i] = *_e->Get(_i); } } else { _o->path.resize(0); } } @@ -905,16 +905,16 @@ inline void FinishSizePrefixedMonsterBuffer( fbb.FinishSizePrefixed(root); } -inline flatbuffers::unique_ptr<MyGame::Sample::MonsterT> UnPackMonster( +inline std::unique_ptr<MyGame::Sample::MonsterT> UnPackMonster( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MyGame::Sample::MonsterT>(GetMonster(buf)->UnPack(res)); + return std::unique_ptr<MyGame::Sample::MonsterT>(GetMonster(buf)->UnPack(res)); } -inline flatbuffers::unique_ptr<MyGame::Sample::MonsterT> UnPackSizePrefixedMonster( +inline std::unique_ptr<MyGame::Sample::MonsterT> UnPackSizePrefixedMonster( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MyGame::Sample::MonsterT>(GetSizePrefixedMonster(buf)->UnPack(res)); + return std::unique_ptr<MyGame::Sample::MonsterT>(GetSizePrefixedMonster(buf)->UnPack(res)); } } // namespace Sample diff --git a/scripts/generate_code.py b/scripts/generate_code.py index 6c18c7f8..57af85ca 100755 --- a/scripts/generate_code.py +++ b/scripts/generate_code.py @@ -28,6 +28,7 @@ ts_code_gen = Path(root_path, "tests/ts") samples_path = Path(root_path, "samples") reflection_path = Path(root_path, "reflection") + # Generate the code for flatbuffers reflection schema def flatc_reflection(options, location, target): full_options = ["--no-prefix"] + options @@ -45,6 +46,7 @@ def flatc_reflection(options, location, target): shutil.move(str(new_reflection_path), str(original_reflection_path)) shutil.rmtree(str(Path(reflection_path, temp_dir))) + def flatc_annotate(schema, file, include=None, cwd=tests_path): cmd = [str(flatc_path)] if include: @@ -52,6 +54,7 @@ def flatc_annotate(schema, file, include=None, cwd=tests_path): cmd += ["--annotate", schema, file] result = subprocess.run(cmd, cwd=str(cwd), check=True) + # Glob a pattern relative to file path def glob(path, pattern): return [str(p) for p in path.glob(pattern)] @@ -66,8 +69,6 @@ CS_OPTS = ["--csharp", "--cs-gen-json-serializer"] CPP_OPTS = [ "--cpp", "--gen-compare", - "--cpp-ptr-type", - "flatbuffers::unique_ptr", ] + (["--cpp-std", "c++0x"] if args.cpp_0x else []) CPP_17_OPTS = NO_INCL_OPTS + [ @@ -97,7 +98,7 @@ SWIFT_OPTS_CODE_GEN = [ "--swift", "--gen-json-emit", "--bfbs-filenames", - str(swift_code_gen) + str(swift_code_gen), ] JAVA_OPTS = ["--java"] KOTLIN_OPTS = ["--kotlin"] @@ -128,22 +129,19 @@ flatc( ) flatc( - NO_INCL_OPTS - + DART_OPTS, + NO_INCL_OPTS + DART_OPTS, schema="include_test/include_test1.fbs", include="include_test/sub", ) flatc( - NO_INCL_OPTS - + DART_OPTS, + NO_INCL_OPTS + DART_OPTS, schema="include_test/sub/include_test2.fbs", include="include_test", ) flatc( - NO_INCL_OPTS - + TS_OPTS, + NO_INCL_OPTS + TS_OPTS, cwd=ts_code_gen, schema="../monster_test.fbs", include="../include_test", @@ -210,6 +208,23 @@ flatc( ) flatc( + [ + "--cpp", + "--reflect-names", + "--no-includes", + "--gen-mutable", + "--gen-object-api", + "--gen-compare", + "--gen-name-strings", + ], + prefix="namespace_test", + schema=[ + "namespace_test/namespace_test1.fbs", + "namespace_test/namespace_test2.fbs", + ], +) + +flatc( BASE_OPTS + CPP_OPTS + CS_OPTS + JAVA_OPTS + KOTLIN_OPTS + PHP_OPTS, prefix="union_vector", schema="union_vector/union_vector.fbs", @@ -268,13 +283,11 @@ flatc( flatc_annotate( schema="../reflection/reflection.fbs", file="monster_test.bfbs", - include="include_test" + include="include_test", ) flatc_annotate( - schema="monster_test.fbs", - file="monsterdata_test.mon", - include="include_test" + schema="monster_test.fbs", file="monsterdata_test.mon", include="include_test" ) flatc( @@ -358,7 +371,7 @@ flatc(["--csharp", "--gen-object-api"], schema=type_field_collsion_schema) flatc( CS_OPTS + ["--gen-object-api", "--gen-onefile"], prefix="union_value_collsion", - schema="union_value_collision.fbs" + schema="union_value_collision.fbs", ) # Generate string/vector default code for tests @@ -415,13 +428,13 @@ flatc( flatc( SWIFT_OPTS_CODE_GEN + BASE_OPTS + ["--grpc", "--swift-implementation-only"], schema="test_import.fbs", - cwd=swift_code_gen + cwd=swift_code_gen, ) flatc( SWIFT_OPTS_CODE_GEN + NO_INCL_OPTS + ["--grpc"], schema="test_no_include.fbs", - cwd=swift_code_gen + cwd=swift_code_gen, ) # Swift Wasm Tests @@ -454,7 +467,9 @@ flatc( schema="monster_test.fbs", ) flatc( - CPP_OPTS + NO_INCL_OPTS + ["--grpc", "--filename-suffix", "_suffix", "--filename-ext", "hpp"], + CPP_OPTS + + NO_INCL_OPTS + + ["--grpc", "--filename-suffix", "_suffix", "--filename-ext", "hpp"], include="include_test", prefix="monster_test_suffix", schema="monster_test.fbs", @@ -482,7 +497,11 @@ flatc( # Private annotations annotations_test_schema = "private_annotation_test.fbs" -flatc(RUST_OPTS + ["--no-leak-private-annotation", "--gen-object-api"], prefix="private_annotation_test", schema=annotations_test_schema) +flatc( + RUST_OPTS + ["--no-leak-private-annotation", "--gen-object-api"], + prefix="private_annotation_test", + schema=annotations_test_schema, +) # Sample files samples_schema = "monster.fbs" @@ -510,7 +529,8 @@ flatc_reflection(["-p"], "python/flatbuffers", "reflection") # Java Reflection flatc_reflection( ["-j", "--java-package-prefix", "com.google.flatbuffers"], - "java/src/main/java", "com/google/flatbuffers/reflection" + "java/src/main/java", + "com/google/flatbuffers/reflection", ) # Annotation diff --git a/tests/alignment_test_generated.h b/tests/alignment_test_generated.h index 0c61c8fe..71421cac 100644 --- a/tests/alignment_test_generated.h +++ b/tests/alignment_test_generated.h @@ -130,7 +130,7 @@ inline bool operator!=(const BadAlignmentLarge &lhs, const BadAlignmentLarge &rh struct OuterLargeT : public ::flatbuffers::NativeTable { typedef OuterLarge TableType; - flatbuffers::unique_ptr<BadAlignmentLarge> large{}; + std::unique_ptr<BadAlignmentLarge> large{}; OuterLargeT() = default; OuterLargeT(const OuterLargeT &o); OuterLargeT(OuterLargeT&&) FLATBUFFERS_NOEXCEPT = default; @@ -192,7 +192,7 @@ inline ::flatbuffers::Offset<OuterLarge> CreateOuterLarge( struct BadAlignmentRootT : public ::flatbuffers::NativeTable { typedef BadAlignmentRoot TableType; - flatbuffers::unique_ptr<OuterLargeT> large{}; + std::unique_ptr<OuterLargeT> large{}; std::vector<BadAlignmentSmall> small{}; BadAlignmentRootT() = default; BadAlignmentRootT(const BadAlignmentRootT &o); @@ -308,7 +308,7 @@ inline OuterLargeT *OuterLarge::UnPack(const ::flatbuffers::resolver_function_t inline void OuterLarge::UnPackTo(OuterLargeT *_o, const ::flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = large(); if (_e) _o->large = flatbuffers::unique_ptr<BadAlignmentLarge>(new BadAlignmentLarge(*_e)); } + { auto _e = large(); if (_e) _o->large = std::unique_ptr<BadAlignmentLarge>(new BadAlignmentLarge(*_e)); } } inline ::flatbuffers::Offset<OuterLarge> OuterLarge::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const OuterLargeT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) { @@ -357,7 +357,7 @@ inline BadAlignmentRootT *BadAlignmentRoot::UnPack(const ::flatbuffers::resolver inline void BadAlignmentRoot::UnPackTo(BadAlignmentRootT *_o, const ::flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = large(); if (_e) { if(_o->large) { _e->UnPackTo(_o->large.get(), _resolver); } else { _o->large = flatbuffers::unique_ptr<OuterLargeT>(_e->UnPack(_resolver)); } } else if (_o->large) { _o->large.reset(); } } + { auto _e = large(); if (_e) { if(_o->large) { _e->UnPackTo(_o->large.get(), _resolver); } else { _o->large = std::unique_ptr<OuterLargeT>(_e->UnPack(_resolver)); } } else if (_o->large) { _o->large.reset(); } } { auto _e = small(); if (_e) { _o->small.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->small[_i] = *_e->Get(_i); } } else { _o->small.resize(0); } } } @@ -482,16 +482,16 @@ inline void FinishSizePrefixedBadAlignmentRootBuffer( fbb.FinishSizePrefixed(root); } -inline flatbuffers::unique_ptr<BadAlignmentRootT> UnPackBadAlignmentRoot( +inline std::unique_ptr<BadAlignmentRootT> UnPackBadAlignmentRoot( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<BadAlignmentRootT>(GetBadAlignmentRoot(buf)->UnPack(res)); + return std::unique_ptr<BadAlignmentRootT>(GetBadAlignmentRoot(buf)->UnPack(res)); } -inline flatbuffers::unique_ptr<BadAlignmentRootT> UnPackSizePrefixedBadAlignmentRoot( +inline std::unique_ptr<BadAlignmentRootT> UnPackSizePrefixedBadAlignmentRoot( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<BadAlignmentRootT>(GetSizePrefixedBadAlignmentRoot(buf)->UnPack(res)); + return std::unique_ptr<BadAlignmentRootT>(GetSizePrefixedBadAlignmentRoot(buf)->UnPack(res)); } #endif // FLATBUFFERS_GENERATED_ALIGNMENTTEST_H_ diff --git a/tests/arrays_test_generated.h b/tests/arrays_test_generated.h index 7df769f4..3d137f89 100644 --- a/tests/arrays_test_generated.h +++ b/tests/arrays_test_generated.h @@ -271,7 +271,7 @@ inline bool operator!=(const ArrayStruct &lhs, const ArrayStruct &rhs) { struct ArrayTableT : public ::flatbuffers::NativeTable { typedef ArrayTable TableType; - flatbuffers::unique_ptr<MyGame::Example::ArrayStruct> a{}; + std::unique_ptr<MyGame::Example::ArrayStruct> a{}; ArrayTableT() = default; ArrayTableT(const ArrayTableT &o); ArrayTableT(ArrayTableT&&) FLATBUFFERS_NOEXCEPT = default; @@ -360,7 +360,7 @@ inline ArrayTableT *ArrayTable::UnPack(const ::flatbuffers::resolver_function_t inline void ArrayTable::UnPackTo(ArrayTableT *_o, const ::flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = a(); if (_e) _o->a = flatbuffers::unique_ptr<MyGame::Example::ArrayStruct>(new MyGame::Example::ArrayStruct(*_e)); } + { auto _e = a(); if (_e) _o->a = std::unique_ptr<MyGame::Example::ArrayStruct>(new MyGame::Example::ArrayStruct(*_e)); } } inline ::flatbuffers::Offset<ArrayTable> ArrayTable::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const ArrayTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) { @@ -521,16 +521,16 @@ inline void FinishSizePrefixedArrayTableBuffer( fbb.FinishSizePrefixed(root, ArrayTableIdentifier()); } -inline flatbuffers::unique_ptr<MyGame::Example::ArrayTableT> UnPackArrayTable( +inline std::unique_ptr<MyGame::Example::ArrayTableT> UnPackArrayTable( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MyGame::Example::ArrayTableT>(GetArrayTable(buf)->UnPack(res)); + return std::unique_ptr<MyGame::Example::ArrayTableT>(GetArrayTable(buf)->UnPack(res)); } -inline flatbuffers::unique_ptr<MyGame::Example::ArrayTableT> UnPackSizePrefixedArrayTable( +inline std::unique_ptr<MyGame::Example::ArrayTableT> UnPackSizePrefixedArrayTable( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MyGame::Example::ArrayTableT>(GetSizePrefixedArrayTable(buf)->UnPack(res)); + return std::unique_ptr<MyGame::Example::ArrayTableT>(GetSizePrefixedArrayTable(buf)->UnPack(res)); } } // namespace Example diff --git a/tests/monster_extra_generated.h b/tests/monster_extra_generated.h index 6ed45fe2..ac8f6147 100644 --- a/tests/monster_extra_generated.h +++ b/tests/monster_extra_generated.h @@ -400,16 +400,16 @@ inline void FinishSizePrefixedMonsterExtraBuffer( fbb.FinishSizePrefixed(root, MonsterExtraIdentifier()); } -inline flatbuffers::unique_ptr<MyGame::MonsterExtraT> UnPackMonsterExtra( +inline std::unique_ptr<MyGame::MonsterExtraT> UnPackMonsterExtra( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MyGame::MonsterExtraT>(GetMonsterExtra(buf)->UnPack(res)); + return std::unique_ptr<MyGame::MonsterExtraT>(GetMonsterExtra(buf)->UnPack(res)); } -inline flatbuffers::unique_ptr<MyGame::MonsterExtraT> UnPackSizePrefixedMonsterExtra( +inline std::unique_ptr<MyGame::MonsterExtraT> UnPackSizePrefixedMonsterExtra( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MyGame::MonsterExtraT>(GetSizePrefixedMonsterExtra(buf)->UnPack(res)); + return std::unique_ptr<MyGame::MonsterExtraT>(GetSizePrefixedMonsterExtra(buf)->UnPack(res)); } } // namespace MyGame diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h index 127522dc..f7b8f4ac 100644 --- a/tests/monster_test_generated.h +++ b/tests/monster_test_generated.h @@ -1267,7 +1267,7 @@ inline ::flatbuffers::Offset<Referrable> CreateReferrable( struct MonsterT : public ::flatbuffers::NativeTable { typedef Monster TableType; - flatbuffers::unique_ptr<MyGame::Example::Vec3> pos{}; + std::unique_ptr<MyGame::Example::Vec3> pos{}; int16_t mana = 150; int16_t hp = 100; std::string name{}; @@ -1276,10 +1276,10 @@ struct MonsterT : public ::flatbuffers::NativeTable { MyGame::Example::AnyUnion test{}; std::vector<MyGame::Example::Test> test4{}; std::vector<std::string> testarrayofstring{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::MonsterT>> testarrayoftables{}; - flatbuffers::unique_ptr<MyGame::Example::MonsterT> enemy{}; + std::vector<std::unique_ptr<MyGame::Example::MonsterT>> testarrayoftables{}; + std::unique_ptr<MyGame::Example::MonsterT> enemy{}; std::vector<uint8_t> testnestedflatbuffer{}; - flatbuffers::unique_ptr<MyGame::Example::StatT> testempty{}; + std::unique_ptr<MyGame::Example::StatT> testempty{}; bool testbool = false; int32_t testhashs32_fnv1 = 0; uint32_t testhashu32_fnv1 = 0; @@ -1299,13 +1299,13 @@ struct MonsterT : public ::flatbuffers::NativeTable { std::vector<MyGame::Example::Test> test5{}; std::vector<int64_t> vector_of_longs{}; std::vector<double> vector_of_doubles{}; - flatbuffers::unique_ptr<MyGame::InParentNamespaceT> parent_namespace_test{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::ReferrableT>> vector_of_referrables{}; + std::unique_ptr<MyGame::InParentNamespaceT> parent_namespace_test{}; + std::vector<std::unique_ptr<MyGame::Example::ReferrableT>> vector_of_referrables{}; ReferrableT *single_weak_reference = nullptr; std::vector<ReferrableT *> vector_of_weak_references{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::ReferrableT>> vector_of_strong_referrables{}; + std::vector<std::unique_ptr<MyGame::Example::ReferrableT>> vector_of_strong_referrables{}; ReferrableT *co_owning_reference = nullptr; - std::vector<flatbuffers::unique_ptr<ReferrableT>> vector_of_co_owning_references{}; + std::vector<std::unique_ptr<ReferrableT>> vector_of_co_owning_references{}; ReferrableT *non_owning_reference = nullptr; std::vector<ReferrableT *> vector_of_non_owning_references{}; MyGame::Example::AnyUniqueAliasesUnion any_unique{}; @@ -1313,7 +1313,7 @@ struct MonsterT : public ::flatbuffers::NativeTable { std::vector<MyGame::Example::Color> vector_of_enums{}; MyGame::Example::Race signed_enum = MyGame::Example::Race_None; std::vector<uint8_t> testrequirednestedflatbuffer{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::StatT>> scalar_key_sorted_tables{}; + std::vector<std::unique_ptr<MyGame::Example::StatT>> scalar_key_sorted_tables{}; MyGame::Example::Test native_inline{}; MyGame::Example::LongEnum long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0); MyGame::Example::LongEnum long_enum_normal_default = MyGame::Example::LongEnum_LongOne; @@ -2871,7 +2871,7 @@ inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) { (lhs.test == rhs.test) && (lhs.test4 == rhs.test4) && (lhs.testarrayofstring == rhs.testarrayofstring) && - (lhs.testarrayoftables.size() == rhs.testarrayoftables.size() && std::equal(lhs.testarrayoftables.cbegin(), lhs.testarrayoftables.cend(), rhs.testarrayoftables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &a, flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.testarrayoftables.size() == rhs.testarrayoftables.size() && std::equal(lhs.testarrayoftables.cbegin(), lhs.testarrayoftables.cend(), rhs.testarrayoftables.cbegin(), [](std::unique_ptr<MyGame::Example::MonsterT> const &a, std::unique_ptr<MyGame::Example::MonsterT> const &b) { return (a == b) || (a && b && *a == *b); })) && ((lhs.enemy == rhs.enemy) || (lhs.enemy && rhs.enemy && *lhs.enemy == *rhs.enemy)) && (lhs.testnestedflatbuffer == rhs.testnestedflatbuffer) && ((lhs.testempty == rhs.testempty) || (lhs.testempty && rhs.testempty && *lhs.testempty == *rhs.testempty)) && @@ -2895,10 +2895,10 @@ inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) { (lhs.vector_of_longs == rhs.vector_of_longs) && (lhs.vector_of_doubles == rhs.vector_of_doubles) && ((lhs.parent_namespace_test == rhs.parent_namespace_test) || (lhs.parent_namespace_test && rhs.parent_namespace_test && *lhs.parent_namespace_test == *rhs.parent_namespace_test)) && - (lhs.vector_of_referrables.size() == rhs.vector_of_referrables.size() && std::equal(lhs.vector_of_referrables.cbegin(), lhs.vector_of_referrables.cend(), rhs.vector_of_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.vector_of_referrables.size() == rhs.vector_of_referrables.size() && std::equal(lhs.vector_of_referrables.cbegin(), lhs.vector_of_referrables.cend(), rhs.vector_of_referrables.cbegin(), [](std::unique_ptr<MyGame::Example::ReferrableT> const &a, std::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && (lhs.single_weak_reference == rhs.single_weak_reference) && (lhs.vector_of_weak_references == rhs.vector_of_weak_references) && - (lhs.vector_of_strong_referrables.size() == rhs.vector_of_strong_referrables.size() && std::equal(lhs.vector_of_strong_referrables.cbegin(), lhs.vector_of_strong_referrables.cend(), rhs.vector_of_strong_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.vector_of_strong_referrables.size() == rhs.vector_of_strong_referrables.size() && std::equal(lhs.vector_of_strong_referrables.cbegin(), lhs.vector_of_strong_referrables.cend(), rhs.vector_of_strong_referrables.cbegin(), [](std::unique_ptr<MyGame::Example::ReferrableT> const &a, std::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && (lhs.co_owning_reference == rhs.co_owning_reference) && (lhs.vector_of_co_owning_references == rhs.vector_of_co_owning_references) && (lhs.non_owning_reference == rhs.non_owning_reference) && @@ -2908,7 +2908,7 @@ inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) { (lhs.vector_of_enums == rhs.vector_of_enums) && (lhs.signed_enum == rhs.signed_enum) && (lhs.testrequirednestedflatbuffer == rhs.testrequirednestedflatbuffer) && - (lhs.scalar_key_sorted_tables.size() == rhs.scalar_key_sorted_tables.size() && std::equal(lhs.scalar_key_sorted_tables.cbegin(), lhs.scalar_key_sorted_tables.cend(), rhs.scalar_key_sorted_tables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::StatT> const &a, flatbuffers::unique_ptr<MyGame::Example::StatT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.scalar_key_sorted_tables.size() == rhs.scalar_key_sorted_tables.size() && std::equal(lhs.scalar_key_sorted_tables.cbegin(), lhs.scalar_key_sorted_tables.cend(), rhs.scalar_key_sorted_tables.cbegin(), [](std::unique_ptr<MyGame::Example::StatT> const &a, std::unique_ptr<MyGame::Example::StatT> const &b) { return (a == b) || (a && b && *a == *b); })) && (lhs.native_inline == rhs.native_inline) && (lhs.long_enum_non_enum_default == rhs.long_enum_non_enum_default) && (lhs.long_enum_normal_default == rhs.long_enum_normal_default) && @@ -3064,7 +3064,7 @@ inline MonsterT *Monster::UnPack(const ::flatbuffers::resolver_function_t *_reso inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = pos(); if (_e) _o->pos = flatbuffers::unique_ptr<MyGame::Example::Vec3>(new MyGame::Example::Vec3(*_e)); } + { auto _e = pos(); if (_e) _o->pos = std::unique_ptr<MyGame::Example::Vec3>(new MyGame::Example::Vec3(*_e)); } { auto _e = mana(); _o->mana = _e; } { auto _e = hp(); _o->hp = _e; } { auto _e = name(); if (_e) _o->name = _e->str(); } @@ -3074,10 +3074,10 @@ inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_functi { auto _e = test(); if (_e) _o->test.value = MyGame::Example::AnyUnion::UnPack(_e, test_type(), _resolver); } { auto _e = test4(); if (_e) { _o->test4.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test4[_i] = *_e->Get(_i); } } else { _o->test4.resize(0); } } { auto _e = testarrayofstring(); if (_e) { _o->testarrayofstring.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring[_i] = _e->Get(_i)->str(); } } else { _o->testarrayofstring.resize(0); } } - { auto _e = testarrayoftables(); if (_e) { _o->testarrayoftables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->testarrayoftables[_i]) { _e->Get(_i)->UnPackTo(_o->testarrayoftables[_i].get(), _resolver); } else { _o->testarrayoftables[_i] = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->testarrayoftables.resize(0); } } - { auto _e = enemy(); if (_e) { if(_o->enemy) { _e->UnPackTo(_o->enemy.get(), _resolver); } else { _o->enemy = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->UnPack(_resolver)); } } else if (_o->enemy) { _o->enemy.reset(); } } + { auto _e = testarrayoftables(); if (_e) { _o->testarrayoftables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->testarrayoftables[_i]) { _e->Get(_i)->UnPackTo(_o->testarrayoftables[_i].get(), _resolver); } else { _o->testarrayoftables[_i] = std::unique_ptr<MyGame::Example::MonsterT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->testarrayoftables.resize(0); } } + { auto _e = enemy(); if (_e) { if(_o->enemy) { _e->UnPackTo(_o->enemy.get(), _resolver); } else { _o->enemy = std::unique_ptr<MyGame::Example::MonsterT>(_e->UnPack(_resolver)); } } else if (_o->enemy) { _o->enemy.reset(); } } { auto _e = testnestedflatbuffer(); if (_e) { _o->testnestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testnestedflatbuffer.begin()); } } - { auto _e = testempty(); if (_e) { if(_o->testempty) { _e->UnPackTo(_o->testempty.get(), _resolver); } else { _o->testempty = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->UnPack(_resolver)); } } else if (_o->testempty) { _o->testempty.reset(); } } + { auto _e = testempty(); if (_e) { if(_o->testempty) { _e->UnPackTo(_o->testempty.get(), _resolver); } else { _o->testempty = std::unique_ptr<MyGame::Example::StatT>(_e->UnPack(_resolver)); } } else if (_o->testempty) { _o->testempty.reset(); } } { auto _e = testbool(); _o->testbool = _e; } { auto _e = testhashs32_fnv1(); _o->testhashs32_fnv1 = _e; } { auto _e = testhashu32_fnv1(); _o->testhashu32_fnv1 = _e; } @@ -3097,11 +3097,11 @@ inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_functi { auto _e = test5(); if (_e) { _o->test5.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test5[_i] = *_e->Get(_i); } } else { _o->test5.resize(0); } } { auto _e = vector_of_longs(); if (_e) { _o->vector_of_longs.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_longs[_i] = _e->Get(_i); } } else { _o->vector_of_longs.resize(0); } } { auto _e = vector_of_doubles(); if (_e) { _o->vector_of_doubles.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_doubles[_i] = _e->Get(_i); } } else { _o->vector_of_doubles.resize(0); } } - { auto _e = parent_namespace_test(); if (_e) { if(_o->parent_namespace_test) { _e->UnPackTo(_o->parent_namespace_test.get(), _resolver); } else { _o->parent_namespace_test = flatbuffers::unique_ptr<MyGame::InParentNamespaceT>(_e->UnPack(_resolver)); } } else if (_o->parent_namespace_test) { _o->parent_namespace_test.reset(); } } - { auto _e = vector_of_referrables(); if (_e) { _o->vector_of_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_referrables[_i].get(), _resolver); } else { _o->vector_of_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_referrables.resize(0); } } + { auto _e = parent_namespace_test(); if (_e) { if(_o->parent_namespace_test) { _e->UnPackTo(_o->parent_namespace_test.get(), _resolver); } else { _o->parent_namespace_test = std::unique_ptr<MyGame::InParentNamespaceT>(_e->UnPack(_resolver)); } } else if (_o->parent_namespace_test) { _o->parent_namespace_test.reset(); } } + { auto _e = vector_of_referrables(); if (_e) { _o->vector_of_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_referrables[_i].get(), _resolver); } else { _o->vector_of_referrables[_i] = std::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_referrables.resize(0); } } { auto _e = single_weak_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->single_weak_reference), static_cast<::flatbuffers::hash_value_t>(_e)); else _o->single_weak_reference = nullptr; } { auto _e = vector_of_weak_references(); if (_e) { _o->vector_of_weak_references.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_weak_references[_i]), static_cast<::flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_weak_references[_i] = nullptr; } } else { _o->vector_of_weak_references.resize(0); } } - { auto _e = vector_of_strong_referrables(); if (_e) { _o->vector_of_strong_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_strong_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_strong_referrables[_i].get(), _resolver); } else { _o->vector_of_strong_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_strong_referrables.resize(0); } } + { auto _e = vector_of_strong_referrables(); if (_e) { _o->vector_of_strong_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_strong_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_strong_referrables[_i].get(), _resolver); } else { _o->vector_of_strong_referrables[_i] = std::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_strong_referrables.resize(0); } } { auto _e = co_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->co_owning_reference), static_cast<::flatbuffers::hash_value_t>(_e)); else _o->co_owning_reference = nullptr; } { auto _e = vector_of_co_owning_references(); if (_e) { _o->vector_of_co_owning_references.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, default_ptr_type*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_co_owning_references[_i]), static_cast<::flatbuffers::hash_value_t>(_e->Get(_i)));/* else do nothing */; } } else { _o->vector_of_co_owning_references.resize(0); } } { auto _e = non_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->non_owning_reference), static_cast<::flatbuffers::hash_value_t>(_e)); else _o->non_owning_reference = nullptr; } @@ -3113,7 +3113,7 @@ inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_functi { auto _e = vector_of_enums(); if (_e) { _o->vector_of_enums.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_enums[_i] = static_cast<MyGame::Example::Color>(_e->Get(_i)); } } else { _o->vector_of_enums.resize(0); } } { auto _e = signed_enum(); _o->signed_enum = _e; } { auto _e = testrequirednestedflatbuffer(); if (_e) { _o->testrequirednestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testrequirednestedflatbuffer.begin()); } } - { auto _e = scalar_key_sorted_tables(); if (_e) { _o->scalar_key_sorted_tables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->scalar_key_sorted_tables[_i]) { _e->Get(_i)->UnPackTo(_o->scalar_key_sorted_tables[_i].get(), _resolver); } else { _o->scalar_key_sorted_tables[_i] = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->scalar_key_sorted_tables.resize(0); } } + { auto _e = scalar_key_sorted_tables(); if (_e) { _o->scalar_key_sorted_tables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->scalar_key_sorted_tables[_i]) { _e->Get(_i)->UnPackTo(_o->scalar_key_sorted_tables[_i].get(), _resolver); } else { _o->scalar_key_sorted_tables[_i] = std::unique_ptr<MyGame::Example::StatT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->scalar_key_sorted_tables.resize(0); } } { auto _e = native_inline(); if (_e) _o->native_inline = *_e; } { auto _e = long_enum_non_enum_default(); _o->long_enum_non_enum_default = _e; } { auto _e = long_enum_normal_default(); _o->long_enum_normal_default = _e; } @@ -4224,16 +4224,16 @@ inline void FinishSizePrefixedMonsterBuffer( fbb.FinishSizePrefixed(root, MonsterIdentifier()); } -inline flatbuffers::unique_ptr<MyGame::Example::MonsterT> UnPackMonster( +inline std::unique_ptr<MyGame::Example::MonsterT> UnPackMonster( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MyGame::Example::MonsterT>(GetMonster(buf)->UnPack(res)); + return std::unique_ptr<MyGame::Example::MonsterT>(GetMonster(buf)->UnPack(res)); } -inline flatbuffers::unique_ptr<MyGame::Example::MonsterT> UnPackSizePrefixedMonster( +inline std::unique_ptr<MyGame::Example::MonsterT> UnPackSizePrefixedMonster( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MyGame::Example::MonsterT>(GetSizePrefixedMonster(buf)->UnPack(res)); + return std::unique_ptr<MyGame::Example::MonsterT>(GetSizePrefixedMonster(buf)->UnPack(res)); } } // namespace Example diff --git a/tests/monster_test_suffix/ext_only/monster_test_generated.hpp b/tests/monster_test_suffix/ext_only/monster_test_generated.hpp index d11788e1..9c64fbbc 100644 --- a/tests/monster_test_suffix/ext_only/monster_test_generated.hpp +++ b/tests/monster_test_suffix/ext_only/monster_test_generated.hpp @@ -1259,7 +1259,7 @@ inline ::flatbuffers::Offset<Referrable> CreateReferrable( struct MonsterT : public ::flatbuffers::NativeTable { typedef Monster TableType; - flatbuffers::unique_ptr<MyGame::Example::Vec3> pos{}; + std::unique_ptr<MyGame::Example::Vec3> pos{}; int16_t mana = 150; int16_t hp = 100; std::string name{}; @@ -1268,10 +1268,10 @@ struct MonsterT : public ::flatbuffers::NativeTable { MyGame::Example::AnyUnion test{}; std::vector<MyGame::Example::Test> test4{}; std::vector<std::string> testarrayofstring{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::MonsterT>> testarrayoftables{}; - flatbuffers::unique_ptr<MyGame::Example::MonsterT> enemy{}; + std::vector<std::unique_ptr<MyGame::Example::MonsterT>> testarrayoftables{}; + std::unique_ptr<MyGame::Example::MonsterT> enemy{}; std::vector<uint8_t> testnestedflatbuffer{}; - flatbuffers::unique_ptr<MyGame::Example::StatT> testempty{}; + std::unique_ptr<MyGame::Example::StatT> testempty{}; bool testbool = false; int32_t testhashs32_fnv1 = 0; uint32_t testhashu32_fnv1 = 0; @@ -1291,13 +1291,13 @@ struct MonsterT : public ::flatbuffers::NativeTable { std::vector<MyGame::Example::Test> test5{}; std::vector<int64_t> vector_of_longs{}; std::vector<double> vector_of_doubles{}; - flatbuffers::unique_ptr<MyGame::InParentNamespaceT> parent_namespace_test{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::ReferrableT>> vector_of_referrables{}; + std::unique_ptr<MyGame::InParentNamespaceT> parent_namespace_test{}; + std::vector<std::unique_ptr<MyGame::Example::ReferrableT>> vector_of_referrables{}; ReferrableT *single_weak_reference = nullptr; std::vector<ReferrableT *> vector_of_weak_references{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::ReferrableT>> vector_of_strong_referrables{}; + std::vector<std::unique_ptr<MyGame::Example::ReferrableT>> vector_of_strong_referrables{}; ReferrableT *co_owning_reference = nullptr; - std::vector<flatbuffers::unique_ptr<ReferrableT>> vector_of_co_owning_references{}; + std::vector<std::unique_ptr<ReferrableT>> vector_of_co_owning_references{}; ReferrableT *non_owning_reference = nullptr; std::vector<ReferrableT *> vector_of_non_owning_references{}; MyGame::Example::AnyUniqueAliasesUnion any_unique{}; @@ -1305,7 +1305,7 @@ struct MonsterT : public ::flatbuffers::NativeTable { std::vector<MyGame::Example::Color> vector_of_enums{}; MyGame::Example::Race signed_enum = MyGame::Example::Race_None; std::vector<uint8_t> testrequirednestedflatbuffer{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::StatT>> scalar_key_sorted_tables{}; + std::vector<std::unique_ptr<MyGame::Example::StatT>> scalar_key_sorted_tables{}; MyGame::Example::Test native_inline{}; MyGame::Example::LongEnum long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0); MyGame::Example::LongEnum long_enum_normal_default = MyGame::Example::LongEnum_LongOne; @@ -2861,7 +2861,7 @@ inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) { (lhs.test == rhs.test) && (lhs.test4 == rhs.test4) && (lhs.testarrayofstring == rhs.testarrayofstring) && - (lhs.testarrayoftables.size() == rhs.testarrayoftables.size() && std::equal(lhs.testarrayoftables.cbegin(), lhs.testarrayoftables.cend(), rhs.testarrayoftables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &a, flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.testarrayoftables.size() == rhs.testarrayoftables.size() && std::equal(lhs.testarrayoftables.cbegin(), lhs.testarrayoftables.cend(), rhs.testarrayoftables.cbegin(), [](std::unique_ptr<MyGame::Example::MonsterT> const &a, std::unique_ptr<MyGame::Example::MonsterT> const &b) { return (a == b) || (a && b && *a == *b); })) && ((lhs.enemy == rhs.enemy) || (lhs.enemy && rhs.enemy && *lhs.enemy == *rhs.enemy)) && (lhs.testnestedflatbuffer == rhs.testnestedflatbuffer) && ((lhs.testempty == rhs.testempty) || (lhs.testempty && rhs.testempty && *lhs.testempty == *rhs.testempty)) && @@ -2885,10 +2885,10 @@ inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) { (lhs.vector_of_longs == rhs.vector_of_longs) && (lhs.vector_of_doubles == rhs.vector_of_doubles) && ((lhs.parent_namespace_test == rhs.parent_namespace_test) || (lhs.parent_namespace_test && rhs.parent_namespace_test && *lhs.parent_namespace_test == *rhs.parent_namespace_test)) && - (lhs.vector_of_referrables.size() == rhs.vector_of_referrables.size() && std::equal(lhs.vector_of_referrables.cbegin(), lhs.vector_of_referrables.cend(), rhs.vector_of_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.vector_of_referrables.size() == rhs.vector_of_referrables.size() && std::equal(lhs.vector_of_referrables.cbegin(), lhs.vector_of_referrables.cend(), rhs.vector_of_referrables.cbegin(), [](std::unique_ptr<MyGame::Example::ReferrableT> const &a, std::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && (lhs.single_weak_reference == rhs.single_weak_reference) && (lhs.vector_of_weak_references == rhs.vector_of_weak_references) && - (lhs.vector_of_strong_referrables.size() == rhs.vector_of_strong_referrables.size() && std::equal(lhs.vector_of_strong_referrables.cbegin(), lhs.vector_of_strong_referrables.cend(), rhs.vector_of_strong_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.vector_of_strong_referrables.size() == rhs.vector_of_strong_referrables.size() && std::equal(lhs.vector_of_strong_referrables.cbegin(), lhs.vector_of_strong_referrables.cend(), rhs.vector_of_strong_referrables.cbegin(), [](std::unique_ptr<MyGame::Example::ReferrableT> const &a, std::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && (lhs.co_owning_reference == rhs.co_owning_reference) && (lhs.vector_of_co_owning_references == rhs.vector_of_co_owning_references) && (lhs.non_owning_reference == rhs.non_owning_reference) && @@ -2898,7 +2898,7 @@ inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) { (lhs.vector_of_enums == rhs.vector_of_enums) && (lhs.signed_enum == rhs.signed_enum) && (lhs.testrequirednestedflatbuffer == rhs.testrequirednestedflatbuffer) && - (lhs.scalar_key_sorted_tables.size() == rhs.scalar_key_sorted_tables.size() && std::equal(lhs.scalar_key_sorted_tables.cbegin(), lhs.scalar_key_sorted_tables.cend(), rhs.scalar_key_sorted_tables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::StatT> const &a, flatbuffers::unique_ptr<MyGame::Example::StatT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.scalar_key_sorted_tables.size() == rhs.scalar_key_sorted_tables.size() && std::equal(lhs.scalar_key_sorted_tables.cbegin(), lhs.scalar_key_sorted_tables.cend(), rhs.scalar_key_sorted_tables.cbegin(), [](std::unique_ptr<MyGame::Example::StatT> const &a, std::unique_ptr<MyGame::Example::StatT> const &b) { return (a == b) || (a && b && *a == *b); })) && (lhs.native_inline == rhs.native_inline) && (lhs.long_enum_non_enum_default == rhs.long_enum_non_enum_default) && (lhs.long_enum_normal_default == rhs.long_enum_normal_default) && @@ -3054,7 +3054,7 @@ inline MonsterT *Monster::UnPack(const ::flatbuffers::resolver_function_t *_reso inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = pos(); if (_e) _o->pos = flatbuffers::unique_ptr<MyGame::Example::Vec3>(new MyGame::Example::Vec3(*_e)); } + { auto _e = pos(); if (_e) _o->pos = std::unique_ptr<MyGame::Example::Vec3>(new MyGame::Example::Vec3(*_e)); } { auto _e = mana(); _o->mana = _e; } { auto _e = hp(); _o->hp = _e; } { auto _e = name(); if (_e) _o->name = _e->str(); } @@ -3064,10 +3064,10 @@ inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_functi { auto _e = test(); if (_e) _o->test.value = MyGame::Example::AnyUnion::UnPack(_e, test_type(), _resolver); } { auto _e = test4(); if (_e) { _o->test4.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test4[_i] = *_e->Get(_i); } } else { _o->test4.resize(0); } } { auto _e = testarrayofstring(); if (_e) { _o->testarrayofstring.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring[_i] = _e->Get(_i)->str(); } } else { _o->testarrayofstring.resize(0); } } - { auto _e = testarrayoftables(); if (_e) { _o->testarrayoftables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->testarrayoftables[_i]) { _e->Get(_i)->UnPackTo(_o->testarrayoftables[_i].get(), _resolver); } else { _o->testarrayoftables[_i] = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->testarrayoftables.resize(0); } } - { auto _e = enemy(); if (_e) { if(_o->enemy) { _e->UnPackTo(_o->enemy.get(), _resolver); } else { _o->enemy = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->UnPack(_resolver)); } } else if (_o->enemy) { _o->enemy.reset(); } } + { auto _e = testarrayoftables(); if (_e) { _o->testarrayoftables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->testarrayoftables[_i]) { _e->Get(_i)->UnPackTo(_o->testarrayoftables[_i].get(), _resolver); } else { _o->testarrayoftables[_i] = std::unique_ptr<MyGame::Example::MonsterT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->testarrayoftables.resize(0); } } + { auto _e = enemy(); if (_e) { if(_o->enemy) { _e->UnPackTo(_o->enemy.get(), _resolver); } else { _o->enemy = std::unique_ptr<MyGame::Example::MonsterT>(_e->UnPack(_resolver)); } } else if (_o->enemy) { _o->enemy.reset(); } } { auto _e = testnestedflatbuffer(); if (_e) { _o->testnestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testnestedflatbuffer.begin()); } } - { auto _e = testempty(); if (_e) { if(_o->testempty) { _e->UnPackTo(_o->testempty.get(), _resolver); } else { _o->testempty = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->UnPack(_resolver)); } } else if (_o->testempty) { _o->testempty.reset(); } } + { auto _e = testempty(); if (_e) { if(_o->testempty) { _e->UnPackTo(_o->testempty.get(), _resolver); } else { _o->testempty = std::unique_ptr<MyGame::Example::StatT>(_e->UnPack(_resolver)); } } else if (_o->testempty) { _o->testempty.reset(); } } { auto _e = testbool(); _o->testbool = _e; } { auto _e = testhashs32_fnv1(); _o->testhashs32_fnv1 = _e; } { auto _e = testhashu32_fnv1(); _o->testhashu32_fnv1 = _e; } @@ -3087,11 +3087,11 @@ inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_functi { auto _e = test5(); if (_e) { _o->test5.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test5[_i] = *_e->Get(_i); } } else { _o->test5.resize(0); } } { auto _e = vector_of_longs(); if (_e) { _o->vector_of_longs.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_longs[_i] = _e->Get(_i); } } else { _o->vector_of_longs.resize(0); } } { auto _e = vector_of_doubles(); if (_e) { _o->vector_of_doubles.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_doubles[_i] = _e->Get(_i); } } else { _o->vector_of_doubles.resize(0); } } - { auto _e = parent_namespace_test(); if (_e) { if(_o->parent_namespace_test) { _e->UnPackTo(_o->parent_namespace_test.get(), _resolver); } else { _o->parent_namespace_test = flatbuffers::unique_ptr<MyGame::InParentNamespaceT>(_e->UnPack(_resolver)); } } else if (_o->parent_namespace_test) { _o->parent_namespace_test.reset(); } } - { auto _e = vector_of_referrables(); if (_e) { _o->vector_of_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_referrables[_i].get(), _resolver); } else { _o->vector_of_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_referrables.resize(0); } } + { auto _e = parent_namespace_test(); if (_e) { if(_o->parent_namespace_test) { _e->UnPackTo(_o->parent_namespace_test.get(), _resolver); } else { _o->parent_namespace_test = std::unique_ptr<MyGame::InParentNamespaceT>(_e->UnPack(_resolver)); } } else if (_o->parent_namespace_test) { _o->parent_namespace_test.reset(); } } + { auto _e = vector_of_referrables(); if (_e) { _o->vector_of_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_referrables[_i].get(), _resolver); } else { _o->vector_of_referrables[_i] = std::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_referrables.resize(0); } } { auto _e = single_weak_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->single_weak_reference), static_cast<::flatbuffers::hash_value_t>(_e)); else _o->single_weak_reference = nullptr; } { auto _e = vector_of_weak_references(); if (_e) { _o->vector_of_weak_references.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_weak_references[_i]), static_cast<::flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_weak_references[_i] = nullptr; } } else { _o->vector_of_weak_references.resize(0); } } - { auto _e = vector_of_strong_referrables(); if (_e) { _o->vector_of_strong_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_strong_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_strong_referrables[_i].get(), _resolver); } else { _o->vector_of_strong_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_strong_referrables.resize(0); } } + { auto _e = vector_of_strong_referrables(); if (_e) { _o->vector_of_strong_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_strong_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_strong_referrables[_i].get(), _resolver); } else { _o->vector_of_strong_referrables[_i] = std::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_strong_referrables.resize(0); } } { auto _e = co_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->co_owning_reference), static_cast<::flatbuffers::hash_value_t>(_e)); else _o->co_owning_reference = nullptr; } { auto _e = vector_of_co_owning_references(); if (_e) { _o->vector_of_co_owning_references.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, default_ptr_type*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_co_owning_references[_i]), static_cast<::flatbuffers::hash_value_t>(_e->Get(_i)));/* else do nothing */; } } else { _o->vector_of_co_owning_references.resize(0); } } { auto _e = non_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->non_owning_reference), static_cast<::flatbuffers::hash_value_t>(_e)); else _o->non_owning_reference = nullptr; } @@ -3103,7 +3103,7 @@ inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_functi { auto _e = vector_of_enums(); if (_e) { _o->vector_of_enums.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_enums[_i] = static_cast<MyGame::Example::Color>(_e->Get(_i)); } } else { _o->vector_of_enums.resize(0); } } { auto _e = signed_enum(); _o->signed_enum = _e; } { auto _e = testrequirednestedflatbuffer(); if (_e) { _o->testrequirednestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testrequirednestedflatbuffer.begin()); } } - { auto _e = scalar_key_sorted_tables(); if (_e) { _o->scalar_key_sorted_tables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->scalar_key_sorted_tables[_i]) { _e->Get(_i)->UnPackTo(_o->scalar_key_sorted_tables[_i].get(), _resolver); } else { _o->scalar_key_sorted_tables[_i] = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->scalar_key_sorted_tables.resize(0); } } + { auto _e = scalar_key_sorted_tables(); if (_e) { _o->scalar_key_sorted_tables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->scalar_key_sorted_tables[_i]) { _e->Get(_i)->UnPackTo(_o->scalar_key_sorted_tables[_i].get(), _resolver); } else { _o->scalar_key_sorted_tables[_i] = std::unique_ptr<MyGame::Example::StatT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->scalar_key_sorted_tables.resize(0); } } { auto _e = native_inline(); if (_e) _o->native_inline = *_e; } { auto _e = long_enum_non_enum_default(); _o->long_enum_non_enum_default = _e; } { auto _e = long_enum_normal_default(); _o->long_enum_normal_default = _e; } @@ -4214,16 +4214,16 @@ inline void FinishSizePrefixedMonsterBuffer( fbb.FinishSizePrefixed(root, MonsterIdentifier()); } -inline flatbuffers::unique_ptr<MyGame::Example::MonsterT> UnPackMonster( +inline std::unique_ptr<MyGame::Example::MonsterT> UnPackMonster( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MyGame::Example::MonsterT>(GetMonster(buf)->UnPack(res)); + return std::unique_ptr<MyGame::Example::MonsterT>(GetMonster(buf)->UnPack(res)); } -inline flatbuffers::unique_ptr<MyGame::Example::MonsterT> UnPackSizePrefixedMonster( +inline std::unique_ptr<MyGame::Example::MonsterT> UnPackSizePrefixedMonster( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MyGame::Example::MonsterT>(GetSizePrefixedMonster(buf)->UnPack(res)); + return std::unique_ptr<MyGame::Example::MonsterT>(GetSizePrefixedMonster(buf)->UnPack(res)); } } // namespace Example diff --git a/tests/monster_test_suffix/filesuffix_only/monster_test_suffix.h b/tests/monster_test_suffix/filesuffix_only/monster_test_suffix.h index d11788e1..9c64fbbc 100644 --- a/tests/monster_test_suffix/filesuffix_only/monster_test_suffix.h +++ b/tests/monster_test_suffix/filesuffix_only/monster_test_suffix.h @@ -1259,7 +1259,7 @@ inline ::flatbuffers::Offset<Referrable> CreateReferrable( struct MonsterT : public ::flatbuffers::NativeTable { typedef Monster TableType; - flatbuffers::unique_ptr<MyGame::Example::Vec3> pos{}; + std::unique_ptr<MyGame::Example::Vec3> pos{}; int16_t mana = 150; int16_t hp = 100; std::string name{}; @@ -1268,10 +1268,10 @@ struct MonsterT : public ::flatbuffers::NativeTable { MyGame::Example::AnyUnion test{}; std::vector<MyGame::Example::Test> test4{}; std::vector<std::string> testarrayofstring{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::MonsterT>> testarrayoftables{}; - flatbuffers::unique_ptr<MyGame::Example::MonsterT> enemy{}; + std::vector<std::unique_ptr<MyGame::Example::MonsterT>> testarrayoftables{}; + std::unique_ptr<MyGame::Example::MonsterT> enemy{}; std::vector<uint8_t> testnestedflatbuffer{}; - flatbuffers::unique_ptr<MyGame::Example::StatT> testempty{}; + std::unique_ptr<MyGame::Example::StatT> testempty{}; bool testbool = false; int32_t testhashs32_fnv1 = 0; uint32_t testhashu32_fnv1 = 0; @@ -1291,13 +1291,13 @@ struct MonsterT : public ::flatbuffers::NativeTable { std::vector<MyGame::Example::Test> test5{}; std::vector<int64_t> vector_of_longs{}; std::vector<double> vector_of_doubles{}; - flatbuffers::unique_ptr<MyGame::InParentNamespaceT> parent_namespace_test{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::ReferrableT>> vector_of_referrables{}; + std::unique_ptr<MyGame::InParentNamespaceT> parent_namespace_test{}; + std::vector<std::unique_ptr<MyGame::Example::ReferrableT>> vector_of_referrables{}; ReferrableT *single_weak_reference = nullptr; std::vector<ReferrableT *> vector_of_weak_references{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::ReferrableT>> vector_of_strong_referrables{}; + std::vector<std::unique_ptr<MyGame::Example::ReferrableT>> vector_of_strong_referrables{}; ReferrableT *co_owning_reference = nullptr; - std::vector<flatbuffers::unique_ptr<ReferrableT>> vector_of_co_owning_references{}; + std::vector<std::unique_ptr<ReferrableT>> vector_of_co_owning_references{}; ReferrableT *non_owning_reference = nullptr; std::vector<ReferrableT *> vector_of_non_owning_references{}; MyGame::Example::AnyUniqueAliasesUnion any_unique{}; @@ -1305,7 +1305,7 @@ struct MonsterT : public ::flatbuffers::NativeTable { std::vector<MyGame::Example::Color> vector_of_enums{}; MyGame::Example::Race signed_enum = MyGame::Example::Race_None; std::vector<uint8_t> testrequirednestedflatbuffer{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::StatT>> scalar_key_sorted_tables{}; + std::vector<std::unique_ptr<MyGame::Example::StatT>> scalar_key_sorted_tables{}; MyGame::Example::Test native_inline{}; MyGame::Example::LongEnum long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0); MyGame::Example::LongEnum long_enum_normal_default = MyGame::Example::LongEnum_LongOne; @@ -2861,7 +2861,7 @@ inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) { (lhs.test == rhs.test) && (lhs.test4 == rhs.test4) && (lhs.testarrayofstring == rhs.testarrayofstring) && - (lhs.testarrayoftables.size() == rhs.testarrayoftables.size() && std::equal(lhs.testarrayoftables.cbegin(), lhs.testarrayoftables.cend(), rhs.testarrayoftables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &a, flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.testarrayoftables.size() == rhs.testarrayoftables.size() && std::equal(lhs.testarrayoftables.cbegin(), lhs.testarrayoftables.cend(), rhs.testarrayoftables.cbegin(), [](std::unique_ptr<MyGame::Example::MonsterT> const &a, std::unique_ptr<MyGame::Example::MonsterT> const &b) { return (a == b) || (a && b && *a == *b); })) && ((lhs.enemy == rhs.enemy) || (lhs.enemy && rhs.enemy && *lhs.enemy == *rhs.enemy)) && (lhs.testnestedflatbuffer == rhs.testnestedflatbuffer) && ((lhs.testempty == rhs.testempty) || (lhs.testempty && rhs.testempty && *lhs.testempty == *rhs.testempty)) && @@ -2885,10 +2885,10 @@ inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) { (lhs.vector_of_longs == rhs.vector_of_longs) && (lhs.vector_of_doubles == rhs.vector_of_doubles) && ((lhs.parent_namespace_test == rhs.parent_namespace_test) || (lhs.parent_namespace_test && rhs.parent_namespace_test && *lhs.parent_namespace_test == *rhs.parent_namespace_test)) && - (lhs.vector_of_referrables.size() == rhs.vector_of_referrables.size() && std::equal(lhs.vector_of_referrables.cbegin(), lhs.vector_of_referrables.cend(), rhs.vector_of_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.vector_of_referrables.size() == rhs.vector_of_referrables.size() && std::equal(lhs.vector_of_referrables.cbegin(), lhs.vector_of_referrables.cend(), rhs.vector_of_referrables.cbegin(), [](std::unique_ptr<MyGame::Example::ReferrableT> const &a, std::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && (lhs.single_weak_reference == rhs.single_weak_reference) && (lhs.vector_of_weak_references == rhs.vector_of_weak_references) && - (lhs.vector_of_strong_referrables.size() == rhs.vector_of_strong_referrables.size() && std::equal(lhs.vector_of_strong_referrables.cbegin(), lhs.vector_of_strong_referrables.cend(), rhs.vector_of_strong_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.vector_of_strong_referrables.size() == rhs.vector_of_strong_referrables.size() && std::equal(lhs.vector_of_strong_referrables.cbegin(), lhs.vector_of_strong_referrables.cend(), rhs.vector_of_strong_referrables.cbegin(), [](std::unique_ptr<MyGame::Example::ReferrableT> const &a, std::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && (lhs.co_owning_reference == rhs.co_owning_reference) && (lhs.vector_of_co_owning_references == rhs.vector_of_co_owning_references) && (lhs.non_owning_reference == rhs.non_owning_reference) && @@ -2898,7 +2898,7 @@ inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) { (lhs.vector_of_enums == rhs.vector_of_enums) && (lhs.signed_enum == rhs.signed_enum) && (lhs.testrequirednestedflatbuffer == rhs.testrequirednestedflatbuffer) && - (lhs.scalar_key_sorted_tables.size() == rhs.scalar_key_sorted_tables.size() && std::equal(lhs.scalar_key_sorted_tables.cbegin(), lhs.scalar_key_sorted_tables.cend(), rhs.scalar_key_sorted_tables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::StatT> const &a, flatbuffers::unique_ptr<MyGame::Example::StatT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.scalar_key_sorted_tables.size() == rhs.scalar_key_sorted_tables.size() && std::equal(lhs.scalar_key_sorted_tables.cbegin(), lhs.scalar_key_sorted_tables.cend(), rhs.scalar_key_sorted_tables.cbegin(), [](std::unique_ptr<MyGame::Example::StatT> const &a, std::unique_ptr<MyGame::Example::StatT> const &b) { return (a == b) || (a && b && *a == *b); })) && (lhs.native_inline == rhs.native_inline) && (lhs.long_enum_non_enum_default == rhs.long_enum_non_enum_default) && (lhs.long_enum_normal_default == rhs.long_enum_normal_default) && @@ -3054,7 +3054,7 @@ inline MonsterT *Monster::UnPack(const ::flatbuffers::resolver_function_t *_reso inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = pos(); if (_e) _o->pos = flatbuffers::unique_ptr<MyGame::Example::Vec3>(new MyGame::Example::Vec3(*_e)); } + { auto _e = pos(); if (_e) _o->pos = std::unique_ptr<MyGame::Example::Vec3>(new MyGame::Example::Vec3(*_e)); } { auto _e = mana(); _o->mana = _e; } { auto _e = hp(); _o->hp = _e; } { auto _e = name(); if (_e) _o->name = _e->str(); } @@ -3064,10 +3064,10 @@ inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_functi { auto _e = test(); if (_e) _o->test.value = MyGame::Example::AnyUnion::UnPack(_e, test_type(), _resolver); } { auto _e = test4(); if (_e) { _o->test4.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test4[_i] = *_e->Get(_i); } } else { _o->test4.resize(0); } } { auto _e = testarrayofstring(); if (_e) { _o->testarrayofstring.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring[_i] = _e->Get(_i)->str(); } } else { _o->testarrayofstring.resize(0); } } - { auto _e = testarrayoftables(); if (_e) { _o->testarrayoftables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->testarrayoftables[_i]) { _e->Get(_i)->UnPackTo(_o->testarrayoftables[_i].get(), _resolver); } else { _o->testarrayoftables[_i] = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->testarrayoftables.resize(0); } } - { auto _e = enemy(); if (_e) { if(_o->enemy) { _e->UnPackTo(_o->enemy.get(), _resolver); } else { _o->enemy = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->UnPack(_resolver)); } } else if (_o->enemy) { _o->enemy.reset(); } } + { auto _e = testarrayoftables(); if (_e) { _o->testarrayoftables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->testarrayoftables[_i]) { _e->Get(_i)->UnPackTo(_o->testarrayoftables[_i].get(), _resolver); } else { _o->testarrayoftables[_i] = std::unique_ptr<MyGame::Example::MonsterT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->testarrayoftables.resize(0); } } + { auto _e = enemy(); if (_e) { if(_o->enemy) { _e->UnPackTo(_o->enemy.get(), _resolver); } else { _o->enemy = std::unique_ptr<MyGame::Example::MonsterT>(_e->UnPack(_resolver)); } } else if (_o->enemy) { _o->enemy.reset(); } } { auto _e = testnestedflatbuffer(); if (_e) { _o->testnestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testnestedflatbuffer.begin()); } } - { auto _e = testempty(); if (_e) { if(_o->testempty) { _e->UnPackTo(_o->testempty.get(), _resolver); } else { _o->testempty = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->UnPack(_resolver)); } } else if (_o->testempty) { _o->testempty.reset(); } } + { auto _e = testempty(); if (_e) { if(_o->testempty) { _e->UnPackTo(_o->testempty.get(), _resolver); } else { _o->testempty = std::unique_ptr<MyGame::Example::StatT>(_e->UnPack(_resolver)); } } else if (_o->testempty) { _o->testempty.reset(); } } { auto _e = testbool(); _o->testbool = _e; } { auto _e = testhashs32_fnv1(); _o->testhashs32_fnv1 = _e; } { auto _e = testhashu32_fnv1(); _o->testhashu32_fnv1 = _e; } @@ -3087,11 +3087,11 @@ inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_functi { auto _e = test5(); if (_e) { _o->test5.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test5[_i] = *_e->Get(_i); } } else { _o->test5.resize(0); } } { auto _e = vector_of_longs(); if (_e) { _o->vector_of_longs.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_longs[_i] = _e->Get(_i); } } else { _o->vector_of_longs.resize(0); } } { auto _e = vector_of_doubles(); if (_e) { _o->vector_of_doubles.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_doubles[_i] = _e->Get(_i); } } else { _o->vector_of_doubles.resize(0); } } - { auto _e = parent_namespace_test(); if (_e) { if(_o->parent_namespace_test) { _e->UnPackTo(_o->parent_namespace_test.get(), _resolver); } else { _o->parent_namespace_test = flatbuffers::unique_ptr<MyGame::InParentNamespaceT>(_e->UnPack(_resolver)); } } else if (_o->parent_namespace_test) { _o->parent_namespace_test.reset(); } } - { auto _e = vector_of_referrables(); if (_e) { _o->vector_of_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_referrables[_i].get(), _resolver); } else { _o->vector_of_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_referrables.resize(0); } } + { auto _e = parent_namespace_test(); if (_e) { if(_o->parent_namespace_test) { _e->UnPackTo(_o->parent_namespace_test.get(), _resolver); } else { _o->parent_namespace_test = std::unique_ptr<MyGame::InParentNamespaceT>(_e->UnPack(_resolver)); } } else if (_o->parent_namespace_test) { _o->parent_namespace_test.reset(); } } + { auto _e = vector_of_referrables(); if (_e) { _o->vector_of_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_referrables[_i].get(), _resolver); } else { _o->vector_of_referrables[_i] = std::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_referrables.resize(0); } } { auto _e = single_weak_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->single_weak_reference), static_cast<::flatbuffers::hash_value_t>(_e)); else _o->single_weak_reference = nullptr; } { auto _e = vector_of_weak_references(); if (_e) { _o->vector_of_weak_references.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_weak_references[_i]), static_cast<::flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_weak_references[_i] = nullptr; } } else { _o->vector_of_weak_references.resize(0); } } - { auto _e = vector_of_strong_referrables(); if (_e) { _o->vector_of_strong_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_strong_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_strong_referrables[_i].get(), _resolver); } else { _o->vector_of_strong_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_strong_referrables.resize(0); } } + { auto _e = vector_of_strong_referrables(); if (_e) { _o->vector_of_strong_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_strong_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_strong_referrables[_i].get(), _resolver); } else { _o->vector_of_strong_referrables[_i] = std::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_strong_referrables.resize(0); } } { auto _e = co_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->co_owning_reference), static_cast<::flatbuffers::hash_value_t>(_e)); else _o->co_owning_reference = nullptr; } { auto _e = vector_of_co_owning_references(); if (_e) { _o->vector_of_co_owning_references.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, default_ptr_type*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_co_owning_references[_i]), static_cast<::flatbuffers::hash_value_t>(_e->Get(_i)));/* else do nothing */; } } else { _o->vector_of_co_owning_references.resize(0); } } { auto _e = non_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->non_owning_reference), static_cast<::flatbuffers::hash_value_t>(_e)); else _o->non_owning_reference = nullptr; } @@ -3103,7 +3103,7 @@ inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_functi { auto _e = vector_of_enums(); if (_e) { _o->vector_of_enums.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_enums[_i] = static_cast<MyGame::Example::Color>(_e->Get(_i)); } } else { _o->vector_of_enums.resize(0); } } { auto _e = signed_enum(); _o->signed_enum = _e; } { auto _e = testrequirednestedflatbuffer(); if (_e) { _o->testrequirednestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testrequirednestedflatbuffer.begin()); } } - { auto _e = scalar_key_sorted_tables(); if (_e) { _o->scalar_key_sorted_tables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->scalar_key_sorted_tables[_i]) { _e->Get(_i)->UnPackTo(_o->scalar_key_sorted_tables[_i].get(), _resolver); } else { _o->scalar_key_sorted_tables[_i] = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->scalar_key_sorted_tables.resize(0); } } + { auto _e = scalar_key_sorted_tables(); if (_e) { _o->scalar_key_sorted_tables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->scalar_key_sorted_tables[_i]) { _e->Get(_i)->UnPackTo(_o->scalar_key_sorted_tables[_i].get(), _resolver); } else { _o->scalar_key_sorted_tables[_i] = std::unique_ptr<MyGame::Example::StatT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->scalar_key_sorted_tables.resize(0); } } { auto _e = native_inline(); if (_e) _o->native_inline = *_e; } { auto _e = long_enum_non_enum_default(); _o->long_enum_non_enum_default = _e; } { auto _e = long_enum_normal_default(); _o->long_enum_normal_default = _e; } @@ -4214,16 +4214,16 @@ inline void FinishSizePrefixedMonsterBuffer( fbb.FinishSizePrefixed(root, MonsterIdentifier()); } -inline flatbuffers::unique_ptr<MyGame::Example::MonsterT> UnPackMonster( +inline std::unique_ptr<MyGame::Example::MonsterT> UnPackMonster( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MyGame::Example::MonsterT>(GetMonster(buf)->UnPack(res)); + return std::unique_ptr<MyGame::Example::MonsterT>(GetMonster(buf)->UnPack(res)); } -inline flatbuffers::unique_ptr<MyGame::Example::MonsterT> UnPackSizePrefixedMonster( +inline std::unique_ptr<MyGame::Example::MonsterT> UnPackSizePrefixedMonster( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MyGame::Example::MonsterT>(GetSizePrefixedMonster(buf)->UnPack(res)); + return std::unique_ptr<MyGame::Example::MonsterT>(GetSizePrefixedMonster(buf)->UnPack(res)); } } // namespace Example diff --git a/tests/monster_test_suffix/monster_test_suffix.hpp b/tests/monster_test_suffix/monster_test_suffix.hpp index d11788e1..9c64fbbc 100644 --- a/tests/monster_test_suffix/monster_test_suffix.hpp +++ b/tests/monster_test_suffix/monster_test_suffix.hpp @@ -1259,7 +1259,7 @@ inline ::flatbuffers::Offset<Referrable> CreateReferrable( struct MonsterT : public ::flatbuffers::NativeTable { typedef Monster TableType; - flatbuffers::unique_ptr<MyGame::Example::Vec3> pos{}; + std::unique_ptr<MyGame::Example::Vec3> pos{}; int16_t mana = 150; int16_t hp = 100; std::string name{}; @@ -1268,10 +1268,10 @@ struct MonsterT : public ::flatbuffers::NativeTable { MyGame::Example::AnyUnion test{}; std::vector<MyGame::Example::Test> test4{}; std::vector<std::string> testarrayofstring{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::MonsterT>> testarrayoftables{}; - flatbuffers::unique_ptr<MyGame::Example::MonsterT> enemy{}; + std::vector<std::unique_ptr<MyGame::Example::MonsterT>> testarrayoftables{}; + std::unique_ptr<MyGame::Example::MonsterT> enemy{}; std::vector<uint8_t> testnestedflatbuffer{}; - flatbuffers::unique_ptr<MyGame::Example::StatT> testempty{}; + std::unique_ptr<MyGame::Example::StatT> testempty{}; bool testbool = false; int32_t testhashs32_fnv1 = 0; uint32_t testhashu32_fnv1 = 0; @@ -1291,13 +1291,13 @@ struct MonsterT : public ::flatbuffers::NativeTable { std::vector<MyGame::Example::Test> test5{}; std::vector<int64_t> vector_of_longs{}; std::vector<double> vector_of_doubles{}; - flatbuffers::unique_ptr<MyGame::InParentNamespaceT> parent_namespace_test{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::ReferrableT>> vector_of_referrables{}; + std::unique_ptr<MyGame::InParentNamespaceT> parent_namespace_test{}; + std::vector<std::unique_ptr<MyGame::Example::ReferrableT>> vector_of_referrables{}; ReferrableT *single_weak_reference = nullptr; std::vector<ReferrableT *> vector_of_weak_references{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::ReferrableT>> vector_of_strong_referrables{}; + std::vector<std::unique_ptr<MyGame::Example::ReferrableT>> vector_of_strong_referrables{}; ReferrableT *co_owning_reference = nullptr; - std::vector<flatbuffers::unique_ptr<ReferrableT>> vector_of_co_owning_references{}; + std::vector<std::unique_ptr<ReferrableT>> vector_of_co_owning_references{}; ReferrableT *non_owning_reference = nullptr; std::vector<ReferrableT *> vector_of_non_owning_references{}; MyGame::Example::AnyUniqueAliasesUnion any_unique{}; @@ -1305,7 +1305,7 @@ struct MonsterT : public ::flatbuffers::NativeTable { std::vector<MyGame::Example::Color> vector_of_enums{}; MyGame::Example::Race signed_enum = MyGame::Example::Race_None; std::vector<uint8_t> testrequirednestedflatbuffer{}; - std::vector<flatbuffers::unique_ptr<MyGame::Example::StatT>> scalar_key_sorted_tables{}; + std::vector<std::unique_ptr<MyGame::Example::StatT>> scalar_key_sorted_tables{}; MyGame::Example::Test native_inline{}; MyGame::Example::LongEnum long_enum_non_enum_default = static_cast<MyGame::Example::LongEnum>(0); MyGame::Example::LongEnum long_enum_normal_default = MyGame::Example::LongEnum_LongOne; @@ -2861,7 +2861,7 @@ inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) { (lhs.test == rhs.test) && (lhs.test4 == rhs.test4) && (lhs.testarrayofstring == rhs.testarrayofstring) && - (lhs.testarrayoftables.size() == rhs.testarrayoftables.size() && std::equal(lhs.testarrayoftables.cbegin(), lhs.testarrayoftables.cend(), rhs.testarrayoftables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &a, flatbuffers::unique_ptr<MyGame::Example::MonsterT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.testarrayoftables.size() == rhs.testarrayoftables.size() && std::equal(lhs.testarrayoftables.cbegin(), lhs.testarrayoftables.cend(), rhs.testarrayoftables.cbegin(), [](std::unique_ptr<MyGame::Example::MonsterT> const &a, std::unique_ptr<MyGame::Example::MonsterT> const &b) { return (a == b) || (a && b && *a == *b); })) && ((lhs.enemy == rhs.enemy) || (lhs.enemy && rhs.enemy && *lhs.enemy == *rhs.enemy)) && (lhs.testnestedflatbuffer == rhs.testnestedflatbuffer) && ((lhs.testempty == rhs.testempty) || (lhs.testempty && rhs.testempty && *lhs.testempty == *rhs.testempty)) && @@ -2885,10 +2885,10 @@ inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) { (lhs.vector_of_longs == rhs.vector_of_longs) && (lhs.vector_of_doubles == rhs.vector_of_doubles) && ((lhs.parent_namespace_test == rhs.parent_namespace_test) || (lhs.parent_namespace_test && rhs.parent_namespace_test && *lhs.parent_namespace_test == *rhs.parent_namespace_test)) && - (lhs.vector_of_referrables.size() == rhs.vector_of_referrables.size() && std::equal(lhs.vector_of_referrables.cbegin(), lhs.vector_of_referrables.cend(), rhs.vector_of_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.vector_of_referrables.size() == rhs.vector_of_referrables.size() && std::equal(lhs.vector_of_referrables.cbegin(), lhs.vector_of_referrables.cend(), rhs.vector_of_referrables.cbegin(), [](std::unique_ptr<MyGame::Example::ReferrableT> const &a, std::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && (lhs.single_weak_reference == rhs.single_weak_reference) && (lhs.vector_of_weak_references == rhs.vector_of_weak_references) && - (lhs.vector_of_strong_referrables.size() == rhs.vector_of_strong_referrables.size() && std::equal(lhs.vector_of_strong_referrables.cbegin(), lhs.vector_of_strong_referrables.cend(), rhs.vector_of_strong_referrables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &a, flatbuffers::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.vector_of_strong_referrables.size() == rhs.vector_of_strong_referrables.size() && std::equal(lhs.vector_of_strong_referrables.cbegin(), lhs.vector_of_strong_referrables.cend(), rhs.vector_of_strong_referrables.cbegin(), [](std::unique_ptr<MyGame::Example::ReferrableT> const &a, std::unique_ptr<MyGame::Example::ReferrableT> const &b) { return (a == b) || (a && b && *a == *b); })) && (lhs.co_owning_reference == rhs.co_owning_reference) && (lhs.vector_of_co_owning_references == rhs.vector_of_co_owning_references) && (lhs.non_owning_reference == rhs.non_owning_reference) && @@ -2898,7 +2898,7 @@ inline bool operator==(const MonsterT &lhs, const MonsterT &rhs) { (lhs.vector_of_enums == rhs.vector_of_enums) && (lhs.signed_enum == rhs.signed_enum) && (lhs.testrequirednestedflatbuffer == rhs.testrequirednestedflatbuffer) && - (lhs.scalar_key_sorted_tables.size() == rhs.scalar_key_sorted_tables.size() && std::equal(lhs.scalar_key_sorted_tables.cbegin(), lhs.scalar_key_sorted_tables.cend(), rhs.scalar_key_sorted_tables.cbegin(), [](flatbuffers::unique_ptr<MyGame::Example::StatT> const &a, flatbuffers::unique_ptr<MyGame::Example::StatT> const &b) { return (a == b) || (a && b && *a == *b); })) && + (lhs.scalar_key_sorted_tables.size() == rhs.scalar_key_sorted_tables.size() && std::equal(lhs.scalar_key_sorted_tables.cbegin(), lhs.scalar_key_sorted_tables.cend(), rhs.scalar_key_sorted_tables.cbegin(), [](std::unique_ptr<MyGame::Example::StatT> const &a, std::unique_ptr<MyGame::Example::StatT> const &b) { return (a == b) || (a && b && *a == *b); })) && (lhs.native_inline == rhs.native_inline) && (lhs.long_enum_non_enum_default == rhs.long_enum_non_enum_default) && (lhs.long_enum_normal_default == rhs.long_enum_normal_default) && @@ -3054,7 +3054,7 @@ inline MonsterT *Monster::UnPack(const ::flatbuffers::resolver_function_t *_reso inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = pos(); if (_e) _o->pos = flatbuffers::unique_ptr<MyGame::Example::Vec3>(new MyGame::Example::Vec3(*_e)); } + { auto _e = pos(); if (_e) _o->pos = std::unique_ptr<MyGame::Example::Vec3>(new MyGame::Example::Vec3(*_e)); } { auto _e = mana(); _o->mana = _e; } { auto _e = hp(); _o->hp = _e; } { auto _e = name(); if (_e) _o->name = _e->str(); } @@ -3064,10 +3064,10 @@ inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_functi { auto _e = test(); if (_e) _o->test.value = MyGame::Example::AnyUnion::UnPack(_e, test_type(), _resolver); } { auto _e = test4(); if (_e) { _o->test4.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test4[_i] = *_e->Get(_i); } } else { _o->test4.resize(0); } } { auto _e = testarrayofstring(); if (_e) { _o->testarrayofstring.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofstring[_i] = _e->Get(_i)->str(); } } else { _o->testarrayofstring.resize(0); } } - { auto _e = testarrayoftables(); if (_e) { _o->testarrayoftables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->testarrayoftables[_i]) { _e->Get(_i)->UnPackTo(_o->testarrayoftables[_i].get(), _resolver); } else { _o->testarrayoftables[_i] = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->testarrayoftables.resize(0); } } - { auto _e = enemy(); if (_e) { if(_o->enemy) { _e->UnPackTo(_o->enemy.get(), _resolver); } else { _o->enemy = flatbuffers::unique_ptr<MyGame::Example::MonsterT>(_e->UnPack(_resolver)); } } else if (_o->enemy) { _o->enemy.reset(); } } + { auto _e = testarrayoftables(); if (_e) { _o->testarrayoftables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->testarrayoftables[_i]) { _e->Get(_i)->UnPackTo(_o->testarrayoftables[_i].get(), _resolver); } else { _o->testarrayoftables[_i] = std::unique_ptr<MyGame::Example::MonsterT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->testarrayoftables.resize(0); } } + { auto _e = enemy(); if (_e) { if(_o->enemy) { _e->UnPackTo(_o->enemy.get(), _resolver); } else { _o->enemy = std::unique_ptr<MyGame::Example::MonsterT>(_e->UnPack(_resolver)); } } else if (_o->enemy) { _o->enemy.reset(); } } { auto _e = testnestedflatbuffer(); if (_e) { _o->testnestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testnestedflatbuffer.begin()); } } - { auto _e = testempty(); if (_e) { if(_o->testempty) { _e->UnPackTo(_o->testempty.get(), _resolver); } else { _o->testempty = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->UnPack(_resolver)); } } else if (_o->testempty) { _o->testempty.reset(); } } + { auto _e = testempty(); if (_e) { if(_o->testempty) { _e->UnPackTo(_o->testempty.get(), _resolver); } else { _o->testempty = std::unique_ptr<MyGame::Example::StatT>(_e->UnPack(_resolver)); } } else if (_o->testempty) { _o->testempty.reset(); } } { auto _e = testbool(); _o->testbool = _e; } { auto _e = testhashs32_fnv1(); _o->testhashs32_fnv1 = _e; } { auto _e = testhashu32_fnv1(); _o->testhashu32_fnv1 = _e; } @@ -3087,11 +3087,11 @@ inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_functi { auto _e = test5(); if (_e) { _o->test5.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->test5[_i] = *_e->Get(_i); } } else { _o->test5.resize(0); } } { auto _e = vector_of_longs(); if (_e) { _o->vector_of_longs.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_longs[_i] = _e->Get(_i); } } else { _o->vector_of_longs.resize(0); } } { auto _e = vector_of_doubles(); if (_e) { _o->vector_of_doubles.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_doubles[_i] = _e->Get(_i); } } else { _o->vector_of_doubles.resize(0); } } - { auto _e = parent_namespace_test(); if (_e) { if(_o->parent_namespace_test) { _e->UnPackTo(_o->parent_namespace_test.get(), _resolver); } else { _o->parent_namespace_test = flatbuffers::unique_ptr<MyGame::InParentNamespaceT>(_e->UnPack(_resolver)); } } else if (_o->parent_namespace_test) { _o->parent_namespace_test.reset(); } } - { auto _e = vector_of_referrables(); if (_e) { _o->vector_of_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_referrables[_i].get(), _resolver); } else { _o->vector_of_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_referrables.resize(0); } } + { auto _e = parent_namespace_test(); if (_e) { if(_o->parent_namespace_test) { _e->UnPackTo(_o->parent_namespace_test.get(), _resolver); } else { _o->parent_namespace_test = std::unique_ptr<MyGame::InParentNamespaceT>(_e->UnPack(_resolver)); } } else if (_o->parent_namespace_test) { _o->parent_namespace_test.reset(); } } + { auto _e = vector_of_referrables(); if (_e) { _o->vector_of_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_referrables[_i].get(), _resolver); } else { _o->vector_of_referrables[_i] = std::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_referrables.resize(0); } } { auto _e = single_weak_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->single_weak_reference), static_cast<::flatbuffers::hash_value_t>(_e)); else _o->single_weak_reference = nullptr; } { auto _e = vector_of_weak_references(); if (_e) { _o->vector_of_weak_references.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_weak_references[_i]), static_cast<::flatbuffers::hash_value_t>(_e->Get(_i))); else _o->vector_of_weak_references[_i] = nullptr; } } else { _o->vector_of_weak_references.resize(0); } } - { auto _e = vector_of_strong_referrables(); if (_e) { _o->vector_of_strong_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_strong_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_strong_referrables[_i].get(), _resolver); } else { _o->vector_of_strong_referrables[_i] = flatbuffers::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_strong_referrables.resize(0); } } + { auto _e = vector_of_strong_referrables(); if (_e) { _o->vector_of_strong_referrables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->vector_of_strong_referrables[_i]) { _e->Get(_i)->UnPackTo(_o->vector_of_strong_referrables[_i].get(), _resolver); } else { _o->vector_of_strong_referrables[_i] = std::unique_ptr<MyGame::Example::ReferrableT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->vector_of_strong_referrables.resize(0); } } { auto _e = co_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->co_owning_reference), static_cast<::flatbuffers::hash_value_t>(_e)); else _o->co_owning_reference = nullptr; } { auto _e = vector_of_co_owning_references(); if (_e) { _o->vector_of_co_owning_references.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { /*vector resolver, default_ptr_type*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->vector_of_co_owning_references[_i]), static_cast<::flatbuffers::hash_value_t>(_e->Get(_i)));/* else do nothing */; } } else { _o->vector_of_co_owning_references.resize(0); } } { auto _e = non_owning_reference(); /*scalar resolver, naked*/ if (_resolver) (*_resolver)(reinterpret_cast<void **>(&_o->non_owning_reference), static_cast<::flatbuffers::hash_value_t>(_e)); else _o->non_owning_reference = nullptr; } @@ -3103,7 +3103,7 @@ inline void Monster::UnPackTo(MonsterT *_o, const ::flatbuffers::resolver_functi { auto _e = vector_of_enums(); if (_e) { _o->vector_of_enums.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->vector_of_enums[_i] = static_cast<MyGame::Example::Color>(_e->Get(_i)); } } else { _o->vector_of_enums.resize(0); } } { auto _e = signed_enum(); _o->signed_enum = _e; } { auto _e = testrequirednestedflatbuffer(); if (_e) { _o->testrequirednestedflatbuffer.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->testrequirednestedflatbuffer.begin()); } } - { auto _e = scalar_key_sorted_tables(); if (_e) { _o->scalar_key_sorted_tables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->scalar_key_sorted_tables[_i]) { _e->Get(_i)->UnPackTo(_o->scalar_key_sorted_tables[_i].get(), _resolver); } else { _o->scalar_key_sorted_tables[_i] = flatbuffers::unique_ptr<MyGame::Example::StatT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->scalar_key_sorted_tables.resize(0); } } + { auto _e = scalar_key_sorted_tables(); if (_e) { _o->scalar_key_sorted_tables.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->scalar_key_sorted_tables[_i]) { _e->Get(_i)->UnPackTo(_o->scalar_key_sorted_tables[_i].get(), _resolver); } else { _o->scalar_key_sorted_tables[_i] = std::unique_ptr<MyGame::Example::StatT>(_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->scalar_key_sorted_tables.resize(0); } } { auto _e = native_inline(); if (_e) _o->native_inline = *_e; } { auto _e = long_enum_non_enum_default(); _o->long_enum_non_enum_default = _e; } { auto _e = long_enum_normal_default(); _o->long_enum_normal_default = _e; } @@ -4214,16 +4214,16 @@ inline void FinishSizePrefixedMonsterBuffer( fbb.FinishSizePrefixed(root, MonsterIdentifier()); } -inline flatbuffers::unique_ptr<MyGame::Example::MonsterT> UnPackMonster( +inline std::unique_ptr<MyGame::Example::MonsterT> UnPackMonster( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MyGame::Example::MonsterT>(GetMonster(buf)->UnPack(res)); + return std::unique_ptr<MyGame::Example::MonsterT>(GetMonster(buf)->UnPack(res)); } -inline flatbuffers::unique_ptr<MyGame::Example::MonsterT> UnPackSizePrefixedMonster( +inline std::unique_ptr<MyGame::Example::MonsterT> UnPackSizePrefixedMonster( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MyGame::Example::MonsterT>(GetSizePrefixedMonster(buf)->UnPack(res)); + return std::unique_ptr<MyGame::Example::MonsterT>(GetSizePrefixedMonster(buf)->UnPack(res)); } } // namespace Example diff --git a/tests/namespace_test/namespace_test2_generated.h b/tests/namespace_test/namespace_test2_generated.h index 212d0f1e..d59355df 100644 --- a/tests/namespace_test/namespace_test2_generated.h +++ b/tests/namespace_test/namespace_test2_generated.h @@ -69,10 +69,10 @@ struct TableInFirstNST : public ::flatbuffers::NativeTable { static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { return "NamespaceA.TableInFirstNST"; } - flatbuffers::unique_ptr<NamespaceA::NamespaceB::TableInNestedNST> foo_table{}; + std::unique_ptr<NamespaceA::NamespaceB::TableInNestedNST> foo_table{}; NamespaceA::NamespaceB::EnumInNestedNS foo_enum = NamespaceA::NamespaceB::EnumInNestedNS_A; NamespaceA::NamespaceB::UnionInNestedNSUnion foo_union{}; - flatbuffers::unique_ptr<NamespaceA::NamespaceB::StructInNestedNS> foo_struct{}; + std::unique_ptr<NamespaceA::NamespaceB::StructInNestedNS> foo_struct{}; TableInFirstNST() = default; TableInFirstNST(const TableInFirstNST &o); TableInFirstNST(TableInFirstNST&&) FLATBUFFERS_NOEXCEPT = default; @@ -203,8 +203,8 @@ struct TableInCT : public ::flatbuffers::NativeTable { static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { return "NamespaceC.TableInCT"; } - flatbuffers::unique_ptr<NamespaceA::TableInFirstNST> refer_to_a1{}; - flatbuffers::unique_ptr<NamespaceA::SecondTableInAT> refer_to_a2{}; + std::unique_ptr<NamespaceA::TableInFirstNST> refer_to_a1{}; + std::unique_ptr<NamespaceA::SecondTableInAT> refer_to_a2{}; TableInCT() = default; TableInCT(const TableInCT &o); TableInCT(TableInCT&&) FLATBUFFERS_NOEXCEPT = default; @@ -291,7 +291,7 @@ struct SecondTableInAT : public ::flatbuffers::NativeTable { static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { return "NamespaceA.SecondTableInAT"; } - flatbuffers::unique_ptr<NamespaceC::TableInCT> refer_to_c{}; + std::unique_ptr<NamespaceC::TableInCT> refer_to_c{}; SecondTableInAT() = default; SecondTableInAT(const SecondTableInAT &o); SecondTableInAT(SecondTableInAT&&) FLATBUFFERS_NOEXCEPT = default; @@ -393,11 +393,11 @@ inline TableInFirstNST *TableInFirstNS::UnPack(const ::flatbuffers::resolver_fun inline void TableInFirstNS::UnPackTo(TableInFirstNST *_o, const ::flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = foo_table(); if (_e) { if(_o->foo_table) { _e->UnPackTo(_o->foo_table.get(), _resolver); } else { _o->foo_table = flatbuffers::unique_ptr<NamespaceA::NamespaceB::TableInNestedNST>(_e->UnPack(_resolver)); } } else if (_o->foo_table) { _o->foo_table.reset(); } } + { auto _e = foo_table(); if (_e) { if(_o->foo_table) { _e->UnPackTo(_o->foo_table.get(), _resolver); } else { _o->foo_table = std::unique_ptr<NamespaceA::NamespaceB::TableInNestedNST>(_e->UnPack(_resolver)); } } else if (_o->foo_table) { _o->foo_table.reset(); } } { auto _e = foo_enum(); _o->foo_enum = _e; } { auto _e = foo_union_type(); _o->foo_union.type = _e; } { auto _e = foo_union(); if (_e) _o->foo_union.value = NamespaceA::NamespaceB::UnionInNestedNSUnion::UnPack(_e, foo_union_type(), _resolver); } - { auto _e = foo_struct(); if (_e) _o->foo_struct = flatbuffers::unique_ptr<NamespaceA::NamespaceB::StructInNestedNS>(new NamespaceA::NamespaceB::StructInNestedNS(*_e)); } + { auto _e = foo_struct(); if (_e) _o->foo_struct = std::unique_ptr<NamespaceA::NamespaceB::StructInNestedNS>(new NamespaceA::NamespaceB::StructInNestedNS(*_e)); } } inline ::flatbuffers::Offset<TableInFirstNS> TableInFirstNS::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const TableInFirstNST* _o, const ::flatbuffers::rehasher_function_t *_rehasher) { @@ -458,8 +458,8 @@ inline TableInCT *TableInC::UnPack(const ::flatbuffers::resolver_function_t *_re inline void TableInC::UnPackTo(TableInCT *_o, const ::flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = refer_to_a1(); if (_e) { if(_o->refer_to_a1) { _e->UnPackTo(_o->refer_to_a1.get(), _resolver); } else { _o->refer_to_a1 = flatbuffers::unique_ptr<NamespaceA::TableInFirstNST>(_e->UnPack(_resolver)); } } else if (_o->refer_to_a1) { _o->refer_to_a1.reset(); } } - { auto _e = refer_to_a2(); if (_e) { if(_o->refer_to_a2) { _e->UnPackTo(_o->refer_to_a2.get(), _resolver); } else { _o->refer_to_a2 = flatbuffers::unique_ptr<NamespaceA::SecondTableInAT>(_e->UnPack(_resolver)); } } else if (_o->refer_to_a2) { _o->refer_to_a2.reset(); } } + { auto _e = refer_to_a1(); if (_e) { if(_o->refer_to_a1) { _e->UnPackTo(_o->refer_to_a1.get(), _resolver); } else { _o->refer_to_a1 = std::unique_ptr<NamespaceA::TableInFirstNST>(_e->UnPack(_resolver)); } } else if (_o->refer_to_a1) { _o->refer_to_a1.reset(); } } + { auto _e = refer_to_a2(); if (_e) { if(_o->refer_to_a2) { _e->UnPackTo(_o->refer_to_a2.get(), _resolver); } else { _o->refer_to_a2 = std::unique_ptr<NamespaceA::SecondTableInAT>(_e->UnPack(_resolver)); } } else if (_o->refer_to_a2) { _o->refer_to_a2.reset(); } } } inline ::flatbuffers::Offset<TableInC> TableInC::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const TableInCT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) { @@ -511,7 +511,7 @@ inline SecondTableInAT *SecondTableInA::UnPack(const ::flatbuffers::resolver_fun inline void SecondTableInA::UnPackTo(SecondTableInAT *_o, const ::flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = refer_to_c(); if (_e) { if(_o->refer_to_c) { _e->UnPackTo(_o->refer_to_c.get(), _resolver); } else { _o->refer_to_c = flatbuffers::unique_ptr<NamespaceC::TableInCT>(_e->UnPack(_resolver)); } } else if (_o->refer_to_c) { _o->refer_to_c.reset(); } } + { auto _e = refer_to_c(); if (_e) { if(_o->refer_to_c) { _e->UnPackTo(_o->refer_to_c.get(), _resolver); } else { _o->refer_to_c = std::unique_ptr<NamespaceC::TableInCT>(_e->UnPack(_resolver)); } } else if (_o->refer_to_c) { _o->refer_to_c.reset(); } } } inline ::flatbuffers::Offset<SecondTableInA> SecondTableInA::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const SecondTableInAT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) { diff --git a/tests/native_inline_table_test_generated.h b/tests/native_inline_table_test_generated.h index aabd99ab..7c025a69 100644 --- a/tests/native_inline_table_test_generated.h +++ b/tests/native_inline_table_test_generated.h @@ -214,7 +214,7 @@ inline TestNativeInlineTableT *TestNativeInlineTable::UnPack(const ::flatbuffers inline void TestNativeInlineTable::UnPackTo(TestNativeInlineTableT *_o, const ::flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = t(); if (_e) { _o->t.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->t[_i] = *flatbuffers::unique_ptr<NativeInlineTableT>(_e->Get(_i)->UnPack(_resolver)); } } else { _o->t.resize(0); } } + { auto _e = t(); if (_e) { _o->t.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->t[_i] = *std::unique_ptr<NativeInlineTableT>(_e->Get(_i)->UnPack(_resolver)); } } else { _o->t.resize(0); } } } inline ::flatbuffers::Offset<TestNativeInlineTable> TestNativeInlineTable::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const TestNativeInlineTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) { diff --git a/tests/native_type_test_generated.h b/tests/native_type_test_generated.h index 062176b2..6c3534be 100644 --- a/tests/native_type_test_generated.h +++ b/tests/native_type_test_generated.h @@ -321,16 +321,16 @@ inline void FinishSizePrefixedApplicationDataBuffer( fbb.FinishSizePrefixed(root); } -inline flatbuffers::unique_ptr<Geometry::ApplicationDataT> UnPackApplicationData( +inline std::unique_ptr<Geometry::ApplicationDataT> UnPackApplicationData( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<Geometry::ApplicationDataT>(GetApplicationData(buf)->UnPack(res)); + return std::unique_ptr<Geometry::ApplicationDataT>(GetApplicationData(buf)->UnPack(res)); } -inline flatbuffers::unique_ptr<Geometry::ApplicationDataT> UnPackSizePrefixedApplicationData( +inline std::unique_ptr<Geometry::ApplicationDataT> UnPackSizePrefixedApplicationData( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<Geometry::ApplicationDataT>(GetSizePrefixedApplicationData(buf)->UnPack(res)); + return std::unique_ptr<Geometry::ApplicationDataT>(GetSizePrefixedApplicationData(buf)->UnPack(res)); } } // namespace Geometry diff --git a/tests/optional_scalars_generated.h b/tests/optional_scalars_generated.h index 40a3c91c..3cfc19c3 100644 --- a/tests/optional_scalars_generated.h +++ b/tests/optional_scalars_generated.h @@ -944,16 +944,16 @@ inline void FinishSizePrefixedScalarStuffBuffer( fbb.FinishSizePrefixed(root, ScalarStuffIdentifier()); } -inline flatbuffers::unique_ptr<optional_scalars::ScalarStuffT> UnPackScalarStuff( +inline std::unique_ptr<optional_scalars::ScalarStuffT> UnPackScalarStuff( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<optional_scalars::ScalarStuffT>(GetScalarStuff(buf)->UnPack(res)); + return std::unique_ptr<optional_scalars::ScalarStuffT>(GetScalarStuff(buf)->UnPack(res)); } -inline flatbuffers::unique_ptr<optional_scalars::ScalarStuffT> UnPackSizePrefixedScalarStuff( +inline std::unique_ptr<optional_scalars::ScalarStuffT> UnPackSizePrefixedScalarStuff( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<optional_scalars::ScalarStuffT>(GetSizePrefixedScalarStuff(buf)->UnPack(res)); + return std::unique_ptr<optional_scalars::ScalarStuffT>(GetSizePrefixedScalarStuff(buf)->UnPack(res)); } } // namespace optional_scalars diff --git a/tests/union_vector/union_vector_generated.h b/tests/union_vector/union_vector_generated.h index d1d06aaa..b44d7241 100644 --- a/tests/union_vector/union_vector_generated.h +++ b/tests/union_vector/union_vector_generated.h @@ -1274,16 +1274,16 @@ inline void FinishSizePrefixedMovieBuffer( fbb.FinishSizePrefixed(root, MovieIdentifier()); } -inline flatbuffers::unique_ptr<MovieT> UnPackMovie( +inline std::unique_ptr<MovieT> UnPackMovie( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MovieT>(GetMovie(buf)->UnPack(res)); + return std::unique_ptr<MovieT>(GetMovie(buf)->UnPack(res)); } -inline flatbuffers::unique_ptr<MovieT> UnPackSizePrefixedMovie( +inline std::unique_ptr<MovieT> UnPackSizePrefixedMovie( const void *buf, const ::flatbuffers::resolver_function_t *res = nullptr) { - return flatbuffers::unique_ptr<MovieT>(GetSizePrefixedMovie(buf)->UnPack(res)); + return std::unique_ptr<MovieT>(GetSizePrefixedMovie(buf)->UnPack(res)); } #endif // FLATBUFFERS_GENERATED_UNIONVECTOR_H_ |