Skip to content

Commit 7c39447

Browse files
committed
#ICE-206
Fixing all code locations affected by the api change of 'Span'.
1 parent 15c9b95 commit 7c39447

File tree

21 files changed

+100
-90
lines changed

21 files changed

+100
-90
lines changed

source/code/core/collections/public/ice/container/array.hxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ namespace ice::array
7474
template<typename Type, ice::ContainerLogic Logic>
7575
inline auto back(ice::Array<Type, Logic>& arr) noexcept -> Type&;
7676

77-
78-
7977
template<typename Type, ice::ContainerLogic Logic>
8078
inline auto count(ice::Array<Type, Logic> const& arr) noexcept -> ice::u32;
8179

source/code/core/collections/public/ice/container/impl/array_impl.inl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ namespace ice
8383
{
8484
ice::mem_copy_construct_n_at(
8585
ice::array::memory(*this),
86-
ice::span::data(values),
86+
values.data(),
8787
values.size()
8888
);
8989
}
9090
else
9191
{
92-
ice::memcpy(_data, ice::span::data(values), ice::span::size_bytes(values));
92+
ice::memcpy(_data, values.data(), values.size().bytes());
9393
}
9494

9595
_count = values.size().u32();
@@ -362,15 +362,15 @@ namespace ice
362362
{
363363
ice::mem_copy_construct_n_at<Type>(
364364
Memory{ .location = arr._data + arr._count, .size = ice::size_of<Type> * missing_items, .alignment = ice::align_of<Type> },
365-
ice::span::data(items),
365+
items.data(),
366366
items.size().u32()
367367
);
368368
}
369369
else
370370
{
371371
ice::memcpy(
372372
Memory{ .location = arr._data + arr._count, .size = ice::size_of<Type> * missing_items, .alignment = ice::align_of<Type> },
373-
ice::span::data_view(items)
373+
items.data_view()
374374
);
375375
}
376376

source/code/core/collections/public/ice/container/impl/queue_impl.inl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ namespace ice
461461
.size = ice::size_of<Type> * head_space,
462462
.alignment = ice::align_of<Type>
463463
},
464-
ice::span::data(items),
464+
items.data(),
465465
head_space
466466
);
467467
ice::mem_copy_construct_n_at<Type>(
@@ -470,7 +470,7 @@ namespace ice
470470
.size = ice::size_of<Type> * tail_space,
471471
.alignment = ice::align_of<Type>
472472
},
473-
ice::span::data(items) + head_space,
473+
items.data() + head_space,
474474
tail_space
475475
);
476476
}
@@ -483,7 +483,7 @@ namespace ice
483483
.alignment = ice::align_of<Type>
484484
},
485485
Data{
486-
.location = ice::span::data(items),
486+
.location = items.data(),
487487
.size = ice::size_of<Type> * head_space,
488488
.alignment = ice::align_of<Type>
489489
}
@@ -495,7 +495,7 @@ namespace ice
495495
.alignment = ice::align_of<Type>
496496
},
497497
Data{
498-
.location = ice::span::data(items) + head_space,
498+
.location = items.data() + head_space,
499499
.size = ice::size_of<Type> * tail_space,
500500
.alignment = ice::align_of<Type>
501501
}
@@ -605,13 +605,13 @@ namespace ice
605605

606606
if constexpr (Logic == ContainerLogic::Complex)
607607
{
608-
ice::mem_move_n_to(ice::span::begin(out_values), queue._data + queue._offset, first_part_count);
609-
ice::mem_move_n_to(ice::span::begin(out_values) + first_part_count, queue._data, second_part);
608+
ice::mem_move_n_to(out_values.begin(), queue._data + queue._offset, first_part_count);
609+
ice::mem_move_n_to(out_values.begin() + first_part_count, queue._data, second_part);
610610
}
611611
else
612612
{
613-
ice::memcpy(ice::span::begin(out_values), queue._data + queue._offset, first_part_count * sizeof(Type));
614-
ice::memcpy(ice::span::begin(out_values) + first_part_count, queue._data, second_part * sizeof(Type));
613+
ice::memcpy(out_values.begin(), queue._data + queue._offset, first_part_count * sizeof(Type));
614+
ice::memcpy(out_values.begin() + first_part_count, queue._data, second_part * sizeof(Type));
615615
}
616616

617617
ice::queue::pop_front(queue, taken_items);

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,25 @@ namespace ice
6767
template<typename T, typename U> requires (std::convertible_to<T, U>)
6868
constexpr auto lower_bound(ice::Span<T> values, U const& value) noexcept -> ice::u32
6969
{
70-
return static_cast<ice::u32>(std::lower_bound(ice::span::begin(values), ice::span::end(values), value) - ice::span::begin(values));
70+
return static_cast<ice::u32>(std::lower_bound(values.begin(), values.end(), value) - values.begin());
7171
}
7272

7373
template<typename T, typename Comp, typename U> requires (std::convertible_to<T, U>)
7474
constexpr auto lower_bound(ice::Span<T> values, U const& value, Comp&& comp) noexcept -> ice::u32
7575
{
76-
return static_cast<ice::u32>(std::lower_bound(ice::span::begin(values), ice::span::end(values), value, ice::forward<Comp>(comp)) - ice::span::begin(values));
76+
return static_cast<ice::u32>(std::lower_bound(values.begin(), values.end(), value, ice::forward<Comp>(comp)) - values.begin());
7777
}
7878

7979
template<typename T, typename U> requires (std::convertible_to<T, U>)
8080
constexpr auto upper_bound(ice::Span<T> values, U const& value) noexcept -> ice::u32
8181
{
82-
return static_cast<ice::u32>(std::upper_bound(ice::span::begin(values), ice::span::end(values), value) - ice::span::begin(values));
82+
return static_cast<ice::u32>(std::upper_bound(values.begin(), values.end(), value) - values.begin());
8383
}
8484

8585
template<typename T, typename Comp, typename U> requires (std::convertible_to<T, U>)
8686
constexpr auto upper_bound(ice::Span<T> values, U const& value, Comp&& comp) noexcept -> ice::u32
8787
{
88-
return static_cast<ice::u32>(std::upper_bound(ice::span::begin(values), ice::span::end(values), value, ice::forward<Comp>(comp)) - ice::span::begin(values));
88+
return static_cast<ice::u32>(std::upper_bound(values.begin(), values.end(), value, ice::forward<Comp>(comp)) - values.begin());
8989
}
9090

9191
template<typename T, typename U> requires (std::convertible_to<T, U>)
@@ -274,7 +274,7 @@ namespace ice
274274
template<typename T, typename Pred>
275275
inline void sort(ice::Span<T> span, Pred&& pred) noexcept
276276
{
277-
std::sort(ice::span::begin(span), ice::span::end(span), ice::forward<Pred>(pred));
277+
std::sort(span.begin(), span.end(), ice::forward<Pred>(pred));
278278
}
279279

280280
template<typename K, typename V, typename Pred>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ SCENARIO("ice :: Data")
4848

4949
data = ice::data_view(values_span);
5050

51-
CHECK(data.location == ice::span::data(values_span));
52-
CHECK(data.size == ice::span::size_bytes(values_span));
53-
CHECK(data.alignment == ice::span::alignment(values_span));
51+
CHECK(data.location == values_span.data());
52+
CHECK(data.size == values_span.size());
53+
CHECK(data.alignment == ice::align_of<ice::Span<ice::u64 const>::ValueType>);
5454
}
5555
}

source/code/core/memsys/private/mem.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ namespace ice
9494
return std::memcpy(dest, source, size.value);
9595
}
9696

97+
auto memcpy(void* dest, ice::Data source) noexcept -> void*
98+
{
99+
return std::memcpy(dest, source.location, source.size.value);
100+
}
101+
97102
auto memcpy(ice::Memory memory, ice::Data data) noexcept -> ice::Memory
98103
{
99104
ICE_ASSERT_CORE(memory.alignment >= data.alignment);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ namespace ice
3939
void release_aligned(void* pointer) noexcept;
4040

4141
auto memcpy(void* dest, void const* source, ice::usize size) noexcept -> void*;
42+
auto memcpy(void* dest, ice::Data source) noexcept -> void*;
4243
auto memcpy(ice::Memory memory, ice::Data data) noexcept -> ice::Memory;
44+
4345
auto memset(ice::Memory memory, ice::u8 value) noexcept -> ice::Memory;
4446

4547
constexpr AllocRequest::AllocRequest(ice::usize size, ice::ualign alignment) noexcept

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,45 +30,45 @@ namespace ice
3030
}
3131

3232
template<typename T>
33-
auto mem_construct_n_at(ice::Memory memory, ice::u32 count) noexcept -> T*
33+
auto mem_construct_n_at(ice::Memory memory, ice::u64 count) noexcept -> T*
3434
{
3535
// TODO: Assert (align + size)
3636
T* target_mem = reinterpret_cast<T*>(memory.location);
37-
for (ice::u32 idx = 0; idx < count; ++idx)
37+
for (ice::u64 idx = 0; idx < count; ++idx)
3838
{
3939
new (target_mem + idx) T{ };
4040
}
4141
return target_mem;
4242
}
4343

4444
template<typename T>
45-
auto mem_move_construct_n_at(ice::Memory memory, T* objects, ice::u32 count) noexcept -> T*
45+
auto mem_move_construct_n_at(ice::Memory memory, T* objects, ice::u64 count) noexcept -> T*
4646
{
4747
// TODO: Assert (align + size)
4848
T* target_mem = reinterpret_cast<T*>(memory.location);
49-
for (ice::u32 idx = 0; idx < count; ++idx)
49+
for (ice::u64 idx = 0; idx < count; ++idx)
5050
{
5151
new (target_mem + idx) T{ ice::move(objects[idx]) };
5252
}
5353
return target_mem;
5454
}
5555

5656
template<typename T>
57-
auto mem_move_n_to(T* target_objects, T* objects, ice::u32 count) noexcept -> T*
57+
auto mem_move_n_to(T* target_objects, T* objects, ice::u64 count) noexcept -> T*
5858
{
59-
for (ice::u32 idx = 0; idx < count; ++idx)
59+
for (ice::u64 idx = 0; idx < count; ++idx)
6060
{
6161
target_objects[idx] = ice::move(objects[idx]);
6262
}
6363
return target_objects;
6464
}
6565

6666
template<typename T>
67-
auto mem_copy_construct_n_at(ice::Memory memory, T const* objects, ice::u32 count) noexcept -> T*
67+
auto mem_copy_construct_n_at(ice::Memory memory, T const* objects, ice::u64 count) noexcept -> T*
6868
{
6969
// TODO: Assert (align + size)
7070
T* target_mem = reinterpret_cast<T*>(memory.location);
71-
for (ice::u32 idx = 0; idx < count; ++idx)
71+
for (ice::u64 idx = 0; idx < count; ++idx)
7272
{
7373
new (target_mem + idx) T{ objects[idx] };
7474
}
@@ -84,9 +84,9 @@ namespace ice
8484
}
8585

8686
template<typename T>
87-
void mem_destruct_n_at(T* location, ice::u32 count) noexcept
87+
void mem_destruct_n_at(T* location, ice::u64 count) noexcept
8888
{
89-
for (ice::u32 idx = 0; idx < count; ++idx)
89+
for (ice::u64 idx = 0; idx < count; ++idx)
9090
{
9191
ice::mem_destruct_at(location + idx);
9292
}

source/code/core/utils/public/ice/algorithm.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace ice
1111
template<typename T, typename U = T>
1212
constexpr auto accumulate(ice::Span<T const> range, U val) noexcept
1313
{
14-
return ::std::accumulate(ice::begin(range), ice::end(range), val);
14+
return ::std::accumulate(range.begin(), range.end(), val);
1515
}
1616

1717
} // namespace ice

source/code/iceshard/engine/private/ecs/ecs_archetype_index.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,20 +230,20 @@ namespace ice::ecs
230230
ice::memcpy(mem_archetype_name, archetype_info.name.data_view());
231231

232232
// Copy the component idnetifiers
233-
ice::memcpy(mem_component_data, ice::span::data_view(archetype_info.component_identifiers));
233+
ice::memcpy(mem_component_data, archetype_info.component_identifiers.data_view());
234234
component_identifiers = reinterpret_cast<ice::StringID const*>(mem_component_data.location);
235235

236236
// Calculate where we start storing the u32 values...
237237
mem_component_data = ice::ptr_add(result, offset_values);
238238

239239
// Copy the size and alignment.
240240
component_sizes = reinterpret_cast<ice::u32 const*>(mem_component_data.location);
241-
ice::memcpy(mem_component_data, ice::span::data_view(archetype_info.component_sizes));
242-
mem_component_data = ice::ptr_add(mem_component_data, ice::span::size_bytes(archetype_info.component_sizes));
241+
ice::memcpy(mem_component_data, archetype_info.component_sizes.data_view());
242+
mem_component_data = ice::ptr_add(mem_component_data, archetype_info.component_sizes.size());
243243

244244
component_alignments = reinterpret_cast<ice::u32 const*>(mem_component_data.location);
245-
ice::memcpy(mem_component_data, ice::span::data_view(archetype_info.component_alignments));
246-
mem_component_data = ice::ptr_add(mem_component_data, ice::span::size_bytes(archetype_info.component_alignments));
245+
ice::memcpy(mem_component_data, archetype_info.component_alignments.data_view());
246+
mem_component_data = ice::ptr_add(mem_component_data, archetype_info.component_alignments.size());
247247

248248
// Save location to store calculated offsets
249249
component_offsets = reinterpret_cast<ice::u32*>(mem_component_data.location);

0 commit comments

Comments
 (0)