Skip to content

Commit 45aaa0d

Browse files
committed
Fixed: Amalgamation issues
Tweaked: Minor cleanup
1 parent c78ea9f commit 45aaa0d

File tree

6 files changed

+40
-42
lines changed

6 files changed

+40
-42
lines changed

include/gaia/ecs/chunk.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ namespace gaia {
386386

387387
//! Updates the version numbers for this chunk.
388388
void update_versions() {
389-
update_version(m_header.worldVersion);
389+
::gaia::ecs::update_version(m_header.worldVersion);
390390
update_world_version();
391391
}
392392

@@ -567,7 +567,7 @@ namespace gaia {
567567
++m_header.countEnabled;
568568
entity_view_mut()[row] = entity;
569569

570-
update_version(m_header.worldVersion);
570+
::gaia::ecs::update_version(m_header.worldVersion);
571571
update_world_version();
572572

573573
return row;
@@ -1056,7 +1056,7 @@ namespace gaia {
10561056
"Set providing a row can only be used with generic components");
10571057

10581058
// Update the world version
1059-
update_version(m_header.worldVersion);
1059+
::gaia::ecs::update_version(m_header.worldVersion);
10601060

10611061
GAIA_ASSERT(row < m_header.capacity);
10621062
return view_mut<T>()[row];
@@ -1077,7 +1077,7 @@ namespace gaia {
10771077
GAIA_ASSERT(type.kind() == entity_kind_v<T>);
10781078

10791079
// Update the world version
1080-
update_version(m_header.worldVersion);
1080+
::gaia::ecs::update_version(m_header.worldVersion);
10811081

10821082
GAIA_ASSERT(row < m_header.capacity);
10831083

@@ -1291,7 +1291,7 @@ namespace gaia {
12911291
//! Returns true if the provided version is newer than the one stored internally
12921292
GAIA_NODISCARD bool changed(uint32_t version, uint32_t compIdx) const {
12931293
auto versions = comp_version_view();
1294-
return version_changed(versions[compIdx], version);
1294+
return ::gaia::ecs::version_changed(versions[compIdx], version);
12951295
}
12961296

12971297
//! Update the version of a component at the index \param compIdx

include/gaia/ecs/chunk_allocator.h

+17-20
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
#pragma once
22
#include "../config/config.h"
33

4+
#include <cinttypes>
45
#include <cstdint>
56

6-
#if GAIA_ECS_CHUNK_ALLOCATOR
7-
#include <cinttypes>
8-
9-
#include "../cnt/darray.h"
10-
#include "../cnt/sarray.h"
11-
#include "../cnt/sarray_ext.h"
12-
#include "../config/logging.h"
13-
#include "../config/profiler.h"
14-
#include "../core/bit_utils.h"
15-
#include "../core/dyn_singleton.h"
16-
#include "../core/span.h"
17-
#include "../core/utility.h"
18-
#include "../mem/mem_alloc.h"
19-
#include "common.h"
20-
#endif
7+
#include "../cnt/darray.h"
8+
#include "../cnt/sarray.h"
9+
#include "../config/logging.h"
10+
#include "../core/bit_utils.h"
11+
#include "../core/dyn_singleton.h"
12+
#include "../core/utility.h"
13+
#include "../mem/mem_alloc.h"
14+
#include "common.h"
2115

2216
namespace gaia {
2317
namespace ecs {
@@ -59,7 +53,7 @@ namespace gaia {
5953

6054
//! Allocator for ECS Chunks. Memory is organized in pages of chunks.
6155
class ChunkAllocatorImpl {
62-
friend gaia::ecs::ChunkAllocator;
56+
friend ::gaia::ecs::ChunkAllocator;
6357

6458
struct MemoryPage {
6559
static constexpr uint16_t NBlocks = 62;
@@ -371,17 +365,20 @@ namespace gaia {
371365
}
372366

373367
private:
368+
static constexpr const char* s_strChunkAlloc_Chunk = "Chunk";
369+
static constexpr const char* s_strChunkAlloc_MemPage = "MemoryPage";
370+
374371
static MemoryPage* alloc_page(uint8_t sizeType) {
375372
const uint32_t size = mem_block_size(sizeType) * MemoryPage::NBlocks;
376-
auto* pPageData = mem::AllocHelper::alloc_alig<uint8_t>("Chunk", 16U, size);
377-
auto* pMemoryPage = mem::AllocHelper::alloc<MemoryPage>("MemoryPage");
373+
auto* pPageData = mem::AllocHelper::alloc_alig<uint8_t>(s_strChunkAlloc_Chunk, 16U, size);
374+
auto* pMemoryPage = mem::AllocHelper::alloc<MemoryPage>(s_strChunkAlloc_MemPage);
378375
return new (pMemoryPage) MemoryPage(pPageData, sizeType);
379376
}
380377

381378
static void free_page(MemoryPage* pMemoryPage) {
382-
mem::AllocHelper::free_alig("Chunk", pMemoryPage->m_data);
379+
mem::AllocHelper::free_alig(s_strChunkAlloc_Chunk, pMemoryPage->m_data);
383380
pMemoryPage->~MemoryPage();
384-
mem::AllocHelper::free("MemoryPage", pMemoryPage);
381+
mem::AllocHelper::free(s_strChunkAlloc_MemPage, pMemoryPage);
385382
}
386383

387384
void done() {

include/gaia/ecs/query.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ namespace gaia {
863863
template <typename TIter, typename Func>
864864
void run_query_on_chunks(QueryInfo& queryInfo, Func func) {
865865
// Update the world version
866-
update_version(*m_worldVersion);
866+
::gaia::ecs::update_version(*m_worldVersion);
867867

868868
const bool hasFilters = queryInfo.has_filters();
869869
if (hasFilters)

make_single_header.bat

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ echo off
22

33
set PATH_TO_AMALGAMATE_DIR="%1"
44
set PATH_TO_AMALGAMATE=%PATH_TO_AMALGAMATE_DIR%\\amalgamate
5+
del single_include/gaia.h
56
%PATH_TO_AMALGAMATE% -i include -w "*.cpp;*.h;*.hpp;*.inl" include/gaia.h single_include/gaia.h

make_single_header.sh

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
PATH_TO_AMALGAMATE_DIR="${@:1}"
44
PATH_TO_AMALGAMATE=${PATH_TO_AMALGAMATE_DIR}/amalgamate
5+
rm -f ./single_include/gaia.h
56
${PATH_TO_AMALGAMATE} -i ./include -w "*.cpp;*.h;*.hpp;*.inl" ./include/gaia.h ./single_include/gaia.h

single_include/gaia.h

+15-16
Original file line numberDiff line numberDiff line change
@@ -16240,11 +16240,9 @@ namespace gaia {
1624016240
/*** Start of inlined file: chunk_allocator.h ***/
1624116241
#pragma once
1624216242

16243+
#include <cinttypes>
1624316244
#include <cstdint>
1624416245

16245-
#if GAIA_ECS_CHUNK_ALLOCATOR
16246-
#include <cinttypes>
16247-
1624816246

1624916247
/*** Start of inlined file: dyn_singleton.h ***/
1625016248
#pragma once
@@ -16321,8 +16319,6 @@ namespace gaia {
1632116319

1632216320
/*** End of inlined file: common.h ***/
1632316321

16324-
#endif
16325-
1632616322
namespace gaia {
1632716323
namespace ecs {
1632816324
//! Size of one allocated block of memory
@@ -16363,7 +16359,7 @@ namespace gaia {
1636316359

1636416360
//! Allocator for ECS Chunks. Memory is organized in pages of chunks.
1636516361
class ChunkAllocatorImpl {
16366-
friend gaia::ecs::ChunkAllocator;
16362+
friend ::gaia::ecs::ChunkAllocator;
1636716363

1636816364
struct MemoryPage {
1636916365
static constexpr uint16_t NBlocks = 62;
@@ -16675,17 +16671,20 @@ namespace gaia {
1667516671
}
1667616672

1667716673
private:
16674+
static constexpr const char* s_strChunkAlloc_Chunk = "Chunk";
16675+
static constexpr const char* s_strChunkAlloc_MemPage = "MemoryPage";
16676+
1667816677
static MemoryPage* alloc_page(uint8_t sizeType) {
1667916678
const uint32_t size = mem_block_size(sizeType) * MemoryPage::NBlocks;
16680-
auto* pPageData = mem::AllocHelper::alloc_alig<uint8_t>("Chunk", 16U, size);
16681-
auto* pMemoryPage = mem::AllocHelper::alloc<MemoryPage>("MemoryPage");
16679+
auto* pPageData = mem::AllocHelper::alloc_alig<uint8_t>(s_strChunkAlloc_Chunk, 16U, size);
16680+
auto* pMemoryPage = mem::AllocHelper::alloc<MemoryPage>(s_strChunkAlloc_MemPage);
1668216681
return new (pMemoryPage) MemoryPage(pPageData, sizeType);
1668316682
}
1668416683

1668516684
static void free_page(MemoryPage* pMemoryPage) {
16686-
mem::AllocHelper::free_alig("Chunk", pMemoryPage->m_data);
16685+
mem::AllocHelper::free_alig(s_strChunkAlloc_Chunk, pMemoryPage->m_data);
1668716686
pMemoryPage->~MemoryPage();
16688-
mem::AllocHelper::free("MemoryPage", pMemoryPage);
16687+
mem::AllocHelper::free(s_strChunkAlloc_MemPage, pMemoryPage);
1668916688
}
1669016689

1669116690
void done() {
@@ -18034,7 +18033,7 @@ namespace gaia {
1803418033

1803518034
//! Updates the version numbers for this chunk.
1803618035
void update_versions() {
18037-
update_version(m_header.worldVersion);
18036+
::gaia::ecs::update_version(m_header.worldVersion);
1803818037
update_world_version();
1803918038
}
1804018039

@@ -18215,7 +18214,7 @@ namespace gaia {
1821518214
++m_header.countEnabled;
1821618215
entity_view_mut()[row] = entity;
1821718216

18218-
update_version(m_header.worldVersion);
18217+
::gaia::ecs::update_version(m_header.worldVersion);
1821918218
update_world_version();
1822018219

1822118220
return row;
@@ -18704,7 +18703,7 @@ namespace gaia {
1870418703
"Set providing a row can only be used with generic components");
1870518704

1870618705
// Update the world version
18707-
update_version(m_header.worldVersion);
18706+
::gaia::ecs::update_version(m_header.worldVersion);
1870818707

1870918708
GAIA_ASSERT(row < m_header.capacity);
1871018709
return view_mut<T>()[row];
@@ -18725,7 +18724,7 @@ namespace gaia {
1872518724
GAIA_ASSERT(type.kind() == entity_kind_v<T>);
1872618725

1872718726
// Update the world version
18728-
update_version(m_header.worldVersion);
18727+
::gaia::ecs::update_version(m_header.worldVersion);
1872918728

1873018729
GAIA_ASSERT(row < m_header.capacity);
1873118730

@@ -18939,7 +18938,7 @@ namespace gaia {
1893918938
//! Returns true if the provided version is newer than the one stored internally
1894018939
GAIA_NODISCARD bool changed(uint32_t version, uint32_t compIdx) const {
1894118940
auto versions = comp_version_view();
18942-
return version_changed(versions[compIdx], version);
18941+
return ::gaia::ecs::version_changed(versions[compIdx], version);
1894318942
}
1894418943

1894518944
//! Update the version of a component at the index \param compIdx
@@ -23359,7 +23358,7 @@ namespace gaia {
2335923358
template <typename TIter, typename Func>
2336023359
void run_query_on_chunks(QueryInfo& queryInfo, Func func) {
2336123360
// Update the world version
23362-
update_version(*m_worldVersion);
23361+
::gaia::ecs::update_version(*m_worldVersion);
2336323362

2336423363
const bool hasFilters = queryInfo.has_filters();
2336523364
if (hasFilters)

0 commit comments

Comments
 (0)