From 58201e09fea09ee57f44a9ee02850fcf6b7cac24 Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:12:29 +0000 Subject: [PATCH 01/21] =?UTF-8?q?=F0=9F=8E=A8=20refactored=20list=20type?= =?UTF-8?q?=20and=20made=20the=20node=20type=20generic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/list.h | 278 ++++++++++++++++++++++++++++------------------ 1 file changed, 167 insertions(+), 111 deletions(-) diff --git a/ashura/std/list.h b/ashura/std/list.h index 5b26b1fa..bb7e366e 100644 --- a/ashura/std/list.h +++ b/ashura/std/list.h @@ -6,228 +6,284 @@ namespace ash { -/// @brief Circular Doubly-Linked list node. -/// head->next and head->prev are always non-null. -/// -/// always construct with operator new. -/// -/// @warning only use for scenarios where O(1) random insertion and/or removal -/// is a must. ListNode requires stable addressing, must not be relocated once -/// constructed. -/// -template -struct [[nodiscard]] ListNode : Pin<> +namespace intr { - ListNode * next = this; - ListNode * prev = this; - T v = {}; - - void isolate() - { - next = this; - prev = this; - } - - [[nodiscard]] constexpr bool is_linked() const - { - return next != nullptr && prev != nullptr; - } - - [[nodiscard]] constexpr bool is_isolated() const - { - return next == this && prev == this; - } -}; namespace list { -/// @brief +/// @brief Unlink Node `head` from the List, producing a new one-element List /// @tparam T -/// @param node must be valid and non-null -template -static constexpr void unlink_node(ListNode * node) +/// @param head must be valid and non-null +/// @return popped list, never null +template +constexpr void unlink(Node * head) { // detach from siblings - node->next->prev = node->prev; - node->prev->next = node->next; + head->*next->*prev = head->*prev; + head->*prev->*next = head->*next; // create 1 element node - node->next = node; - node->prev = node; + head->*next = head; + head->*prev = head; } -/// @brief +/// @brief Remove from the front of the list, producing a new one-element List /// @tparam T /// @param head must be valid and non-null, set to null if empty -/// @return popped element or null -template -[[nodiscard]] constexpr ListNode * pop_front(ListNode *& head) +/// @return unlinked element or null +template +[[nodiscard]] constexpr Node * unlink_front(Node *& head) { - ListNode * out = head; - ListNode * new_head = (head->next == head) ? nullptr : head->next; - unlink_node(out); + Node * out = head; + Node * new_head = (head->*next == head) ? nullptr : head->*next; + unlink(out); head = new_head; return out; } -/// @brief +/// @brief Remove from the back of the list, producing a new one-element List /// @tparam T /// @param head must be valid and non-null, set to null if empty -/// @return -template -[[nodiscard]] constexpr ListNode * pop_back(ListNode *& head) +/// @return unlinked element or null +template +[[nodiscard]] constexpr Node * unlink_back(Node *& head) { - ListNode * out = head->prev; - ListNode * new_head = (head->prev == head) ? nullptr : head; - unlink_node(out); + Node * out = head->*prev; + Node * new_head = (head->*prev == head) ? nullptr : head; + unlink(out); head = new_head; return out; } -/// -/// @brief +/// @brief Attach List `ext` to the end of List `head` /// /// @tparam T -/// @param node must be valid and non-null +/// @param head must be valid and non-null /// @param ext must be valid and non-null /// -template -constexpr void attach(ListNode * node, ListNode * ext) +template +constexpr void link(Node * head, Node * ext) { - ListNode * node_head = node; - ListNode * node_tail = node->prev; - ListNode * ext_head = ext; - ListNode * ext_tail = ext->prev; - ext_head->prev = node_tail; - ext_tail->next = node_head; - node_head->prev = ext_tail; - node_tail->next = ext_head; + Node * node_head = head; + Node * node_tail = head->*prev; + Node * ext_head = ext; + Node * ext_tail = ext->*prev; + ext_head->*prev = node_tail; + ext_tail->*next = node_head; + node_head->*prev = ext_tail; + node_tail->*next = ext_head; } +/// @brief Attach List `ext` to the back of List `head`, using `head` as anchor /// -/// @brief -/// -/// @tparam T /// @param head must be valid and non-null /// @param ext must be valid and non-null -/// -template -[[nodiscard]] constexpr ListNode * push_back(ListNode * head, - ListNode * ext) +/// @return the new head of the list +template +[[nodiscard]] constexpr Node * link_back(Node * head, Node * ext) { - attach(head, ext); + link(head, ext); return head; } +/// @brief Attach List `ext` to the front of List `head`, using `head` as anchor /// -/// @brief -/// -/// @tparam T /// @param head must be valid and non-null /// @param ext must be valid and non-null -/// -template -[[nodiscard]] constexpr ListNode * push_front(ListNode * head, - ListNode * ext) +/// @return the new head of the list +template +[[nodiscard]] constexpr Node * link_front(Node * head, Node * ext) { - attach(ext, head); + link(ext, head); return ext; } } // namespace list +} // namespace intr -// [ ] iterator model /// @brief A non-owning intrusive doubly circularly linked list. This is backed /// by an external allocator. -/// @tparam T type contained by the list's nodes -template +/// @tparam N node type +/// @tparam prev previous element getter +/// @tparam next next element getter +template struct [[nodiscard]] List { - ListNode * head; + typedef N Node; - constexpr List() : head{nullptr} + static constexpr Node * Node::* PREV = prev; + + static constexpr Node * Node::* NEXT = next; + + struct Iter { - } + Node * iter_ = nullptr; + Node * head_ = nullptr; + bool past_head_ = true; + + constexpr Node & operator*() const + { + return *iter_; + } + + constexpr Iter & operator++() + { + iter_ = iter_->next; + past_head_ = true; + return *this; + } + + constexpr bool operator!=(IterEnd) const + { + bool const finished = (past_head_ && iter_ == head_); + return !finished; + } + }; - explicit constexpr List(ListNode * head) : head{head} + Node * head_ = nullptr; + + constexpr List() = default; + + explicit constexpr List(Node * head_) : head_{head_} { } constexpr List(List const &) = delete; - constexpr List(List && other) : head{other.head} + constexpr List(List && other) : head_{other.head_} { - other.head = nullptr; + other.head_ = nullptr; } constexpr List & operator=(List const &) = delete; constexpr List & operator=(List && other) { - swap(head, other.head); + swap(head_, other.head_); return *this; } constexpr ~List() { - CHECK_DESC("Linked list's elements were leaked", head == nullptr); + CHECK_DESC(head_ == nullptr, "Linked list's elements were not released"); + } + + constexpr void leak() + { + head_ = nullptr; } constexpr bool is_empty() const { - return head == nullptr; + return head_ == nullptr; } - [[nodiscard]] constexpr ListNode * tail() const + [[nodiscard]] constexpr Node * head() const { - if (head == nullptr) [[unlikely]] + return head_; + } + + [[nodiscard]] constexpr Node * tail() const + { + if (head_ == nullptr) [[unlikely]] { return nullptr; } - return head->prev; + return head_->*prev; } - [[nodiscard]] constexpr ListNode * pop_front() + [[nodiscard]] constexpr Node * pop_front() { - if (head == nullptr) [[unlikely]] + if (head_ == nullptr) [[unlikely]] { return nullptr; } - return list::pop_front(head); + Node * node = intr::list::unlink_front(head_); + node->*prev = nullptr; + node->*next = nullptr; + + return node; } - [[nodiscard]] constexpr ListNode * pop_back() + [[nodiscard]] constexpr Node * pop_back() { - if (head == nullptr) [[unlikely]] + if (head_ == nullptr) [[unlikely]] { return nullptr; } - return list::pop_back(head); + Node * node = intr::list::unlink_back(head_); + node->*prev = nullptr; + node->*next = nullptr; + + return node; + } + + /// @param node non-null node to push + constexpr void push_front(Node * node) + { + node->*next = node; + node->*prev = node; + + if (head_ == nullptr) [[unlikely]] + { + head_ = node; + return; + } + + head_ = intr::list::link_front(head_, node); } - constexpr void push_front(ListNode * ext) + /// @param node non-null node to push + constexpr void push_back(Node * node) { - if (head == nullptr) [[unlikely]] + node->*next = node; + node->*prev = node; + + if (head_ == nullptr) [[unlikely]] { - head = ext; + head_ = node; return; } - head = list::push_front(head, ext); + head_ = intr::list::link_back(head_, node); } - constexpr void push_back(ListNode * ext) + constexpr void extend_front(List list) { - if (head == nullptr) [[unlikely]] + if (list.head_ == nullptr) [[unlikely]] { - head = ext; return; } - head = list::push_back(head, ext); + head_ = intr::list::link_front(head_, list.head_); + + list.leak(); + } + + constexpr void extend_back(List list) + { + if (list.head_ == nullptr) [[unlikely]] + { + return; + } + + head_ = intr::list::link_back(head_, list.head_); + + list.leak(); + } + + constexpr Iter begin() const + { + return Iter{ + .iter_ = head_, .head_ = head_, .past_head_ = (head_ == nullptr)}; + } + + constexpr auto end() const + { + return IterEnd{}; } }; From ad8a4f8e302f4a1e166980891df4f3a0924fce80 Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:25:52 +0000 Subject: [PATCH 02/21] =?UTF-8?q?=F0=9F=8E=A8=20adopted=20new=20iterator?= =?UTF-8?q?=20&=20view=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/engine/canvas.cc | 6 +- ashura/engine/engine.cc | 6 +- ashura/engine/font_impl.h | 2 +- ashura/engine/view_system.h | 18 +-- ashura/engine/views.cc | 10 +- ashura/std/allocators.h | 2 +- ashura/std/bench/hash_map.cc | 2 +- ashura/std/format.cc | 12 +- ashura/std/map.h | 10 +- ashura/std/obj.h | 12 +- ashura/std/range.h | 135 ++++++++-------- ashura/std/tests/sparse_vec.cc | 17 +- ashura/std/text.h | 20 +-- ashura/std/types.h | 110 +++++++++++-- ashura/std/vec.h | 273 +++++++++++++++++++-------------- 15 files changed, 375 insertions(+), 260 deletions(-) diff --git a/ashura/engine/canvas.cc b/ashura/engine/canvas.cc index 6855072d..44cd5bb2 100644 --- a/ashura/engine/canvas.cc +++ b/ashura/engine/canvas.cc @@ -430,7 +430,7 @@ static inline void flush_batch(Canvas & c) .params_ssbo = ctx.ngons.descriptor, .textures = ctx.gpu.texture_views, .index_counts = - ctx.canvas.ngon_index_counts.span().slice(batch.objects)}; + ctx.canvas.ngon_index_counts.view().slice(batch.objects)}; ctx.passes.ngon->encode(ctx.gpu, ctx.enc, params); }); return; @@ -667,7 +667,7 @@ Canvas & Canvas::text(ShapeInfo const & info, TextBlock const & block, f32 cursor = space_align(block_width, ln.metrics.width, alignment) - ln.metrics.width * 0.5F; for (TextRun const & run : - layout.runs.span().slice(ln.first_run, ln.num_runs)) + layout.runs.view().slice(ln.first_run, ln.num_runs)) { FontStyle const & font_style = block.fonts[run.style]; TextStyle const & run_style = style.runs[run.style]; @@ -823,7 +823,7 @@ Canvas & Canvas::triangles(ShapeInfo const & info, Span points, ngon_vertices.extend(points).unwrap(); ngon_indices.extend(idx).unwrap(); - for (u32 & v : ngon_indices.span().slice(first_index)) + for (u32 & v : ngon_indices.view().slice(first_index)) { v += first_vertex; } diff --git a/ashura/engine/engine.cc b/ashura/engine/engine.cc index 4f2f1169..b4265bcc 100644 --- a/ashura/engine/engine.cc +++ b/ashura/engine/engine.cc @@ -265,7 +265,7 @@ void Engine::init(AllocatorImpl allocator, void * app, data_u32.resize_uninit(data.size() >> 2).unwrap(); - mem::copy(data.span(), data_u32.span().as_u8()); + mem::copy(data.view(), data_u32.view().as_u8()); logger->trace("Loaded shader ", shader_id, " from file"); @@ -442,7 +442,7 @@ void Engine::recreate_swapchain_() for (gpu::ColorSpace cp : preferred_color_spaces) { - Span sel = find_if(formats.span(), [&](gpu::SurfaceFormat a) { + Span sel = find_if(formats.view(), [&](gpu::SurfaceFormat a) { return a.color_space == cp; }); if (!sel.is_empty()) @@ -460,7 +460,7 @@ void Engine::recreate_swapchain_() for (gpu::PresentMode pm : preferred_present_modes) { - if (!find(present_modes.span(), pm).is_empty()) + if (!find(present_modes.view(), pm).is_empty()) { found_present_mode = true; present_mode = pm; diff --git a/ashura/engine/font_impl.h b/ashura/engine/font_impl.h index 21787f4d..bc6b20ef 100644 --- a/ashura/engine/font_impl.h +++ b/ashura/engine/font_impl.h @@ -234,7 +234,7 @@ struct FontImpl : Font rect_pack::pack_rects(pack_context, rects.data() + num_packed, num_rasterized_glyphs - num_packed); auto [just_packed, unpacked] = - partition(rects.span().slice(num_packed), + partition(rects.view().slice(num_packed), [](rect_pack::rect const & r) { return r.was_packed; }); for (u32 i = num_packed; i < (num_packed + just_packed.span); i++) { diff --git a/ashura/engine/view_system.h b/ashura/engine/view_system.h index de0b52a2..21e2681f 100644 --- a/ashura/engine/view_system.h +++ b/ashura/engine/view_system.h @@ -322,9 +322,9 @@ struct ViewSystem void focus_order() { - iota(focus_ordering.span(), 0U); + iota(focus_ordering.view(), 0U); - indirect_sort(focus_ordering.span(), [&](u32 a, u32 b) { + indirect_sort(focus_ordering.view(), [&](u32 a, u32 b) { return tab_indices[a] < tab_indices[b]; }); @@ -349,7 +349,7 @@ struct ViewSystem { ViewNode const & node = nodes[i]; views[i]->size(extents[i], - extents.span().slice(node.first_child, node.num_children)); + extents.view().slice(node.first_child, node.num_children)); } centers[0] = Vec2::splat(0); @@ -361,8 +361,8 @@ struct ViewSystem i--; ViewNode const & node = nodes[i]; ViewLayout layout = views[i]->fit( - extents[i], extents.span().slice(node.first_child, node.num_children), - centers.span().slice(node.first_child, node.num_children)); + extents[i], extents.view().slice(node.first_child, node.num_children), + centers.view().slice(node.first_child, node.num_children)); extents[i] = layout.extent; viewport_extents[i] = layout.viewport_extent; viewport_transforms[i] = layout.viewport_transform; @@ -418,7 +418,7 @@ struct ViewSystem } } - fill(clips.span(), CRect::from_offset({0, 0}, viewport_extent)); + fill(clips.view(), CRect::from_offset({0, 0}, viewport_extent)); /// recursive view clipping for (u32 i = 0; i < n; i++) @@ -471,7 +471,7 @@ struct ViewSystem ViewNode const & node = nodes[i]; z_indices[i] = views[i]->z_index( z_indices[i], - z_indices.span().slice(node.first_child, node.num_children)); + z_indices.view().slice(node.first_child, node.num_children)); } stacking_contexts[0] = 0; @@ -484,10 +484,10 @@ struct ViewSystem } } - iota(z_ordering.span(), 0U); + iota(z_ordering.view(), 0U); // sort layers with priority: stacking_context, z_index, node depth - indirect_sort(z_ordering.span(), [&](u32 a, u32 b) { + indirect_sort(z_ordering.view(), [&](u32 a, u32 b) { if (stacking_contexts[a] < stacking_contexts[b]) { return true; diff --git a/ashura/engine/views.cc b/ashura/engine/views.cc index 41cceaee..0b259e4a 100644 --- a/ashura/engine/views.cc +++ b/ashura/engine/views.cc @@ -16,8 +16,9 @@ void ScalarDragBox::scalar_parse(Span text, ScalarState & styling) { case ScalarInputType::i32: { - i32 value = 0; - auto [ptr, ec] = fast_float::from_chars(text.begin(), text.end(), value); + i32 value = 0; + auto [ptr, ec] = + fast_float::from_chars(text.pbegin(), text.pend(), value); if (ec != std::errc{} || value < styling.min.i32 || value > styling.max.i32) { @@ -29,8 +30,9 @@ void ScalarDragBox::scalar_parse(Span text, ScalarState & styling) case ScalarInputType::f32: { - f32 value = 0; - auto [ptr, ec] = fast_float::from_chars(text.begin(), text.end(), value); + f32 value = 0; + auto [ptr, ec] = + fast_float::from_chars(text.pbegin(), text.pend(), value); if (ec != std::errc{} || value < styling.min.f32 || value > styling.max.f32) { diff --git a/ashura/std/allocators.h b/ashura/std/allocators.h index 88afbc6d..678ab3c0 100644 --- a/ashura/std/allocators.h +++ b/ashura/std/allocators.h @@ -142,7 +142,7 @@ struct Arena final : Allocator [[nodiscard]] inline Arena to_arena(Span buffer) { - return Arena{buffer.data(), buffer.end(), buffer.begin()}; + return Arena{buffer.pbegin(), buffer.pend(), buffer.pbegin()}; } /// @max_num_arenas: maximum number of arenas that can be allocated diff --git a/ashura/std/bench/hash_map.cc b/ashura/std/bench/hash_map.cc index 010a943a..d9b6b68b 100644 --- a/ashura/std/bench/hash_map.cc +++ b/ashura/std/bench/hash_map.cc @@ -1214,7 +1214,7 @@ struct std::less> { bool operator()(Span a, Span b) const { - return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end()); + return std::lexicographical_compare(a.pbegin(), a.pend(), b.pbegin(), b.pend()); } }; diff --git a/ashura/std/format.cc b/ashura/std/format.cc index acf88b06..54649543 100644 --- a/ashura/std/format.cc +++ b/ashura/std/format.cc @@ -41,14 +41,14 @@ bool push_int(fmt::Context const & ctx, fmt::Spec const & spec, IntT value) } auto [ptr, ec] = - std::to_chars(ctx.scratch.begin(), ctx.scratch.end(), value, base); + std::to_chars(ctx.scratch.pbegin(), ctx.scratch.pend(), value, base); if (ec != std::errc{}) { return false; } return ctx.push( - Span{ctx.scratch.begin(), (usize) (ptr - ctx.scratch.begin())}); + Span{ctx.scratch.pbegin(), (usize) (ptr - ctx.scratch.pbegin())}); } template @@ -71,19 +71,19 @@ bool push_float(fmt::Context const & ctx, fmt::Spec const & spec, FloatT value) std::to_chars_result result{}; if (spec.precision > 0) { - result = std::to_chars(ctx.scratch.begin(), ctx.scratch.end(), value, + result = std::to_chars(ctx.scratch.pbegin(), ctx.scratch.pend(), value, format, spec.precision); } else { result = - std::to_chars(ctx.scratch.begin(), ctx.scratch.end(), value, format); + std::to_chars(ctx.scratch.pbegin(), ctx.scratch.pend(), value, format); } if (result.ec == std::errc{}) { - return ctx.push( - Span{ctx.scratch.begin(), (usize) (result.ptr - ctx.scratch.begin())}); + return ctx.push(Span{ctx.scratch.pbegin(), + (usize) (result.ptr - ctx.scratch.pbegin())}); } return false; } diff --git a/ashura/std/map.h b/ashura/std/map.h index 95ab6fef..a71b5bae 100644 --- a/ashura/std/map.h +++ b/ashura/std/map.h @@ -84,7 +84,7 @@ struct [[nodiscard]] Map } }; - struct Range + struct View { Distance * iter_ = nullptr; Distance const * end_ = nullptr; @@ -527,7 +527,7 @@ struct [[nodiscard]] Map return false; } - constexpr Range span() const + constexpr View view() const { Iter iter{.iter_ = probe_dists_, .end_ = probe_dists_ + num_probes_, @@ -535,15 +535,15 @@ struct [[nodiscard]] Map iter.seek(); - return Range{.iter_ = iter.iter_, .end_ = iter.end_, .probe_ = iter.probe_}; + return View{.iter_ = iter.iter_, .end_ = iter.end_, .probe_ = iter.probe_}; } constexpr Iter begin() const { - return span().begin(); + return view().begin(); } - constexpr IterEnd end() const + constexpr auto end() const { return IterEnd{}; } diff --git a/ashura/std/obj.h b/ashura/std/obj.h index 4d9b7c2a..f5d2de62 100644 --- a/ashura/std/obj.h +++ b/ashura/std/obj.h @@ -12,7 +12,7 @@ namespace obj template constexpr void default_construct(Span dst) { - for (T * iter = dst.begin(); iter != dst.end(); iter++) + for (T * iter = dst.pbegin(); iter != dst.pend(); iter++) { new (iter) T{}; } @@ -21,7 +21,7 @@ constexpr void default_construct(Span dst) template constexpr void move_construct(Span src, U * dst) { - for (T * in = src.begin(); in != src.end(); in++, dst++) + for (T * in = src.pbegin(); in != src.pend(); in++, dst++) { new (dst) T{static_cast(*in)}; } @@ -36,7 +36,7 @@ constexpr void move_construct(Span src, Span dst) template constexpr void copy_construct(Span src, U * dst) { - for (T * in = src.begin(); in != src.end(); in++, dst++) + for (T * in = src.pbegin(); in != src.pend(); in++, dst++) { new (dst) T{*in}; } @@ -53,7 +53,7 @@ constexpr void destruct(Span src) { if constexpr (!TriviallyDestructible) { - for (T * iter = src.begin(); iter != src.end(); iter++) + for (T * iter = src.pbegin(); iter != src.pend(); iter++) { iter->~T(); } @@ -63,7 +63,7 @@ constexpr void destruct(Span src) template constexpr void move_assign(Span src, U * dst) { - for (T * in = src.begin(); in != src.end(); in++, dst++) + for (T * in = src.pbegin(); in != src.pend(); in++, dst++) { *in = static_cast(*dst); } @@ -78,7 +78,7 @@ constexpr void move_assign(Span src, Span dst) template constexpr void copy_assign(Span src, U * dst) { - for (T * in = src.begin(); in != src.end(); in++, dst++) + for (T * in = src.pbegin(); in != src.pend(); in++, dst++) { *dst = *in; } diff --git a/ashura/std/range.h b/ashura/std/range.h index c9cb5aaa..5a14ee7e 100644 --- a/ashura/std/range.h +++ b/ashura/std/range.h @@ -120,11 +120,10 @@ constexpr SkipIndexRange range(I min, I max, I advance) } /// @warning Equality is only determined by the first iterator -template +template struct ZipIter { Tuple iters_{}; - BaseIterEnd end0_{}; constexpr ZipIter & operator++() { @@ -139,22 +138,20 @@ struct ZipIter iters_); } - constexpr bool operator!=(IterEnd) const + constexpr bool operator!=(IterEnd end) const { - return iters_.v0 != end0_; + return iters_.v0 != end; } }; -template +template struct ZipRange { Tuple begins_{}; - BaseIterEnd end0_{}; constexpr auto begin() const { - return ZipIter{.iters_{begins_}, - .end0_{end0_}}; + return ZipIter{.iters_{begins_}}; } constexpr auto end() const @@ -174,12 +171,11 @@ constexpr auto zip(Base && base, Ranges &&... ranges) }; } -template +template struct EnumerateIter { - Index index_{}; - Iter iter_{}; - IterEnd end_{}; + Index index_{}; + Iter iter_{}; constexpr EnumerateIter & operator++() { @@ -190,25 +186,23 @@ struct EnumerateIter constexpr auto operator*() const { - return Tuple{index_, iter_}; + return Tuple{index_, *iter_}; } - constexpr bool operator!=(IterEnd) const + constexpr bool operator!=(IterEnd end) const { - return iter_ != end_; + return iter_ != end; } }; -template +template struct EnumerateRange { - IterBegin begin_; - IterEnd end_; + Iter iter_; constexpr auto begin() const { - return EnumerateIter{ - .index_ = 0, .iter_ = begin_, .end_ = end_}; + return EnumerateIter{.index_ = 0, .iter_ = iter_}; } constexpr auto end() const @@ -220,11 +214,10 @@ struct EnumerateRange template constexpr auto enumerate(R && range) { - return EnumerateRange{ - .begin_{begin(range)}, .end_{end(range)}}; + return EnumerateRange{.iter_{begin(range)}}; } -template +template constexpr void swap_range(A && a, B && b, SwapOp && swap_op = {}) { auto a_iter = begin(a); @@ -239,7 +232,7 @@ constexpr void swap_range(A && a, B && b, SwapOp && swap_op = {}) } } -template +template constexpr void fill(R && dst, U && value) { auto iter = begin(dst); @@ -345,17 +338,17 @@ constexpr bool begins_with(B && body, H && head, Cmp && cmp = {}) return true; } -template -constexpr bool ends_with(B && body, F && foot, Cmp && cmp = {}) +template +constexpr bool ends_with(Span body, Span foot, Cmp && cmp = {}) { - if (size(foot) > size(body)) + if (foot.size() > body.size()) { return false; } - auto foot_iter = begin(foot); - auto foot_end = end(foot); - auto body_iter = end(body) - size(foot); + auto foot_iter = foot.pbegin(); + auto foot_end = foot.pbegin(); + auto body_iter = body.pend() - foot.size(); while (foot_iter != foot_end) { @@ -465,7 +458,7 @@ constexpr bool range_eq(A && a, B && b, Cmp && cmp = {}) return true; } -template +template constexpr void transform(I && in, O && out, Map && mapper) { auto in_iter = begin(in); @@ -480,7 +473,7 @@ constexpr void transform(I && in, O && out, Map && mapper) } } -template +template constexpr void transform(O && out, Map && mapper) { auto out_iter = begin(out); @@ -524,7 +517,7 @@ constexpr Init transform_reduce(R && range, Init && init, Map && mapper, return static_cast(init); } -template +template constexpr void replace(R && range, E && target, F && replacement, Cmp && cmp = {}) { @@ -540,7 +533,7 @@ constexpr void replace(R && range, E && target, F && replacement, } } -template +template constexpr void replace_if(R && range, F && replacement, Test && test) { auto iter = begin(range); @@ -555,18 +548,16 @@ constexpr void replace_if(R && range, F && replacement, Test && test) } } -template -constexpr void reverse(R && range, SwapOp && swap = {}) +template +constexpr void reverse(Span span, SwapOp && swap = {}) { - if (is_empty(range)) + if (span.is_empty()) { return; } - // [ ] Use range API - - auto head = begin(range); - auto tail = end(range) - 1; + auto * head = span.pbegin(); + auto * tail = span.pend() - 1; while (head < tail) { @@ -582,10 +573,10 @@ constexpr void split(Span span, Span delimeter, Op op, Cmp && cmp = {}); template constexpr Span strip(Span src, Span other, Cmp && cmp = {}); -template -constexpr void sort(S && span, Cmp && cmp = {}) +template +constexpr void sort(Span span, Cmp && cmp = {}) { - std::sort(begin(span), end(span), cmp); + std::sort(span.pbegin(), span.pend(), cmp); } template @@ -594,10 +585,10 @@ constexpr void indirect_sort(Span indices, Cmp && cmp = {}) sort(indices, [&](I a, I b) { return cmp(a, b); }); } -template -constexpr void stable_sort(S && span, Cmp && cmp = {}) +template +constexpr void stable_sort(Span span, Cmp && cmp = {}) { - std::stable_sort(begin(span), end(span), cmp); + std::stable_sort(span.pbegin(), span.pend(), cmp); } template @@ -606,12 +597,12 @@ constexpr void indirect_stable_sort(Span indices, Cmp && cmp = {}) stable_sort(indices, [&](I a, I b) { return cmp(a, b); }); } -template -constexpr Tuple partition(R && range, Predicate && predicate) +template +constexpr Tuple partition(Span range, Predicate && predicate) { - auto iter = begin(range); - auto range_end = end(range); - auto const first = begin(range); + auto iter = range.pbegin(); + auto range_end = range.pend(); + auto const first = range.pbegin(); while (iter != range_end && predicate(*iter)) { @@ -653,9 +644,9 @@ template constexpr T inclusive_scan(Span in, Span out, T && init = {}, Op && op = {}) { - T const * in_iter = begin(in); - T const * in_end = end(in); - T * out_iter = begin(out); + T const * in_iter = in.pbegin(); + T const * in_end = in.pend(); + T * out_iter = out.pbegin(); while (in_iter != in_end) { @@ -672,9 +663,9 @@ template constexpr T exclusive_scan(Span in, Span out, T && init = {}, Op && op = {}) { - T const * in_iter = begin(in); - T const * in_end = end(in); - T * out_iter = begin(out); + T const * in_iter = in.pbegin(); + T const * in_end = in.pend(); + T * out_iter = out.pbegin(); while (in_iter != in_end) { @@ -735,10 +726,11 @@ struct PrefixRunRange /// @param ends run-ends of the data. Must be sorted. template constexpr PrefixRunRange prefix_run(Span data, - Span ends) + Span runs) { - return PrefixRunRange{ - .run_begin_ = ends.begin(), .run_end_ = ends.end(), .data_ = data.data()}; + return PrefixRunRange{.run_begin_ = runs.pbegin(), + .run_end_ = runs.pend(), + .data_ = data.data()}; } template @@ -791,10 +783,11 @@ struct SuffixRunRange /// @param ends run-ends of the data. Must be sorted. template constexpr SuffixRunRange suffix_run(Span data, - Span ends) + Span runs) { - return SuffixRunRange{ - .run_begin_ = ends.begin(), .run_end_ = ends.end(), .data_ = data.data()}; + return SuffixRunRange{.run_begin_ = runs.pbegin(), + .run_end_ = runs.pend(), + .data_ = data.data()}; } /// @brief search for first element less than or equal to value @@ -802,10 +795,10 @@ template constexpr Span lower_bound(Span span, U && value, Cmp && cmp = {}) { auto split = [](Span span) -> Tuple, Span> { - auto half_end = span.begin() + (span.size() >> 1); + auto half_end = span.pbegin() + (span.size() >> 1); return { - Span{span.begin(), half_end }, - Span{half_end, span.end()} + Span{span.pbegin(), half_end }, + Span{half_end, span.pend()} }; }; @@ -824,7 +817,7 @@ constexpr Span lower_bound(Span span, U && value, Cmp && cmp = {}) } } - return Span{iter.data(), span.end()}; + return Span{iter.data(), span.pend()}; } /// @brief search for first element greater than value @@ -894,10 +887,8 @@ constexpr WindowRange window(Span span, usize window_size, usize advance) return WindowRange{}; } - T const * end = span.data() + span.size(); - - return WindowRange{.begin_ = span.data(), - .end_ = end, + return WindowRange{.begin_ = span.pbegin(), + .end_ = span.pend(), .window_size_ = window_size, .window_advance_ = advance}; } diff --git a/ashura/std/tests/sparse_vec.cc b/ashura/std/tests/sparse_vec.cc index 3d40182a..b265212d 100644 --- a/ashura/std/tests/sparse_vec.cc +++ b/ashura/std/tests/sparse_vec.cc @@ -30,7 +30,7 @@ TEST(SparseVecTest, Start) ASSERT_EQ(f.size(), 10); ASSERT_EQ(f[7], 8); ASSERT_EQ(f[9], 0); - ASSERT_TRUE(f.extend_defaulted(5)); + ASSERT_TRUE(f.extend(5)); ASSERT_EQ(f.size(), 15); ASSERT_EQ(f[10], 0); ASSERT_EQ(f[12], 0); @@ -46,16 +46,23 @@ TEST(SparseVecTest, Start) SparseVec, Vec, BitVec> set; + for (auto [a, b, c] : set) + { + a += 2; + b += 3; + (void) c; + } + ASSERT_TRUE(set.push(69U, 67U, true)); ASSERT_EQ(set.size(), 1); ASSERT_EQ(set.size(), set.dense.v0.size()); ASSERT_TRUE(set.push(42U, 32U, false)); ASSERT_EQ(set.size(), 2); ASSERT_EQ(set.size(), set.dense.v0.size()); - ASSERT_EQ(set.dense.v0[0], 69U); - ASSERT_EQ(set.dense.v0[1], 42U); - ASSERT_EQ(set.dense.v2[0], true); - ASSERT_EQ(set.dense.v2[1], false); + ASSERT_EQ(set[0].v0, 69U); + ASSERT_EQ(set[1].v0, 42U); + ASSERT_EQ(set[0].v2, true); + ASSERT_EQ(set[1].v2, false); ASSERT_TRUE(set.try_erase(0)); ASSERT_EQ(set.size(), 1); ASSERT_EQ(set.size(), set.dense.v0.size()); diff --git a/ashura/std/text.h b/ashura/std/text.h index 0d6e94a2..161442dc 100644 --- a/ashura/std/text.h +++ b/ashura/std/text.h @@ -16,7 +16,7 @@ namespace ash { c8 const * in = text.data(); usize count = 0; - while (in != text.end()) + while (in != text.pend()) { if ((*in & 0xc0) != 0x80) { @@ -34,7 +34,7 @@ namespace ash { c8 const * in = encoded.data(); c32 * out = decoded.data(); - while (in != encoded.end()) + while (in != encoded.pend()) { if ((*in & 0xF8) == 0xF0) { @@ -63,7 +63,7 @@ namespace ash *out++ = c1; } } - return out - decoded.begin(); + return out - decoded.pbegin(); } /// @brief encoded.size must be at least decoded.size * 4 @@ -73,7 +73,7 @@ namespace ash c8 * out = encoded.data(); c32 const * in = decoded.data(); - while (in != decoded.end()) + while (in != decoded.pend()) { if (*in <= 0x7F) { @@ -103,7 +103,7 @@ namespace ash } } - return out - encoded.begin(); + return out - encoded.pbegin(); } /// @brief converts UTF-8 text from @p encoded to UTF-32 and appends into @p @@ -116,7 +116,7 @@ inline Result<> utf8_decode(Span encoded, Vec & decoded) { return Err{}; } - (void) utf8_decode(encoded, decoded.span().slice(first, count)); + (void) utf8_decode(encoded, decoded.view().slice(first, count)); return Ok{}; } @@ -132,7 +132,7 @@ inline Result<> utf8_decode(Span encoded, Vec & decoded) return Err{}; } usize const count = - utf8_encode(decoded, encoded.span().slice(first, max_count)); + utf8_encode(decoded, encoded.view().slice(first, max_count)); encoded.resize_uninit(first + count).unwrap(); return Ok{}; } @@ -140,10 +140,10 @@ inline Result<> utf8_decode(Span encoded, Vec & decoded) constexpr void replace_invalid_codepoints(Span input, Span output, c32 replacement) { - c32 const * in = input.begin(); - c32 * out = output.begin(); + c32 const * in = input.pbegin(); + c32 * out = output.pbegin(); - while (in < input.end()) + while (in < input.pend()) { if (*in > 0x10'FFFF) [[unlikely]] { diff --git a/ashura/std/types.h b/ashura/std/types.h index a8eace8c..173ffb29 100644 --- a/ashura/std/types.h +++ b/ashura/std/types.h @@ -971,6 +971,9 @@ constexpr auto is_empty(T && a) return size(a) == 0; } +/// @brief Iterator Model. Iterators are only required to +/// produce values, they are not required to provide +/// references to the values template concept Iter = requires (T it) { { @@ -978,35 +981,42 @@ concept Iter = requires (T it) { *it }; { - // pre-fix advancement + // in-place (pre-fix) advancement ++it }; }; +/// @brief Range Model. Ranges are read-only by default. template concept Range = requires (R r) { - { begin(r) } -> Iter; - { !(begin(r) != end(r)) }; + { + // can get an iterator to its beginning element + begin(r) + } -> Iter; + { + // returns boolean when asked if it has ended + !(begin(r) != end(r)) + }; }; +// [ ] struct ExampleRange +// { +// [ ] nth(); +// }; + +// [ ] change to range set using iter template constexpr void iter_set(T * iterator, Arg && arg) { *iterator = static_cast(arg); } -template -constexpr void iter_set(Uninitialized, T * iterator, Arg && arg) -{ - new (iterator) T{static_cast(arg)}; -} - // [ ] output iterator - base: set to intial value template -concept OutputIter = Iter; +concept OutIter = Iter; template -concept OutputRange = Range; +concept OutRange = Range; template struct Array @@ -1285,12 +1295,12 @@ template concept SpanCompatibleContainer = SpanContainer && SpanCompatible, T>; -// [ ] adopt span iterator for span and array template struct Span { using Type = T; using Repr = T; + using Iter = SpanIter; T * data_ = nullptr; usize size_ = 0; @@ -1307,7 +1317,7 @@ struct Span { } - constexpr Span(SpanIter iter, IterEnd) : Span{iter.iter_, iter.end_} + constexpr Span(Iter iter, IterEnd = {}) : Span{iter.iter_, iter.end_} { } @@ -1366,12 +1376,22 @@ struct Span return sizeof(T) * size_; } - constexpr T * begin() const + constexpr Iter begin() const + { + return Iter{.iter_ = data_, .end_ = data_ + size_}; + } + + constexpr auto end() const + { + return IterEnd{}; + } + + constexpr T * pbegin() const { return data_; } - constexpr T * end() const + constexpr T * pend() const { return data_ + size_; } @@ -1476,6 +1496,18 @@ constexpr auto span(C & c) return Span{data(c), size(c)}; } +template +constexpr Span view(T (&array)[N]) +{ + return span(array); +} + +template +constexpr auto view(R & range) -> decltype(range.view()) +{ + return range.view(); +} + constexpr Span operator""_str(char const * lit, usize n) { return Span{lit, n}; @@ -1664,11 +1696,36 @@ constexpr usize find_clear_bit(Span s) return impl_find_clear_bit(s); } +template +struct BitSpanIter +{ + Span repr_{}; + usize bit_pos_ = 0; + usize bit_size_ = 0; + + constexpr bool operator*() const + { + return get_bit(repr_, bit_pos_); + } + + constexpr BitSpanIter & operator++() + { + ++bit_pos_; + return *this; + } + + constexpr bool operator!=(IterEnd) const + { + return bit_pos_ != bit_size_; + } +}; + template struct BitSpan { using Type = bool; using Repr = R; + using Iter = BitSpanIter; Span repr_ = {}; usize bit_size_ = 0; @@ -1711,6 +1768,16 @@ struct BitSpan return bit_size_ == 0; } + constexpr auto begin() const + { + return Iter{.repr_ = repr_, .bit_pos_ = 0, .bit_size_ = bit_size_}; + } + + constexpr auto end() const + { + return IterEnd{}; + } + constexpr bool has_trailing() const { return bit_size_ != (repr_.size_bytes() * 8); @@ -2068,4 +2135,17 @@ struct Pin constexpr ~Pin() = default; }; +/// @brief uninitialized storage +template +struct InplaceStorage +{ + alignas(Alignment) mutable u8 storage_[Capacity]; +}; + +template +struct InplaceStorage +{ + static constexpr u8 * storage_ = nullptr; +}; + } // namespace ash diff --git a/ashura/std/vec.h b/ashura/std/vec.h index fe84b8c7..5bf8f274 100644 --- a/ashura/std/vec.h +++ b/ashura/std/vec.h @@ -17,6 +17,8 @@ struct [[nodiscard]] Vec { using Type = T; using Repr = T; + using Iter = SpanIter; + using View = Span; T * storage_ = nullptr; usize size_ = 0; @@ -142,14 +144,14 @@ struct [[nodiscard]] Vec return capacity_; } - constexpr T * begin() const + constexpr auto begin() const { - return data(); + return Iter{.iter_ = data(), .end_ = data() + size_}; } - constexpr T * end() const + constexpr auto end() const { - return data() + size_; + return IterEnd{}; } constexpr T & first() const @@ -441,7 +443,7 @@ struct [[nodiscard]] Vec return Ok{}; } - constexpr Result<> extend_defaulted(usize extension) + constexpr Result<> extend(usize extension) { usize const pos = size_; @@ -516,7 +518,7 @@ struct [[nodiscard]] Vec return extend_uninit(new_size - size_); } - constexpr Result<> resize_defaulted(usize new_size) + constexpr Result<> resize(usize new_size) { if (new_size <= size_) { @@ -524,12 +526,12 @@ struct [[nodiscard]] Vec return Ok{}; } - return extend_defaulted(new_size - size_); + return extend(new_size - size_); } - constexpr Span span() const + constexpr View view() const { - return Span{data(), size()}; + return View{data(), size()}; } }; @@ -572,6 +574,11 @@ template requires (NonConst) struct [[nodiscard]] PinVec { + using Type = T; + using Repr = T; + using Iter = SpanIter; + using View = Span; + T * storage_; usize size_; usize capacity_; @@ -666,7 +673,7 @@ struct [[nodiscard]] PinVec return out; } - obj::copy_construct(span(), out.value().span()); + obj::copy_construct(span(), out.value().view()); return out; } @@ -711,14 +718,14 @@ struct [[nodiscard]] PinVec return capacity_; } - constexpr T * begin() const + constexpr auto begin() const { - return data(); + return Iter{.iter_ = data(), .end_ = data() + size_}; } - constexpr T * end() const + constexpr auto end() const { - return data() + size_; + return IterEnd{}; } constexpr T & first() const @@ -793,7 +800,7 @@ struct [[nodiscard]] PinVec return Ok{}; } - constexpr Result<> extend_defaulted(usize extension) + constexpr Result<> extend(usize extension) { usize const pos = size_; @@ -852,9 +859,9 @@ struct [[nodiscard]] PinVec return Ok{}; } - constexpr Span span() const + constexpr View view() const { - return Span{data(), size()}; + return View{data(), size()}; } }; @@ -864,6 +871,8 @@ struct [[nodiscard]] BitVec { using Type = bool; using Repr = R; + using Iter = BitSpanIter; + using View = BitSpan; Vec repr_ = {}; usize bit_size_ = 0; @@ -920,6 +929,16 @@ struct [[nodiscard]] BitVec return bit_size_ == 0; } + constexpr auto begin() const + { + return Iter{.repr_ = repr_, .bit_pos_ = 0, .bit_size_ = bit_size_}; + } + + constexpr auto end() const + { + return IterEnd{}; + } + constexpr bool has_trailing() const { return bit_size_ != (repr_.size_ * sizeof(R) * 8); @@ -964,12 +983,12 @@ struct [[nodiscard]] BitVec constexpr bool get(usize index) const { - return ash::get_bit(repr_.span(), index); + return ash::get_bit(repr_.view(), index); } constexpr void set(usize index, bool value) const { - ash::assign_bit(repr_.span(), index, value); + ash::assign_bit(repr_.view(), index, value); } constexpr bool get_bit(usize index) const @@ -979,17 +998,17 @@ struct [[nodiscard]] BitVec constexpr bool set_bit(usize index) const { - return ash::set_bit(repr_.span(), index); + return ash::set_bit(repr_.view(), index); } constexpr bool clear_bit(usize index) const { - return ash::clear_bit(repr_.span(), index); + return ash::clear_bit(repr_.view(), index); } constexpr void flip_bit(usize index) const { - ash::flip_bit(repr_.span(), index); + ash::flip_bit(repr_.view(), index); } constexpr Result<> reserve(usize target_capacity) @@ -1083,7 +1102,7 @@ struct [[nodiscard]] BitVec return Ok{}; } - constexpr Result<> extend_defaulted(usize extension) + constexpr Result<> extend(usize extension) { usize const pos = bit_size_; @@ -1111,7 +1130,7 @@ struct [[nodiscard]] BitVec return extend_uninit(new_size - bit_size_); } - constexpr Result<> resize_defaulted(usize new_size) + constexpr Result<> resize(usize new_size) { if (new_size <= bit_size_) { @@ -1119,7 +1138,7 @@ struct [[nodiscard]] BitVec return Ok{}; } - return extend_defaulted(new_size - bit_size_); + return extend(new_size - bit_size_); } constexpr void swap(usize a, usize b) const @@ -1130,23 +1149,23 @@ struct [[nodiscard]] BitVec set(b, av); } - constexpr BitSpan span() const + constexpr auto view() const { - return BitSpan{repr_, bit_size_}; + return View{repr_, bit_size_}; } }; template -requires (NonConst && C > 0) -struct [[nodiscard]] InplaceVec +requires (NonConst) +struct [[nodiscard]] InplaceVec : InplaceStorage { using Type = T; using Repr = T; + using Iter = SpanIter; + using View = Span; static constexpr usize Capacity = C; - // uninitialized storage - alignas(T) u8 storage_[C * sizeof(T)]; usize size_ = 0; constexpr InplaceVec() = default; @@ -1196,14 +1215,9 @@ struct [[nodiscard]] InplaceVec return size_ == 0; } - constexpr T * data() - { - return reinterpret_cast(storage_); - } - - constexpr T const * data() const + constexpr T * data() const { - return reinterpret_cast(storage_); + return reinterpret_cast(this->storage_); } constexpr usize size() const @@ -1231,77 +1245,37 @@ struct [[nodiscard]] InplaceVec return Capacity; } - constexpr T * begin() - { - return data(); - } - - constexpr T const * begin() const - { - return data(); - } - - constexpr T * end() - { - return data() + size_; - } - - constexpr T const * end() const + constexpr auto begin() const { - return data() + size_; + return Iter{.iter_ = data(), .end_ = data() + size_}; } - constexpr T & first() + constexpr auto end() const { - return get(0); + return IterEnd{}; } - constexpr T const & first() const + constexpr T & first() const { return get(0); } - constexpr T & last() - { - return get(size_ - 1); - } - - constexpr T const & last() const + constexpr T & last() const { return get(size_ - 1); } - constexpr T & operator[](usize index) - { - return get(index); - } - - constexpr T const & operator[](usize index) const + constexpr T & operator[](usize index) const { return get(index); } - constexpr T & get(usize index) - { - return data()[index]; - } - - constexpr T const & get(usize index) const + constexpr T & get(usize index) const { return data()[index]; } - constexpr T * try_get(usize index) - { - if (index >= size_) [[unlikely]] - { - return nullptr; - } - - return data() + index; - } - - constexpr T const * try_get(usize index) const + constexpr T * try_get(usize index) const { if (index >= size_) [[unlikely]] { @@ -1312,7 +1286,7 @@ struct [[nodiscard]] InplaceVec } template - constexpr void set(usize index, Args &&... args) + constexpr void set(usize index, Args &&... args) const { data()[index] = T{static_cast(args)...}; } @@ -1498,7 +1472,7 @@ struct [[nodiscard]] InplaceVec return Ok{}; } - constexpr Result<> extend_defaulted(usize extension) + constexpr Result<> extend(usize extension) { usize const pos = size_; @@ -1572,7 +1546,7 @@ struct [[nodiscard]] InplaceVec return extend_uninit(new_size - size_); } - constexpr Result<> resize_defaulted(usize new_size) + constexpr Result<> resize(usize new_size) { if (new_size <= size_) { @@ -1580,17 +1554,12 @@ struct [[nodiscard]] InplaceVec return Ok{}; } - return extend_defaulted(new_size - size_); + return extend(new_size - size_); } - constexpr Span span() + constexpr auto view() const { - return Span{data(), size()}; - } - - constexpr Span span() const - { - return Span{data(), size()}; + return View{data(), size()}; } }; @@ -1626,6 +1595,53 @@ struct SparseVec using Id = u64; using Ids = Vec; + struct Iter + { + Tuple iters_; + + constexpr auto operator*() const + { + return apply( + [](auto &... iters) { return Tuple{*iters...}; }, + iters_); + } + + constexpr Iter & operator++() + { + apply([](auto &... iters) { (++iters, ...); }, iters_); + return *this; + } + + constexpr bool operator!=(IterEnd) const + { + return apply( + [](auto &... iters) { + bool const proceed = (sizeof...(iters) != 0); + return (proceed && ... && (iters != IterEnd{})); + }, + iters_); + } + }; + + struct View + { + Tuple views_; + + constexpr auto begin() const + { + return apply( + [](auto &&... views) { + return Tuple{ash::begin(views)...}; + }, + views_); + } + + constexpr auto end() const + { + return IterEnd{}; + } + }; + Ids index_to_id = {}; Ids id_to_index = {}; Dense dense = {}; @@ -1690,6 +1706,27 @@ struct SparseVec return static_cast(index_to_id.size()); } + constexpr auto begin() const + { + return Iter{.iters_ = apply( + [](auto &... vecs) { + return Tuple{ + ash::begin(vecs)...}; + }, + dense)}; + } + + constexpr auto end() const + { + return IterEnd{}; + } + + constexpr auto view() const + { + return apply([](auto &... dense) { return View{ash::view(dense)...}; }, + dense); + } + constexpr void clear() { apply([](auto &... d) { (d.clear(), ...); }, dense); @@ -1723,9 +1760,14 @@ struct SparseVec return index < size(); } - constexpr u64 operator[](u64 id) const + constexpr auto operator[](u64 id) const { - return id_to_index[id]; + u64 const index = id_to_index[id]; + return apply( + [index](auto &... dense) { + return Tuple{dense[index]...}; + }, + dense); } constexpr u64 to_index(u64 id) const @@ -1857,26 +1899,14 @@ struct SparseVec } } - template - struct Pusher - { - template - static constexpr void push(Tuple & t, Head && head, Tail &&... tail) - { - get(t).push(static_cast(head)).unwrap(); - if constexpr (sizeof...(tail) != 0) - { - Pusher::push(t, static_cast(tail)...); - } - } - }; - template + requires (sizeof...(Args) == sizeof...(V)) constexpr Result push(Args &&... args) - requires (sizeof...(Args) == sizeof...(V)) { u64 const index = size(); + // grow here so we can handle all memory allocation + // failures at once. the proceeding unwrap calls will not fail if (!grow(size() + 1)) [[unlikely]] { return Err{}; @@ -1894,7 +1924,12 @@ struct SparseVec return Err{}; } - Pusher<0>::push(dense, static_cast(args)...); + Tuple args_tuple{static_cast(args)...}; + + index_apply([&]() { + (get(dense).push(get(args_tuple)).unwrap(), ...); + }); + return id; } }; @@ -1933,20 +1968,20 @@ namespace fmt { inline bool push(Context const & ctx, Spec const & spec, Vec const & str) { - return push(ctx, spec, str.span()); + return push(ctx, spec, str.view()); } inline bool push(Context const & ctx, Spec const & spec, PinVec const & str) { - return push(ctx, spec, str.span()); + return push(ctx, spec, str.view()); } template inline bool push(Context const & ctx, Spec const & spec, InplaceVec const & str) { - return push(ctx, spec, str.span()); + return push(ctx, spec, str.view()); } } // namespace fmt From 55bee47752c295ee5c9fac66638801b082e7d156 Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:27:30 +0000 Subject: [PATCH 03/21] =?UTF-8?q?=F0=9F=90=9B=20fixed=20bug=20in=20super?= =?UTF-8?q?=20class=20derive=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/super.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ashura/std/super.h b/ashura/std/super.h index cafea465..3b5730e4 100644 --- a/ashura/std/super.h +++ b/ashura/std/super.h @@ -48,12 +48,12 @@ struct Super Lifecycle lifecycle; template - requires (Derives && ALIGNMENT >= alignof(Object) && + requires (Derives && ALIGNMENT >= alignof(Object) && CAPACITY >= sizeof(Object)) constexpr Super(Object object, Lifecycle lifecycle = LIFECYCLE) : - lifecycle{lifecycle} + lifecycle_{lifecycle} { - base_ptr = new (storage) Object{static_cast(object)}; + base_ = new (storage_) Object{static_cast(object)}; } constexpr Super(Super const &) = delete; From 48f04154466edd9922a24afe6532b7b854fd1a27 Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:36:39 +0000 Subject: [PATCH 04/21] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20used=20inline=20cons?= =?UTF-8?q?texpr=20for=20header=20values?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/engine/canvas.cc | 12 +- ashura/engine/color.h | 714 ++++++++++++++++++------------------ ashura/engine/font.h | 2 +- ashura/engine/font_impl.h | 2 +- ashura/engine/gpu_context.h | 26 +- ashura/engine/input.h | 78 ++-- ashura/engine/view.h | 2 +- ashura/gpu/gpu.h | 60 +-- ashura/gpu/vulkan.h | 20 +- ashura/std/async.cc | 2 +- ashura/std/async.h | 2 +- ashura/std/enum.gen.h | 2 +- ashura/std/enum.py | 2 +- ashura/std/fs.h | 2 +- ashura/std/lambda.h | 4 +- ashura/std/locale.h | 258 ++++++------- ashura/std/mem.h | 8 +- ashura/std/super.h | 4 +- ashura/std/text.h | 32 +- ashura/std/tuple.gen.h | 2 +- ashura/std/tuple.py | 2 +- ashura/std/types.h | 62 ++-- ashura/std/v.gen.h | 32 +- ashura/std/v.py | 2 +- 24 files changed, 667 insertions(+), 665 deletions(-) diff --git a/ashura/engine/canvas.cc b/ashura/engine/canvas.cc index 44cd5bb2..9905aa49 100644 --- a/ashura/engine/canvas.cc +++ b/ashura/engine/canvas.cc @@ -638,12 +638,12 @@ Canvas & Canvas::text(ShapeInfo const & info, TextBlock const & block, f32 const block_width = max(layout.extent.x, style.align_width); Vec2 const block_extent{block_width, layout.extent.y}; - constexpr u8 PASS_BACKGROUND = 0; - constexpr u8 PASS_GLYPH_SHADOWS = 1; - constexpr u8 PASS_GLYPHS = 2; - constexpr u8 PASS_UNDERLINE = 3; - constexpr u8 PASS_STRIKETHROUGH = 4; - constexpr u8 NUM_PASSES = 5; + static constexpr u8 PASS_BACKGROUND = 0; + static constexpr u8 PASS_GLYPH_SHADOWS = 1; + static constexpr u8 PASS_GLYPHS = 2; + static constexpr u8 PASS_UNDERLINE = 3; + static constexpr u8 PASS_STRIKETHROUGH = 4; + static constexpr u8 NUM_PASSES = 5; for (u8 pass = 0; pass < NUM_PASSES; pass++) { diff --git a/ashura/engine/color.h b/ashura/engine/color.h index c026ff59..71392a93 100644 --- a/ashura/engine/color.h +++ b/ashura/engine/color.h @@ -8,97 +8,97 @@ namespace ash namespace colors { -constexpr Vec4U8 WHITE = Vec4U8{0xFF, 0xFF, 0xFF, 0xFF}; -constexpr Vec4U8 BLACK = Vec4U8{0x00, 0x00, 0x00, 0xFF}; -constexpr Vec4U8 RED = Vec4U8{0xFF, 0x00, 0x00, 0xFF}; -constexpr Vec4U8 BLUE = Vec4U8{0x00, 0x00, 0xFF, 0xFF}; -constexpr Vec4U8 GREEN = Vec4U8{0x00, 0xFF, 0x00, 0xFF}; -constexpr Vec4U8 CYAN = Vec4U8{0x00, 0xFF, 0xFF, 0xFF}; -constexpr Vec4U8 MAGENTA = Vec4U8{0xFF, 0x00, 0xFF, 0xFF}; -constexpr Vec4U8 YELLOW = Vec4U8{0xFF, 0xFF, 0x00, 0xFF}; +inline constexpr Vec4U8 WHITE = Vec4U8{0xFF, 0xFF, 0xFF, 0xFF}; +inline constexpr Vec4U8 BLACK = Vec4U8{0x00, 0x00, 0x00, 0xFF}; +inline constexpr Vec4U8 RED = Vec4U8{0xFF, 0x00, 0x00, 0xFF}; +inline constexpr Vec4U8 BLUE = Vec4U8{0x00, 0x00, 0xFF, 0xFF}; +inline constexpr Vec4U8 GREEN = Vec4U8{0x00, 0xFF, 0x00, 0xFF}; +inline constexpr Vec4U8 CYAN = Vec4U8{0x00, 0xFF, 0xFF, 0xFF}; +inline constexpr Vec4U8 MAGENTA = Vec4U8{0xFF, 0x00, 0xFF, 0xFF}; +inline constexpr Vec4U8 YELLOW = Vec4U8{0xFF, 0xFF, 0x00, 0xFF}; } // namespace colors // ios default system colors namespace ios { -constexpr Vec4U8 LIGHT_BLUE = Vec4U8{0, 122, 0xFF, 0xFF}; -constexpr Vec4U8 DARK_BLUE = Vec4U8{10, 132, 0xFF, 0xFF}; -constexpr Vec4U8 LIGHT_BROWN = Vec4U8{162, 132, 94, 0xFF}; -constexpr Vec4U8 DARK_BROWN = Vec4U8{172, 142, 104, 0xFF}; -constexpr Vec4U8 LIGHT_CYAN = Vec4U8{50, 173, 230, 0xFF}; -constexpr Vec4U8 DARK_CYAN = Vec4U8{100, 210, 0xFF, 0xFF}; -constexpr Vec4U8 LIGHT_GREEN = Vec4U8{52, 199, 89, 0xFF}; -constexpr Vec4U8 DARK_GREEN = Vec4U8{48, 209, 88, 0xFF}; -constexpr Vec4U8 LIGHT_INDIGO = Vec4U8{88, 86, 214, 0xFF}; -constexpr Vec4U8 DARK_INDIGO = Vec4U8{94, 92, 230, 0xFF}; -constexpr Vec4U8 LIGHT_MINT = Vec4U8{0, 199, 190, 0xFF}; -constexpr Vec4U8 DARK_MINT = Vec4U8{102, 212, 207, 0xFF}; -constexpr Vec4U8 LIGHT_ORANGE = Vec4U8{255, 149, 0, 0xFF}; -constexpr Vec4U8 DARK_ORANGE = Vec4U8{255, 159, 10, 0xFF}; -constexpr Vec4U8 LIGHT_PINK = Vec4U8{255, 45, 85, 0xFF}; -constexpr Vec4U8 DARK_PINK = Vec4U8{255, 55, 95, 0xFF}; -constexpr Vec4U8 LIGHT_PURPLE = Vec4U8{175, 82, 222, 0xFF}; -constexpr Vec4U8 DARK_PURPLE = Vec4U8{191, 90, 242, 0xFF}; -constexpr Vec4U8 LIGHT_RED = Vec4U8{255, 59, 48, 0xFF}; -constexpr Vec4U8 DARK_RED = Vec4U8{255, 69, 58, 0xFF}; -constexpr Vec4U8 LIGHT_TEAL = Vec4U8{48, 176, 199, 0xFF}; -constexpr Vec4U8 DARK_TEAL = Vec4U8{64, 200, 224, 0xFF}; -constexpr Vec4U8 LIGHT_YELLOW = Vec4U8{255, 204, 0, 0xFF}; -constexpr Vec4U8 DARK_YELLOW = Vec4U8{255, 214, 10, 0xFF}; - -constexpr Vec4U8 LIGHT_GRAY = Vec4U8{142, 142, 147, 0xFF}; -constexpr Vec4U8 DARK_GRAY = Vec4U8{142, 142, 147, 0xFF}; -constexpr Vec4U8 LIGHT_GRAY_2 = Vec4U8{174, 174, 178, 0xFF}; -constexpr Vec4U8 DARK_GRAY_2 = Vec4U8{99, 99, 102, 0xFF}; -constexpr Vec4U8 LIGHT_GRAY_3 = Vec4U8{199, 199, 204, 0xFF}; -constexpr Vec4U8 DARK_GRAY_3 = Vec4U8{72, 72, 74, 0xFF}; -constexpr Vec4U8 LIGHT_GRAY_4 = Vec4U8{209, 209, 214, 0xFF}; -constexpr Vec4U8 DARK_GRAY_4 = Vec4U8{58, 58, 60, 0xFF}; -constexpr Vec4U8 LIGHT_GRAY_5 = Vec4U8{229, 229, 234, 0xFF}; -constexpr Vec4U8 DARK_GRAY_5 = Vec4U8{44, 44, 46, 0xFF}; -constexpr Vec4U8 LIGHT_GRAY_6 = Vec4U8{242, 242, 247, 0xFF}; -constexpr Vec4U8 DARK_GRAY_6 = Vec4U8{28, 28, 30, 0xFF}; +inline constexpr Vec4U8 LIGHT_BLUE = Vec4U8{0, 122, 0xFF, 0xFF}; +inline constexpr Vec4U8 DARK_BLUE = Vec4U8{10, 132, 0xFF, 0xFF}; +inline constexpr Vec4U8 LIGHT_BROWN = Vec4U8{162, 132, 94, 0xFF}; +inline constexpr Vec4U8 DARK_BROWN = Vec4U8{172, 142, 104, 0xFF}; +inline constexpr Vec4U8 LIGHT_CYAN = Vec4U8{50, 173, 230, 0xFF}; +inline constexpr Vec4U8 DARK_CYAN = Vec4U8{100, 210, 0xFF, 0xFF}; +inline constexpr Vec4U8 LIGHT_GREEN = Vec4U8{52, 199, 89, 0xFF}; +inline constexpr Vec4U8 DARK_GREEN = Vec4U8{48, 209, 88, 0xFF}; +inline constexpr Vec4U8 LIGHT_INDIGO = Vec4U8{88, 86, 214, 0xFF}; +inline constexpr Vec4U8 DARK_INDIGO = Vec4U8{94, 92, 230, 0xFF}; +inline constexpr Vec4U8 LIGHT_MINT = Vec4U8{0, 199, 190, 0xFF}; +inline constexpr Vec4U8 DARK_MINT = Vec4U8{102, 212, 207, 0xFF}; +inline constexpr Vec4U8 LIGHT_ORANGE = Vec4U8{255, 149, 0, 0xFF}; +inline constexpr Vec4U8 DARK_ORANGE = Vec4U8{255, 159, 10, 0xFF}; +inline constexpr Vec4U8 LIGHT_PINK = Vec4U8{255, 45, 85, 0xFF}; +inline constexpr Vec4U8 DARK_PINK = Vec4U8{255, 55, 95, 0xFF}; +inline constexpr Vec4U8 LIGHT_PURPLE = Vec4U8{175, 82, 222, 0xFF}; +inline constexpr Vec4U8 DARK_PURPLE = Vec4U8{191, 90, 242, 0xFF}; +inline constexpr Vec4U8 LIGHT_RED = Vec4U8{255, 59, 48, 0xFF}; +inline constexpr Vec4U8 DARK_RED = Vec4U8{255, 69, 58, 0xFF}; +inline constexpr Vec4U8 LIGHT_TEAL = Vec4U8{48, 176, 199, 0xFF}; +inline constexpr Vec4U8 DARK_TEAL = Vec4U8{64, 200, 224, 0xFF}; +inline constexpr Vec4U8 LIGHT_YELLOW = Vec4U8{255, 204, 0, 0xFF}; +inline constexpr Vec4U8 DARK_YELLOW = Vec4U8{255, 214, 10, 0xFF}; + +inline constexpr Vec4U8 LIGHT_GRAY = Vec4U8{142, 142, 147, 0xFF}; +inline constexpr Vec4U8 DARK_GRAY = Vec4U8{142, 142, 147, 0xFF}; +inline constexpr Vec4U8 LIGHT_GRAY_2 = Vec4U8{174, 174, 178, 0xFF}; +inline constexpr Vec4U8 DARK_GRAY_2 = Vec4U8{99, 99, 102, 0xFF}; +inline constexpr Vec4U8 LIGHT_GRAY_3 = Vec4U8{199, 199, 204, 0xFF}; +inline constexpr Vec4U8 DARK_GRAY_3 = Vec4U8{72, 72, 74, 0xFF}; +inline constexpr Vec4U8 LIGHT_GRAY_4 = Vec4U8{209, 209, 214, 0xFF}; +inline constexpr Vec4U8 DARK_GRAY_4 = Vec4U8{58, 58, 60, 0xFF}; +inline constexpr Vec4U8 LIGHT_GRAY_5 = Vec4U8{229, 229, 234, 0xFF}; +inline constexpr Vec4U8 DARK_GRAY_5 = Vec4U8{44, 44, 46, 0xFF}; +inline constexpr Vec4U8 LIGHT_GRAY_6 = Vec4U8{242, 242, 247, 0xFF}; +inline constexpr Vec4U8 DARK_GRAY_6 = Vec4U8{28, 28, 30, 0xFF}; // ios accessible colors namespace accessible { -constexpr Vec4U8 LIGHT_BLUE = Vec4U8{0, 64, 221, 0xFF}; -constexpr Vec4U8 DARK_BLUE = Vec4U8{64, 156, 0xFF, 0xFF}; -constexpr Vec4U8 LIGHT_BROWN = Vec4U8{127, 101, 69, 0xFF}; -constexpr Vec4U8 DARK_BROWN = Vec4U8{181, 148, 105, 0xFF}; -constexpr Vec4U8 LIGHT_CYAN = Vec4U8{0, 113, 164, 0xFF}; -constexpr Vec4U8 DARK_CYAN = Vec4U8{112, 215, 0xFF, 0xFF}; -constexpr Vec4U8 LIGHT_GREEN = Vec4U8{36, 138, 61, 0xFF}; -constexpr Vec4U8 DARK_GREEN = Vec4U8{48, 219, 91, 0xFF}; -constexpr Vec4U8 LIGHT_INDIGO = Vec4U8{54, 52, 163, 0xFF}; -constexpr Vec4U8 DARK_INDIGO = Vec4U8{125, 122, 0xFF, 0xFF}; -constexpr Vec4U8 LIGHT_MINT = Vec4U8{12, 129, 123, 0xFF}; -constexpr Vec4U8 DARK_MINT = Vec4U8{102, 212, 207, 0xFF}; -constexpr Vec4U8 LIGHT_ORANGE = Vec4U8{201, 52, 0, 0xFF}; -constexpr Vec4U8 DARK_ORANGE = Vec4U8{255, 179, 64, 0xFF}; -constexpr Vec4U8 LIGHT_PINK = Vec4U8{211, 15, 69, 0xFF}; -constexpr Vec4U8 DARK_PINK = Vec4U8{255, 100, 130, 0xFF}; -constexpr Vec4U8 LIGHT_PURPLE = Vec4U8{137, 68, 171, 0xFF}; -constexpr Vec4U8 DARK_PURPLE = Vec4U8{218, 143, 0xFF, 0xFF}; -constexpr Vec4U8 LIGHT_RED = Vec4U8{215, 0, 21, 0xFF}; -constexpr Vec4U8 DARK_RED = Vec4U8{255, 105, 97, 0xFF}; -constexpr Vec4U8 LIGHT_TEAL = Vec4U8{0, 130, 153, 0xFF}; -constexpr Vec4U8 DARK_TEAL = Vec4U8{93, 230, 0xFF, 0xFF}; -constexpr Vec4U8 LIGHT_YELLOW = Vec4U8{178, 80, 0, 0xFF}; -constexpr Vec4U8 DARK_YELLOW = Vec4U8{255, 212, 38, 0xFF}; - -constexpr Vec4U8 LIGHT_GRAY = Vec4U8{108, 108, 112, 0xFF}; -constexpr Vec4U8 DARK_GRAY = Vec4U8{174, 174, 178, 0xFF}; -constexpr Vec4U8 LIGHT_GRAY_2 = Vec4U8{142, 142, 147, 0xFF}; -constexpr Vec4U8 DARK_GRAY_2 = Vec4U8{124, 124, 128, 0xFF}; -constexpr Vec4U8 LIGHT_GRAY_3 = Vec4U8{174, 174, 178, 0xFF}; -constexpr Vec4U8 DARK_GRAY_3 = Vec4U8{84, 84, 86, 0xFF}; -constexpr Vec4U8 LIGHT_GRAY_4 = Vec4U8{188, 188, 192, 0xFF}; -constexpr Vec4U8 DARK_GRAY_4 = Vec4U8{68, 68, 70, 0xFF}; -constexpr Vec4U8 LIGHT_GRAY_5 = Vec4U8{216, 216, 220, 0xFF}; -constexpr Vec4U8 DARK_GRAY_5 = Vec4U8{54, 54, 56, 0xFF}; -constexpr Vec4U8 LIGHT_GRAY_6 = Vec4U8{235, 235, 240, 0xFF}; -constexpr Vec4U8 DARK_GRAY_6 = Vec4U8{36, 36, 36, 0xFF}; +inline constexpr Vec4U8 LIGHT_BLUE = Vec4U8{0, 64, 221, 0xFF}; +inline constexpr Vec4U8 DARK_BLUE = Vec4U8{64, 156, 0xFF, 0xFF}; +inline constexpr Vec4U8 LIGHT_BROWN = Vec4U8{127, 101, 69, 0xFF}; +inline constexpr Vec4U8 DARK_BROWN = Vec4U8{181, 148, 105, 0xFF}; +inline constexpr Vec4U8 LIGHT_CYAN = Vec4U8{0, 113, 164, 0xFF}; +inline constexpr Vec4U8 DARK_CYAN = Vec4U8{112, 215, 0xFF, 0xFF}; +inline constexpr Vec4U8 LIGHT_GREEN = Vec4U8{36, 138, 61, 0xFF}; +inline constexpr Vec4U8 DARK_GREEN = Vec4U8{48, 219, 91, 0xFF}; +inline constexpr Vec4U8 LIGHT_INDIGO = Vec4U8{54, 52, 163, 0xFF}; +inline constexpr Vec4U8 DARK_INDIGO = Vec4U8{125, 122, 0xFF, 0xFF}; +inline constexpr Vec4U8 LIGHT_MINT = Vec4U8{12, 129, 123, 0xFF}; +inline constexpr Vec4U8 DARK_MINT = Vec4U8{102, 212, 207, 0xFF}; +inline constexpr Vec4U8 LIGHT_ORANGE = Vec4U8{201, 52, 0, 0xFF}; +inline constexpr Vec4U8 DARK_ORANGE = Vec4U8{255, 179, 64, 0xFF}; +inline constexpr Vec4U8 LIGHT_PINK = Vec4U8{211, 15, 69, 0xFF}; +inline constexpr Vec4U8 DARK_PINK = Vec4U8{255, 100, 130, 0xFF}; +inline constexpr Vec4U8 LIGHT_PURPLE = Vec4U8{137, 68, 171, 0xFF}; +inline constexpr Vec4U8 DARK_PURPLE = Vec4U8{218, 143, 0xFF, 0xFF}; +inline constexpr Vec4U8 LIGHT_RED = Vec4U8{215, 0, 21, 0xFF}; +inline constexpr Vec4U8 DARK_RED = Vec4U8{255, 105, 97, 0xFF}; +inline constexpr Vec4U8 LIGHT_TEAL = Vec4U8{0, 130, 153, 0xFF}; +inline constexpr Vec4U8 DARK_TEAL = Vec4U8{93, 230, 0xFF, 0xFF}; +inline constexpr Vec4U8 LIGHT_YELLOW = Vec4U8{178, 80, 0, 0xFF}; +inline constexpr Vec4U8 DARK_YELLOW = Vec4U8{255, 212, 38, 0xFF}; + +inline constexpr Vec4U8 LIGHT_GRAY = Vec4U8{108, 108, 112, 0xFF}; +inline constexpr Vec4U8 DARK_GRAY = Vec4U8{174, 174, 178, 0xFF}; +inline constexpr Vec4U8 LIGHT_GRAY_2 = Vec4U8{142, 142, 147, 0xFF}; +inline constexpr Vec4U8 DARK_GRAY_2 = Vec4U8{124, 124, 128, 0xFF}; +inline constexpr Vec4U8 LIGHT_GRAY_3 = Vec4U8{174, 174, 178, 0xFF}; +inline constexpr Vec4U8 DARK_GRAY_3 = Vec4U8{84, 84, 86, 0xFF}; +inline constexpr Vec4U8 LIGHT_GRAY_4 = Vec4U8{188, 188, 192, 0xFF}; +inline constexpr Vec4U8 DARK_GRAY_4 = Vec4U8{68, 68, 70, 0xFF}; +inline constexpr Vec4U8 LIGHT_GRAY_5 = Vec4U8{216, 216, 220, 0xFF}; +inline constexpr Vec4U8 DARK_GRAY_5 = Vec4U8{54, 54, 56, 0xFF}; +inline constexpr Vec4U8 LIGHT_GRAY_6 = Vec4U8{235, 235, 240, 0xFF}; +inline constexpr Vec4U8 DARK_GRAY_6 = Vec4U8{36, 36, 36, 0xFF}; } // namespace accessible } // namespace ios @@ -106,281 +106,281 @@ constexpr Vec4U8 DARK_GRAY_6 = Vec4U8{36, 36, 36, 0xFF}; /// @brief Material Design Colors namespace mdc { -constexpr Vec4U8 RED_50 = Vec4U8{0xFF, 0xEB, 0xEE, 0xFF}; -constexpr Vec4U8 RED_100 = Vec4U8{0xFF, 0xCD, 0xD2, 0xFF}; -constexpr Vec4U8 RED_200 = Vec4U8{0xEF, 0x9A, 0x9A, 0xFF}; -constexpr Vec4U8 RED_300 = Vec4U8{0xE5, 0x73, 0x73, 0xFF}; -constexpr Vec4U8 RED_400 = Vec4U8{0xEF, 0x53, 0x50, 0xFF}; -constexpr Vec4U8 RED_500 = Vec4U8{0xF4, 0x43, 0x36, 0xFF}; -constexpr Vec4U8 RED_600 = Vec4U8{0xE5, 0x39, 0x35, 0xFF}; -constexpr Vec4U8 RED_700 = Vec4U8{0xD3, 0x2F, 0x2F, 0xFF}; -constexpr Vec4U8 RED_800 = Vec4U8{0xC6, 0x28, 0x28, 0xFF}; -constexpr Vec4U8 RED_900 = Vec4U8{0xB7, 0x1C, 0x1C, 0xFF}; -constexpr Vec4U8 RED_A100 = Vec4U8{0xFF, 0x8A, 0x80, 0xFF}; -constexpr Vec4U8 RED_A200 = Vec4U8{0xFF, 0x52, 0x52, 0xFF}; -constexpr Vec4U8 RED_A400 = Vec4U8{0xFF, 0x17, 0x44, 0xFF}; -constexpr Vec4U8 RED_A700 = Vec4U8{0xD5, 0x00, 0x00, 0xFF}; - -constexpr Vec4U8 PINK_50 = Vec4U8{0xFC, 0xE4, 0xEC, 0xFF}; -constexpr Vec4U8 PINK_100 = Vec4U8{0xF8, 0xBB, 0xD0, 0xFF}; -constexpr Vec4U8 PINK_200 = Vec4U8{0xF4, 0x8F, 0xB1, 0xFF}; -constexpr Vec4U8 PINK_300 = Vec4U8{0xF0, 0x62, 0x92, 0xFF}; -constexpr Vec4U8 PINK_400 = Vec4U8{0xEC, 0x40, 0x7A, 0xFF}; -constexpr Vec4U8 PINK_500 = Vec4U8{0xE9, 0x1E, 0x63, 0xFF}; -constexpr Vec4U8 PINK_600 = Vec4U8{0xD8, 0x1B, 0x60, 0xFF}; -constexpr Vec4U8 PINK_700 = Vec4U8{0xC2, 0x18, 0x5B, 0xFF}; -constexpr Vec4U8 PINK_800 = Vec4U8{0xAD, 0x14, 0x57, 0xFF}; -constexpr Vec4U8 PINK_900 = Vec4U8{0x88, 0x0E, 0x4F, 0xFF}; -constexpr Vec4U8 PINK_A100 = Vec4U8{0xFF, 0x80, 0xAB, 0xFF}; -constexpr Vec4U8 PINK_A200 = Vec4U8{0xFF, 0x40, 0x81, 0xFF}; -constexpr Vec4U8 PINK_A400 = Vec4U8{0xF5, 0x00, 0x57, 0xFF}; -constexpr Vec4U8 PINK_A700 = Vec4U8{0xC5, 0x11, 0x62, 0xFF}; - -constexpr Vec4U8 PURPLE_50 = Vec4U8{0xF3, 0xE5, 0xF5, 0xFF}; -constexpr Vec4U8 PURPLE_100 = Vec4U8{0xE1, 0xBE, 0xE7, 0xFF}; -constexpr Vec4U8 PURPLE_200 = Vec4U8{0xCE, 0x93, 0xD8, 0xFF}; -constexpr Vec4U8 PURPLE_300 = Vec4U8{0xBA, 0x68, 0xC8, 0xFF}; -constexpr Vec4U8 PURPLE_400 = Vec4U8{0xAB, 0x47, 0xBC, 0xFF}; -constexpr Vec4U8 PURPLE_500 = Vec4U8{0x9C, 0x27, 0xB0, 0xFF}; -constexpr Vec4U8 PURPLE_600 = Vec4U8{0x8E, 0x24, 0xAA, 0xFF}; -constexpr Vec4U8 PURPLE_700 = Vec4U8{0x7B, 0x1F, 0xA2, 0xFF}; -constexpr Vec4U8 PURPLE_800 = Vec4U8{0x6A, 0x1B, 0x9A, 0xFF}; -constexpr Vec4U8 PURPLE_900 = Vec4U8{0x4A, 0x14, 0x8C, 0xFF}; -constexpr Vec4U8 PURPLE_A100 = Vec4U8{0xEA, 0x80, 0xFC, 0xFF}; -constexpr Vec4U8 PURPLE_A200 = Vec4U8{0xE0, 0x40, 0xFB, 0xFF}; -constexpr Vec4U8 PURPLE_A400 = Vec4U8{0xD5, 0x00, 0xF9, 0xFF}; -constexpr Vec4U8 PURPLE_A700 = Vec4U8{0xAA, 0x00, 0xFF, 0xFF}; - -constexpr Vec4U8 DEEP_PURPLE_50 = Vec4U8{0xED, 0xE7, 0xF6, 0xFF}; -constexpr Vec4U8 DEEP_PURPLE_100 = Vec4U8{0xD1, 0xC4, 0xE9, 0xFF}; -constexpr Vec4U8 DEEP_PURPLE_200 = Vec4U8{0xB3, 0x9D, 0xDB, 0xFF}; -constexpr Vec4U8 DEEP_PURPLE_300 = Vec4U8{0x95, 0x75, 0xCD, 0xFF}; -constexpr Vec4U8 DEEP_PURPLE_400 = Vec4U8{0x7E, 0x57, 0xC2, 0xFF}; -constexpr Vec4U8 DEEP_PURPLE_500 = Vec4U8{0x67, 0x3A, 0xB7, 0xFF}; -constexpr Vec4U8 DEEP_PURPLE_600 = Vec4U8{0x5E, 0x35, 0xB1, 0xFF}; -constexpr Vec4U8 DEEP_PURPLE_700 = Vec4U8{0x51, 0x2D, 0xA8, 0xFF}; -constexpr Vec4U8 DEEP_PURPLE_800 = Vec4U8{0x45, 0x27, 0xA0, 0xFF}; -constexpr Vec4U8 DEEP_PURPLE_900 = Vec4U8{0x31, 0x1B, 0x92, 0xFF}; -constexpr Vec4U8 DEEP_PURPLE_A100 = Vec4U8{0xB3, 0x88, 0xFF, 0xFF}; -constexpr Vec4U8 DEEP_PURPLE_A200 = Vec4U8{0x7C, 0x4D, 0xFF, 0xFF}; -constexpr Vec4U8 DEEP_PURPLE_A400 = Vec4U8{0x65, 0x1F, 0xFF, 0xFF}; -constexpr Vec4U8 DEEP_PURPLE_A700 = Vec4U8{0x62, 0x00, 0xEA, 0xFF}; - -constexpr Vec4U8 INDIGO_50 = Vec4U8{0xE8, 0xEA, 0xF6, 0xFF}; -constexpr Vec4U8 INDIGO_100 = Vec4U8{0xC5, 0xCA, 0xE9, 0xFF}; -constexpr Vec4U8 INDIGO_200 = Vec4U8{0x9F, 0xA8, 0xDA, 0xFF}; -constexpr Vec4U8 INDIGO_300 = Vec4U8{0x79, 0x86, 0xCB, 0xFF}; -constexpr Vec4U8 INDIGO_400 = Vec4U8{0x5C, 0x6B, 0xC0, 0xFF}; -constexpr Vec4U8 INDIGO_500 = Vec4U8{0x3F, 0x51, 0xB5, 0xFF}; -constexpr Vec4U8 INDIGO_600 = Vec4U8{0x39, 0x49, 0xAB, 0xFF}; -constexpr Vec4U8 INDIGO_700 = Vec4U8{0x30, 0x3F, 0x9F, 0xFF}; -constexpr Vec4U8 INDIGO_800 = Vec4U8{0x28, 0x35, 0x93, 0xFF}; -constexpr Vec4U8 INDIGO_900 = Vec4U8{0x1A, 0x23, 0x7E, 0xFF}; -constexpr Vec4U8 INDIGO_A100 = Vec4U8{0x8C, 0x9E, 0xFF, 0xFF}; -constexpr Vec4U8 INDIGO_A200 = Vec4U8{0x53, 0x6D, 0xFE, 0xFF}; -constexpr Vec4U8 INDIGO_A400 = Vec4U8{0x3D, 0x5A, 0xFE, 0xFF}; -constexpr Vec4U8 INDIGO_A700 = Vec4U8{0x30, 0x4F, 0xFE, 0xFF}; - -constexpr Vec4U8 BLUE_50 = Vec4U8{0xE3, 0xF2, 0xFD, 0xFF}; -constexpr Vec4U8 BLUE_100 = Vec4U8{0xBB, 0xDE, 0xFB, 0xFF}; -constexpr Vec4U8 BLUE_200 = Vec4U8{0x90, 0xCA, 0xF9, 0xFF}; -constexpr Vec4U8 BLUE_300 = Vec4U8{0x64, 0xB5, 0xF6, 0xFF}; -constexpr Vec4U8 BLUE_400 = Vec4U8{0x42, 0xA5, 0xF5, 0xFF}; -constexpr Vec4U8 BLUE_500 = Vec4U8{0x21, 0x96, 0xF3, 0xFF}; -constexpr Vec4U8 BLUE_600 = Vec4U8{0x1E, 0x88, 0xE5, 0xFF}; -constexpr Vec4U8 BLUE_700 = Vec4U8{0x19, 0x76, 0xD2, 0xFF}; -constexpr Vec4U8 BLUE_800 = Vec4U8{0x15, 0x65, 0xC0, 0xFF}; -constexpr Vec4U8 BLUE_900 = Vec4U8{0x0D, 0x47, 0xA1, 0xFF}; -constexpr Vec4U8 BLUE_A100 = Vec4U8{0x82, 0xB1, 0xFF, 0xFF}; -constexpr Vec4U8 BLUE_A200 = Vec4U8{0x44, 0x8A, 0xFF, 0xFF}; -constexpr Vec4U8 BLUE_A400 = Vec4U8{0x29, 0x79, 0xFF, 0xFF}; -constexpr Vec4U8 BLUE_A700 = Vec4U8{0x29, 0x62, 0xFF, 0xFF}; - -constexpr Vec4U8 LIGHT_BLUE_50 = Vec4U8{0xE1, 0xF5, 0xFE, 0xFF}; -constexpr Vec4U8 LIGHT_BLUE_100 = Vec4U8{0xB3, 0xE5, 0xFC, 0xFF}; -constexpr Vec4U8 LIGHT_BLUE_200 = Vec4U8{0x81, 0xD4, 0xFA, 0xFF}; -constexpr Vec4U8 LIGHT_BLUE_300 = Vec4U8{0x4F, 0xC3, 0xF7, 0xFF}; -constexpr Vec4U8 LIGHT_BLUE_400 = Vec4U8{0x29, 0xB6, 0xF6, 0xFF}; -constexpr Vec4U8 LIGHT_BLUE_500 = Vec4U8{0x03, 0xA9, 0xF4, 0xFF}; -constexpr Vec4U8 LIGHT_BLUE_600 = Vec4U8{0x03, 0x9B, 0xE5, 0xFF}; -constexpr Vec4U8 LIGHT_BLUE_700 = Vec4U8{0x02, 0x88, 0xD1, 0xFF}; -constexpr Vec4U8 LIGHT_BLUE_800 = Vec4U8{0x02, 0x77, 0xBD, 0xFF}; -constexpr Vec4U8 LIGHT_BLUE_900 = Vec4U8{0x01, 0x57, 0x9B, 0xFF}; -constexpr Vec4U8 LIGHT_BLUE_A100 = Vec4U8{0x80, 0xD8, 0xFF, 0xFF}; -constexpr Vec4U8 LIGHT_BLUE_A200 = Vec4U8{0x40, 0xC4, 0xFF, 0xFF}; -constexpr Vec4U8 LIGHT_BLUE_A400 = Vec4U8{0x00, 0xB0, 0xFF, 0xFF}; -constexpr Vec4U8 LIGHT_BLUE_A700 = Vec4U8{0x00, 0x91, 0xEA, 0xFF}; - -constexpr Vec4U8 CYAN_50 = Vec4U8{0xE0, 0xF7, 0xFA, 0xFF}; -constexpr Vec4U8 CYAN_100 = Vec4U8{0xB2, 0xEB, 0xF2, 0xFF}; -constexpr Vec4U8 CYAN_200 = Vec4U8{0x80, 0xDE, 0xEA, 0xFF}; -constexpr Vec4U8 CYAN_300 = Vec4U8{0x4D, 0xD0, 0xE1, 0xFF}; -constexpr Vec4U8 CYAN_400 = Vec4U8{0x26, 0xC6, 0xDA, 0xFF}; -constexpr Vec4U8 CYAN_500 = Vec4U8{0x00, 0xBC, 0xD4, 0xFF}; -constexpr Vec4U8 CYAN_600 = Vec4U8{0x00, 0xAC, 0xC1, 0xFF}; -constexpr Vec4U8 CYAN_700 = Vec4U8{0x00, 0x97, 0xA7, 0xFF}; -constexpr Vec4U8 CYAN_800 = Vec4U8{0x00, 0x83, 0x8F, 0xFF}; -constexpr Vec4U8 CYAN_900 = Vec4U8{0x00, 0x60, 0x64, 0xFF}; -constexpr Vec4U8 CYAN_A100 = Vec4U8{0x84, 0xFF, 0xFF, 0xFF}; -constexpr Vec4U8 CYAN_A200 = Vec4U8{0x18, 0xFF, 0xFF, 0xFF}; -constexpr Vec4U8 CYAN_A400 = Vec4U8{0x00, 0xE5, 0xFF, 0xFF}; -constexpr Vec4U8 CYAN_A700 = Vec4U8{0x00, 0xB8, 0xD4, 0xFF}; - -constexpr Vec4U8 TEAL_50 = Vec4U8{0xE0, 0xF2, 0xF1, 0xFF}; -constexpr Vec4U8 TEAL_100 = Vec4U8{0xB2, 0xDF, 0xDB, 0xFF}; -constexpr Vec4U8 TEAL_200 = Vec4U8{0x80, 0xCB, 0xC4, 0xFF}; -constexpr Vec4U8 TEAL_300 = Vec4U8{0x4D, 0xB6, 0xAC, 0xFF}; -constexpr Vec4U8 TEAL_400 = Vec4U8{0x26, 0xA6, 0x9A, 0xFF}; -constexpr Vec4U8 TEAL_500 = Vec4U8{0x00, 0x96, 0x88, 0xFF}; -constexpr Vec4U8 TEAL_600 = Vec4U8{0x00, 0x89, 0x7B, 0xFF}; -constexpr Vec4U8 TEAL_700 = Vec4U8{0x00, 0x79, 0x6B, 0xFF}; -constexpr Vec4U8 TEAL_800 = Vec4U8{0x00, 0x69, 0x5C, 0xFF}; -constexpr Vec4U8 TEAL_900 = Vec4U8{0x00, 0x4D, 0x40, 0xFF}; -constexpr Vec4U8 TEAL_A100 = Vec4U8{0xA7, 0xFF, 0xEB, 0xFF}; -constexpr Vec4U8 TEAL_A200 = Vec4U8{0x64, 0xFF, 0xDA, 0xFF}; -constexpr Vec4U8 TEAL_A400 = Vec4U8{0x1D, 0xE9, 0xB6, 0xFF}; -constexpr Vec4U8 TEAL_A700 = Vec4U8{0x00, 0xBF, 0xA5, 0xFF}; - -constexpr Vec4U8 GREEN_50 = Vec4U8{0xE8, 0xF5, 0xE9, 0xFF}; -constexpr Vec4U8 GREEN_100 = Vec4U8{0xC8, 0xE6, 0xC9, 0xFF}; -constexpr Vec4U8 GREEN_200 = Vec4U8{0xA5, 0xD6, 0xA7, 0xFF}; -constexpr Vec4U8 GREEN_300 = Vec4U8{0x81, 0xC7, 0x84, 0xFF}; -constexpr Vec4U8 GREEN_400 = Vec4U8{0x66, 0xBB, 0x6A, 0xFF}; -constexpr Vec4U8 GREEN_500 = Vec4U8{0x4C, 0xAF, 0x50, 0xFF}; -constexpr Vec4U8 GREEN_600 = Vec4U8{0x43, 0xA0, 0x47, 0xFF}; -constexpr Vec4U8 GREEN_700 = Vec4U8{0x38, 0x8E, 0x3C, 0xFF}; -constexpr Vec4U8 GREEN_800 = Vec4U8{0x2E, 0x7D, 0x32, 0xFF}; -constexpr Vec4U8 GREEN_900 = Vec4U8{0x1B, 0x5E, 0x20, 0xFF}; -constexpr Vec4U8 GREEN_A100 = Vec4U8{0xB9, 0xF6, 0xCA, 0xFF}; -constexpr Vec4U8 GREEN_A200 = Vec4U8{0x69, 0xF0, 0xAE, 0xFF}; -constexpr Vec4U8 GREEN_A400 = Vec4U8{0x00, 0xE6, 0x76, 0xFF}; -constexpr Vec4U8 GREEN_A700 = Vec4U8{0x00, 0xC8, 0x53, 0xFF}; - -constexpr Vec4U8 LIGHT_GREEN_50 = Vec4U8{0xF1, 0xF8, 0xE9, 0xFF}; -constexpr Vec4U8 LIGHT_GREEN_100 = Vec4U8{0xDC, 0xED, 0xC8, 0xFF}; -constexpr Vec4U8 LIGHT_GREEN_200 = Vec4U8{0xC5, 0xE1, 0xA5, 0xFF}; -constexpr Vec4U8 LIGHT_GREEN_300 = Vec4U8{0xAE, 0xD5, 0x81, 0xFF}; -constexpr Vec4U8 LIGHT_GREEN_400 = Vec4U8{0x9C, 0xCC, 0x65, 0xFF}; -constexpr Vec4U8 LIGHT_GREEN_500 = Vec4U8{0x8B, 0xC3, 0x4A, 0xFF}; -constexpr Vec4U8 LIGHT_GREEN_600 = Vec4U8{0x7C, 0xB3, 0x42, 0xFF}; -constexpr Vec4U8 LIGHT_GREEN_700 = Vec4U8{0x68, 0x9F, 0x38, 0xFF}; -constexpr Vec4U8 LIGHT_GREEN_800 = Vec4U8{0x55, 0x8B, 0x2F, 0xFF}; -constexpr Vec4U8 LIGHT_GREEN_900 = Vec4U8{0x33, 0x69, 0x1E, 0xFF}; -constexpr Vec4U8 LIGHT_GREEN_A100 = Vec4U8{0xCC, 0xFF, 0x90, 0xFF}; -constexpr Vec4U8 LIGHT_GREEN_A200 = Vec4U8{0xB2, 0xFF, 0x59, 0xFF}; -constexpr Vec4U8 LIGHT_GREEN_A400 = Vec4U8{0x76, 0xFF, 0x03, 0xFF}; -constexpr Vec4U8 LIGHT_GREEN_A700 = Vec4U8{0x64, 0xDD, 0x17, 0xFF}; - -constexpr Vec4U8 LIME_50 = Vec4U8{0xF9, 0xFB, 0xE7, 0xFF}; -constexpr Vec4U8 LIME_100 = Vec4U8{0xF0, 0xF4, 0xC3, 0xFF}; -constexpr Vec4U8 LIME_200 = Vec4U8{0xE6, 0xEE, 0x9C, 0xFF}; -constexpr Vec4U8 LIME_300 = Vec4U8{0xDC, 0xE7, 0x75, 0xFF}; -constexpr Vec4U8 LIME_400 = Vec4U8{0xD4, 0xE1, 0x57, 0xFF}; -constexpr Vec4U8 LIME_500 = Vec4U8{0xCD, 0xDC, 0x39, 0xFF}; -constexpr Vec4U8 LIME_600 = Vec4U8{0xC0, 0xCA, 0x33, 0xFF}; -constexpr Vec4U8 LIME_700 = Vec4U8{0xAF, 0xB4, 0x2B, 0xFF}; -constexpr Vec4U8 LIME_800 = Vec4U8{0x9E, 0x9D, 0x24, 0xFF}; -constexpr Vec4U8 LIME_900 = Vec4U8{0x82, 0x77, 0x17, 0xFF}; -constexpr Vec4U8 LIME_A100 = Vec4U8{0xF4, 0xFF, 0x81, 0xFF}; -constexpr Vec4U8 LIME_A200 = Vec4U8{0xEE, 0xFF, 0x41, 0xFF}; -constexpr Vec4U8 LIME_A400 = Vec4U8{0xC6, 0xFF, 0x00, 0xFF}; -constexpr Vec4U8 LIME_A700 = Vec4U8{0xAE, 0xEA, 0x00, 0xFF}; - -constexpr Vec4U8 YELLOW_50 = Vec4U8{0xFF, 0xFD, 0xE7, 0xFF}; -constexpr Vec4U8 YELLOW_100 = Vec4U8{0xFF, 0xF9, 0xC4, 0xFF}; -constexpr Vec4U8 YELLOW_200 = Vec4U8{0xFF, 0xF5, 0x9D, 0xFF}; -constexpr Vec4U8 YELLOW_300 = Vec4U8{0xFF, 0xF1, 0x76, 0xFF}; -constexpr Vec4U8 YELLOW_400 = Vec4U8{0xFF, 0xEE, 0x58, 0xFF}; -constexpr Vec4U8 YELLOW_500 = Vec4U8{0xFF, 0xEB, 0x3B, 0xFF}; -constexpr Vec4U8 YELLOW_600 = Vec4U8{0xFD, 0xD8, 0x35, 0xFF}; -constexpr Vec4U8 YELLOW_700 = Vec4U8{0xFB, 0xC0, 0x2D, 0xFF}; -constexpr Vec4U8 YELLOW_800 = Vec4U8{0xF9, 0xA8, 0x25, 0xFF}; -constexpr Vec4U8 YELLOW_900 = Vec4U8{0xF5, 0x7F, 0x17, 0xFF}; -constexpr Vec4U8 YELLOW_A100 = Vec4U8{0xFF, 0xFF, 0x8D, 0xFF}; -constexpr Vec4U8 YELLOW_A200 = Vec4U8{0xFF, 0xFF, 0x00, 0xFF}; -constexpr Vec4U8 YELLOW_A400 = Vec4U8{0xFF, 0xEA, 0x00, 0xFF}; -constexpr Vec4U8 YELLOW_A700 = Vec4U8{0xFF, 0xD6, 0x00, 0xFF}; - -constexpr Vec4U8 AMBER_50 = Vec4U8{0xFF, 0xF8, 0xE1, 0xFF}; -constexpr Vec4U8 AMBER_100 = Vec4U8{0xFF, 0xEC, 0xB3, 0xFF}; -constexpr Vec4U8 AMBER_200 = Vec4U8{0xFF, 0xE0, 0x82, 0xFF}; -constexpr Vec4U8 AMBER_300 = Vec4U8{0xFF, 0xD5, 0x4F, 0xFF}; -constexpr Vec4U8 AMBER_400 = Vec4U8{0xFF, 0xCA, 0x28, 0xFF}; -constexpr Vec4U8 AMBER_500 = Vec4U8{0xFF, 0xC1, 0x07, 0xFF}; -constexpr Vec4U8 AMBER_600 = Vec4U8{0xFF, 0xB3, 0x00, 0xFF}; -constexpr Vec4U8 AMBER_700 = Vec4U8{0xFF, 0xA0, 0x00, 0xFF}; -constexpr Vec4U8 AMBER_800 = Vec4U8{0xFF, 0x8F, 0x00, 0xFF}; -constexpr Vec4U8 AMBER_900 = Vec4U8{0xFF, 0x6F, 0x00, 0xFF}; -constexpr Vec4U8 AMBER_A100 = Vec4U8{0xFF, 0xE5, 0x7F, 0xFF}; -constexpr Vec4U8 AMBER_A200 = Vec4U8{0xFF, 0xD7, 0x40, 0xFF}; -constexpr Vec4U8 AMBER_A400 = Vec4U8{0xFF, 0xC4, 0x00, 0xFF}; -constexpr Vec4U8 AMBER_A700 = Vec4U8{0xFF, 0xAB, 0x00, 0xFF}; - -constexpr Vec4U8 ORANGE_50 = Vec4U8{0xFF, 0xF3, 0xE0, 0xFF}; -constexpr Vec4U8 ORANGE_100 = Vec4U8{0xFF, 0xE0, 0xB2, 0xFF}; -constexpr Vec4U8 ORANGE_200 = Vec4U8{0xFF, 0xCC, 0x80, 0xFF}; -constexpr Vec4U8 ORANGE_300 = Vec4U8{0xFF, 0xB7, 0x4D, 0xFF}; -constexpr Vec4U8 ORANGE_400 = Vec4U8{0xFF, 0xA7, 0x26, 0xFF}; -constexpr Vec4U8 ORANGE_500 = Vec4U8{0xFF, 0x98, 0x00, 0xFF}; -constexpr Vec4U8 ORANGE_600 = Vec4U8{0xFB, 0x8C, 0x00, 0xFF}; -constexpr Vec4U8 ORANGE_700 = Vec4U8{0xF5, 0x7C, 0x00, 0xFF}; -constexpr Vec4U8 ORANGE_800 = Vec4U8{0xEF, 0x6C, 0x00, 0xFF}; -constexpr Vec4U8 ORANGE_900 = Vec4U8{0xE6, 0x51, 0x00, 0xFF}; -constexpr Vec4U8 ORANGE_A100 = Vec4U8{0xFF, 0xD1, 0x80, 0xFF}; -constexpr Vec4U8 ORANGE_A200 = Vec4U8{0xFF, 0xAB, 0x40, 0xFF}; -constexpr Vec4U8 ORANGE_A400 = Vec4U8{0xFF, 0x91, 0x00, 0xFF}; -constexpr Vec4U8 ORANGE_A700 = Vec4U8{0xFF, 0x6D, 0x00, 0xFF}; - -constexpr Vec4U8 DEEP_ORANGE_50 = Vec4U8{0xFB, 0xE9, 0xE7, 0xFF}; -constexpr Vec4U8 DEEP_ORANGE_100 = Vec4U8{0xFF, 0xCC, 0xBC, 0xFF}; -constexpr Vec4U8 DEEP_ORANGE_200 = Vec4U8{0xFF, 0xAB, 0x91, 0xFF}; -constexpr Vec4U8 DEEP_ORANGE_300 = Vec4U8{0xFF, 0x8A, 0x65, 0xFF}; -constexpr Vec4U8 DEEP_ORANGE_400 = Vec4U8{0xFF, 0x70, 0x43, 0xFF}; -constexpr Vec4U8 DEEP_ORANGE_500 = Vec4U8{0xFF, 0x57, 0x22, 0xFF}; -constexpr Vec4U8 DEEP_ORANGE_600 = Vec4U8{0xF4, 0x51, 0x1E, 0xFF}; -constexpr Vec4U8 DEEP_ORANGE_700 = Vec4U8{0xE6, 0x4A, 0x19, 0xFF}; -constexpr Vec4U8 DEEP_ORANGE_800 = Vec4U8{0xD8, 0x43, 0x15, 0xFF}; -constexpr Vec4U8 DEEP_ORANGE_900 = Vec4U8{0xBF, 0x36, 0x0C, 0xFF}; -constexpr Vec4U8 DEEP_ORANGE_A100 = Vec4U8{0xFF, 0x9E, 0x80, 0xFF}; -constexpr Vec4U8 DEEP_ORANGE_A200 = Vec4U8{0xFF, 0x6E, 0x40, 0xFF}; -constexpr Vec4U8 DEEP_ORANGE_A400 = Vec4U8{0xFF, 0x3D, 0x00, 0xFF}; -constexpr Vec4U8 DEEP_ORANGE_A700 = Vec4U8{0xDD, 0x2C, 0x00, 0xFF}; - -constexpr Vec4U8 BROWN_50 = Vec4U8{0xEF, 0xEB, 0xE9, 0xFF}; -constexpr Vec4U8 BROWN_100 = Vec4U8{0xD7, 0xCC, 0xC8, 0xFF}; -constexpr Vec4U8 BROWN_200 = Vec4U8{0xBC, 0xAA, 0xA4, 0xFF}; -constexpr Vec4U8 BROWN_300 = Vec4U8{0xA1, 0x88, 0x7F, 0xFF}; -constexpr Vec4U8 BROWN_400 = Vec4U8{0x8D, 0x6E, 0x63, 0xFF}; -constexpr Vec4U8 BROWN_500 = Vec4U8{0x79, 0x55, 0x48, 0xFF}; -constexpr Vec4U8 BROWN_600 = Vec4U8{0x6D, 0x4C, 0x41, 0xFF}; -constexpr Vec4U8 BROWN_700 = Vec4U8{0x5D, 0x40, 0x37, 0xFF}; -constexpr Vec4U8 BROWN_800 = Vec4U8{0x4E, 0x34, 0x2E, 0xFF}; -constexpr Vec4U8 BROWN_900 = Vec4U8{0x3E, 0x27, 0x23, 0xFF}; - -constexpr Vec4U8 GRAY_50 = Vec4U8{0xFA, 0xFA, 0xFA, 0xFF}; -constexpr Vec4U8 GRAY_100 = Vec4U8{0xF5, 0xF5, 0xF5, 0xFF}; -constexpr Vec4U8 GRAY_200 = Vec4U8{0xEE, 0xEE, 0xEE, 0xFF}; -constexpr Vec4U8 GRAY_300 = Vec4U8{0xE0, 0xE0, 0xE0, 0xFF}; -constexpr Vec4U8 GRAY_400 = Vec4U8{0xBD, 0xBD, 0xBD, 0xFF}; -constexpr Vec4U8 GRAY_500 = Vec4U8{0x9E, 0x9E, 0x9E, 0xFF}; -constexpr Vec4U8 GRAY_600 = Vec4U8{0x75, 0x75, 0x75, 0xFF}; -constexpr Vec4U8 GRAY_700 = Vec4U8{0x61, 0x61, 0x61, 0xFF}; -constexpr Vec4U8 GRAY_800 = Vec4U8{0x42, 0x42, 0x42, 0xFF}; -constexpr Vec4U8 GRAY_900 = Vec4U8{0x21, 0x21, 0x21, 0xFF}; - -constexpr Vec4U8 BLUE_GRAY_50 = Vec4U8{0xEC, 0xEF, 0xF1, 0xFF}; -constexpr Vec4U8 BLUE_GRAY_100 = Vec4U8{0xCF, 0xD8, 0xDC, 0xFF}; -constexpr Vec4U8 BLUE_GRAY_200 = Vec4U8{0xB0, 0xBE, 0xC5, 0xFF}; -constexpr Vec4U8 BLUE_GRAY_300 = Vec4U8{0x90, 0xA4, 0xAE, 0xFF}; -constexpr Vec4U8 BLUE_GRAY_400 = Vec4U8{0x78, 0x90, 0x9C, 0xFF}; -constexpr Vec4U8 BLUE_GRAY_500 = Vec4U8{0x60, 0x7D, 0x8B, 0xFF}; -constexpr Vec4U8 BLUE_GRAY_600 = Vec4U8{0x54, 0x6E, 0x7A, 0xFF}; -constexpr Vec4U8 BLUE_GRAY_700 = Vec4U8{0x45, 0x5A, 0x64, 0xFF}; -constexpr Vec4U8 BLUE_GRAY_800 = Vec4U8{0x37, 0x47, 0x4F, 0xFF}; -constexpr Vec4U8 BLUE_GRAY_900 = Vec4U8{0x26, 0x32, 0x38, 0xFF}; - -constexpr Vec4U8 WHITE = Vec4U8{0xFF, 0xFF, 0xFF, 0xFF}; -constexpr Vec4U8 BLACK = Vec4U8{0x00, 0x00, 0x00, 0xFF}; +inline constexpr Vec4U8 RED_50 = Vec4U8{0xFF, 0xEB, 0xEE, 0xFF}; +inline constexpr Vec4U8 RED_100 = Vec4U8{0xFF, 0xCD, 0xD2, 0xFF}; +inline constexpr Vec4U8 RED_200 = Vec4U8{0xEF, 0x9A, 0x9A, 0xFF}; +inline constexpr Vec4U8 RED_300 = Vec4U8{0xE5, 0x73, 0x73, 0xFF}; +inline constexpr Vec4U8 RED_400 = Vec4U8{0xEF, 0x53, 0x50, 0xFF}; +inline constexpr Vec4U8 RED_500 = Vec4U8{0xF4, 0x43, 0x36, 0xFF}; +inline constexpr Vec4U8 RED_600 = Vec4U8{0xE5, 0x39, 0x35, 0xFF}; +inline constexpr Vec4U8 RED_700 = Vec4U8{0xD3, 0x2F, 0x2F, 0xFF}; +inline constexpr Vec4U8 RED_800 = Vec4U8{0xC6, 0x28, 0x28, 0xFF}; +inline constexpr Vec4U8 RED_900 = Vec4U8{0xB7, 0x1C, 0x1C, 0xFF}; +inline constexpr Vec4U8 RED_A100 = Vec4U8{0xFF, 0x8A, 0x80, 0xFF}; +inline constexpr Vec4U8 RED_A200 = Vec4U8{0xFF, 0x52, 0x52, 0xFF}; +inline constexpr Vec4U8 RED_A400 = Vec4U8{0xFF, 0x17, 0x44, 0xFF}; +inline constexpr Vec4U8 RED_A700 = Vec4U8{0xD5, 0x00, 0x00, 0xFF}; + +inline constexpr Vec4U8 PINK_50 = Vec4U8{0xFC, 0xE4, 0xEC, 0xFF}; +inline constexpr Vec4U8 PINK_100 = Vec4U8{0xF8, 0xBB, 0xD0, 0xFF}; +inline constexpr Vec4U8 PINK_200 = Vec4U8{0xF4, 0x8F, 0xB1, 0xFF}; +inline constexpr Vec4U8 PINK_300 = Vec4U8{0xF0, 0x62, 0x92, 0xFF}; +inline constexpr Vec4U8 PINK_400 = Vec4U8{0xEC, 0x40, 0x7A, 0xFF}; +inline constexpr Vec4U8 PINK_500 = Vec4U8{0xE9, 0x1E, 0x63, 0xFF}; +inline constexpr Vec4U8 PINK_600 = Vec4U8{0xD8, 0x1B, 0x60, 0xFF}; +inline constexpr Vec4U8 PINK_700 = Vec4U8{0xC2, 0x18, 0x5B, 0xFF}; +inline constexpr Vec4U8 PINK_800 = Vec4U8{0xAD, 0x14, 0x57, 0xFF}; +inline constexpr Vec4U8 PINK_900 = Vec4U8{0x88, 0x0E, 0x4F, 0xFF}; +inline constexpr Vec4U8 PINK_A100 = Vec4U8{0xFF, 0x80, 0xAB, 0xFF}; +inline constexpr Vec4U8 PINK_A200 = Vec4U8{0xFF, 0x40, 0x81, 0xFF}; +inline constexpr Vec4U8 PINK_A400 = Vec4U8{0xF5, 0x00, 0x57, 0xFF}; +inline constexpr Vec4U8 PINK_A700 = Vec4U8{0xC5, 0x11, 0x62, 0xFF}; + +inline constexpr Vec4U8 PURPLE_50 = Vec4U8{0xF3, 0xE5, 0xF5, 0xFF}; +inline constexpr Vec4U8 PURPLE_100 = Vec4U8{0xE1, 0xBE, 0xE7, 0xFF}; +inline constexpr Vec4U8 PURPLE_200 = Vec4U8{0xCE, 0x93, 0xD8, 0xFF}; +inline constexpr Vec4U8 PURPLE_300 = Vec4U8{0xBA, 0x68, 0xC8, 0xFF}; +inline constexpr Vec4U8 PURPLE_400 = Vec4U8{0xAB, 0x47, 0xBC, 0xFF}; +inline constexpr Vec4U8 PURPLE_500 = Vec4U8{0x9C, 0x27, 0xB0, 0xFF}; +inline constexpr Vec4U8 PURPLE_600 = Vec4U8{0x8E, 0x24, 0xAA, 0xFF}; +inline constexpr Vec4U8 PURPLE_700 = Vec4U8{0x7B, 0x1F, 0xA2, 0xFF}; +inline constexpr Vec4U8 PURPLE_800 = Vec4U8{0x6A, 0x1B, 0x9A, 0xFF}; +inline constexpr Vec4U8 PURPLE_900 = Vec4U8{0x4A, 0x14, 0x8C, 0xFF}; +inline constexpr Vec4U8 PURPLE_A100 = Vec4U8{0xEA, 0x80, 0xFC, 0xFF}; +inline constexpr Vec4U8 PURPLE_A200 = Vec4U8{0xE0, 0x40, 0xFB, 0xFF}; +inline constexpr Vec4U8 PURPLE_A400 = Vec4U8{0xD5, 0x00, 0xF9, 0xFF}; +inline constexpr Vec4U8 PURPLE_A700 = Vec4U8{0xAA, 0x00, 0xFF, 0xFF}; + +inline constexpr Vec4U8 DEEP_PURPLE_50 = Vec4U8{0xED, 0xE7, 0xF6, 0xFF}; +inline constexpr Vec4U8 DEEP_PURPLE_100 = Vec4U8{0xD1, 0xC4, 0xE9, 0xFF}; +inline constexpr Vec4U8 DEEP_PURPLE_200 = Vec4U8{0xB3, 0x9D, 0xDB, 0xFF}; +inline constexpr Vec4U8 DEEP_PURPLE_300 = Vec4U8{0x95, 0x75, 0xCD, 0xFF}; +inline constexpr Vec4U8 DEEP_PURPLE_400 = Vec4U8{0x7E, 0x57, 0xC2, 0xFF}; +inline constexpr Vec4U8 DEEP_PURPLE_500 = Vec4U8{0x67, 0x3A, 0xB7, 0xFF}; +inline constexpr Vec4U8 DEEP_PURPLE_600 = Vec4U8{0x5E, 0x35, 0xB1, 0xFF}; +inline constexpr Vec4U8 DEEP_PURPLE_700 = Vec4U8{0x51, 0x2D, 0xA8, 0xFF}; +inline constexpr Vec4U8 DEEP_PURPLE_800 = Vec4U8{0x45, 0x27, 0xA0, 0xFF}; +inline constexpr Vec4U8 DEEP_PURPLE_900 = Vec4U8{0x31, 0x1B, 0x92, 0xFF}; +inline constexpr Vec4U8 DEEP_PURPLE_A100 = Vec4U8{0xB3, 0x88, 0xFF, 0xFF}; +inline constexpr Vec4U8 DEEP_PURPLE_A200 = Vec4U8{0x7C, 0x4D, 0xFF, 0xFF}; +inline constexpr Vec4U8 DEEP_PURPLE_A400 = Vec4U8{0x65, 0x1F, 0xFF, 0xFF}; +inline constexpr Vec4U8 DEEP_PURPLE_A700 = Vec4U8{0x62, 0x00, 0xEA, 0xFF}; + +inline constexpr Vec4U8 INDIGO_50 = Vec4U8{0xE8, 0xEA, 0xF6, 0xFF}; +inline constexpr Vec4U8 INDIGO_100 = Vec4U8{0xC5, 0xCA, 0xE9, 0xFF}; +inline constexpr Vec4U8 INDIGO_200 = Vec4U8{0x9F, 0xA8, 0xDA, 0xFF}; +inline constexpr Vec4U8 INDIGO_300 = Vec4U8{0x79, 0x86, 0xCB, 0xFF}; +inline constexpr Vec4U8 INDIGO_400 = Vec4U8{0x5C, 0x6B, 0xC0, 0xFF}; +inline constexpr Vec4U8 INDIGO_500 = Vec4U8{0x3F, 0x51, 0xB5, 0xFF}; +inline constexpr Vec4U8 INDIGO_600 = Vec4U8{0x39, 0x49, 0xAB, 0xFF}; +inline constexpr Vec4U8 INDIGO_700 = Vec4U8{0x30, 0x3F, 0x9F, 0xFF}; +inline constexpr Vec4U8 INDIGO_800 = Vec4U8{0x28, 0x35, 0x93, 0xFF}; +inline constexpr Vec4U8 INDIGO_900 = Vec4U8{0x1A, 0x23, 0x7E, 0xFF}; +inline constexpr Vec4U8 INDIGO_A100 = Vec4U8{0x8C, 0x9E, 0xFF, 0xFF}; +inline constexpr Vec4U8 INDIGO_A200 = Vec4U8{0x53, 0x6D, 0xFE, 0xFF}; +inline constexpr Vec4U8 INDIGO_A400 = Vec4U8{0x3D, 0x5A, 0xFE, 0xFF}; +inline constexpr Vec4U8 INDIGO_A700 = Vec4U8{0x30, 0x4F, 0xFE, 0xFF}; + +inline constexpr Vec4U8 BLUE_50 = Vec4U8{0xE3, 0xF2, 0xFD, 0xFF}; +inline constexpr Vec4U8 BLUE_100 = Vec4U8{0xBB, 0xDE, 0xFB, 0xFF}; +inline constexpr Vec4U8 BLUE_200 = Vec4U8{0x90, 0xCA, 0xF9, 0xFF}; +inline constexpr Vec4U8 BLUE_300 = Vec4U8{0x64, 0xB5, 0xF6, 0xFF}; +inline constexpr Vec4U8 BLUE_400 = Vec4U8{0x42, 0xA5, 0xF5, 0xFF}; +inline constexpr Vec4U8 BLUE_500 = Vec4U8{0x21, 0x96, 0xF3, 0xFF}; +inline constexpr Vec4U8 BLUE_600 = Vec4U8{0x1E, 0x88, 0xE5, 0xFF}; +inline constexpr Vec4U8 BLUE_700 = Vec4U8{0x19, 0x76, 0xD2, 0xFF}; +inline constexpr Vec4U8 BLUE_800 = Vec4U8{0x15, 0x65, 0xC0, 0xFF}; +inline constexpr Vec4U8 BLUE_900 = Vec4U8{0x0D, 0x47, 0xA1, 0xFF}; +inline constexpr Vec4U8 BLUE_A100 = Vec4U8{0x82, 0xB1, 0xFF, 0xFF}; +inline constexpr Vec4U8 BLUE_A200 = Vec4U8{0x44, 0x8A, 0xFF, 0xFF}; +inline constexpr Vec4U8 BLUE_A400 = Vec4U8{0x29, 0x79, 0xFF, 0xFF}; +inline constexpr Vec4U8 BLUE_A700 = Vec4U8{0x29, 0x62, 0xFF, 0xFF}; + +inline constexpr Vec4U8 LIGHT_BLUE_50 = Vec4U8{0xE1, 0xF5, 0xFE, 0xFF}; +inline constexpr Vec4U8 LIGHT_BLUE_100 = Vec4U8{0xB3, 0xE5, 0xFC, 0xFF}; +inline constexpr Vec4U8 LIGHT_BLUE_200 = Vec4U8{0x81, 0xD4, 0xFA, 0xFF}; +inline constexpr Vec4U8 LIGHT_BLUE_300 = Vec4U8{0x4F, 0xC3, 0xF7, 0xFF}; +inline constexpr Vec4U8 LIGHT_BLUE_400 = Vec4U8{0x29, 0xB6, 0xF6, 0xFF}; +inline constexpr Vec4U8 LIGHT_BLUE_500 = Vec4U8{0x03, 0xA9, 0xF4, 0xFF}; +inline constexpr Vec4U8 LIGHT_BLUE_600 = Vec4U8{0x03, 0x9B, 0xE5, 0xFF}; +inline constexpr Vec4U8 LIGHT_BLUE_700 = Vec4U8{0x02, 0x88, 0xD1, 0xFF}; +inline constexpr Vec4U8 LIGHT_BLUE_800 = Vec4U8{0x02, 0x77, 0xBD, 0xFF}; +inline constexpr Vec4U8 LIGHT_BLUE_900 = Vec4U8{0x01, 0x57, 0x9B, 0xFF}; +inline constexpr Vec4U8 LIGHT_BLUE_A100 = Vec4U8{0x80, 0xD8, 0xFF, 0xFF}; +inline constexpr Vec4U8 LIGHT_BLUE_A200 = Vec4U8{0x40, 0xC4, 0xFF, 0xFF}; +inline constexpr Vec4U8 LIGHT_BLUE_A400 = Vec4U8{0x00, 0xB0, 0xFF, 0xFF}; +inline constexpr Vec4U8 LIGHT_BLUE_A700 = Vec4U8{0x00, 0x91, 0xEA, 0xFF}; + +inline constexpr Vec4U8 CYAN_50 = Vec4U8{0xE0, 0xF7, 0xFA, 0xFF}; +inline constexpr Vec4U8 CYAN_100 = Vec4U8{0xB2, 0xEB, 0xF2, 0xFF}; +inline constexpr Vec4U8 CYAN_200 = Vec4U8{0x80, 0xDE, 0xEA, 0xFF}; +inline constexpr Vec4U8 CYAN_300 = Vec4U8{0x4D, 0xD0, 0xE1, 0xFF}; +inline constexpr Vec4U8 CYAN_400 = Vec4U8{0x26, 0xC6, 0xDA, 0xFF}; +inline constexpr Vec4U8 CYAN_500 = Vec4U8{0x00, 0xBC, 0xD4, 0xFF}; +inline constexpr Vec4U8 CYAN_600 = Vec4U8{0x00, 0xAC, 0xC1, 0xFF}; +inline constexpr Vec4U8 CYAN_700 = Vec4U8{0x00, 0x97, 0xA7, 0xFF}; +inline constexpr Vec4U8 CYAN_800 = Vec4U8{0x00, 0x83, 0x8F, 0xFF}; +inline constexpr Vec4U8 CYAN_900 = Vec4U8{0x00, 0x60, 0x64, 0xFF}; +inline constexpr Vec4U8 CYAN_A100 = Vec4U8{0x84, 0xFF, 0xFF, 0xFF}; +inline constexpr Vec4U8 CYAN_A200 = Vec4U8{0x18, 0xFF, 0xFF, 0xFF}; +inline constexpr Vec4U8 CYAN_A400 = Vec4U8{0x00, 0xE5, 0xFF, 0xFF}; +inline constexpr Vec4U8 CYAN_A700 = Vec4U8{0x00, 0xB8, 0xD4, 0xFF}; + +inline constexpr Vec4U8 TEAL_50 = Vec4U8{0xE0, 0xF2, 0xF1, 0xFF}; +inline constexpr Vec4U8 TEAL_100 = Vec4U8{0xB2, 0xDF, 0xDB, 0xFF}; +inline constexpr Vec4U8 TEAL_200 = Vec4U8{0x80, 0xCB, 0xC4, 0xFF}; +inline constexpr Vec4U8 TEAL_300 = Vec4U8{0x4D, 0xB6, 0xAC, 0xFF}; +inline constexpr Vec4U8 TEAL_400 = Vec4U8{0x26, 0xA6, 0x9A, 0xFF}; +inline constexpr Vec4U8 TEAL_500 = Vec4U8{0x00, 0x96, 0x88, 0xFF}; +inline constexpr Vec4U8 TEAL_600 = Vec4U8{0x00, 0x89, 0x7B, 0xFF}; +inline constexpr Vec4U8 TEAL_700 = Vec4U8{0x00, 0x79, 0x6B, 0xFF}; +inline constexpr Vec4U8 TEAL_800 = Vec4U8{0x00, 0x69, 0x5C, 0xFF}; +inline constexpr Vec4U8 TEAL_900 = Vec4U8{0x00, 0x4D, 0x40, 0xFF}; +inline constexpr Vec4U8 TEAL_A100 = Vec4U8{0xA7, 0xFF, 0xEB, 0xFF}; +inline constexpr Vec4U8 TEAL_A200 = Vec4U8{0x64, 0xFF, 0xDA, 0xFF}; +inline constexpr Vec4U8 TEAL_A400 = Vec4U8{0x1D, 0xE9, 0xB6, 0xFF}; +inline constexpr Vec4U8 TEAL_A700 = Vec4U8{0x00, 0xBF, 0xA5, 0xFF}; + +inline constexpr Vec4U8 GREEN_50 = Vec4U8{0xE8, 0xF5, 0xE9, 0xFF}; +inline constexpr Vec4U8 GREEN_100 = Vec4U8{0xC8, 0xE6, 0xC9, 0xFF}; +inline constexpr Vec4U8 GREEN_200 = Vec4U8{0xA5, 0xD6, 0xA7, 0xFF}; +inline constexpr Vec4U8 GREEN_300 = Vec4U8{0x81, 0xC7, 0x84, 0xFF}; +inline constexpr Vec4U8 GREEN_400 = Vec4U8{0x66, 0xBB, 0x6A, 0xFF}; +inline constexpr Vec4U8 GREEN_500 = Vec4U8{0x4C, 0xAF, 0x50, 0xFF}; +inline constexpr Vec4U8 GREEN_600 = Vec4U8{0x43, 0xA0, 0x47, 0xFF}; +inline constexpr Vec4U8 GREEN_700 = Vec4U8{0x38, 0x8E, 0x3C, 0xFF}; +inline constexpr Vec4U8 GREEN_800 = Vec4U8{0x2E, 0x7D, 0x32, 0xFF}; +inline constexpr Vec4U8 GREEN_900 = Vec4U8{0x1B, 0x5E, 0x20, 0xFF}; +inline constexpr Vec4U8 GREEN_A100 = Vec4U8{0xB9, 0xF6, 0xCA, 0xFF}; +inline constexpr Vec4U8 GREEN_A200 = Vec4U8{0x69, 0xF0, 0xAE, 0xFF}; +inline constexpr Vec4U8 GREEN_A400 = Vec4U8{0x00, 0xE6, 0x76, 0xFF}; +inline constexpr Vec4U8 GREEN_A700 = Vec4U8{0x00, 0xC8, 0x53, 0xFF}; + +inline constexpr Vec4U8 LIGHT_GREEN_50 = Vec4U8{0xF1, 0xF8, 0xE9, 0xFF}; +inline constexpr Vec4U8 LIGHT_GREEN_100 = Vec4U8{0xDC, 0xED, 0xC8, 0xFF}; +inline constexpr Vec4U8 LIGHT_GREEN_200 = Vec4U8{0xC5, 0xE1, 0xA5, 0xFF}; +inline constexpr Vec4U8 LIGHT_GREEN_300 = Vec4U8{0xAE, 0xD5, 0x81, 0xFF}; +inline constexpr Vec4U8 LIGHT_GREEN_400 = Vec4U8{0x9C, 0xCC, 0x65, 0xFF}; +inline constexpr Vec4U8 LIGHT_GREEN_500 = Vec4U8{0x8B, 0xC3, 0x4A, 0xFF}; +inline constexpr Vec4U8 LIGHT_GREEN_600 = Vec4U8{0x7C, 0xB3, 0x42, 0xFF}; +inline constexpr Vec4U8 LIGHT_GREEN_700 = Vec4U8{0x68, 0x9F, 0x38, 0xFF}; +inline constexpr Vec4U8 LIGHT_GREEN_800 = Vec4U8{0x55, 0x8B, 0x2F, 0xFF}; +inline constexpr Vec4U8 LIGHT_GREEN_900 = Vec4U8{0x33, 0x69, 0x1E, 0xFF}; +inline constexpr Vec4U8 LIGHT_GREEN_A100 = Vec4U8{0xCC, 0xFF, 0x90, 0xFF}; +inline constexpr Vec4U8 LIGHT_GREEN_A200 = Vec4U8{0xB2, 0xFF, 0x59, 0xFF}; +inline constexpr Vec4U8 LIGHT_GREEN_A400 = Vec4U8{0x76, 0xFF, 0x03, 0xFF}; +inline constexpr Vec4U8 LIGHT_GREEN_A700 = Vec4U8{0x64, 0xDD, 0x17, 0xFF}; + +inline constexpr Vec4U8 LIME_50 = Vec4U8{0xF9, 0xFB, 0xE7, 0xFF}; +inline constexpr Vec4U8 LIME_100 = Vec4U8{0xF0, 0xF4, 0xC3, 0xFF}; +inline constexpr Vec4U8 LIME_200 = Vec4U8{0xE6, 0xEE, 0x9C, 0xFF}; +inline constexpr Vec4U8 LIME_300 = Vec4U8{0xDC, 0xE7, 0x75, 0xFF}; +inline constexpr Vec4U8 LIME_400 = Vec4U8{0xD4, 0xE1, 0x57, 0xFF}; +inline constexpr Vec4U8 LIME_500 = Vec4U8{0xCD, 0xDC, 0x39, 0xFF}; +inline constexpr Vec4U8 LIME_600 = Vec4U8{0xC0, 0xCA, 0x33, 0xFF}; +inline constexpr Vec4U8 LIME_700 = Vec4U8{0xAF, 0xB4, 0x2B, 0xFF}; +inline constexpr Vec4U8 LIME_800 = Vec4U8{0x9E, 0x9D, 0x24, 0xFF}; +inline constexpr Vec4U8 LIME_900 = Vec4U8{0x82, 0x77, 0x17, 0xFF}; +inline constexpr Vec4U8 LIME_A100 = Vec4U8{0xF4, 0xFF, 0x81, 0xFF}; +inline constexpr Vec4U8 LIME_A200 = Vec4U8{0xEE, 0xFF, 0x41, 0xFF}; +inline constexpr Vec4U8 LIME_A400 = Vec4U8{0xC6, 0xFF, 0x00, 0xFF}; +inline constexpr Vec4U8 LIME_A700 = Vec4U8{0xAE, 0xEA, 0x00, 0xFF}; + +inline constexpr Vec4U8 YELLOW_50 = Vec4U8{0xFF, 0xFD, 0xE7, 0xFF}; +inline constexpr Vec4U8 YELLOW_100 = Vec4U8{0xFF, 0xF9, 0xC4, 0xFF}; +inline constexpr Vec4U8 YELLOW_200 = Vec4U8{0xFF, 0xF5, 0x9D, 0xFF}; +inline constexpr Vec4U8 YELLOW_300 = Vec4U8{0xFF, 0xF1, 0x76, 0xFF}; +inline constexpr Vec4U8 YELLOW_400 = Vec4U8{0xFF, 0xEE, 0x58, 0xFF}; +inline constexpr Vec4U8 YELLOW_500 = Vec4U8{0xFF, 0xEB, 0x3B, 0xFF}; +inline constexpr Vec4U8 YELLOW_600 = Vec4U8{0xFD, 0xD8, 0x35, 0xFF}; +inline constexpr Vec4U8 YELLOW_700 = Vec4U8{0xFB, 0xC0, 0x2D, 0xFF}; +inline constexpr Vec4U8 YELLOW_800 = Vec4U8{0xF9, 0xA8, 0x25, 0xFF}; +inline constexpr Vec4U8 YELLOW_900 = Vec4U8{0xF5, 0x7F, 0x17, 0xFF}; +inline constexpr Vec4U8 YELLOW_A100 = Vec4U8{0xFF, 0xFF, 0x8D, 0xFF}; +inline constexpr Vec4U8 YELLOW_A200 = Vec4U8{0xFF, 0xFF, 0x00, 0xFF}; +inline constexpr Vec4U8 YELLOW_A400 = Vec4U8{0xFF, 0xEA, 0x00, 0xFF}; +inline constexpr Vec4U8 YELLOW_A700 = Vec4U8{0xFF, 0xD6, 0x00, 0xFF}; + +inline constexpr Vec4U8 AMBER_50 = Vec4U8{0xFF, 0xF8, 0xE1, 0xFF}; +inline constexpr Vec4U8 AMBER_100 = Vec4U8{0xFF, 0xEC, 0xB3, 0xFF}; +inline constexpr Vec4U8 AMBER_200 = Vec4U8{0xFF, 0xE0, 0x82, 0xFF}; +inline constexpr Vec4U8 AMBER_300 = Vec4U8{0xFF, 0xD5, 0x4F, 0xFF}; +inline constexpr Vec4U8 AMBER_400 = Vec4U8{0xFF, 0xCA, 0x28, 0xFF}; +inline constexpr Vec4U8 AMBER_500 = Vec4U8{0xFF, 0xC1, 0x07, 0xFF}; +inline constexpr Vec4U8 AMBER_600 = Vec4U8{0xFF, 0xB3, 0x00, 0xFF}; +inline constexpr Vec4U8 AMBER_700 = Vec4U8{0xFF, 0xA0, 0x00, 0xFF}; +inline constexpr Vec4U8 AMBER_800 = Vec4U8{0xFF, 0x8F, 0x00, 0xFF}; +inline constexpr Vec4U8 AMBER_900 = Vec4U8{0xFF, 0x6F, 0x00, 0xFF}; +inline constexpr Vec4U8 AMBER_A100 = Vec4U8{0xFF, 0xE5, 0x7F, 0xFF}; +inline constexpr Vec4U8 AMBER_A200 = Vec4U8{0xFF, 0xD7, 0x40, 0xFF}; +inline constexpr Vec4U8 AMBER_A400 = Vec4U8{0xFF, 0xC4, 0x00, 0xFF}; +inline constexpr Vec4U8 AMBER_A700 = Vec4U8{0xFF, 0xAB, 0x00, 0xFF}; + +inline constexpr Vec4U8 ORANGE_50 = Vec4U8{0xFF, 0xF3, 0xE0, 0xFF}; +inline constexpr Vec4U8 ORANGE_100 = Vec4U8{0xFF, 0xE0, 0xB2, 0xFF}; +inline constexpr Vec4U8 ORANGE_200 = Vec4U8{0xFF, 0xCC, 0x80, 0xFF}; +inline constexpr Vec4U8 ORANGE_300 = Vec4U8{0xFF, 0xB7, 0x4D, 0xFF}; +inline constexpr Vec4U8 ORANGE_400 = Vec4U8{0xFF, 0xA7, 0x26, 0xFF}; +inline constexpr Vec4U8 ORANGE_500 = Vec4U8{0xFF, 0x98, 0x00, 0xFF}; +inline constexpr Vec4U8 ORANGE_600 = Vec4U8{0xFB, 0x8C, 0x00, 0xFF}; +inline constexpr Vec4U8 ORANGE_700 = Vec4U8{0xF5, 0x7C, 0x00, 0xFF}; +inline constexpr Vec4U8 ORANGE_800 = Vec4U8{0xEF, 0x6C, 0x00, 0xFF}; +inline constexpr Vec4U8 ORANGE_900 = Vec4U8{0xE6, 0x51, 0x00, 0xFF}; +inline constexpr Vec4U8 ORANGE_A100 = Vec4U8{0xFF, 0xD1, 0x80, 0xFF}; +inline constexpr Vec4U8 ORANGE_A200 = Vec4U8{0xFF, 0xAB, 0x40, 0xFF}; +inline constexpr Vec4U8 ORANGE_A400 = Vec4U8{0xFF, 0x91, 0x00, 0xFF}; +inline constexpr Vec4U8 ORANGE_A700 = Vec4U8{0xFF, 0x6D, 0x00, 0xFF}; + +inline constexpr Vec4U8 DEEP_ORANGE_50 = Vec4U8{0xFB, 0xE9, 0xE7, 0xFF}; +inline constexpr Vec4U8 DEEP_ORANGE_100 = Vec4U8{0xFF, 0xCC, 0xBC, 0xFF}; +inline constexpr Vec4U8 DEEP_ORANGE_200 = Vec4U8{0xFF, 0xAB, 0x91, 0xFF}; +inline constexpr Vec4U8 DEEP_ORANGE_300 = Vec4U8{0xFF, 0x8A, 0x65, 0xFF}; +inline constexpr Vec4U8 DEEP_ORANGE_400 = Vec4U8{0xFF, 0x70, 0x43, 0xFF}; +inline constexpr Vec4U8 DEEP_ORANGE_500 = Vec4U8{0xFF, 0x57, 0x22, 0xFF}; +inline constexpr Vec4U8 DEEP_ORANGE_600 = Vec4U8{0xF4, 0x51, 0x1E, 0xFF}; +inline constexpr Vec4U8 DEEP_ORANGE_700 = Vec4U8{0xE6, 0x4A, 0x19, 0xFF}; +inline constexpr Vec4U8 DEEP_ORANGE_800 = Vec4U8{0xD8, 0x43, 0x15, 0xFF}; +inline constexpr Vec4U8 DEEP_ORANGE_900 = Vec4U8{0xBF, 0x36, 0x0C, 0xFF}; +inline constexpr Vec4U8 DEEP_ORANGE_A100 = Vec4U8{0xFF, 0x9E, 0x80, 0xFF}; +inline constexpr Vec4U8 DEEP_ORANGE_A200 = Vec4U8{0xFF, 0x6E, 0x40, 0xFF}; +inline constexpr Vec4U8 DEEP_ORANGE_A400 = Vec4U8{0xFF, 0x3D, 0x00, 0xFF}; +inline constexpr Vec4U8 DEEP_ORANGE_A700 = Vec4U8{0xDD, 0x2C, 0x00, 0xFF}; + +inline constexpr Vec4U8 BROWN_50 = Vec4U8{0xEF, 0xEB, 0xE9, 0xFF}; +inline constexpr Vec4U8 BROWN_100 = Vec4U8{0xD7, 0xCC, 0xC8, 0xFF}; +inline constexpr Vec4U8 BROWN_200 = Vec4U8{0xBC, 0xAA, 0xA4, 0xFF}; +inline constexpr Vec4U8 BROWN_300 = Vec4U8{0xA1, 0x88, 0x7F, 0xFF}; +inline constexpr Vec4U8 BROWN_400 = Vec4U8{0x8D, 0x6E, 0x63, 0xFF}; +inline constexpr Vec4U8 BROWN_500 = Vec4U8{0x79, 0x55, 0x48, 0xFF}; +inline constexpr Vec4U8 BROWN_600 = Vec4U8{0x6D, 0x4C, 0x41, 0xFF}; +inline constexpr Vec4U8 BROWN_700 = Vec4U8{0x5D, 0x40, 0x37, 0xFF}; +inline constexpr Vec4U8 BROWN_800 = Vec4U8{0x4E, 0x34, 0x2E, 0xFF}; +inline constexpr Vec4U8 BROWN_900 = Vec4U8{0x3E, 0x27, 0x23, 0xFF}; + +inline constexpr Vec4U8 GRAY_50 = Vec4U8{0xFA, 0xFA, 0xFA, 0xFF}; +inline constexpr Vec4U8 GRAY_100 = Vec4U8{0xF5, 0xF5, 0xF5, 0xFF}; +inline constexpr Vec4U8 GRAY_200 = Vec4U8{0xEE, 0xEE, 0xEE, 0xFF}; +inline constexpr Vec4U8 GRAY_300 = Vec4U8{0xE0, 0xE0, 0xE0, 0xFF}; +inline constexpr Vec4U8 GRAY_400 = Vec4U8{0xBD, 0xBD, 0xBD, 0xFF}; +inline constexpr Vec4U8 GRAY_500 = Vec4U8{0x9E, 0x9E, 0x9E, 0xFF}; +inline constexpr Vec4U8 GRAY_600 = Vec4U8{0x75, 0x75, 0x75, 0xFF}; +inline constexpr Vec4U8 GRAY_700 = Vec4U8{0x61, 0x61, 0x61, 0xFF}; +inline constexpr Vec4U8 GRAY_800 = Vec4U8{0x42, 0x42, 0x42, 0xFF}; +inline constexpr Vec4U8 GRAY_900 = Vec4U8{0x21, 0x21, 0x21, 0xFF}; + +inline constexpr Vec4U8 BLUE_GRAY_50 = Vec4U8{0xEC, 0xEF, 0xF1, 0xFF}; +inline constexpr Vec4U8 BLUE_GRAY_100 = Vec4U8{0xCF, 0xD8, 0xDC, 0xFF}; +inline constexpr Vec4U8 BLUE_GRAY_200 = Vec4U8{0xB0, 0xBE, 0xC5, 0xFF}; +inline constexpr Vec4U8 BLUE_GRAY_300 = Vec4U8{0x90, 0xA4, 0xAE, 0xFF}; +inline constexpr Vec4U8 BLUE_GRAY_400 = Vec4U8{0x78, 0x90, 0x9C, 0xFF}; +inline constexpr Vec4U8 BLUE_GRAY_500 = Vec4U8{0x60, 0x7D, 0x8B, 0xFF}; +inline constexpr Vec4U8 BLUE_GRAY_600 = Vec4U8{0x54, 0x6E, 0x7A, 0xFF}; +inline constexpr Vec4U8 BLUE_GRAY_700 = Vec4U8{0x45, 0x5A, 0x64, 0xFF}; +inline constexpr Vec4U8 BLUE_GRAY_800 = Vec4U8{0x37, 0x47, 0x4F, 0xFF}; +inline constexpr Vec4U8 BLUE_GRAY_900 = Vec4U8{0x26, 0x32, 0x38, 0xFF}; + +inline constexpr Vec4U8 WHITE = Vec4U8{0xFF, 0xFF, 0xFF, 0xFF}; +inline constexpr Vec4U8 BLACK = Vec4U8{0x00, 0x00, 0x00, 0xFF}; } // namespace mdc diff --git a/ashura/engine/font.h b/ashura/engine/font.h index a663c8d1..993c9a68 100644 --- a/ashura/engine/font.h +++ b/ashura/engine/font.h @@ -11,7 +11,7 @@ namespace ash { // App Unit (AU) -constexpr i32 AU_UNIT = 128 * 64; +inline constexpr i32 AU_UNIT = 128 * 64; static_assert((AU_UNIT % 64) == 0, "App Unit needs to be in 26.6 Fractional Unit"); diff --git a/ashura/engine/font_impl.h b/ashura/engine/font_impl.h index bc6b20ef..a18a5ad0 100644 --- a/ashura/engine/font_impl.h +++ b/ashura/engine/font_impl.h @@ -130,7 +130,7 @@ struct FontImpl : Font virtual Result<> rasterize(u32 font_height, AllocatorImpl allocator) override { - constexpr u32 MIN_ATLAS_EXTENT = 512; + static constexpr u32 MIN_ATLAS_EXTENT = 512; static_assert(MIN_ATLAS_EXTENT > 0, "Font atlas extent must be non-zero"); static_assert(MIN_ATLAS_EXTENT > 128, "Font atlas extent must be at least 128px"); diff --git a/ashura/engine/gpu_context.h b/ashura/engine/gpu_context.h index c350508b..f8426dcd 100644 --- a/ashura/engine/gpu_context.h +++ b/ashura/engine/gpu_context.h @@ -11,19 +11,19 @@ namespace ash { -constexpr u32 TEXTURE_WHITE = 0; -constexpr u32 TEXTURE_BLACK = 1; -constexpr u32 TEXTURE_TRANSPARENT = 2; -constexpr u32 TEXTURE_RED = 3; -constexpr u32 TEXTURE_GREEN = 4; -constexpr u32 TEXTURE_BLUE = 5; -constexpr u32 NUM_DEFAULT_TEXTURES = TEXTURE_BLUE + 1; - -constexpr u32 SAMPLER_LINEAR = 0; -constexpr u32 SAMPLER_NEAREST = 1; -constexpr u32 SAMPLER_LINEAR_CLAMPED = 2; -constexpr u32 SAMPLER_NEAREST_CLAMPED = 3; -constexpr u32 NUM_DEFAULT_SAMPLERS = SAMPLER_NEAREST_CLAMPED + 1; +inline constexpr u32 TEXTURE_WHITE = 0; +inline constexpr u32 TEXTURE_BLACK = 1; +inline constexpr u32 TEXTURE_TRANSPARENT = 2; +inline constexpr u32 TEXTURE_RED = 3; +inline constexpr u32 TEXTURE_GREEN = 4; +inline constexpr u32 TEXTURE_BLUE = 5; +inline constexpr u32 NUM_DEFAULT_TEXTURES = TEXTURE_BLUE + 1; + +inline constexpr u32 SAMPLER_LINEAR = 0; +inline constexpr u32 SAMPLER_NEAREST = 1; +inline constexpr u32 SAMPLER_LINEAR_CLAMPED = 2; +inline constexpr u32 SAMPLER_NEAREST_CLAMPED = 3; +inline constexpr u32 NUM_DEFAULT_SAMPLERS = SAMPLER_NEAREST_CLAMPED + 1; struct FramebufferAttachment { diff --git a/ashura/engine/input.h b/ashura/engine/input.h index 7a961814..f2787278 100644 --- a/ashura/engine/input.h +++ b/ashura/engine/input.h @@ -546,7 +546,7 @@ enum class KeyCode : u16 EndCall = 290 }; -constexpr u16 NUM_KEYS = 512; +inline constexpr u16 NUM_KEYS = 512; enum class MouseButtons : u8 { @@ -743,44 +743,44 @@ enum class Cursor }; /// @brief default charset is ASCII -constexpr char const MIME_TEXT_PLAIN[] = "text/plain"; -constexpr char const MIME_TEXT_UTF8[] = "text/plain;charset=UTF-8"; -constexpr char const MIME_TEXT_CSS[] = "text/css"; -constexpr char const MIME_TEXT_CSV[] = "text/csv"; -constexpr char const MIME_TEXT_HTML[] = "text/html"; -constexpr char const MIME_TEXT_JS[] = "text/javascript"; -constexpr char const MIME_TEXT_MARKDOWN[] = "text/markdown"; - -constexpr char const MIME_IMAGE_AVIF[] = "image/avif"; -constexpr char const MIME_IMAGE_BMP[] = "image/bmp"; -constexpr char const MIME_IMAGE_HEIF[] = "image/heif"; -constexpr char const MIME_IMAGE_JPEG[] = "image/jpeg"; -constexpr char const MIME_IMAGE_PNG[] = "image/png"; -constexpr char const MIME_IMAGE_SVG[] = "image/svg+xml"; -constexpr char const MIME_IMAGE_WEBP[] = "image/webp"; - -constexpr char const MIME_VIDEO_AV1[] = "video/AV1"; -constexpr char const MIME_VIDEO_H264[] = "video/H264"; -constexpr char const MIME_VIDEO_H265[] = "video/H265"; -constexpr char const MIME_VIDEO_H266[] = "video/H266"; -constexpr char const MIME_VIDEO_MATROSKA[] = "video/matroska"; -constexpr char const MIME_VIDEO_MP4[] = "video/mp4"; -constexpr char const MIME_VIDEO_RAW[] = "video/raw"; -constexpr char const MIME_VIDEO_VP8[] = "video/VP8"; -constexpr char const MIME_VIDEO_VP9[] = "video/VP9"; - -constexpr char const MIME_MODEL_GLTF_BINARY[] = "model/gltf+binary"; -constexpr char const MIME_MODEL_GLTF_JSON[] = "model/gltf+json"; -constexpr char const MIME_MODEL_MESH[] = "model/mesh"; -constexpr char const MIME_MODEL_MTL[] = "model/mtl"; -constexpr char const MIME_MODEL_OBJ[] = "model/obj"; -constexpr char const MIME_MODEL_STL[] = "model/stl"; - -constexpr char const MIME_FONT_OTF[] = "font/otf"; -constexpr char const MIME_FONT_SFNT[] = "font/sfnt"; -constexpr char const MIME_FONT_TTF[] = "font/ttf"; -constexpr char const MIME_FONT_WOFF[] = "font/woff"; -constexpr char const MIME_FONT_WOFF2[] = "font/woff2"; +inline constexpr char const MIME_TEXT_PLAIN[] = "text/plain"; +inline constexpr char const MIME_TEXT_UTF8[] = "text/plain;charset=UTF-8"; +inline constexpr char const MIME_TEXT_CSS[] = "text/css"; +inline constexpr char const MIME_TEXT_CSV[] = "text/csv"; +inline constexpr char const MIME_TEXT_HTML[] = "text/html"; +inline constexpr char const MIME_TEXT_JS[] = "text/javascript"; +inline constexpr char const MIME_TEXT_MARKDOWN[] = "text/markdown"; + +inline constexpr char const MIME_IMAGE_AVIF[] = "image/avif"; +inline constexpr char const MIME_IMAGE_BMP[] = "image/bmp"; +inline constexpr char const MIME_IMAGE_HEIF[] = "image/heif"; +inline constexpr char const MIME_IMAGE_JPEG[] = "image/jpeg"; +inline constexpr char const MIME_IMAGE_PNG[] = "image/png"; +inline constexpr char const MIME_IMAGE_SVG[] = "image/svg+xml"; +inline constexpr char const MIME_IMAGE_WEBP[] = "image/webp"; + +inline constexpr char const MIME_VIDEO_AV1[] = "video/AV1"; +inline constexpr char const MIME_VIDEO_H264[] = "video/H264"; +inline constexpr char const MIME_VIDEO_H265[] = "video/H265"; +inline constexpr char const MIME_VIDEO_H266[] = "video/H266"; +inline constexpr char const MIME_VIDEO_MATROSKA[] = "video/matroska"; +inline constexpr char const MIME_VIDEO_MP4[] = "video/mp4"; +inline constexpr char const MIME_VIDEO_RAW[] = "video/raw"; +inline constexpr char const MIME_VIDEO_VP8[] = "video/VP8"; +inline constexpr char const MIME_VIDEO_VP9[] = "video/VP9"; + +inline constexpr char const MIME_MODEL_GLTF_BINARY[] = "model/gltf+binary"; +inline constexpr char const MIME_MODEL_GLTF_JSON[] = "model/gltf+json"; +inline constexpr char const MIME_MODEL_MESH[] = "model/mesh"; +inline constexpr char const MIME_MODEL_MTL[] = "model/mtl"; +inline constexpr char const MIME_MODEL_OBJ[] = "model/obj"; +inline constexpr char const MIME_MODEL_STL[] = "model/stl"; + +inline constexpr char const MIME_FONT_OTF[] = "font/otf"; +inline constexpr char const MIME_FONT_SFNT[] = "font/sfnt"; +inline constexpr char const MIME_FONT_TTF[] = "font/ttf"; +inline constexpr char const MIME_FONT_WOFF[] = "font/woff"; +inline constexpr char const MIME_FONT_WOFF2[] = "font/woff2"; struct ClipBoard { diff --git a/ashura/engine/view.h b/ashura/engine/view.h index bad90ff5..de1dcf7c 100644 --- a/ashura/engine/view.h +++ b/ashura/engine/view.h @@ -398,7 +398,7 @@ struct CoreViewTheme f32 focus_thickness = 0; }; -constexpr CoreViewTheme DEFAULT_THEME = { +inline constexpr CoreViewTheme DEFAULT_THEME = { .background = Vec4U8{0x19, 0x19, 0x19, 0xFF} .norm(), .surface = Vec4U8{0x33, 0x33, 0x33, 0xFF} diff --git a/ashura/gpu/gpu.h b/ashura/gpu/gpu.h index cb909abd..fb0c6a3c 100644 --- a/ashura/gpu/gpu.h +++ b/ashura/gpu/gpu.h @@ -13,36 +13,36 @@ namespace ash namespace gpu { -constexpr u32 REMAINING_MIP_LEVELS = ~0U; -constexpr u32 REMAINING_ARRAY_LAYERS = ~0U; -constexpr u64 WHOLE_SIZE = ~0ULL; - -constexpr u32 MAX_IMAGE_EXTENT_1D = 8'192; -constexpr u32 MAX_IMAGE_EXTENT_2D = 8'192; -constexpr u32 MAX_IMAGE_EXTENT_3D = 2'048; -constexpr u32 MAX_IMAGE_EXTENT_CUBE = 8'192; -constexpr u32 MAX_IMAGE_ARRAY_LAYERS = 1'024; -constexpr u32 MAX_VIEWPORT_EXTENT = 8'192; -constexpr u32 MAX_FRAMEBUFFER_EXTENT = 8'192; -constexpr u32 MAX_FRAMEBUFFER_LAYERS = 1'024; -constexpr u32 MAX_VERTEX_ATTRIBUTES = 16; -constexpr u32 MAX_PUSH_CONSTANTS_SIZE = 128; -constexpr u32 MAX_UPDATE_BUFFER_SIZE = 65'536; -constexpr u32 MAX_PIPELINE_DESCRIPTOR_SETS = 8; -constexpr u32 MAX_PIPELINE_DYNAMIC_UNIFORM_BUFFERS = 8; -constexpr u32 MAX_PIPELINE_DYNAMIC_STORAGE_BUFFERS = 8; -constexpr u32 MAX_PIPELINE_INPUT_ATTACHMENTS = 8; -constexpr u32 MAX_PIPELINE_COLOR_ATTACHMENTS = 8; -constexpr u32 MAX_DESCRIPTOR_SET_DESCRIPTORS = 4'096; -constexpr u32 MAX_BINDING_DESCRIPTORS = 4'096; -constexpr u32 MAX_DESCRIPTOR_SET_BINDINGS = 16; -constexpr u32 MAX_FRAME_BUFFERING = 4; -constexpr u32 MAX_SWAPCHAIN_IMAGES = 4; -constexpr u64 MAX_UNIFORM_BUFFER_RANGE = 65'536; -constexpr f32 MAX_SAMPLER_ANISOTROPY = 16; -constexpr u32 MAX_CLIP_DISTANCES = 8; -constexpr u32 MAX_CULL_DISTANCES = 8; -constexpr u32 MAX_COMBINED_CLIP_AND_CULL_DISTANCES = 8; +inline constexpr u32 REMAINING_MIP_LEVELS = ~0U; +inline constexpr u32 REMAINING_ARRAY_LAYERS = ~0U; +inline constexpr u64 WHOLE_SIZE = ~0ULL; + +inline constexpr u32 MAX_IMAGE_EXTENT_1D = 8'192; +inline constexpr u32 MAX_IMAGE_EXTENT_2D = 8'192; +inline constexpr u32 MAX_IMAGE_EXTENT_3D = 2'048; +inline constexpr u32 MAX_IMAGE_EXTENT_CUBE = 8'192; +inline constexpr u32 MAX_IMAGE_ARRAY_LAYERS = 1'024; +inline constexpr u32 MAX_VIEWPORT_EXTENT = 8'192; +inline constexpr u32 MAX_FRAMEBUFFER_EXTENT = 8'192; +inline constexpr u32 MAX_FRAMEBUFFER_LAYERS = 1'024; +inline constexpr u32 MAX_VERTEX_ATTRIBUTES = 16; +inline constexpr u32 MAX_PUSH_CONSTANTS_SIZE = 128; +inline constexpr u32 MAX_UPDATE_BUFFER_SIZE = 65'536; +inline constexpr u32 MAX_PIPELINE_DESCRIPTOR_SETS = 8; +inline constexpr u32 MAX_PIPELINE_DYNAMIC_UNIFORM_BUFFERS = 8; +inline constexpr u32 MAX_PIPELINE_DYNAMIC_STORAGE_BUFFERS = 8; +inline constexpr u32 MAX_PIPELINE_INPUT_ATTACHMENTS = 8; +inline constexpr u32 MAX_PIPELINE_COLOR_ATTACHMENTS = 8; +inline constexpr u32 MAX_DESCRIPTOR_SET_DESCRIPTORS = 4'096; +inline constexpr u32 MAX_BINDING_DESCRIPTORS = 4'096; +inline constexpr u32 MAX_DESCRIPTOR_SET_BINDINGS = 16; +inline constexpr u32 MAX_FRAME_BUFFERING = 4; +inline constexpr u32 MAX_SWAPCHAIN_IMAGES = 4; +inline constexpr u64 MAX_UNIFORM_BUFFER_RANGE = 65'536; +inline constexpr f32 MAX_SAMPLER_ANISOTROPY = 16; +inline constexpr u32 MAX_CLIP_DISTANCES = 8; +inline constexpr u32 MAX_CULL_DISTANCES = 8; +inline constexpr u32 MAX_COMBINED_CLIP_AND_CULL_DISTANCES = 8; typedef Vec2U Offset; typedef Vec2U Extent; diff --git a/ashura/gpu/vulkan.h b/ashura/gpu/vulkan.h index 1c39479b..9426d554 100644 --- a/ashura/gpu/vulkan.h +++ b/ashura/gpu/vulkan.h @@ -19,14 +19,14 @@ namespace vk using gpu::Status; -constexpr char const * ENGINE_NAME = "Ash"; -constexpr u32 ENGINE_VERSION = VK_MAKE_API_VERSION(0, 0, 0, 1); -constexpr char const * CLIENT_NAME = "Ash Client"; -constexpr u32 CLIENT_VERSION = VK_MAKE_API_VERSION(0, 0, 0, 1); +inline constexpr char const * ENGINE_NAME = "Ash"; +inline constexpr u32 ENGINE_VERSION = VK_MAKE_API_VERSION(0, 0, 0, 1); +inline constexpr char const * CLIENT_NAME = "Ash Client"; +inline constexpr u32 CLIENT_VERSION = VK_MAKE_API_VERSION(0, 0, 0, 1); -constexpr u32 MAX_MEMORY_HEAP_PROPERTIES = 32; -constexpr u32 MAX_MEMORY_HEAPS = 16; -constexpr u8 NUM_DESCRIPTOR_TYPES = 11; +inline constexpr u32 MAX_MEMORY_HEAP_PROPERTIES = 32; +inline constexpr u32 MAX_MEMORY_HEAPS = 16; +inline constexpr u8 NUM_DESCRIPTOR_TYPES = 11; typedef VkSampler Sampler; typedef VkShaderModule Shader; @@ -268,9 +268,9 @@ struct BufferView VkBufferView vk_view = nullptr; }; -constexpr u32 COLOR_ASPECT_IDX = 0; -constexpr u32 DEPTH_ASPECT_IDX = 0; -constexpr u32 STENCIL_ASPECT_IDX = 1; +inline constexpr u32 COLOR_ASPECT_IDX = 0; +inline constexpr u32 DEPTH_ASPECT_IDX = 0; +inline constexpr u32 STENCIL_ASPECT_IDX = 1; struct Image { diff --git a/ashura/std/async.cc b/ashura/std/async.cc index ee57c00a..15e07cc3 100644 --- a/ashura/std/async.cc +++ b/ashura/std/async.cc @@ -17,7 +17,7 @@ namespace ash { -constexpr usize TASK_ARENA_SIZE = PAGE_SIZE; +inline constexpr usize TASK_ARENA_SIZE = PAGE_SIZE; /// memory is returned back to the scheduler once ac reaches 0. /// diff --git a/ashura/std/async.h b/ashura/std/async.h index 7739c491..163d36c8 100644 --- a/ashura/std/async.h +++ b/ashura/std/async.h @@ -767,7 +767,7 @@ template return await_semaphores(semaphores, stages, timeout); } -constexpr usize MAX_TASK_FRAME_SIZE = PAGE_SIZE >> 4; +inline constexpr usize MAX_TASK_FRAME_SIZE = PAGE_SIZE >> 4; template concept TaskFrame = requires (F f) { diff --git a/ashura/std/enum.gen.h b/ashura/std/enum.gen.h index 4f8c6ec9..5195cc6e 100644 --- a/ashura/std/enum.gen.h +++ b/ashura/std/enum.gen.h @@ -10,7 +10,7 @@ namespace ash { -static constexpr usize MAX_ENUM_SIZE = 16; +inline constexpr usize MAX_ENUM_SIZE = 16; template struct Enum diff --git a/ashura/std/enum.py b/ashura/std/enum.py index 73715bd1..19b35dd9 100644 --- a/ashura/std/enum.py +++ b/ashura/std/enum.py @@ -22,7 +22,7 @@ def out(code): return file.write(code) namespace ash {{ -static constexpr usize MAX_ENUM_SIZE = {MAX_ENUM_SIZE}; +inline constexpr usize MAX_ENUM_SIZE = {MAX_ENUM_SIZE}; template struct Enum diff --git a/ashura/std/fs.h b/ashura/std/fs.h index 22d1076f..bf172ca1 100644 --- a/ashura/std/fs.h +++ b/ashura/std/fs.h @@ -7,7 +7,7 @@ namespace ash { -static constexpr usize MAX_PATH_SIZE = 256; +inline constexpr usize MAX_PATH_SIZE = 256; enum class [[nodiscard]] IoErr : i32 { diff --git a/ashura/std/lambda.h b/ashura/std/lambda.h index 228d2d08..ad79b4c9 100644 --- a/ashura/std/lambda.h +++ b/ashura/std/lambda.h @@ -7,9 +7,9 @@ namespace ash { -static constexpr usize DEFAULT_LAMBDA_ALIGNMENT = 32; +inline constexpr usize DEFAULT_LAMBDA_ALIGNMENT = 32; -static constexpr usize DEFAULT_LAMBDA_CAPACITY = 48; +inline constexpr usize DEFAULT_LAMBDA_CAPACITY = 48; template diff --git a/ashura/std/locale.h b/ashura/std/locale.h index c9123655..9a29ff4e 100644 --- a/ashura/std/locale.h +++ b/ashura/std/locale.h @@ -4,135 +4,135 @@ namespace ash { -// IETF BCP 47 language tags. See: -// https://en.wikipedia.org/wiki/IETF_language_tag -namespace languages +/// @brief IETF BCP 47 language tags. See: +/// https://en.wikipedia.org/wiki/IETF_language_tag +namespace lang { -constexpr char AFRIKAANS[] = "af"; -constexpr char AMHARIC[] = "am"; -constexpr char ARABIC[] = "ar"; -constexpr char MAPUDUNGUN[] = "arn"; -constexpr char ASSAMESE[] = "as"; -constexpr char AZERBAIJANI[] = "az"; -constexpr char BASHKIR[] = "ba"; -constexpr char BELARUSIAN[] = "be"; -constexpr char BULGARIAN[] = "bg"; -constexpr char BENGALI[] = "bn"; -constexpr char TIBETAN[] = "bo"; -constexpr char BRETON[] = "br"; -constexpr char BOSNIAN[] = "bs"; -constexpr char CATALAN[] = "ca"; -constexpr char CORSICAN[] = "co"; -constexpr char CZECH[] = "cs"; -constexpr char WELSH[] = "cy"; -constexpr char DANISH[] = "da"; -constexpr char GERMAN[] = "de"; -constexpr char LOWER_SORBIAN[] = "dsb"; -constexpr char DIVEHI[] = "dv"; -constexpr char GREEK[] = "el"; -constexpr char ENGLISH[] = "en"; -constexpr char SPANISH[] = "es"; -constexpr char ESTONIAN[] = "et"; -constexpr char BASQUE[] = "eu"; -constexpr char PERSIAN[] = "fa"; -constexpr char FINNISH[] = "fi"; -constexpr char FILIPINO[] = "fil"; -constexpr char FAROESE[] = "fo"; -constexpr char FRENCH[] = "fr"; -constexpr char FRISIAN[] = "fy"; -constexpr char IRISH[] = "ga"; -constexpr char SCOTTISH_GAELIC[] = "gd"; -constexpr char GALICIAN[] = "gl"; -constexpr char ALSATIAN[] = "gsw"; -constexpr char GUJARATI[] = "gu"; -constexpr char HAUSA[] = "ha"; -constexpr char HEBREW[] = "he"; -constexpr char HINDI[] = "hi"; -constexpr char CROATIAN[] = "hr"; -constexpr char UPPER_SORBIAN[] = "hsb"; -constexpr char HUNGARIAN[] = "hu"; -constexpr char ARMENIAN[] = "hy"; -constexpr char INDONESIAN[] = "id"; -constexpr char IGBO[] = "ig"; -constexpr char YI[] = "ii"; -constexpr char ICELANDIC[] = "is"; -constexpr char ITALIAN[] = "it"; -constexpr char INUKTITUT[] = "iu"; -constexpr char JAPANESE[] = "ja"; -constexpr char GEORGIAN[] = "ka"; -constexpr char KAZAKH[] = "kk"; -constexpr char GREENLANDIC[] = "kl"; -constexpr char KHMER[] = "km"; -constexpr char KANNADA[] = "kn"; -constexpr char KOREAN[] = "ko"; -constexpr char KONKANI[] = "kok"; -constexpr char KYRGYZ[] = "ky"; -constexpr char LUXEMBOURGISH[] = "lb"; -constexpr char LAO[] = "lo"; -constexpr char LITHUANIAN[] = "lt"; -constexpr char LATVIAN[] = "lv"; -constexpr char MAORI_REO[] = "mi"; -constexpr char MACEDONIAN[] = "mk"; -constexpr char MALAYALAM[] = "ml"; -constexpr char MONGOLIAN[] = "mn"; -constexpr char MOHAWK[] = "moh"; -constexpr char MARATHI[] = "mr"; -constexpr char MALAY_BAHASA[] = "ms"; -constexpr char MALTESE[] = "mt"; -constexpr char BURMESE[] = "my"; -constexpr char NORWEGIAN_BOKMAL[] = "nb"; -constexpr char NEPALI[] = "ne"; -constexpr char DUTCH[] = "nl"; -constexpr char NORWEGIAN_NYNORSK[] = "nn"; -constexpr char NORWEGIAN[] = "no"; -constexpr char SESOTHO[] = "st"; -constexpr char OCCITAN[] = "oc"; -constexpr char ODIA[] = "or"; -constexpr char PUNJABI[] = "pa"; -constexpr char POLISH[] = "pl"; -constexpr char DARI[] = "prs"; -constexpr char PASHTO[] = "ps"; -constexpr char PORTUGUESE[] = "pt"; -constexpr char KICHE[] = "quc"; -constexpr char QUECHUA[] = "qu"; -constexpr char ROMANSH[] = "rm"; -constexpr char ROMANIAN[] = "ro"; -constexpr char RUSSIAN[] = "ru"; -constexpr char KINYARWANDA[] = "rw"; -constexpr char SANSKRIT[] = "sa"; -constexpr char YAKUT[] = "sah"; -constexpr char SAMI_NORTHERN[] = "se"; -constexpr char SINHALA[] = "si"; -constexpr char SLOVAK[] = "sk"; -constexpr char SLOVENIAN[] = "sl"; -constexpr char SAMI_SOUTHERN[] = "sma"; -constexpr char SAMI_LULE[] = "smj"; -constexpr char SAMI_INARI[] = "smn"; -constexpr char SAMI_SKOLT[] = "sms"; -constexpr char ALBANIAN[] = "sq"; -constexpr char SERBIAN[] = "sr"; -constexpr char SWEDISH[] = "sv"; -constexpr char KISWAHILI[] = "sw"; -constexpr char SYRIAC[] = "syc"; -constexpr char TAMIL[] = "ta"; -constexpr char TELUGU[] = "te"; -constexpr char TAJIK[] = "tg"; -constexpr char THAI[] = "th"; -constexpr char TURKMEN[] = "tk"; -constexpr char TSWANA[] = "tn"; -constexpr char TURKISH[] = "tr"; -constexpr char TATAR[] = "tt"; -constexpr char TAMAZIGHT[] = "tzm"; -constexpr char UYGHUR[] = "ug"; -constexpr char UKRAINIAN[] = "uk"; -constexpr char URDU[] = "ur"; -constexpr char UZBEK[] = "uz"; -constexpr char VIETNAMESE[] = "vi"; -constexpr char WOLOF[] = "wo"; -constexpr char XHOSA[] = "xh"; -constexpr char YORUBA[] = "yo"; -constexpr char CHINESE[] = "zh"; -constexpr char ZULU[] = "zu"; -} // namespace languages +inline constexpr char AFRIKAANS[] = "af"; +inline constexpr char AMHARIC[] = "am"; +inline constexpr char ARABIC[] = "ar"; +inline constexpr char MAPUDUNGUN[] = "arn"; +inline constexpr char ASSAMESE[] = "as"; +inline constexpr char AZERBAIJANI[] = "az"; +inline constexpr char BASHKIR[] = "ba"; +inline constexpr char BELARUSIAN[] = "be"; +inline constexpr char BULGARIAN[] = "bg"; +inline constexpr char BENGALI[] = "bn"; +inline constexpr char TIBETAN[] = "bo"; +inline constexpr char BRETON[] = "br"; +inline constexpr char BOSNIAN[] = "bs"; +inline constexpr char CATALAN[] = "ca"; +inline constexpr char CORSICAN[] = "co"; +inline constexpr char CZECH[] = "cs"; +inline constexpr char WELSH[] = "cy"; +inline constexpr char DANISH[] = "da"; +inline constexpr char GERMAN[] = "de"; +inline constexpr char LOWER_SORBIAN[] = "dsb"; +inline constexpr char DIVEHI[] = "dv"; +inline constexpr char GREEK[] = "el"; +inline constexpr char ENGLISH[] = "en"; +inline constexpr char SPANISH[] = "es"; +inline constexpr char ESTONIAN[] = "et"; +inline constexpr char BASQUE[] = "eu"; +inline constexpr char PERSIAN[] = "fa"; +inline constexpr char FINNISH[] = "fi"; +inline constexpr char FILIPINO[] = "fil"; +inline constexpr char FAROESE[] = "fo"; +inline constexpr char FRENCH[] = "fr"; +inline constexpr char FRISIAN[] = "fy"; +inline constexpr char IRISH[] = "ga"; +inline constexpr char SCOTTISH_GAELIC[] = "gd"; +inline constexpr char GALICIAN[] = "gl"; +inline constexpr char ALSATIAN[] = "gsw"; +inline constexpr char GUJARATI[] = "gu"; +inline constexpr char HAUSA[] = "ha"; +inline constexpr char HEBREW[] = "he"; +inline constexpr char HINDI[] = "hi"; +inline constexpr char CROATIAN[] = "hr"; +inline constexpr char UPPER_SORBIAN[] = "hsb"; +inline constexpr char HUNGARIAN[] = "hu"; +inline constexpr char ARMENIAN[] = "hy"; +inline constexpr char INDONESIAN[] = "id"; +inline constexpr char IGBO[] = "ig"; +inline constexpr char YI[] = "ii"; +inline constexpr char ICELANDIC[] = "is"; +inline constexpr char ITALIAN[] = "it"; +inline constexpr char INUKTITUT[] = "iu"; +inline constexpr char JAPANESE[] = "ja"; +inline constexpr char GEORGIAN[] = "ka"; +inline constexpr char KAZAKH[] = "kk"; +inline constexpr char GREENLANDIC[] = "kl"; +inline constexpr char KHMER[] = "km"; +inline constexpr char KANNADA[] = "kn"; +inline constexpr char KOREAN[] = "ko"; +inline constexpr char KONKANI[] = "kok"; +inline constexpr char KYRGYZ[] = "ky"; +inline constexpr char LUXEMBOURGISH[] = "lb"; +inline constexpr char LAO[] = "lo"; +inline constexpr char LITHUANIAN[] = "lt"; +inline constexpr char LATVIAN[] = "lv"; +inline constexpr char MAORI_REO[] = "mi"; +inline constexpr char MACEDONIAN[] = "mk"; +inline constexpr char MALAYALAM[] = "ml"; +inline constexpr char MONGOLIAN[] = "mn"; +inline constexpr char MOHAWK[] = "moh"; +inline constexpr char MARATHI[] = "mr"; +inline constexpr char MALAY_BAHASA[] = "ms"; +inline constexpr char MALTESE[] = "mt"; +inline constexpr char BURMESE[] = "my"; +inline constexpr char NORWEGIAN_BOKMAL[] = "nb"; +inline constexpr char NEPALI[] = "ne"; +inline constexpr char DUTCH[] = "nl"; +inline constexpr char NORWEGIAN_NYNORSK[] = "nn"; +inline constexpr char NORWEGIAN[] = "no"; +inline constexpr char SESOTHO[] = "st"; +inline constexpr char OCCITAN[] = "oc"; +inline constexpr char ODIA[] = "or"; +inline constexpr char PUNJABI[] = "pa"; +inline constexpr char POLISH[] = "pl"; +inline constexpr char DARI[] = "prs"; +inline constexpr char PASHTO[] = "ps"; +inline constexpr char PORTUGUESE[] = "pt"; +inline constexpr char KICHE[] = "quc"; +inline constexpr char QUECHUA[] = "qu"; +inline constexpr char ROMANSH[] = "rm"; +inline constexpr char ROMANIAN[] = "ro"; +inline constexpr char RUSSIAN[] = "ru"; +inline constexpr char KINYARWANDA[] = "rw"; +inline constexpr char SANSKRIT[] = "sa"; +inline constexpr char YAKUT[] = "sah"; +inline constexpr char SAMI_NORTHERN[] = "se"; +inline constexpr char SINHALA[] = "si"; +inline constexpr char SLOVAK[] = "sk"; +inline constexpr char SLOVENIAN[] = "sl"; +inline constexpr char SAMI_SOUTHERN[] = "sma"; +inline constexpr char SAMI_LULE[] = "smj"; +inline constexpr char SAMI_INARI[] = "smn"; +inline constexpr char SAMI_SKOLT[] = "sms"; +inline constexpr char ALBANIAN[] = "sq"; +inline constexpr char SERBIAN[] = "sr"; +inline constexpr char SWEDISH[] = "sv"; +inline constexpr char KISWAHILI[] = "sw"; +inline constexpr char SYRIAC[] = "syc"; +inline constexpr char TAMIL[] = "ta"; +inline constexpr char TELUGU[] = "te"; +inline constexpr char TAJIK[] = "tg"; +inline constexpr char THAI[] = "th"; +inline constexpr char TURKMEN[] = "tk"; +inline constexpr char TSWANA[] = "tn"; +inline constexpr char TURKISH[] = "tr"; +inline constexpr char TATAR[] = "tt"; +inline constexpr char TAMAZIGHT[] = "tzm"; +inline constexpr char UYGHUR[] = "ug"; +inline constexpr char UKRAINIAN[] = "uk"; +inline constexpr char URDU[] = "ur"; +inline constexpr char UZBEK[] = "uz"; +inline constexpr char VIETNAMESE[] = "vi"; +inline constexpr char WOLOF[] = "wo"; +inline constexpr char XHOSA[] = "xh"; +inline constexpr char YORUBA[] = "yo"; +inline constexpr char CHINESE[] = "zh"; +inline constexpr char ZULU[] = "zu"; +} // namespace lang } // namespace ash diff --git a/ashura/std/mem.h b/ashura/std/mem.h index 66414ba0..0453eb4c 100644 --- a/ashura/std/mem.h +++ b/ashura/std/mem.h @@ -7,17 +7,17 @@ namespace ash { -constexpr usize MAX_STANDARD_ALIGNMENT = alignof(max_align_t); +inline constexpr usize MAX_STANDARD_ALIGNMENT = alignof(max_align_t); /// @brief Just a hint, this is a common cacheline size. not the actual target's /// cacheline size -constexpr usize CACHELINE_ALIGNMENT = 64; +inline constexpr usize CACHELINE_ALIGNMENT = 64; /// @brief Just a hint, this is the common page alignment. not the actual /// target's page alignment. -constexpr usize PAGE_ALIGNMENT = 16_KB; +inline constexpr usize PAGE_ALIGNMENT = 16_KB; -constexpr usize PAGE_SIZE = PAGE_ALIGNMENT; +inline constexpr usize PAGE_SIZE = PAGE_ALIGNMENT; template constexpr T align_offset(T alignment, T offset) diff --git a/ashura/std/super.h b/ashura/std/super.h index 3b5730e4..911ca38a 100644 --- a/ashura/std/super.h +++ b/ashura/std/super.h @@ -6,9 +6,9 @@ namespace ash { -static constexpr usize DEFAULT_SUPER_ALIGNMENT = 32; +inline constexpr usize DEFAULT_SUPER_ALIGNMENT = 32; -static constexpr usize DEFAULT_SUPER_CAPACITY = 48; +inline constexpr usize DEFAULT_SUPER_CAPACITY = 48; template diff --git a/ashura/std/text.h b/ashura/std/text.h index 161442dc..01c5c71c 100644 --- a/ashura/std/text.h +++ b/ashura/std/text.h @@ -159,20 +159,22 @@ constexpr void replace_invalid_codepoints(Span input, } /// Unicode Ranges - -constexpr Slice32 UTF_BASIC_LATIN{0x0020, 0x007F - 0x0020}; -constexpr Slice32 UTF_LATIN1_SUPPLEMENT{0x00A0, 0x00FF - 0x00A0}; -constexpr Slice32 UTF_LATIN_EXTENDED_A{0x0100, 0x017F - 0x0100}; -constexpr Slice32 UTF_LATIN_EXTENDED_B{0x0180, 0x024F - 0x0180}; -constexpr Slice32 UTF_COMBINING_DIACRITICAL_MARKS{0x0300, 0x036F - 0x0300}; -constexpr Slice32 UTF_ARABIC{0x0600, 0x06FF - 0x0600}; -constexpr Slice32 UTF_GENERAL_PUNCTUATION{0x2000, 0x206F - 0x2000}; -constexpr Slice32 UTF_SUPERSCRIPTS_AND_SUBSCRIPTS{0x2070, 0x209F - 0x2070}; -constexpr Slice32 UTF_CURRENCY_SYMBOLS{0x20A0, 0x20CF - 0x20A0}; -constexpr Slice32 UTF_NUMBER_FORMS{0x2150, 0x218F - 0x2150}; -constexpr Slice32 UTF_ARROWS{0x2190, 0x21FF - 0x2190}; -constexpr Slice32 UTF_MATHEMATICAL_OPERATORS{0x2200, 0x22FF - 0x2200}; -constexpr Slice32 UTF_HIRAGANA{0x3040, 0x309F - 0x3040}; -constexpr Slice32 UTF_KATAKANA{0x30A0, 0x30FF - 0x30A0}; +namespace utf +{ +inline constexpr Tuple BASIC_LATIN{0x0020, 0x007F}; +inline constexpr Tuple LATIN1_SUPPLEMENT{0x00A0, 0x00FF}; +inline constexpr Tuple LATIN_EXTENDED_A{0x0100, 0x017F}; +inline constexpr Tuple LATIN_EXTENDED_B{0x0180, 0x024F}; +inline constexpr Tuple COMBINING_DIACRITICAL_MARKS{0x0300, 0x036F}; +inline constexpr Tuple ARABIC{0x0600, 0x06FF}; +inline constexpr Tuple GENERAL_PUNCTUATION{0x2000, 0x206F}; +inline constexpr Tuple SUPERSCRIPTS_AND_SUBSCRIPTS{0x2070, 0x209F}; +inline constexpr Tuple CURRENCY_SYMBOLS{0x20A0, 0x20CF}; +inline constexpr Tuple NUMBER_FORMS{0x2150, 0x218F}; +inline constexpr Tuple ARROWS{0x2190, 0x21FF}; +inline constexpr Tuple MATHEMATICAL_OPERATORS{0x2200, 0x22FF}; +inline constexpr Tuple HIRAGANA{0x3040, 0x309F}; +inline constexpr Tuple KATAKANA{0x30A0, 0x30FF}; +} // namespace utf } // namespace ash diff --git a/ashura/std/tuple.gen.h b/ashura/std/tuple.gen.h index 8f84d499..457dfd00 100644 --- a/ashura/std/tuple.gen.h +++ b/ashura/std/tuple.gen.h @@ -7,7 +7,7 @@ namespace ash{ -static constexpr usize MAX_TUPLE_SIZE = 16; +inline constexpr usize MAX_TUPLE_SIZE = 16; namespace intr diff --git a/ashura/std/tuple.py b/ashura/std/tuple.py index 70a562af..06af130f 100644 --- a/ashura/std/tuple.py +++ b/ashura/std/tuple.py @@ -18,7 +18,7 @@ def out(code): return file.write(code) namespace ash{{ -static constexpr usize MAX_TUPLE_SIZE = {MAX_TUPLE_SIZE}; +inline constexpr usize MAX_TUPLE_SIZE = {MAX_TUPLE_SIZE}; """) diff --git a/ashura/std/types.h b/ashura/std/types.h index 173ffb29..126ce6c0 100644 --- a/ashura/std/types.h +++ b/ashura/std/types.h @@ -34,49 +34,49 @@ typedef uintptr_t uptr; typedef intptr_t iptr; typedef u64 hash64; -constexpr u8 U8_MIN = 0; -constexpr u8 U8_MAX = 0xFF; +inline constexpr u8 U8_MIN = 0; +inline constexpr u8 U8_MAX = 0xFF; -constexpr i8 I8_MIN = -0x7F - 1; -constexpr i8 I8_MAX = 0x7F; +inline constexpr i8 I8_MIN = -0x7F - 1; +inline constexpr i8 I8_MAX = 0x7F; -constexpr u16 U16_MIN = 0; -constexpr u16 U16_MAX = 0xFFFF; +inline constexpr u16 U16_MIN = 0; +inline constexpr u16 U16_MAX = 0xFFFF; -constexpr i16 I16_MIN = -0x7FFF - 1; -constexpr i16 I16_MAX = 0x7FFF; +inline constexpr i16 I16_MIN = -0x7FFF - 1; +inline constexpr i16 I16_MAX = 0x7FFF; -constexpr u32 U32_MIN = 0; -constexpr u32 U32_MAX = 0xFFFF'FFFFU; +inline constexpr u32 U32_MIN = 0; +inline constexpr u32 U32_MAX = 0xFFFF'FFFFU; -constexpr i32 I32_MIN = -0x7FFF'FFFF - 1; -constexpr i32 I32_MAX = 0x7FFF'FFFF; +inline constexpr i32 I32_MIN = -0x7FFF'FFFF - 1; +inline constexpr i32 I32_MAX = 0x7FFF'FFFF; -constexpr u64 U64_MIN = 0; -constexpr u64 U64_MAX = 0xFFFF'FFFF'FFFF'FFFFULL; +inline constexpr u64 U64_MIN = 0; +inline constexpr u64 U64_MAX = 0xFFFF'FFFF'FFFF'FFFFULL; -constexpr i64 I64_MIN = -0x7FFF'FFFF'FFFF'FFFFLL - 1; -constexpr i64 I64_MAX = 0x7FFF'FFFF'FFFF'FFFFLL; +inline constexpr i64 I64_MIN = -0x7FFF'FFFF'FFFF'FFFFLL - 1; +inline constexpr i64 I64_MAX = 0x7FFF'FFFF'FFFF'FFFFLL; -constexpr usize USIZE_MIN = 0; -constexpr usize USIZE_MAX = SIZE_MAX; +inline constexpr usize USIZE_MIN = 0; +inline constexpr usize USIZE_MAX = SIZE_MAX; -constexpr isize ISIZE_MIN = PTRDIFF_MIN; -constexpr isize ISIZE_MAX = PTRDIFF_MAX; +inline constexpr isize ISIZE_MIN = PTRDIFF_MIN; +inline constexpr isize ISIZE_MAX = PTRDIFF_MAX; -constexpr f32 F32_MIN = -FLT_MAX; -constexpr f32 F32_MIN_POSITIVE = FLT_MIN; -constexpr f32 F32_MAX = FLT_MAX; -constexpr f32 F32_EPS = FLT_EPSILON; -constexpr f32 F32_INF = INFINITY; +inline constexpr f32 F32_MIN = -FLT_MAX; +inline constexpr f32 F32_MIN_POSITIVE = FLT_MIN; +inline constexpr f32 F32_MAX = FLT_MAX; +inline constexpr f32 F32_EPS = FLT_EPSILON; +inline constexpr f32 F32_INF = INFINITY; -constexpr f64 F64_MIN = -DBL_MAX; -constexpr f64 F64_MIN_POSITIVE = DBL_MIN; -constexpr f64 F64_MAX = DBL_MAX; -constexpr f64 F64_EPS = DBL_EPSILON; -constexpr f64 F64_INF = INFINITY; +inline constexpr f64 F64_MIN = -DBL_MAX; +inline constexpr f64 F64_MIN_POSITIVE = DBL_MIN; +inline constexpr f64 F64_MAX = DBL_MAX; +inline constexpr f64 F64_EPS = DBL_EPSILON; +inline constexpr f64 F64_INF = INFINITY; -constexpr f32 PI = 3.14159265358979323846F; +inline constexpr f32 PI = 3.14159265358979323846F; struct Add { diff --git a/ashura/std/v.gen.h b/ashura/std/v.gen.h index 0fcd49bb..19467fea 100644 --- a/ashura/std/v.gen.h +++ b/ashura/std/v.gen.h @@ -18,22 +18,22 @@ struct V } }; -constexpr V<0> v0; -constexpr V<1> v1; -constexpr V<2> v2; -constexpr V<3> v3; -constexpr V<4> v4; -constexpr V<5> v5; -constexpr V<6> v6; -constexpr V<7> v7; -constexpr V<8> v8; -constexpr V<9> v9; -constexpr V<10> v10; -constexpr V<11> v11; -constexpr V<12> v12; -constexpr V<13> v13; -constexpr V<14> v14; -constexpr V<15> v15; +inline constexpr V<0> v0; +inline constexpr V<1> v1; +inline constexpr V<2> v2; +inline constexpr V<3> v3; +inline constexpr V<4> v4; +inline constexpr V<5> v5; +inline constexpr V<6> v6; +inline constexpr V<7> v7; +inline constexpr V<8> v8; +inline constexpr V<9> v9; +inline constexpr V<10> v10; +inline constexpr V<11> v11; +inline constexpr V<12> v12; +inline constexpr V<13> v13; +inline constexpr V<14> v14; +inline constexpr V<15> v15; } // namespace ash diff --git a/ashura/std/v.py b/ashura/std/v.py index c262de72..eb4f8584 100644 --- a/ashura/std/v.py +++ b/ashura/std/v.py @@ -32,7 +32,7 @@ def out(code): return file.write(code) """) -value_defs = [f"constexpr V<{i}> v{i};" for i in range(MAX_SIZE)] +value_defs = [f"inline constexpr V<{i}> v{i};" for i in range(MAX_SIZE)] out("\n".join(value_defs)) From 7cba54ba4863c3d70999f14e7003afdf1a1d419d Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:37:57 +0000 Subject: [PATCH 05/21] =?UTF-8?q?=F0=9F=8E=A8=20improved=20async=20runtime?= =?UTF-8?q?=20Task=20and=20Arena=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/async.cc | 135 ++++++++++++++++++++++---------------------- 1 file changed, 68 insertions(+), 67 deletions(-) diff --git a/ashura/std/async.cc b/ashura/std/async.cc index 15e07cc3..3289e57d 100644 --- a/ashura/std/async.cc +++ b/ashura/std/async.cc @@ -7,7 +7,6 @@ #include "ashura/std/error.h" #include "ashura/std/list.h" #include "ashura/std/log.h" -#include "ashura/std/rc.h" #include "ashura/std/time.h" #include "ashura/std/types.h" #include "ashura/std/vec.h" @@ -19,26 +18,28 @@ namespace ash inline constexpr usize TASK_ARENA_SIZE = PAGE_SIZE; -/// memory is returned back to the scheduler once ac reaches 0. +/// @brief memory is returned back to the scheduler once ac reaches 0. /// /// arenas are individually allocated from heap and span a page boundary. /// -struct TaskArena +struct TaskArena : Pin<> { - AliasCount ac{}; - Arena arena{}; + TaskArena * next = nullptr; + TaskArena * prev = nullptr; + AliasCount ac{}; + Arena arena{}; - static constexpr auto node_flex() + static constexpr auto flex() { return Flex{ - {layout>, + {layout, Layout{.alignment = MAX_STANDARD_ALIGNMENT, .size = TASK_ARENA_SIZE}} }; } }; -/// once task is executed, the arena holding the memory associated with the task -/// is returned back to the source. +/// @brief once the task is executed, the arena holding the memory associated +/// with the task is returned back to the source. /// /// the arena holds the memory for this Task struct, and the memory for its /// related data. this has the advantage that accessing the struct is @@ -59,6 +60,10 @@ struct Task typedef bool (*Run)(void *); + Task * next = nullptr; + + Task * prev = nullptr; + Layout frame_layout{}; Poll poll = [](void *) { return true; }; @@ -68,12 +73,12 @@ struct Task Uninit uninit = noop; /// @brief arena this task was allocated from. always non-null. - ListNode * arena = nullptr; + TaskArena * arena = nullptr; - static constexpr auto node_flex(Layout frame_layout) + static constexpr auto flex(Layout frame_layout) { return Flex{ - {layout>, frame_layout} + {layout, frame_layout} }; } }; @@ -92,11 +97,11 @@ static_assert(MAX_TASK_FRAME_SIZE >= MAX_STANDARD_ALIGNMENT, // assuming it has maximum alignment as well, although this would typically be // maximum of MAX_STANDARD_ALIGNMENT -constexpr Layout MAX_TASK_FRAME_LAYOUT{.alignment = MAX_TASK_FRAME_SIZE, - .size = MAX_TASK_FRAME_SIZE}; +inline constexpr Layout MAX_TASK_FRAME_LAYOUT{.alignment = MAX_TASK_FRAME_SIZE, + .size = MAX_TASK_FRAME_SIZE}; -constexpr Layout MAX_TASK_NODE_FLEX_LAYOUT = - Task::node_flex(MAX_TASK_FRAME_LAYOUT).layout(); +inline constexpr Layout MAX_TASK_NODE_FLEX_LAYOUT = + Task::flex(MAX_TASK_FRAME_LAYOUT).layout(); static_assert(TASK_ARENA_SIZE >= MAX_TASK_NODE_FLEX_LAYOUT.size, "Task arena size is too small to fit the maximum task frame and " @@ -116,11 +121,11 @@ struct TaskAllocator SpinLock lock{}; List list{}; - ListNode * pop() + TaskArena * pop() { - LockGuard guard{lock}; + LockGuard guard{lock}; // return the most recently used arena - ListNode * arena = list.pop_back(); + TaskArena * arena = list.pop_back(); return arena; } @@ -131,8 +136,8 @@ struct TaskAllocator /// allocate a new arena and make it the current arena. struct alignas(CACHELINE_ALIGNMENT) { - SpinLock lock{}; - ListNode * node = nullptr; + SpinLock lock{}; + TaskArena * node = nullptr; } current_arena{}; @@ -161,21 +166,21 @@ struct TaskAllocator } } - void release_arena(ListNode * arena) + void release_arena(TaskArena * arena) { // decrease alias count of arena, if only alias left, add to the arena // free list. - if (arena->v.ac.unalias()) + if (arena->ac.unalias()) { - arena->v.arena.reclaim(); + arena->arena.reclaim(); LockGuard guard{free_list.lock}; free_list.list.push_back(arena); } } - bool alloc_arena(ListNode *& arena) + bool alloc_arena(TaskArena *& arena) { - Flex const flex = TaskArena::node_flex(); + Flex const flex = TaskArena::flex(); Layout const layout = flex.layout(); u8 * head; @@ -188,23 +193,22 @@ struct TaskAllocator u8 * memory; flex.unpack(head, arena, memory); - new (arena) ListNode{ - .v{.arena = to_arena(Span{memory, TASK_ARENA_SIZE})}}; + new (arena) TaskArena{.arena = to_arena(Span{memory, TASK_ARENA_SIZE})}; return true; } - void dealloc_arena(ListNode * arena) + void dealloc_arena(TaskArena * arena) { - Flex const flex = TaskArena::node_flex(); + Flex const flex = TaskArena::flex(); Layout const layout = flex.layout(); source.dealloc(layout.alignment, (u8 *) arena, layout.size); } - bool request_arena(ListNode *& arena) + bool request_arena(TaskArena *& arena) { /// get from free list, otherwise allocate a new arena - ListNode * a = free_list.pop(); + TaskArena * a = free_list.pop(); if (a != nullptr) { arena = a; @@ -213,54 +217,51 @@ struct TaskAllocator return alloc_arena(arena); } - static bool alloc_task(ListNode & arena, TaskInfo const & info, - ListNode *& task) + static bool alloc_task(TaskArena & arena, TaskInfo const & info, Task *& task) { - Flex const flex = Task::node_flex(info.frame_layout); + Flex const flex = Task::flex(info.frame_layout); Layout const layout = flex.layout(); u8 * head; - if (!arena.v.arena.alloc(layout.alignment, layout.size, head)) + if (!arena.arena.alloc(layout.alignment, layout.size, head)) { return false; } - arena.v.ac.alias(); + arena.ac.alias(); u8 * ctx; flex.unpack(head, task, ctx); - new (task) ListNode{ - .v{.frame_layout = info.frame_layout, - .poll = info.poll, - .run = info.run, - .uninit = info.uninit, - .arena = &arena} - }; + new (task) Task{.frame_layout = info.frame_layout, + .poll = info.poll, + .run = info.run, + .uninit = info.uninit, + .arena = &arena}; info.init(ctx); return true; } - static void uninit_task(ListNode * task) + static void uninit_task(Task * task) { - Flex const flex = Task::node_flex(task->v.frame_layout); + Flex const flex = Task::flex(task->frame_layout); u8 * ctx; flex.unpack(task, task, ctx); - task->v.uninit(ctx); + task->uninit(ctx); } - void release_task(ListNode * task) + void release_task(Task * task) { - ListNode * arena = task->v.arena; + TaskArena * arena = task->arena; uninit_task(task); release_arena(arena); } - bool create_task(TaskInfo const & info, ListNode *& task) + bool create_task(TaskInfo const & info, Task *& task) { LockGuard guard{current_arena.lock}; @@ -279,9 +280,9 @@ struct TaskAllocator // decrease alias count of current arena, if last alias, reclaim the memory // instead - if (current_arena.node->v.ac.unalias()) [[unlikely]] + if (current_arena.node->ac.unalias()) [[unlikely]] { - current_arena.node->v.arena.reclaim(); + current_arena.node->arena.reclaim(); } else { @@ -323,16 +324,16 @@ struct TaskQueue return tasks.is_empty(); } - ListNode * pop_task() + Task * pop_task() { - LockGuard guard{lock}; - ListNode * t = tasks.pop_front(); + LockGuard guard{lock}; + Task * t = tasks.pop_front(); return t; } /// @brief push task on the queue /// @param t non-null task node - void push_task(ListNode * t) + void push_task(Task * t) { LockGuard guard{lock}; tasks.push_back(t); @@ -340,7 +341,7 @@ struct TaskQueue void push_task(TaskInfo const & info) { - ListNode * t; + Task * t; CHECK(allocator.create_task(info, t)); push_task(t); } @@ -425,7 +426,7 @@ struct ASH_DLL_EXPORT SchedulerImpl : Scheduler, Pin<> while (true) { - ListNode * task = main_queue.pop_task(); + Task * task = main_queue.pop_task(); if (task == nullptr) { @@ -451,7 +452,7 @@ struct ASH_DLL_EXPORT SchedulerImpl : Scheduler, Pin<> break; } - ListNode * task = q.pop_task(); + Task * task = q.pop_task(); if (task == nullptr) [[unlikely]] { @@ -460,13 +461,13 @@ struct ASH_DLL_EXPORT SchedulerImpl : Scheduler, Pin<> continue; } - Flex const flex = Task::node_flex(task->v.frame_layout); + Flex const flex = Task::flex(task->frame_layout); u8 * frame; flex.unpack(task, task, frame); - if (!task->v.poll(frame)) [[unlikely]] + if (!task->poll(frame)) [[unlikely]] { q.push_task(task); continue; @@ -475,7 +476,7 @@ struct ASH_DLL_EXPORT SchedulerImpl : Scheduler, Pin<> // finally gotten a ready task, reset poll counter poll = 0; - bool const repeat = task->v.run(frame); + bool const repeat = task->run(frame); if (repeat) [[unlikely]] { @@ -491,7 +492,7 @@ struct ASH_DLL_EXPORT SchedulerImpl : Scheduler, Pin<> // run loop done. purge pending tasks while (true) { - ListNode * task = q.pop_task(); + Task * task = q.pop_task(); if (task == nullptr) { @@ -516,7 +517,7 @@ struct ASH_DLL_EXPORT SchedulerImpl : Scheduler, Pin<> break; } - ListNode * task = q.pop_task(); + Task * task = q.pop_task(); if (task == nullptr) [[unlikely]] { @@ -533,19 +534,19 @@ struct ASH_DLL_EXPORT SchedulerImpl : Scheduler, Pin<> } } - Flex const flex = Task::node_flex(task->v.frame_layout); + Flex const flex = Task::flex(task->frame_layout); u8 * frame; flex.unpack(task, task, frame); - if (!task->v.poll(frame)) [[unlikely]] + if (!task->poll(frame)) [[unlikely]] { q.push_task(task); continue; } - bool const repeat = task->v.run(frame); + bool const repeat = task->run(frame); if (repeat) [[unlikely]] { From bb0da5cb4fc339d39040b31f5611455512227282 Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:39:33 +0000 Subject: [PATCH 06/21] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactoring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/engine/font_impl.h | 8 ++++---- ashura/engine/image_decoder.cc | 12 +++++------- ashura/engine/renderer.h | 2 +- ashura/engine/text.cc | 2 +- ashura/engine/text_compositor.h | 3 ++- ashura/std/log.cc | 14 +++++++------- ashura/std/text.h | 1 + ashura/std/traits.h | 5 ----- 8 files changed, 21 insertions(+), 26 deletions(-) diff --git a/ashura/engine/font_impl.h b/ashura/engine/font_impl.h index a18a5ad0..58946fb8 100644 --- a/ashura/engine/font_impl.h +++ b/ashura/engine/font_impl.h @@ -147,7 +147,7 @@ struct FontImpl : Font CpuFontAtlas atlas; - if (!atlas.glyphs.resize_defaulted(glyphs.size32())) + if (!atlas.glyphs.resize(glyphs.size32())) { return Err{}; } @@ -264,7 +264,7 @@ struct FontImpl : Font u64 const atlas_layer_size = atlas_area; u64 const atlas_size = atlas_layer_size * num_layers; - if (!atlas.channels.resize_defaulted(atlas_size)) + if (!atlas.channels.resize(atlas_size)) { return Err{}; } @@ -349,7 +349,7 @@ struct FontImpl : Font Vec views; - views.resize_defaulted(atlas.num_layers).unwrap(); + views.resize(atlas.num_layers).unwrap(); for (u32 i = 0; i < atlas.num_layers; i++) { @@ -427,7 +427,7 @@ struct FontImpl : Font Vec textures; Vec glyphs; - textures.resize_defaulted(atlas.num_layers).unwrap(); + textures.resize(atlas.num_layers).unwrap(); glyphs.extend(atlas.glyphs).unwrap(); for (u32 i = 0; i < atlas.num_layers; i++) diff --git a/ashura/engine/image_decoder.cc b/ashura/engine/image_decoder.cc index 73075428..e9e1bf83 100644 --- a/ashura/engine/image_decoder.cc +++ b/ashura/engine/image_decoder.cc @@ -8,7 +8,6 @@ extern "C" #include "jpeglib.h" #include "png.h" #include "webp/decode.h" -#include "webp/types.h" } namespace ash @@ -202,13 +201,12 @@ ImageDecodeError decode_jpg(Span bytes, DecodedImage & image) ImageDecodeError decode_image(Span bytes, DecodedImage & image) { - constexpr u8 JPG_MAGIC[] = {0xFF, 0xD8, 0xFF}; - - constexpr u8 PNG_MAGIC[] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}; - + static constexpr u8 JPG_MAGIC[] = {0xFF, 0xD8, 0xFF}; + static constexpr u8 PNG_MAGIC[] = {0x89, 0x50, 0x4E, 0x47, + 0x0D, 0x0A, 0x1A, 0x0A}; // RIFF-[file size: 4 bytes]-WEBP - constexpr u8 WEBP_MAGIC1[] = {'R', 'I', 'F', 'F'}; - constexpr u8 WEBP_MAGIC2[] = {'W', 'E', 'B', 'P'}; + static constexpr u8 WEBP_MAGIC1[] = {'R', 'I', 'F', 'F'}; + static constexpr u8 WEBP_MAGIC2[] = {'W', 'E', 'B', 'P'}; if (range_eq(bytes.slice(0, size(JPG_MAGIC)), JPG_MAGIC)) { diff --git a/ashura/engine/renderer.h b/ashura/engine/renderer.h index 1fbe8769..0a0315f5 100644 --- a/ashura/engine/renderer.h +++ b/ashura/engine/renderer.h @@ -158,7 +158,7 @@ struct Renderer p->acquire(ctx, passes, assets); } - resources.resize_defaulted(ctx.buffering).unwrap(); + resources.resize(ctx.buffering).unwrap(); } void release(GpuContext & ctx, AssetMap & assets) diff --git a/ashura/engine/text.cc b/ashura/engine/text.cc index 09a3646d..c9bd24dd 100644 --- a/ashura/engine/text.cc +++ b/ashura/engine/text.cc @@ -297,7 +297,7 @@ void layout_text(TextBlock const & block, f32 max_width, TextLayout & layout) CHECK(block.fonts.size() <= U32_MAX); CHECK(block.runs.size() == block.fonts.size()); - layout.segments.resize_defaulted(block.text.size()).unwrap(); + layout.segments.resize(block.text.size()).unwrap(); Span segments = layout.segments; fill(segments, TextSegment{}); diff --git a/ashura/engine/text_compositor.h b/ashura/engine/text_compositor.h index 447b78d2..2fe7a7f7 100644 --- a/ashura/engine/text_compositor.h +++ b/ashura/engine/text_compositor.h @@ -182,12 +182,13 @@ struct TextCompositor Inner(u32 num_buffer_codepoints, u32 num_records) { + // [ ] use make() CHECK(num_buffer_codepoints > 0); CHECK(num_records > 0); CHECK(is_pow2(num_buffer_codepoints)); CHECK(is_pow2(num_records)); buffer.resize_uninit(num_buffer_codepoints).unwrap(); - records.resize_defaulted(num_records).unwrap(); + records.resize(num_records).unwrap(); } void pop_records(u32 num); diff --git a/ashura/std/log.cc b/ashura/std/log.cc index ee328001..402847af 100644 --- a/ashura/std/log.cc +++ b/ashura/std/log.cc @@ -86,9 +86,9 @@ void StdioSink::log(LogLevels level, Span log_message) break; } - constexpr char const time_format[] = "%d/%m/%Y, %H:%M:%S"; - char time_string[256]; - usize time_string_length = 0; + static constexpr char const time_format[] = "%d/%m/%Y, %H:%M:%S"; + char time_string[256]; + usize time_string_length = 0; std::time_t current_time = std::time(nullptr); if (current_time != (std::time_t) -1) @@ -120,10 +120,10 @@ void StdioSink::flush() void FileSink::log(LogLevels level, Span log_message) { - char const * level_str = get_level_str(level); - constexpr char const time_format[] = "%d/%m/%Y, %H:%M:%S"; - char time_string[256]; - usize time_string_length = 0; + char const * level_str = get_level_str(level); + static constexpr char const time_format[] = "%d/%m/%Y, %H:%M:%S"; + char time_string[256]; + usize time_string_length = 0; std::time_t current_time = std::time(nullptr); if (current_time != (std::time_t) -1) diff --git a/ashura/std/text.h b/ashura/std/text.h index 01c5c71c..420398a0 100644 --- a/ashura/std/text.h +++ b/ashura/std/text.h @@ -2,6 +2,7 @@ #pragma once #include "ashura/std/error.h" #include "ashura/std/result.h" +#include "ashura/std/tuple.h" #include "ashura/std/types.h" #include "ashura/std/vec.h" diff --git a/ashura/std/traits.h b/ashura/std/traits.h index 6cc79eae..31f461eb 100644 --- a/ashura/std/traits.h +++ b/ashura/std/traits.h @@ -158,11 +158,6 @@ struct is_pfn_impl template concept AnyPFn = is_pfn_impl::value; -template -concept AnyFunctor = requires () { - { &F::operator() }; -}; - template concept Predicate = requires (Fn fn, Args... args) { { fn(static_cast(args)...) && true }; From de230a686193544a3443df116f2638c0563a7d3b Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:40:37 +0000 Subject: [PATCH 07/21] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactoring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/editor/editor.cc | 6 +++--- ashura/std/types.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ashura/editor/editor.cc b/ashura/editor/editor.cc index 422b1948..39bf5317 100644 --- a/ashura/editor/editor.cc +++ b/ashura/editor/editor.cc @@ -29,7 +29,7 @@ int main() sw[0].on(); -scalar.frame(250, 100); + scalar.frame(250, 100); slider.range(0, 100).interp(0).axis(Axis::Y); @@ -76,7 +76,7 @@ scalar.frame(250, 100); .axis(Axis::X) .cross_align(0) .main_align(MainAlign::SpaceBetween) - .frame(1920, 1080); + .frame(1'920, 1'080); engine->run(flex); -} \ No newline at end of file +} diff --git a/ashura/std/types.h b/ashura/std/types.h index 126ce6c0..b438edc3 100644 --- a/ashura/std/types.h +++ b/ashura/std/types.h @@ -906,7 +906,7 @@ constexpr auto begin(T && a) -> decltype(a.begin()) } template -constexpr IterEnd end(T (&)[N]) +constexpr auto end(T (&)[N]) { return IterEnd{}; } @@ -962,7 +962,7 @@ constexpr usize size_bits(T (&)[N]) template constexpr auto size_bits(T && a) -> decltype(a.size()) { - return sizeof(T) * 8 * a.size(); + return sizeof(T) * a.size() * 8; } template From 9258846d6f0f9c931107d3fbc5772f59396b4943 Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:41:06 +0000 Subject: [PATCH 08/21] =?UTF-8?q?=E2=9C=A8=20imported=20std::bit=5Fcast?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/types.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ashura/std/types.h b/ashura/std/types.h index b438edc3..d7cf1a3e 100644 --- a/ashura/std/types.h +++ b/ashura/std/types.h @@ -359,6 +359,8 @@ constexpr i32 sat_mul(i32 a, i32 b) // [ ] sat_cast +using std::bit_cast; + template constexpr bool has_bits(T src, T cmp) { From e144c92705ad4b128fb9534165bfd9dff815418b Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:41:40 +0000 Subject: [PATCH 09/21] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactoring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/types.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ashura/std/types.h b/ashura/std/types.h index d7cf1a3e..b3e325b1 100644 --- a/ashura/std/types.h +++ b/ashura/std/types.h @@ -1905,8 +1905,9 @@ struct Fn { using Thunk = R (*)(void *, Args...); - void * data = nullptr; - Thunk thunk = nullptr; + void * data = nullptr; + + Thunk thunk = nullptr; explicit constexpr Fn() = default; @@ -2013,7 +2014,7 @@ auto fn(R (*pfn)(Args...)) /// @brief make a function view from a functor reference. Functor should outlive /// the Fn -template +template auto fn(F & functor) { using Traits = FunctorTraits; From 10ceb142939a9affa9b7ea9f9866cb0b695b3ac4 Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:41:59 +0000 Subject: [PATCH 10/21] =?UTF-8?q?=E2=9C=85=20updated=20list=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/tests/list.cc | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/ashura/std/tests/list.cc b/ashura/std/tests/list.cc index 3b0ba74b..786f9dbd 100644 --- a/ashura/std/tests/list.cc +++ b/ashura/std/tests/list.cc @@ -7,19 +7,26 @@ TEST(ListTest, Insertion) { using namespace ash; - ArenaPool pool; + u8 storage[512]; + Arena arena = to_arena(storage); - List l; - ListNode *x; - ListNode *y; - CHECK(pool.nalloc(1, x)); - CHECK(pool.nalloc(1, y)); - x->isolate(); - y->isolate(); + struct Node + { + Node *next = nullptr, *prev = nullptr; + int v = 0; + }; + List l; + Node * x; + Node * y; + CHECK(arena.nalloc(1, x)); + CHECK(arena.nalloc(1, y)); + + EXPECT_EQ(l.head(), nullptr); l.push_front(x); - EXPECT_NE(l.head, nullptr); - EXPECT_EQ(l.head, x); + EXPECT_NE(l.head(), nullptr); + + EXPECT_EQ(l.head(), x); EXPECT_EQ(l.pop_back(), x); EXPECT_EQ(l.pop_back(), nullptr); l.push_front(x); @@ -27,4 +34,4 @@ TEST(ListTest, Insertion) EXPECT_EQ(l.pop_back(), x); EXPECT_EQ(l.pop_back(), y); EXPECT_EQ(l.pop_back(), nullptr); -} \ No newline at end of file +} From 0738478021209cf8e1b91cbdf005d5af2845d58d Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:42:27 +0000 Subject: [PATCH 11/21] =?UTF-8?q?=E2=9C=A8=20added=20prototype=20for=20enu?= =?UTF-8?q?m=20visit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/enum.gen.h | 112 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/ashura/std/enum.gen.h b/ashura/std/enum.gen.h index 5195cc6e..931628e0 100644 --- a/ashura/std/enum.gen.h +++ b/ashura/std/enum.gen.h @@ -707,6 +707,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; template @@ -814,6 +821,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; template @@ -929,6 +943,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; template @@ -1052,6 +1073,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; template @@ -1183,6 +1211,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; template @@ -1322,6 +1357,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; template @@ -1469,6 +1511,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; template @@ -1624,6 +1673,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; template @@ -1787,6 +1843,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; template @@ -1958,6 +2021,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; template @@ -2137,6 +2207,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; template @@ -2324,6 +2401,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; template @@ -2519,6 +2603,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; template @@ -2722,6 +2813,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; template @@ -2933,6 +3031,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; template @@ -3152,6 +3257,13 @@ constexpr decltype(auto) match(Lambdas && ... lambdas) const } +template +constexpr decltype(auto) visit(Visitors && ... visitors); + +template +constexpr decltype(auto) visit(Visitors && ... visitors) const; + + }; } // namespace ash From f6f5ab185afe0a75cfa3188c44b236886219697c Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:43:06 +0000 Subject: [PATCH 12/21] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20changed=20to=20xxhas?= =?UTF-8?q?h=20header=20and=20inlined=20all=20xxhash=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/hash.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ashura/std/hash.cc b/ashura/std/hash.cc index 15a2e918..0b00477a 100644 --- a/ashura/std/hash.cc +++ b/ashura/std/hash.cc @@ -1,7 +1,8 @@ /// SPDX-License-Identifier: MIT +#define XXH_INLINE_ALL #include "ashura/std/hash.h" #include "ashura/std/types.h" -#include "xxh3.h" +#include "xxhash.h" namespace ash { From 62eef75979d9aac6b9c90d52e8fa62a456e6595b Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:43:25 +0000 Subject: [PATCH 13/21] =?UTF-8?q?=E2=9C=A8=20added=20identity=20hasher=20+?= =?UTF-8?q?=20refactoring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/hash.h | 58 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/ashura/std/hash.h b/ashura/std/hash.h index 56467d39..3e38c337 100644 --- a/ashura/std/hash.h +++ b/ashura/std/hash.h @@ -52,7 +52,61 @@ struct BitHasher } }; -constexpr StrHasher str_hash; -constexpr BitHasher bit_hash; +struct IdentityHasher +{ + constexpr hash64 operator()(u8 a) const + { + return static_cast(a); + } + + constexpr hash64 operator()(u16 a) const + { + return static_cast(a); + } + + constexpr hash64 operator()(u32 a) const + { + return static_cast(a); + } + + constexpr hash64 operator()(u64 a) const + { + return static_cast(a); + } + + constexpr hash64 operator()(i8 a) const + { + return static_cast(a); + } + + constexpr hash64 operator()(i16 a) const + { + return static_cast(a); + } + + constexpr hash64 operator()(i32 a) const + { + return static_cast(a); + } + + constexpr hash64 operator()(i64 a) const + { + return static_cast(a); + } + + constexpr hash64 operator()(f32 a) const + { + return static_cast(bit_cast(a)); + } + + constexpr hash64 operator()(f64 a) const + { + return bit_cast(a); + } +}; + +inline constexpr StrHasher str_hash; +inline constexpr BitHasher bit_hash; +inline constexpr IdentityHasher identity_hash; } // namespace ash From 922c23ef6da68e1478c70be11c572739f7a23063 Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:44:06 +0000 Subject: [PATCH 14/21] =?UTF-8?q?=F0=9F=8E=A8=20added=20assertion=20for=20?= =?UTF-8?q?lambda=20size?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/lambda.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ashura/std/lambda.h b/ashura/std/lambda.h index ad79b4c9..21c31ec4 100644 --- a/ashura/std/lambda.h +++ b/ashura/std/lambda.h @@ -27,6 +27,7 @@ struct Lambda; /// @tparam Alignment alignment of the internal storage in bytes /// @tparam Capacity capacity of the internal storage in bytes template +requires (Alignment > 0 && Capacity > 0) struct Lambda { static constexpr usize ALIGNMENT = Alignment; From abb8ddf5f5da5f8d0cf5a1677a35c967510ef074 Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:44:44 +0000 Subject: [PATCH 15/21] =?UTF-8?q?=F0=9F=8E=A8=20made=20lambda=20members=20?= =?UTF-8?q?private?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/lambda.h | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/ashura/std/lambda.h b/ashura/std/lambda.h index 21c31ec4..10971411 100644 --- a/ashura/std/lambda.h +++ b/ashura/std/lambda.h @@ -56,11 +56,11 @@ struct Lambda } }; - alignas(ALIGNMENT) mutable u8 storage[CAPACITY]; + alignas(ALIGNMENT) mutable u8 storage_[CAPACITY]; - Thunk thunk; + Thunk thunk_; - Lifecycle lifecycle; + Lifecycle lifecycle_; template requires (ALIGNMENT >= alignof(Functor) && CAPACITY >= sizeof(Functor) && @@ -69,10 +69,10 @@ struct Lambda constexpr Lambda(Functor functor, Thunk thunk = &FunctorThunk::thunk, Lifecycle lifecycle = LIFECYCLE) : - thunk{thunk}, - lifecycle{lifecycle} + thunk_{thunk}, + lifecycle_{lifecycle} { - new (storage) Functor{static_cast(functor)}; + new (storage_) Functor{static_cast(functor)}; } constexpr Lambda(Lambda const &) = delete; @@ -82,12 +82,12 @@ struct Lambda template requires (ALIGNMENT >= SrcAlignment && CAPACITY >= SrcCapacity) constexpr Lambda(Lambda && other) : - thunk{other.thunk}, - lifecycle{other.lifecycle} + thunk_{other.thunk_}, + lifecycle_{other.lifecycle_} { - other.lifecycle(other.storage, storage); - other.lifecycle = noop; - other.thunk = nullptr; + other.lifecycle_(other.storage_, storage_); + other.lifecycle_ = noop; + other.thunk_ = nullptr; } template @@ -103,24 +103,24 @@ struct Lambda } } - lifecycle(storage, nullptr); - other.lifecycle(other.storage, storage); - lifecycle = other.lifecycle; - other.lifecycle = noop; - thunk = other.thunk; - other.thunk = nullptr; + lifecycle_(storage_, nullptr); + other.lifecycle_(other.storage_, storage_); + lifecycle_ = other.lifecycle_; + other.lifecycle_ = noop; + thunk_ = other.thunk_; + other.thunk_ = nullptr; return *this; } constexpr ~Lambda() { - lifecycle(storage, nullptr); + lifecycle_(storage_, nullptr); } constexpr R operator()(Args... args) const { - return thunk(storage, static_cast(args)...); + return thunk_(storage_, static_cast(args)...); } }; From 1a20288a289d27becb5845049e337f639ac70748 Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:45:12 +0000 Subject: [PATCH 16/21] =?UTF-8?q?=F0=9F=8E=A8=20removed=20redundant=20func?= =?UTF-8?q?tor=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/lambda.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ashura/std/lambda.h b/ashura/std/lambda.h index 10971411..f135d2bf 100644 --- a/ashura/std/lambda.h +++ b/ashura/std/lambda.h @@ -62,7 +62,7 @@ struct Lambda Lifecycle lifecycle_; - template + template requires (ALIGNMENT >= alignof(Functor) && CAPACITY >= sizeof(Functor) && Callable && Convertible, R>) From 74ffe2bf73189e5525d26e2c433430627054d02a Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:45:54 +0000 Subject: [PATCH 17/21] =?UTF-8?q?=E2=9C=A8=20=F0=9F=8E=A8=20added=20new=20?= =?UTF-8?q?spatial=20alignment=20enums=20+=20made=20them=20inline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/math.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ashura/std/math.h b/ashura/std/math.h index 75a7a831..933e3a98 100644 --- a/ashura/std/math.h +++ b/ashura/std/math.h @@ -2542,11 +2542,15 @@ inline Vec2 rotor(f32 a) return Vec2{cos(a), sin(a)}; } -constexpr Vec2 ALIGNMENT_CENTER{0, 0}; -constexpr Vec2 ALIGNMENT_TOP_LEFT{-1, -1}; -constexpr Vec2 ALIGNMENT_TOP_RIGHT{1, -1}; -constexpr Vec2 ALIGNMENT_BOTTOM_LEFT{-1, 1}; -constexpr Vec2 ALIGNMENT_BOTTOM_RIGHT{1, 1}; +inline constexpr Vec2 ALIGNMENT_CENTER{0, 0}; +inline constexpr Vec2 ALIGNMENT_TOP_LEFT{-1, -1}; +inline constexpr Vec2 ALIGNMENT_TOP_CENTER{0, -1}; +inline constexpr Vec2 ALIGNMENT_TOP_RIGHT{1, -1}; +inline constexpr Vec2 ALIGNMENT_BOTTOM_LEFT{-1, 1}; +inline constexpr Vec2 ALIGNMENT_BOTTOM_CENTER{0, 1}; +inline constexpr Vec2 ALIGNMENT_BOTTOM_RIGHT{1, 1}; +inline constexpr Vec2 ALIGNMENT_LEFT_CENTER{-1, 0}; +inline constexpr Vec2 ALIGNMENT_RIGHT_CENTER{1, 0}; constexpr Vec4 opacity(f32 v) { From 5d78d88f9104e115ed54fa6186d6748cd442b5b7 Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:46:41 +0000 Subject: [PATCH 18/21] =?UTF-8?q?=F0=9F=8E=A8=20made=20super's=20members?= =?UTF-8?q?=20private?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/super.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/ashura/std/super.h b/ashura/std/super.h index 911ca38a..98d365ee 100644 --- a/ashura/std/super.h +++ b/ashura/std/super.h @@ -41,11 +41,11 @@ struct Super } }; - alignas(ALIGNMENT) mutable u8 storage[CAPACITY]; + alignas(ALIGNMENT) mutable u8 storage_[CAPACITY]; - Base * base_ptr; + Base * base_; - Lifecycle lifecycle; + Lifecycle lifecycle_; template requires (Derives && ALIGNMENT >= alignof(Object) && @@ -63,11 +63,11 @@ struct Super template requires (ALIGNMENT >= SrcAlignment && CAPACITY >= SrcCapacity) constexpr Super(Super && other) : - lifecycle{other.lifecycle} + lifecycle_{other.lifecycle_} { - other.lifecycle(other.storage, storage, &base_ptr); - other.lifecycle = noop; - other.base_ptr = nullptr; + other.lifecycle_(other.storage_, storage_, &base_); + other.lifecycle_ = noop; + other.base_ = nullptr; } template @@ -82,28 +82,28 @@ struct Super } } - lifecycle(storage, nullptr, nullptr); - other.lifecycle(other.storage, storage, &base_ptr); - lifecycle = other.lifecycle; - other.lifecycle = noop; - other.base_ptr = nullptr; + lifecycle_(storage_, nullptr, nullptr); + other.lifecycle_(other.storage_, storage_, &base_); + lifecycle_ = other.lifecycle_; + other.lifecycle_ = noop; + other.base_ = nullptr; return *this; } constexpr operator Base &() const { - return *base_ptr; + return *base_; } constexpr Base & get() const { - return *base_ptr; + return *base_; } constexpr ~Super() { - lifecycle(storage, nullptr, nullptr); + lifecycle_(storage_, nullptr, nullptr); } }; From 6b1cacf2337236032cdba9fb446be2cd64a5357d Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:47:50 +0000 Subject: [PATCH 19/21] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20fixed=20index=5Fappl?= =?UTF-8?q?y's=20tparam=20argument=20deduction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/tuple.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/ashura/std/tuple.h b/ashura/std/tuple.h index 8eae6f1d..6644ea05 100644 --- a/ashura/std/tuple.h +++ b/ashura/std/tuple.h @@ -64,22 +64,15 @@ constexpr decltype(auto) apply(F && f, Tuple && t) template constexpr decltype(auto) impl_index_apply(F && f, std::index_sequence) { - return f.template operator()(); + return static_cast(f).template operator()(); } -template +template constexpr decltype(auto) index_apply(F && f) { return impl_index_apply(static_cast(f), std::make_index_sequence{}); } -template -constexpr decltype(auto) zip_apply(F && f, Tuples &&... tuples) -{ - // [ ] impl - // apply over Index -} - template constexpr decltype(auto) impl_fold_reduce(Tuple & fns, In &&... in) { From ec6c360f2b873690630aa1f833c7115a09826295 Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:58:07 +0000 Subject: [PATCH 20/21] =?UTF-8?q?=F0=9F=90=9B=20fixed=20vec::clone=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/vec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ashura/std/vec.h b/ashura/std/vec.h index 5bf8f274..01e63e49 100644 --- a/ashura/std/vec.h +++ b/ashura/std/vec.h @@ -673,7 +673,7 @@ struct [[nodiscard]] PinVec return out; } - obj::copy_construct(span(), out.value().view()); + obj::copy_construct(view(), out.value().view()); return out; } From 331546f55f2068c494eb2d1c5e4be90b07568ed3 Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Thu, 5 Dec 2024 23:58:46 +0000 Subject: [PATCH 21/21] =?UTF-8?q?=F0=9F=8E=A8=20added=20const=20guards=20t?= =?UTF-8?q?o=20bitspan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/std/types.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ashura/std/types.h b/ashura/std/types.h index b3e325b1..befbfb94 100644 --- a/ashura/std/types.h +++ b/ashura/std/types.h @@ -1795,7 +1795,7 @@ struct BitSpan return ash::get_bit(repr_, index); } - constexpr void set(usize index, bool value) const + constexpr void set(usize index, bool value) const requires (NonConst) { ash::assign_bit(repr_, index, value); } @@ -1805,17 +1805,17 @@ struct BitSpan return ash::get_bit(repr_, index); } - constexpr bool set_bit(usize index) const + constexpr bool set_bit(usize index) const requires (NonConst) { return ash::set_bit(repr_, index); } - constexpr bool clear_bit(usize index) const + constexpr bool clear_bit(usize index) const requires (NonConst) { return ash::clear_bit(repr_, index); } - constexpr void flip_bit(usize index) const + constexpr void flip_bit(usize index) const requires (NonConst) { ash::flip_bit(repr_, index); }