Skip to content

Commit 5acb729

Browse files
committed
#ICE-207
Changes to engine source code after additioanl refactor of the Array type.
1 parent e0b9b02 commit 5acb729

File tree

78 files changed

+400
-436
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+400
-436
lines changed

source/code/core/collections/public/ice/shard_container.hxx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace ice
2121
inline auto operator=(ice::ShardContainer&& other) noexcept -> ice::ShardContainer&;
2222
inline auto operator=(ice::ShardContainer const& other) noexcept -> ice::ShardContainer&;
2323

24-
inline operator ice::Span<ice::Shard const>() const noexcept { return ice::array::slice(_data); }
24+
inline operator ice::Span<ice::Shard const>() const noexcept { return _data; }
2525

2626
ice::Array<ice::Shard> _data;
2727
};
@@ -129,22 +129,22 @@ namespace ice
129129

130130
inline void reserve(ice::ShardContainer& container, ice::u32 new_capacity) noexcept
131131
{
132-
ice::array::reserve(container._data, new_capacity);
132+
container._data.reserve(new_capacity);
133133
}
134134

135135
inline void resize(ice::ShardContainer& container, ice::u32 new_size) noexcept
136136
{
137-
ice::array::resize(container._data, new_size);
137+
container._data.resize(new_size);
138138
}
139139

140140
inline void clear(ice::ShardContainer& container) noexcept
141141
{
142-
ice::array::clear(container._data);
142+
container._data.clear();
143143
}
144144

145145
inline void push_back(ice::ShardContainer& container, ice::Shard value) noexcept
146146
{
147-
ice::array::push_back(container._data, value);
147+
container._data.push_back(value);
148148
}
149149

150150
inline void push_back(ice::ShardContainer& container, ice::Span<ice::Shard const> values) noexcept
@@ -171,12 +171,12 @@ namespace ice
171171

172172
inline auto begin(ice::ShardContainer& container) noexcept -> ice::ShardContainer::Iterator
173173
{
174-
return ice::array::begin(container._data);
174+
return container._data.begin();
175175
}
176176

177177
inline auto end(ice::ShardContainer& container) noexcept -> ice::ShardContainer::Iterator
178178
{
179-
return ice::array::end(container._data);
179+
return container._data.end();
180180
}
181181

182182

@@ -212,8 +212,8 @@ namespace ice
212212

213213
inline auto find_first_of(ice::ShardContainer const& container, ice::ShardID shard, ice::u32 offset) noexcept -> ice::Shard
214214
{
215-
auto it = ice::array::begin(container._data);
216-
auto const end = ice::array::end(container._data);
215+
auto it = container._data.begin();
216+
auto const end = container._data.end();
217217

218218
if (offset != ~0)
219219
{
@@ -238,8 +238,8 @@ namespace ice
238238

239239
inline auto find_last_of(ice::ShardContainer const& container, ice::ShardID shard, ice::u32 offset) noexcept -> ice::Shard
240240
{
241-
auto it = ice::array::rbegin(container._data);
242-
auto const end = ice::array::rend(container._data);
241+
auto it = container._data.rbegin();
242+
auto const end = container._data.rend();
243243

244244
if (offset != ~0)
245245
{
@@ -299,7 +299,7 @@ namespace ice
299299
{
300300
if (shard == shard_type && ice::shard_inspect(shard, payload))
301301
{
302-
ice::array::push_back(payloads, payload);
302+
payloads.push_back(payload);
303303
count += 1;
304304
}
305305
}
@@ -331,8 +331,8 @@ namespace ice
331331
template<typename T, ice::usize::base_type Size>
332332
inline bool inspect_first(ice::ShardContainer const& container, ice::ShardID shard_type, T(&payload)[Size]) noexcept
333333
{
334-
auto it = ice::array::begin(container._data);
335-
auto const end = ice::array::end(container._data);
334+
auto it = container._data.begin();
335+
auto const end = container._data.end();
336336

337337
ice::u32 idx = 0;
338338
while (it != end && idx < Size)
@@ -361,12 +361,12 @@ namespace ice
361361

362362
inline auto begin(ice::ShardContainer const& container) noexcept -> ice::ShardContainer::ConstIterator
363363
{
364-
return ice::array::begin(container._data);
364+
return container._data.begin();
365365
}
366366

367367
inline auto end(ice::ShardContainer const& container) noexcept -> ice::ShardContainer::ConstIterator
368368
{
369-
return ice::array::end(container._data);
369+
return container._data.end();
370370
}
371371
}
372372

source/code/core/collections/tests/test_shard_container.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,19 +292,19 @@ SCENARIO("collections 'ice/shard_container.hxx'", "[shard][collection]")
292292
CHECK(payload == payloads[0]);
293293
}
294294

295-
ice::array::clear(payloads);
295+
payloads.clear();
296296
ice::shards::inspect_all(test_container, test_shard_2, payloads);
297297

298298
REQUIRE(payloads.size() == 0);
299299

300-
ice::array::clear(payloads);
300+
payloads.clear();
301301
ice::shards::inspect_all(test_container, test_shard_3, payloads);
302302

303303
REQUIRE(payloads.size() == 2);
304304
CHECK(payloads[0] == test_u32_payload_value2);
305305
CHECK(payloads[1] == test_u32_payload_value1);
306306

307-
ice::array::clear(payloads);
307+
payloads.clear();
308308
ice::shards::inspect_all(test_container, test_shard_4, payloads);
309309

310310
REQUIRE(payloads.size() == 1);

source/code/core/memsys/public/ice/mem_initializers.hxx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,31 @@
88
namespace ice
99
{
1010

11+
template<typename T, typename... Args>
12+
auto mem_construct_at(void* memory_ptr, Args&&... args) noexcept -> T*
13+
{
14+
// TODO: Assert (align + size)
15+
return new (memory_ptr) T{ ice::forward<Args>(args)... };
16+
}
17+
1118
template<typename T, typename... Args>
1219
auto mem_construct_at(ice::Memory memory, Args&&... args) noexcept -> T*
1320
{
1421
// TODO: Assert (align + size)
15-
return new (memory.location) T{ ice::forward<Args>(args)... };
22+
return mem_construct_at<T>(memory.location, ice::forward<Args>(args)...);
23+
}
24+
25+
template<typename T>
26+
auto mem_move_construct_at(void* memory_ptr, T&& other) noexcept -> T*
27+
{
28+
return new (memory_ptr) T{ ice::move(other) };
1629
}
1730

1831
template<typename T>
1932
auto mem_move_construct_at(ice::Memory memory, T&& other) noexcept -> T*
2033
{
2134
// TODO: Assert (align + size)
22-
return new (memory.location) T{ ice::move(other) };
35+
return mem_move_construct_at<T>(memory.location, ice::move(other));
2336
}
2437

2538
template<typename T>

source/code/core/modules/private/module_register.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ namespace ice
124124
/* is_app_context */ false
125125
);
126126

127-
ice::array::push_back(_module_handles, ice::move(module_handle));
127+
_module_handles.push_back(ice::move(module_handle));
128128
return true;
129129
}
130130
}

source/code/core/modules/public/ice/module_query.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ namespace ice
9696
query_apis(Type::Constant_APIName, Type::Constant_APIVersion, temp_tab, &num_apis);
9797

9898
// Fill the array with the found APIs
99-
ice::array::reserve(out_apis, num_apis);
99+
out_apis.reserve(num_apis);
100100
for (ice::u32 idx = 0; idx < num_apis; ++idx)
101101
{
102-
ice::array::push_back(out_apis, *reinterpret_cast<Type*>(temp_tab[idx].api_ptr));
102+
out_apis.push_back(*reinterpret_cast<Type*>(temp_tab[idx].api_ptr));
103103
}
104104
}
105105
return num_apis > 0;

source/code/core/tasks/private/task_thread_pool_impl.cxx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ namespace ice
4747
, _created_threads{ _allocator }
4848
, _user_threads{ _allocator }
4949
{
50-
ice::array::reserve(_thread_pool, info.thread_count);
51-
ice::array::reserve(_managed_threads, info.thread_count);
50+
_thread_pool.reserve(info.thread_count);
51+
_managed_threads.reserve(info.thread_count);
5252
ice::hashmap::reserve(_created_threads, info.thread_count);
5353
ice::hashmap::reserve(_user_threads, info.thread_count);
5454

@@ -64,8 +64,7 @@ namespace ice
6464
detail::format_string(thread_name, info.debug_name_format, idx);
6565

6666
thread_info.debug_name = thread_name;
67-
ice::array::push_back(
68-
_managed_threads,
67+
_managed_threads.push_back(
6968
ice::make_unique<ice::NativeTaskThread>(
7069
_allocator,
7170
_queue,
@@ -79,8 +78,7 @@ namespace ice
7978
{
8079
detail::format_string(thread_name, "ice.aio {}", idx);
8180

82-
ice::array::push_back(
83-
_managed_threads,
81+
_managed_threads.push_back(
8482
ice::make_unique<ice::NativeTaskThread>(
8583
_allocator,
8684
_queue,
@@ -101,8 +99,8 @@ namespace ice
10199
{
102100
ice::hashmap::clear(_user_threads);
103101
ice::hashmap::clear(_created_threads);
104-
ice::array::clear(_managed_threads);
105-
ice::array::clear(_thread_pool);
102+
_managed_threads.clear();
103+
_thread_pool.clear();
106104
}
107105

108106
auto TaskThreadPoolImplementation::thread_count() const noexcept -> ice::u32

source/code/core/utils/private/config/config_builder.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ namespace ice
9191
) noexcept -> ice::usize
9292
{
9393
ice::usize result = 0_B;
94-
ConfigBuilderEntry const* entry = ice::array::begin(config._entries);
95-
ConfigBuilderEntry const* const entry_end = ice::array::end(config._entries);
94+
ConfigBuilderEntry const* entry = config._entries.begin();
95+
ConfigBuilderEntry const* const entry_end = config._entries.end();
9696

9797
if (entry == entry_end)
9898
{
@@ -167,8 +167,8 @@ namespace ice
167167
{
168168
// First add all keys-values to the list
169169
ice::u32 keyoffset = 0;
170-
ice::config::detail::ConfigBuilderEntry const* it_entry = ice::array::begin(config._entries);
171-
ice::config::detail::ConfigBuilderEntry const* const it_end = ice::array::end(config._entries);
170+
ice::config::detail::ConfigBuilderEntry const* it_entry = config._entries.begin();
171+
ice::config::detail::ConfigBuilderEntry const* const it_end = config._entries.end();
172172
do
173173
{
174174
// Copy the whole key information and just update the str offset.
@@ -397,7 +397,7 @@ namespace ice
397397
char const* final_keystrings = reinterpret_cast<char const*>(final_keystrings_mem.location);
398398

399399
// Reserve space to hold all keystring entries and build the string buffer.
400-
ice::array::resize(keyoffsets, ice::hashmap::count(keystrings));
400+
keyoffsets.resize(ice::hashmap::count(keystrings));
401401

402402
ice::ncount keystr_offset = 0;
403403
for (CBKeyString const& keystr : ice::hashmap::values(keystrings))

source/code/core/utils/private/config/config_builder_types.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace ice::config::detail
3939
{
4040
cb_clear_value_type(_allocator, &entry);
4141
}
42-
ice::array::clear(_entries);
42+
_entries.clear();
4343
}
4444

4545
ConfigBuilderContainer::~ConfigBuilderContainer() noexcept

source/code/core/utils/private/config/config_builder_utils.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ namespace ice::config::detail
8989
container._keystrings.push_back(key);
9090

9191
// Add the new entry
92-
ice::array::push_back(container._entries, ConfigKey{ 0, CONFIG_KEYTYPE_STRING, CONFIG_VALTYPE_NONE, offset.u32(), key.size().u32()});
92+
container._entries.push_back(ConfigKey{ 0, CONFIG_KEYTYPE_STRING, CONFIG_VALTYPE_NONE, offset.u32(), key.size().u32()});
9393

9494
// Return the entry
95-
result = ice::array::begin(container._entries) + idx;
95+
result = container._entries.begin() + idx;
9696
}
9797

9898
return result;
@@ -111,7 +111,7 @@ namespace ice::config::detail
111111
ice::config::detail::ConfigBuilderEntry* result;
112112
if (idx < container._entries.size())
113113
{
114-
result = ice::array::begin(container._entries) + idx;
114+
result = container._entries.begin() + idx;
115115
if (clean)
116116
{
117117
cb_clear_value_type(alloc, result);
@@ -126,11 +126,11 @@ namespace ice::config::detail
126126

127127
while(container._entries.size() <= idx)
128128
{
129-
ice::array::push_back(container._entries, ConfigKey{ 0, CONFIG_KEYTYPE_NONE, CONFIG_VALTYPE_NONE, 0, 0 });
129+
container._entries.push_back(ConfigKey{ 0, CONFIG_KEYTYPE_NONE, CONFIG_VALTYPE_NONE, 0, 0 });
130130
}
131131

132132
// Return the entry
133-
result = ice::array::begin(container._entries) + idx;
133+
result = container._entries.begin() + idx;
134134
}
135135

136136
return result;

source/code/core/utils/private/log_internal.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace ice::detail
1616
, _tags{ _allocator }
1717
, _sinks{ _allocator }
1818
{
19-
ice::array::resize(_sinks, 5);
19+
_sinks.resize(5);
2020
}
2121

2222
LogState::~LogState() noexcept = default;
@@ -36,7 +36,7 @@ namespace ice::detail
3636
// Pottentially an error when sinks are added and remove all the time!
3737
// NOTE: Once added sinks should only be reset when a module was reloaded!
3838
ICE_ASSERT_CORE(sinkidx < 50);
39-
ice::array::push_back(_sinks, Sink{ fn_sink, userdata });
39+
_sinks.push_back(Sink{ fn_sink, userdata });
4040
return static_cast<ice::LogSinkID>(sinkidx);
4141
}
4242

0 commit comments

Comments
 (0)