Skip to content

Commit

Permalink
change in namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
rybochodonezzar committed Apr 11, 2020
1 parent 6ed00c4 commit 776516e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions PolyEngine/CMakeListsCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "(Clang|^GNU$)")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-class-memaccess")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument -Wno-missing-braces")
endif()

# Shared compile flags
Expand Down Expand Up @@ -362,4 +362,4 @@ add_subdirectory(${ENGINE_ROOT_DIR}/API ${COMMON_BUILD_DIR}/API)
add_subdirectory(${ENGINE_ROOT_DIR}/Engine ${COMMON_BUILD_DIR}/Engine)
add_subdirectory(${ENGINE_ROOT_DIR}/RenderingDevice/OpenGL ${COMMON_BUILD_DIR}/RenderingDevice/OpenGL)
add_subdirectory(${ENGINE_ROOT_DIR}/Editor ${COMMON_BUILD_DIR}/Editor)
add_subdirectory(${ENGINE_ROOT_DIR}/Standalone ${COMMON_BUILD_DIR}/Standalone)
add_subdirectory(${ENGINE_ROOT_DIR}/Standalone ${COMMON_BUILD_DIR}/Standalone)
56 changes: 28 additions & 28 deletions PolyEngine/Tests/CoreTests/Src/RTTI2Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,75 @@
#include <catch.hpp>
#include <pe/core/rtti/RTTI2.hpp>

using namespace pe::core::rtti;
namespace rtti2 = pe::core::rtti::RTTI2;

struct TestAttr {} constexpr testAttr;

struct TestClass : public virtual RTTI2::RTTIBase {
TestClass() : RTTI2::RTTIBase(RTTI2::TypeManager::get().registerOrGetType<TestClass>()) {}
struct TestClass : public virtual rtti2::RTTIBase {
TestClass() : rtti2::RTTIBase(rtti2::TypeManager::get().registerOrGetType<TestClass>()) {}
};
template <> struct RTTI2::RTTIinfo<TestClass> {
constexpr static auto info = List(testAttr, testAttr, RTTI2::ClassName{ "testname" });
template <> struct rtti2::RTTIinfo<TestClass> {
constexpr static auto info = List(testAttr, testAttr, rtti2::ClassName{ "testname" });
};

TEST_CASE("RTTI2 simple attribute", "[RTTI2]") {
TEST_CASE("rtti2 simple attribute", "[rtti2]") {
TestClass tc{};
CHECK(tc.typeInfo().id != std::type_index{ typeid(void) });
auto ta = tc.typeInfo().get<TestAttr>();
CHECK(ta);
CHECK(ta->size() == 2);
CHECK(tc.typeInfo().get<int>() == nullptr);
auto x = tc.typeInfo().get<RTTI2::ClassName>();
auto x = tc.typeInfo().get<rtti2::ClassName>();
CHECK(x);
CHECK(std::string("testname") == x->name);
}

struct TestAttrUniq {} constexpr testAttrUniq;
template <> struct RTTI2::AttrType<TestAttrUniq> {
using type = RTTI2::UniqueAttribute<TestAttrUniq>;
template <> struct rtti2::AttrType<TestAttrUniq> {
using type = rtti2::UniqueAttribute<TestAttrUniq>;
};
struct TestClass2 : public virtual RTTI2::RTTIBase {
TestClass2() : RTTI2::RTTIBase(RTTI2::TypeManager::get().registerOrGetType<TestClass2>()) {}
struct TestClass2 : public virtual rtti2::RTTIBase {
TestClass2() : rtti2::RTTIBase(rtti2::TypeManager::get().registerOrGetType<TestClass2>()) {}
};
template <> struct RTTI2::RTTIinfo<TestClass2> {
template <> struct rtti2::RTTIinfo<TestClass2> {
constexpr static auto info = List(testAttrUniq, testAttrUniq);
};

TEST_CASE("RTTI2 uniq attribute", "[RTTI2]")
TEST_CASE("rtti2 uniq attribute", "[rtti2]")
{
REQUIRE_THROWS(TestClass2{});
}

struct TestAttrBase { const char* foo; };
template <> struct RTTI2::AttrType<TestAttrBase> {
using type = RTTI2::DerivedAttribute<TestAttrBase>;
template <> struct rtti2::AttrType<TestAttrBase> {
using type = rtti2::DerivedAttribute<TestAttrBase>;
};
struct TestAttrDerived : TestAttrBase {};
template <> struct RTTI2::AttrType<TestAttrDerived> {
using type = RTTI2::DerivedAttribute<TestAttrBase>;
template <> struct rtti2::AttrType<TestAttrDerived> {
using type = rtti2::DerivedAttribute<TestAttrBase>;
};

struct TestClassA : public virtual RTTI2::RTTIBase {
TestClassA() : RTTI2::RTTIBase(RTTI2::TypeManager::get().registerOrGetType<TestClassA>()) {}
struct TestClassA : public virtual rtti2::RTTIBase {
TestClassA() : rtti2::RTTIBase(rtti2::TypeManager::get().registerOrGetType<TestClassA>()) {}
};
template <> struct RTTI2::RTTIinfo<TestClassA> {
constexpr static auto info = List(TestAttrDerived{ "foo" });
template <> struct rtti2::RTTIinfo<TestClassA> {
constexpr static auto info = List(TestAttrDerived{ {"foo"} });
};

struct TestClassB : public virtual RTTI2::RTTIBase, public TestClassA {
TestClassB() : RTTI2::RTTIBase(RTTI2::TypeManager::get().registerOrGetType<TestClassB>()) {}
struct TestClassB : public virtual rtti2::RTTIBase, public TestClassA {
TestClassB() : rtti2::RTTIBase(rtti2::TypeManager::get().registerOrGetType<TestClassB>()) {}
};
template <> struct RTTI2::RTTIinfo<TestClassB> {
constexpr static auto info = List(RTTI2::baseclass<TestClassA>{});
template <> struct rtti2::RTTIinfo<TestClassB> {
constexpr static auto info = List(rtti2::baseclass<TestClassA>{});
};

TEST_CASE("RTTI2 derived", "[RTTI2]") {
TEST_CASE("rtti2 derived", "[rtti2]") {
TestClassA tca{};
auto attr = tca.typeInfo().get<TestAttrBase>();
CHECK(attr);
CHECK(std::string("foo") == attr->at(0)->foo);
TestClassB tcb{};
CHECK(tcb.typeInfo().bases[0].get().id == tca.typeInfo().id);
CHECK(RTTI2::isSame<TestClassA>(tca.typeInfo()));
CHECK(RTTI2::isDerived<TestClassA>(tcb.typeInfo()));
CHECK(rtti2::isSame<TestClassA>(tca.typeInfo()));
CHECK(rtti2::isDerived<TestClassA>(tcb.typeInfo()));
}
4 changes: 2 additions & 2 deletions PolyEngine/Tests/CoreTests/Src/RTTITests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#include <catch.hpp>

#include <pe/core/rtti/RTTI.hpp>
/*
using namespace Poly;

using namespace Poly;
/*
enum class eRTTITestEnum
{
VAL_1,
Expand Down

0 comments on commit 776516e

Please sign in to comment.