diff --git a/BUILD b/BUILD index 16f8feb12..8254bec83 100644 --- a/BUILD +++ b/BUILD @@ -136,9 +136,8 @@ cc_test( "src/util.cpp", "tests/namespace_test/namespace_test1_generated.h", "tests/namespace_test/namespace_test2_generated.h", - "tests/vector3d.h", - "tests/vector3d_pack.h", - "tests/vector3d_pack.cpp", + "tests/native_type_test_impl.h", + "tests/native_type_test_impl.cpp", "tests/test.cpp", "tests/test_assert.cpp", "tests/test_assert.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 40896905d..ee5b6ba64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,9 +117,8 @@ set(FlatBuffers_Tests_SRCS tests/test_assert.cpp tests/test_builder.h tests/test_builder.cpp - tests/vector3d.h - tests/vector3d_pack.h - tests/vector3d_pack.cpp + tests/native_type_test_impl.h + tests/native_type_test_impl.cpp # file generate by running compiler on tests/monster_test.fbs ${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h # file generate by running compiler on tests/arrays_test.fbs diff --git a/tests/native_type_test.fbs b/tests/native_type_test.fbs index 8919967cc..835b3d587 100644 --- a/tests/native_type_test.fbs +++ b/tests/native_type_test.fbs @@ -1,5 +1,4 @@ -native_include "vector3d.h"; -native_include "vector3d_pack.h"; +native_include "native_type_test_impl.h"; namespace Geometry; diff --git a/tests/native_type_test_generated.h b/tests/native_type_test_generated.h index f1888f691..5a79a96e2 100644 --- a/tests/native_type_test_generated.h +++ b/tests/native_type_test_generated.h @@ -6,8 +6,7 @@ #include "flatbuffers/flatbuffers.h" -#include "vector3d.h" -#include "vector3d_pack.h" +#include "native_type_test_impl.h" namespace Geometry { diff --git a/tests/vector3d_pack.cpp b/tests/native_type_test_impl.cpp similarity index 83% rename from tests/vector3d_pack.cpp rename to tests/native_type_test_impl.cpp index 7ebfd8fcb..0f8265d88 100644 --- a/tests/vector3d_pack.cpp +++ b/tests/native_type_test_impl.cpp @@ -1,4 +1,4 @@ -#include "vector3d_pack.h" +#include "native_type_test_impl.h" // looks like VS10 does not support std::vector with explicit alignment // From stackoverflow (https://stackoverflow.com/questions/8456236/how-is-a-vectors-data-aligned): @@ -13,11 +13,11 @@ #include "native_type_test_generated.h" namespace flatbuffers { - Geometry::Vector3D Pack(const Native::Vector3D& obj) { + Geometry::Vector3D Pack(const Native::Vector3D &obj) { return Geometry::Vector3D(obj.x, obj.y, obj.z); } - const Native::Vector3D UnPack(const Geometry::Vector3D& obj) { + const Native::Vector3D UnPack(const Geometry::Vector3D &obj) { return Native::Vector3D(obj.x(), obj.y(), obj.z()); } } diff --git a/tests/native_type_test_impl.h b/tests/native_type_test_impl.h new file mode 100644 index 000000000..681bc110b --- /dev/null +++ b/tests/native_type_test_impl.h @@ -0,0 +1,24 @@ +#ifndef NATIVE_TYPE_TEST_IMPL_H +#define NATIVE_TYPE_TEST_IMPL_H + +namespace Native { + struct Vector3D { + double x; + double y; + double z; + + Vector3D() { x = 0; y = 0; z = 0; }; + Vector3D(double x, double y, double z) { this->x = x; this->y = y; this->z = z; } + }; +} + +namespace Geometry { + struct Vector3D; +} + +namespace flatbuffers { + Geometry::Vector3D Pack(const Native::Vector3D &obj); + const Native::Vector3D UnPack(const Geometry::Vector3D &obj); +} + +#endif // VECTOR3D_PACK_H diff --git a/tests/vector3d.h b/tests/vector3d.h deleted file mode 100644 index cbd821d6d..000000000 --- a/tests/vector3d.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef VECTOR3D_H -#define VECTOR3D_H - -namespace Native { - struct Vector3D { - double x; - double y; - double z; - - Vector3D() { x = 0; y = 0; z = 0; }; - Vector3D(double x, double y, double z) { this->x = x; this->y = y; this->z = z; } - }; -} - -#endif // VECTOR3D_H diff --git a/tests/vector3d_pack.h b/tests/vector3d_pack.h deleted file mode 100644 index beaa43e26..000000000 --- a/tests/vector3d_pack.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef VECTOR3D_PACK_H -#define VECTOR3D_PACK_H - -#include "vector3d.h" - -namespace Geometry { - struct Vector3D; -} - -namespace flatbuffers { - Geometry::Vector3D Pack(const Native::Vector3D& obj); - const Native::Vector3D UnPack(const Geometry::Vector3D& obj); -} - -#endif // VECTOR3D_PACK_H