Skip to content

Commit 407d94d

Browse files
authored
Cherry changes october (#198)
Overview: Minor improvements, fixes and additions across engine libraries. Features: * Introduced 'ownership' concept for Widgets in DevUI library. * Introduced new query operation 'try_entity' * Returns same data as 'for_entity' but allows to fail the operation. * Extended asset category API. * May define 'extension_for_state' function to map 'State' to file extension. Additions: * Added a new 'Ptr' type that tracks ref-counted objects. * Added new functions 'cbegin' and 'cend' for 'HeapVarString' types. * Added new sort function 'sort_many' to sort any number of arrays based on the first. * Added additional utility functions: 'less' and 'equal' * Added formatter to 'ice::Expected' type. * Added missing construtcors to 'Color' type. Changes: * Improved Error tracking for "ResourceWriter" types. * Separated an 'IDevUIWidget' interface from the 'DevUIWidget' type. * Initial attempt on Styling the Dev UI. * Renamed worker threads from 'ice.thread' to 'ice.worker' Fixes: * Fixed 'Color' not always properly translating from 'float' to 'int' representations. * Fixed 'TaskExpected' types not passing 'Error' value when the 'Result' value was different. * Fixed build errors due to duplicate symbols in logger library. * Fixed ImGui being loaded even when not used.
1 parent 7bc1e28 commit 407d94d

File tree

63 files changed

+1366
-95
lines changed

Some content is hidden

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

63 files changed

+1366
-95
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace ice
1515
//! \details Manages a memory block big enough to hold the items that it holds.
1616
//!
1717
//! \tparam Logic The logic used during memory operations for the given type.
18-
//! This value is set by the user to enforce expected behavior for stored types.
18+
//! This value cab be set by the user to enforce expected behavior for stored types.
1919
template<typename Type, ice::ContainerLogic Logic = ice::Constant_DefaultContainerLogic<Type>>
2020
struct Array
2121
{

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,35 @@ namespace ice
162162
return i + 1;
163163
}
164164

165+
template<typename Pred, typename Key, typename... Values>
166+
inline auto qsort_partition_many(
167+
Pred&& pred,
168+
ice::i32 left,
169+
ice::i32 right,
170+
ice::Span<Key> keys,
171+
ice::Span<Values>... values
172+
) noexcept -> ice::i32
173+
{
174+
Key* pivot = &keys[right];
175+
176+
ice::i32 i = left - 1;
177+
ice::i32 j = left;
178+
179+
while (j < right)
180+
{
181+
if (ice::forward<Pred>(pred)(keys[j], *pivot))
182+
{
183+
++i;
184+
ice::swap(keys[i], keys[j]);
185+
(ice::swap(values[i], values[j]), ...);
186+
}
187+
++j;
188+
}
189+
ice::swap(keys[i + 1], keys[right]);
190+
(ice::swap(values[i + 1], values[right]), ...);
191+
return i + 1;
192+
}
193+
165194
template<typename K, typename Pred>
166195
inline auto qsort_partition_indices(ice::Span<K> keys, ice::Span<ice::u32>& indices, Pred&& pred, ice::i32 left, ice::i32 right) noexcept -> ice::i32
167196
{
@@ -200,6 +229,27 @@ namespace ice
200229
}
201230
}
202231

232+
template<typename Pred, typename Key, typename... Values>
233+
inline void qsort_many(
234+
Pred&& pred,
235+
ice::i32 left,
236+
ice::i32 right,
237+
ice::Span<Key> keys,
238+
ice::Span<Values>... values
239+
) noexcept
240+
{
241+
while (left < right)
242+
{
243+
ice::i32 const pi = qsort_partition_many<Pred, Key, Values...>(
244+
ice::forward<Pred>(pred), left, right, keys, values...
245+
);
246+
247+
ice::detail::qsort_many(ice::forward<Pred>(pred), left, pi - 1, keys, values...);
248+
249+
left = pi + 1;
250+
}
251+
}
252+
203253
template<typename K, typename Pred>
204254
inline void qsort_indices(ice::Span<K> keys, ice::Span<ice::u32> indices, Pred&& pred, ice::i32 left, ice::i32 right) noexcept
205255
{
@@ -236,6 +286,16 @@ namespace ice
236286
ice::detail::qsort(keys, values, std::forward<Pred>(pred), first_index, last_index);
237287
}
238288

289+
template<typename Key, typename Pred, typename... Values>
290+
requires ice::concepts::ComparisonFunction<Pred, Key, Key>
291+
inline void sort_many(ice::Span<Key> keys, Pred&& pred, ice::Span<Values>... values) noexcept
292+
{
293+
ice::i32 const first_index = 0;
294+
ice::i32 const last_index = ice::count(keys) - 1;
295+
296+
ice::detail::qsort_many(std::forward<Pred>(pred), first_index, last_index, keys, values...);
297+
}
298+
239299
template<typename K, typename Pred>
240300
inline void sort_indices(ice::Span<K> keys, ice::Span<ice::u32> indices, Pred&& pred) noexcept
241301
{

source/code/core/collections/public/ice/string/heap_var_string.hxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ namespace ice::string
1717
template<typename CharType>
1818
inline auto end(ice::HeapVarString<CharType>& str) noexcept -> typename ice::HeapVarString<CharType>::Iterator;
1919

20+
template<typename CharType>
21+
inline auto cbegin(ice::HeapVarString<CharType> const& str) noexcept -> typename ice::HeapVarString<CharType>::ConstIterator;
22+
23+
template<typename CharType>
24+
inline auto cend(ice::HeapVarString<CharType> const& str) noexcept -> typename ice::HeapVarString<CharType>::ConstIterator;
25+
2026
template<typename CharType>
2127
inline auto rbegin(ice::HeapVarString<CharType>& str) noexcept -> typename ice::HeapVarString<CharType>::ReverseIterator;
2228

source/code/core/collections/public/ice/string/impl/heap_var_string.inl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,20 @@ namespace ice
147147
return str._data + bytes + size;
148148
}
149149

150+
template<typename CharType>
151+
inline auto cbegin(ice::HeapVarString<CharType>& str) noexcept -> typename ice::HeapVarString<CharType>::ConstIterator
152+
{
153+
return ice::string::detail::data_varstring(str._data);
154+
}
155+
156+
template<typename CharType>
157+
inline auto cend(ice::HeapVarString<CharType>& str) noexcept -> typename ice::HeapVarString<CharType>::ConstIterator
158+
{
159+
ice::ucount bytes;
160+
ice::ucount const size = ice::string::detail::read_varstring_size(str._data, bytes);
161+
return str._data + bytes + size;
162+
}
163+
150164
template<typename CharType>
151165
auto deserialize(ice::HeapVarString<CharType>& str, ice::Data data) noexcept -> ice::Data
152166
{

source/code/core/core/public/ice/shard.hxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace ice
1010

1111
//! \brief Small value object able to pass up to 8 bytes of data accross the engine.
1212
//!
13-
//! \detail A single shard is always 16 bytes in size.
13+
//! \details A single shard is always 16 bytes in size.
1414
//! The first 4 bytes represent the name <em>(ice::ShardID)</em> and the next four the typeid <em>(ice::ShardPayloadID)</em> of the carried data.
1515
//! Because this object is designed to only pass small values it's mostly used to carry pointers to constant objects living in a frame.
1616
//!
@@ -29,7 +29,7 @@ namespace ice
2929

3030
//! \brief Creates a ice::ShardID value from a utf8 string.
3131
//!
32-
//! \detail The passed value can contain the name and typeid.
32+
//! \details The passed value can contain the name and typeid.
3333
//! To do so the names need to be separated by a '`' <em>(backquote)</em> character. For example.: `my-shard`ice::u32`
3434
//!
3535
//! \note Even if you create a ice::ShardID with a typeid that is not enabled, it will not allow you to create a shard with such a value.
@@ -40,7 +40,7 @@ namespace ice
4040

4141
//! \brief Creates a ice::Shard value from a utf8 string and the given value.
4242
//!
43-
//! \detail The function returns the final shard if both the definition and the typeid of the given value match.
43+
//! \details The function returns the final shard if both the definition and the typeid of the given value match.
4444
//! Otherwise the shard fails to create.
4545
//!
4646
//! \param[in] definition Follows the same rules described in ice::shardid(std::u8_string_view).
@@ -50,7 +50,7 @@ namespace ice
5050

5151
//! \brief Creates a ice::Shard value from ice::ShardID and the given value.
5252
//!
53-
//! \detail The function returns the final shard if both the shardid and the typeid of the given value match.
53+
//! \details The function returns the final shard if both the shardid and the typeid of the given value match.
5454
//! Otherwise the shard fails to create.
5555
//!
5656
//! \param[in] id ShardID used to create the shard.

source/code/core/core/public/ice/utility.hxx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
namespace ice
88
{
99

10+
using std::tuple;
11+
1012
template<typename... Tuples>
1113
struct tuples_merged;
1214

@@ -51,4 +53,37 @@ namespace ice
5153
template<typename T>
5254
using make_unique_tuple = typename make_unique_tuple_helper<T>::type;
5355

56+
57+
// common functions
58+
59+
namespace concepts
60+
{
61+
template<typename Fn, typename T, typename O>
62+
concept ComparisonFunction = requires(T&& a, O&& b) {
63+
{ std::forward<Fn>(std::declval<Fn>())(std::forward<T>(a), std::forward<O>(b)) } -> std::convertible_to<bool>;
64+
};
65+
}
66+
67+
template<typename Left, typename Right = Left>
68+
constexpr auto equal(Left&& left, Right&& right) noexcept -> bool
69+
{
70+
return std::forward<Left>(left) == std::forward<Left>(right);
71+
}
72+
73+
template<typename Left, typename Right = Left>
74+
constexpr auto less(Left const& left, Right const& right) noexcept -> bool
75+
{
76+
return left < right;
77+
}
78+
79+
// others
80+
81+
template <typename Field, typename Class>
82+
constexpr auto offset_of(Field Class::* member) noexcept -> ice::uptr
83+
{
84+
return reinterpret_cast<ice::uptr>(
85+
&(((Class*)0)->*member)
86+
);
87+
}
88+
5489
} // namespace ice

source/code/core/devui/private/devui_context.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ namespace ice
3838
}
3939

4040
bool devui_register_widget(
41-
ice::DevUIWidget* widget
41+
ice::DevUIWidget* widget,
42+
ice::DevUIWidget* owning_widget
4243
) noexcept
4344
{
4445
if (global_context_register_widget == nullptr)
@@ -50,7 +51,7 @@ namespace ice
5051
return false;
5152
}
5253

53-
global_context_register_widget(widget);
54+
global_context_register_widget(widget, owning_widget);
5455
return true;
5556
}
5657

source/code/core/devui/private/devui_widget.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ namespace ice
99
{
1010

1111
DevUIWidget::DevUIWidget(ice::DevUIWidgetInfo const& info) noexcept
12-
: widget_info{ info }
12+
: IDevUIWidget{ }
13+
, widget_info{ info }
1314
{
1415
}
1516

source/code/core/devui/public/ice/devui_context.hxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ namespace ice
3434
auto devui_trait_name() noexcept -> ice::StringID;
3535

3636
bool devui_register_widget(
37-
ice::DevUIWidget* widget
37+
ice::DevUIWidget* widget,
38+
ice::DevUIWidget* owning_widget = nullptr
3839
) noexcept;
3940

4041
bool devui_remove_widget(

source/code/core/devui/public/ice/devui_frame.hxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace ice
99

1010
struct DevUIWidgetState
1111
{
12+
DevUIWidgetState const* const owner = nullptr;
1213
bool active = false;
1314
};
1415

0 commit comments

Comments
 (0)