From ed6d2f6007b572b907e3cb11b4303c13d1572c9c Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 18 Dec 2025 09:04:13 +0100 Subject: chore: specification updates and patches on the DDK, new source `ddk_c++.cc`. Signed-off-by: Amlal El Mahrouss --- src/kernel/NeKit/Atom.h | 24 +++++++++++++++--------- src/kernel/NeKit/InitializerList.h | 25 ++++++++++++++++--------- 2 files changed, 31 insertions(+), 18 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/NeKit/Atom.h b/src/kernel/NeKit/Atom.h index 7c4ebb5b..7deff14e 100644 --- a/src/kernel/NeKit/Atom.h +++ b/src/kernel/NeKit/Atom.h @@ -3,12 +3,14 @@ Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. ======================================== */ -#pragma once + +#ifndef __NE_KIT_ATOM_H__ +#define __NE_KIT_ATOM_H__ #include namespace Kernel { -template +template class Atom final { public: explicit Atom() = default; @@ -19,15 +21,19 @@ class Atom final { Atom(const Atom&) = delete; public: - T operator[](Size bit) { return (fArrayOfAtoms & (1 << bit)); } - - void operator|(Size bit) { fArrayOfAtoms |= (1 << bit); } + using Type = TypeAtomic; + + const TypeAtomic& operator[](const SizeT& bit) { return (fArrayOfAtoms & (1 << bit)); } - friend Boolean operator==(Atom& atomic, const T& idx) { return atomic[idx] == idx; } - - friend Boolean operator!=(Atom& atomic, const T& idx) { return atomic[idx] != idx; } + void operator|(const SizeT& bit) { fArrayOfAtoms |= (1 << bit); } + Atom& operator|=(const SizeT& bit) { this->operator|(bit); return *this; } + + friend bool operator==(Atom& atomic, const TypeAtomic& idx) { return atomic[idx] == idx; } + friend bool operator!=(Atom& atomic, const TypeAtomic& idx) { return atomic[idx] != idx; } private: - T fArrayOfAtoms; + TypeAtomic fArrayOfAtoms; }; } // namespace Kernel + +#endif diff --git a/src/kernel/NeKit/InitializerList.h b/src/kernel/NeKit/InitializerList.h index d918ba85..46639d4d 100644 --- a/src/kernel/NeKit/InitializerList.h +++ b/src/kernel/NeKit/InitializerList.h @@ -1,19 +1,23 @@ /* ======================================== - Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. ======================================== */ -#pragma once +#ifndef __NE_KIT_INIT_LIST_H__ +#define __NE_KIT_INIT_LIST_H__ #include #include namespace Kernel { -template + // \brief Initalizer List object for containers. +template class InitializerList final { public: - explicit InitializerList(const T* list) { + InitializerList() = delete; + + explicit InitializerList(const Type* list) { if constexpr (N > 0) { for (auto i = 0UL; i < N; ++i) { fList[i] = list[i]; @@ -26,17 +30,20 @@ class InitializerList final { InitializerList& operator=(const InitializerList&) = delete; InitializerList(const InitializerList&) = delete; - T* begin() { return fList; } - T* end() { return fList + N; } + Type* begin() { return fList; } + Type* end() { return fList + N; } + constexpr SizeT size() const { return N; } - T* operator->() { return fList; } - T* operator*() { return fList; } + Type* operator->() { return this->begin(); } + Type* operator*() { return this->begin(); } private: - T fList[N]; + Type fList[N]; }; template using ErrorOrList = ErrorOr>; } // namespace Kernel + +#endif -- cgit v1.2.3