From 110b4bee486dac80e1839741b74b61bb53871920 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Fri, 15 Jun 2018 17:18:01 +1000 Subject: Revert "Update to brace initialisation to allow for easy aggregate use" --- entityx/Entity.h | 4 ++-- entityx/Entity_test.cc | 34 +++++++++++++++++----------------- entityx/Event.h | 2 +- entityx/System.h | 2 +- entityx/System_test.cc | 4 ++-- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/entityx/Entity.h b/entityx/Entity.h index 3ca63ba..7c69e0a 100644 --- a/entityx/Entity.h +++ b/entityx/Entity.h @@ -645,7 +645,7 @@ class EntityManager : entityx::help::NonCopyable { // Placement new into the component pool. Pool *pool = accomodate_component(); - ::new(pool->get(id.index())) C{std::forward(args) ...}; + ::new(pool->get(id.index())) C(std::forward(args) ...); // Set the bit for this component. entity_component_mask_[id.index()].set(family); @@ -960,7 +960,7 @@ ComponentHandle Entity::replace(Args && ... args) { assert(valid()); auto handle = component(); if (handle) { - *(handle.get()) = C{std::forward(args) ...}; + *(handle.get()) = C(std::forward(args) ...); } else { handle = manager_->assign(id_, std::forward(args) ...); } diff --git a/entityx/Entity_test.cc b/entityx/Entity_test.cc index 4b9a9f2..f985794 100644 --- a/entityx/Entity_test.cc +++ b/entityx/Entity_test.cc @@ -142,7 +142,7 @@ TEST_CASE_METHOD(EntityManagerFixture, "TestEntityReuse") { TEST_CASE_METHOD(EntityManagerFixture, "TestComponentConstruction") { auto e = em.create(); - auto p = e.assign(1.f, 2.f); + auto p = e.assign(1, 2); auto cp = e.component(); REQUIRE(p == cp); REQUIRE(1.0 == Approx(cp->x)); @@ -257,8 +257,8 @@ TEST_CASE_METHOD(EntityManagerFixture, "TestIterateAllEntitiesSkipsDestroyed") { TEST_CASE_METHOD(EntityManagerFixture, "TestUnpack") { Entity e = em.create(); - auto p = e.assign(1.f, 2.f); - auto d = e.assign(3.f, 4.f); + auto p = e.assign(1.0, 2.0); + auto d = e.assign(3.0, 4.0); auto t = e.assign("tag"); ComponentHandle up; @@ -399,7 +399,7 @@ TEST_CASE_METHOD(EntityManagerFixture, "TestComponentRemovedEvent") { REQUIRE(!(receiver.removed)); Entity e = em.create(); - ComponentHandle p = e.assign(1.f, 2.f); + ComponentHandle p = e.assign(1.0, 2.0); e.remove(); REQUIRE(receiver.removed == p); REQUIRE(!(e.component())); @@ -420,7 +420,7 @@ TEST_CASE_METHOD(EntityManagerFixture, "TestComponentRemovedEventOnEntityDestroy REQUIRE(!(receiver.removed)); Entity e = em.create(); - e.assign(1.f, 2.f); + e.assign(1.0, 2.0); e.destroy(); REQUIRE(receiver.removed); @@ -474,7 +474,7 @@ TEST_CASE_METHOD(EntityManagerFixture, "TestEntityDestroyHole") { TEST_CASE_METHOD(EntityManagerFixture, "TestComponentHandleInvalidatedWhenEntityDestroyed") { Entity a = em.create(); - ComponentHandle position = a.assign(1.f, 2.f); + ComponentHandle position = a.assign(1, 2); REQUIRE(position); REQUIRE(position->x == 1); REQUIRE(position->y == 2); @@ -505,7 +505,7 @@ TEST_CASE_METHOD(EntityManagerFixture, "TestEntityCreateFromCopy") { Entity a = em.create(); a.assign(); ComponentHandle original = a.component(); - ComponentHandle aPosition = a.assign(1.f, 2.f); + ComponentHandle aPosition = a.assign(1, 2); Entity b = em.create_from_copy(a); ComponentHandle copy = b.component(); ComponentHandle bPosition = b.component(); @@ -522,7 +522,7 @@ TEST_CASE_METHOD(EntityManagerFixture, "TestEntityCreateFromCopy") { TEST_CASE_METHOD(EntityManagerFixture, "TestComponentHandleInvalidatedWhenComponentDestroyed") { Entity a = em.create(); - ComponentHandle position = a.assign(1.f, 2.f); + ComponentHandle position = a.assign(1, 2); REQUIRE(position); REQUIRE(position->x == 1); REQUIRE(position->y == 2); @@ -532,7 +532,7 @@ TEST_CASE_METHOD(EntityManagerFixture, "TestComponentHandleInvalidatedWhenCompon TEST_CASE_METHOD(EntityManagerFixture, "TestDeleteEntityWithNoComponents") { Entity a = em.create(); - a.assign(1.f, 2.f); + a.assign(1, 2); Entity b = em.create(); b.destroy(); } @@ -562,8 +562,8 @@ TEST_CASE_METHOD(EntityManagerFixture, "TestEntityInStdMap") { TEST_CASE_METHOD(EntityManagerFixture, "TestEntityComponentsFromTuple") { Entity e = em.create(); - e.assign(1.f, 2.f); - e.assign(3.f, 4.f); + e.assign(1, 2); + e.assign(3, 4); std::tuple, ComponentHandle> components = e.components(); @@ -622,7 +622,7 @@ TEST_CASE("TestComponentDestructorCalledWhenEntityDestroyed") { TEST_CASE_METHOD(EntityManagerFixture, "TestComponentsRemovedFromReusedEntities") { Entity a = em.create(); Entity::Id aid = a.id(); - a.assign(1.f, 2.f); + a.assign(1, 2); a.destroy(); Entity b = em.create(); @@ -630,12 +630,12 @@ TEST_CASE_METHOD(EntityManagerFixture, "TestComponentsRemovedFromReusedEntities" REQUIRE(aid.index() == bid.index()); REQUIRE(!b.has_component()); - b.assign(3.f, 4.f); + b.assign(3, 4); } TEST_CASE_METHOD(EntityManagerFixture, "TestConstComponentsNotInstantiatedTwice") { Entity a = em.create(); - a.assign(1.f, 2.f); + a.assign(1, 2); const Entity b = a; @@ -647,7 +647,7 @@ TEST_CASE_METHOD(EntityManagerFixture, "TestConstComponentsNotInstantiatedTwice" TEST_CASE_METHOD(EntityManagerFixture, "TestEntityManagerEach") { Entity a = em.create(); - a.assign(1.f, 2.f); + a.assign(1, 2); int count = 0; em.each([&count](Entity entity, Position &position) { count++; @@ -659,7 +659,7 @@ TEST_CASE_METHOD(EntityManagerFixture, "TestEntityManagerEach") { TEST_CASE_METHOD(EntityManagerFixture, "TestViewEach") { Entity a = em.create(); - a.assign(1.f, 2.f); + a.assign(1, 2); int count = 0; em.entities_with_components().each([&count](Entity entity, Position &position) { count++; @@ -671,7 +671,7 @@ TEST_CASE_METHOD(EntityManagerFixture, "TestViewEach") { TEST_CASE_METHOD(EntityManagerFixture, "TestComponentDereference") { Entity a = em.create(); - a.assign(10.f, 5.f); + a.assign(10, 5); auto& positionRef = *a.component(); REQUIRE(positionRef.x == 10); REQUIRE(positionRef.y == 5); diff --git a/entityx/Event.h b/entityx/Event.h index 2d6fe15..cb7b3ab 100644 --- a/entityx/Event.h +++ b/entityx/Event.h @@ -180,7 +180,7 @@ class EventManager : entityx::help::NonCopyable { template void emit(Args && ... args) { // Using 'E event(std::forward...)' causes VS to fail with an internal error. Hack around it. - E event = E{std::forward(args) ...}; + E event = E(std::forward(args) ...); auto sig = signal_for(std::size_t(Event::family())); sig->emit(&event); } diff --git a/entityx/System.h b/entityx/System.h index 50a519f..b39f2ca 100644 --- a/entityx/System.h +++ b/entityx/System.h @@ -118,7 +118,7 @@ class SystemManager : entityx::help::NonCopyable { */ template std::shared_ptr add(Args && ... args) { - std::shared_ptr s(new S{std::forward(args) ...}); + std::shared_ptr s(new S(std::forward(args) ...)); add(s); return s; } diff --git a/entityx/System_test.cc b/entityx/System_test.cc index 504a01b..71ef183 100644 --- a/entityx/System_test.cc +++ b/entityx/System_test.cc @@ -76,8 +76,8 @@ class EntitiesFixture : public EntityX { for (int i = 0; i < 150; ++i) { Entity e = entities.create(); created_entities.push_back(e); - if (i % 2 == 0) e.assign(1.f, 2.f); - if (i % 3 == 0) e.assign(1.f, 1.f); + if (i % 2 == 0) e.assign(1, 2); + if (i % 3 == 0) e.assign(1, 1); e.assign(0); } -- cgit v1.2.3