summaryrefslogtreecommitdiffhomepage
path: root/src/kernel/NeKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-12-18 09:04:13 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-12-18 09:04:13 +0100
commited6d2f6007b572b907e3cb11b4303c13d1572c9c (patch)
tree47f177336db980a138a91a2fb109db8f1a65086c /src/kernel/NeKit
parent3a5c7473910156051951f8ec98488a6c91a3eabd (diff)
chore: specification updates and patches on the DDK, new source `ddk_c++.cc`.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/kernel/NeKit')
-rw-r--r--src/kernel/NeKit/Atom.h24
-rw-r--r--src/kernel/NeKit/InitializerList.h25
2 files changed, 31 insertions, 18 deletions
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 <NeKit/Config.h>
namespace Kernel {
-template <typename T>
+template <class TypeAtomic>
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<T>& atomic, const T& idx) { return atomic[idx] == idx; }
-
- friend Boolean operator!=(Atom<T>& 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<TypeAtomic>& atomic, const TypeAtomic& idx) { return atomic[idx] == idx; }
+ friend bool operator!=(Atom<TypeAtomic>& 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 <NeKit/Config.h>
#include <NeKit/ErrorOr.h>
namespace Kernel {
-template <class T, SizeT N>
+ // \brief Initalizer List object for containers.
+template <class Type, SizeT N>
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 <class T, SizeT N>
using ErrorOrList = ErrorOr<InitializerList<T, N>>;
} // namespace Kernel
+
+#endif