summaryrefslogtreecommitdiffhomepage
path: root/Private/NewKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-28 16:26:33 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-28 16:26:33 +0100
commit06be6d65bb71152be8a28d7bb6b1028b5a588654 (patch)
treeb47625ad70e5ec6093187f9d454f4edeaffb5ed1 /Private/NewKit
parentf69bd40d5d97e371451d2e9c27721422141d828f (diff)
NewKernel: Final things are getting done for the first prototype.
NewBoot: Add ARM64 to HEL. SPEC: Update it to include NewFS into it. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/NewKit')
-rw-r--r--Private/NewKit/Json.hpp128
-rw-r--r--Private/NewKit/KHeap.hpp4
-rw-r--r--Private/NewKit/Panic.hpp20
3 files changed, 80 insertions, 72 deletions
diff --git a/Private/NewKit/Json.hpp b/Private/NewKit/Json.hpp
index 867df909..7c1a85e4 100644
--- a/Private/NewKit/Json.hpp
+++ b/Private/NewKit/Json.hpp
@@ -13,95 +13,101 @@
// last-rev: 5/11/23
#include <NewKit/Defines.hpp>
-#include <NewKit/String.hpp>
#include <NewKit/Stream.hpp>
+#include <NewKit/String.hpp>
#include <NewKit/Utils.hpp>
#include <CompilerKit/Compiler.hpp>
namespace hCore
{
- class JsonType final
+class JsonType final
+{
+ public:
+ explicit JsonType() : hCore::JsonType(1, 1)
{
- public:
- explicit JsonType(SizeT lhsLen, SizeT rhsLen)
- : fKey(lhsLen), fValue(rhsLen)
- {}
+ }
- ~JsonType() = default;
+ explicit JsonType(SizeT lhsLen, SizeT rhsLen) : fKey(lhsLen), fValue(rhsLen)
+ {
+ }
- HCORE_COPY_DEFAULT(JsonType);
+ ~JsonType() = default;
- private:
- StringView fKey;
- StringView fValue;
+ HCORE_COPY_DEFAULT(JsonType);
- public:
- StringView& AsKey() { return fKey; }
- StringView& AsValue() { return fValue; }
+ private:
+ StringView fKey;
+ StringView fValue;
- static JsonType kUndefined;
+ public:
+ StringView &AsKey()
+ {
+ return fKey;
+ }
- };
-
- struct JsonStreamTraits final
+ StringView &AsValue()
{
- JsonType In(const char* full_array)
+ return fValue;
+ }
+
+ static JsonType kUndefined;
+};
+
+struct JsonStreamTraits final
+{
+ JsonType In(const char *full_array)
+ {
+ SizeT len = string_length(full_array);
+
+ if (full_array[0] == '\"' && full_array[len - 1] == ',' || full_array[len - 1] == '\"')
{
- SizeT len = string_length(full_array);
+ Boolean probe_key = true;
+
+ SizeT key_len = 0;
+ SizeT value_len = 0;
- if (full_array[0] == '\"' &&
- full_array[len - 1] == ',' ||
- full_array[len - 1] == '\"')
+ for (SizeT i = 1; i < len; i++)
{
- Boolean probe_key = true;
+ if (full_array[i] == ' ')
+ continue;
- SizeT key_len = 0;
- SizeT value_len = 0;
+ JsonType type(255, 255);
- for (SizeT i = 1; i < len; i++)
+ if (probe_key)
{
- if (full_array[i] == ' ')
- continue;
+ type.AsKey().Data()[key_len] = full_array[i];
+ ++key_len;
- JsonType type(255, 255);
-
- if (probe_key)
+ if (full_array[i] == '\"')
{
- type.AsKey().Data()[key_len] = full_array[i];
- ++key_len;
-
- if (full_array[i] == '\"')
- {
- probe_key = false;
- type.AsKey().Data()[key_len] = 0;
-
- ++i;
- }
+ probe_key = false;
+ type.AsKey().Data()[key_len] = 0;
+
+ ++i;
}
- else
- {
- type.AsValue().Data()[value_len] = full_array[i];
- ++value_len;
+ }
+ else
+ {
+ type.AsValue().Data()[value_len] = full_array[i];
+ ++value_len;
- if (full_array[i] == '\"')
- {
- type.AsValue().Data()[value_len] = 0;
- }
+ if (full_array[i] == '\"')
+ {
+ type.AsValue().Data()[value_len] = 0;
}
}
-
}
-
- return JsonType::kUndefined;
}
- JsonType Out(JsonType& out)
- {
- return out;
- }
-
- };
+ return JsonType::kUndefined;
+ }
+
+ JsonType Out(JsonType &out)
+ {
+ return out;
+ }
+};
- using JsonStream = Stream<JsonStreamTraits, JsonType>;
-} \ No newline at end of file
+using JsonStream = Stream<JsonStreamTraits, JsonType>;
+} // namespace hCore
diff --git a/Private/NewKit/KHeap.hpp b/Private/NewKit/KHeap.hpp
index debe23ee..7c9802d7 100644
--- a/Private/NewKit/KHeap.hpp
+++ b/Private/NewKit/KHeap.hpp
@@ -18,6 +18,6 @@
namespace hCore
{
- Int32 kernel_delete_ptr(voidPtr ptr);
- voidPtr kernel_new_ptr(const SizeT& sz, const bool rw, const bool user);
+Int32 kernel_delete_ptr(voidPtr allocatedPtr);
+voidPtr kernel_new_ptr(const SizeT &sz, const bool rw, const bool user);
} // namespace hCore
diff --git a/Private/NewKit/Panic.hpp b/Private/NewKit/Panic.hpp
index b894d852..4e461587 100644
--- a/Private/NewKit/Panic.hpp
+++ b/Private/NewKit/Panic.hpp
@@ -14,7 +14,7 @@
namespace hCore
{
- void runtime_check(bool bExpression, const char *file, const char *line);
+void runtime_check(bool bExpression, const char *file, const char *line);
}
#define MUST_PASS_COMPILER(EXPR, MSG) static_assert(EXPR, MSG)
@@ -41,22 +41,24 @@ enum RUNTIME_CHECK
namespace hCore
{
- class DumpManager final
+class DumpManager final
+{
+ public:
+ static void Dump(void)
{
- public:
- static void Dump(void)
- {
- // TODO:
- }
- };
+ // TODO:
+ }
+};
- void panic(const Int &id);
+void panic(const Int &id);
} // namespace hCore
#ifdef TRY
#undef TRY
#endif
+#define INIT(OBJ, TYPE, ...) TYPE OBJ = TYPE(__VA_ARGS__)
+
#define TRY(FN) \
if (!FN()) \
{ \