diff options
| author | Amlal <amlalelmahrouss@icloud.com> | 2024-07-28 16:11:46 +0000 |
|---|---|---|
| committer | Amlal <amlalelmahrouss@icloud.com> | 2024-07-28 16:11:46 +0000 |
| commit | c4023005e029ae092dad2689564c490580dd5c28 (patch) | |
| tree | 3080ba07a6b552bf3d7591574cf69b2a3c8fd0fd /Kernel/NewKit | |
| parent | 8c8822fff78f9ff9cd640271da9b3634c4c2f97f (diff) | |
| parent | 4db57a2d646b1538783a0675b38bada7a0f903ae (diff) | |
Merged in MHR-36 (pull request #17)
MHR-36
Diffstat (limited to 'Kernel/NewKit')
| -rw-r--r-- | Kernel/NewKit/ApplicationInterface.hxx | 31 | ||||
| -rw-r--r-- | Kernel/NewKit/Array.hpp | 2 | ||||
| -rw-r--r-- | Kernel/NewKit/ArrayList.hpp | 2 | ||||
| -rw-r--r-- | Kernel/NewKit/Atom.hpp | 2 | ||||
| -rw-r--r-- | Kernel/NewKit/Crc32.hpp | 2 | ||||
| -rw-r--r-- | Kernel/NewKit/CxxAbi.hpp | 6 | ||||
| -rw-r--r-- | Kernel/NewKit/Defines.hpp | 18 | ||||
| -rw-r--r-- | Kernel/NewKit/ErrorOr.hpp | 6 | ||||
| -rw-r--r-- | Kernel/NewKit/Json.hpp | 118 | ||||
| -rw-r--r-- | Kernel/NewKit/Json.hxx | 134 | ||||
| -rw-r--r-- | Kernel/NewKit/KernelCheck.hpp | 10 | ||||
| -rw-r--r-- | Kernel/NewKit/Macros.hpp | 32 | ||||
| -rw-r--r-- | Kernel/NewKit/MutableArray.hpp | 2 | ||||
| -rw-r--r-- | Kernel/NewKit/New.hpp | 4 | ||||
| -rw-r--r-- | Kernel/NewKit/NewKit.hpp | 8 | ||||
| -rw-r--r-- | Kernel/NewKit/OwnPtr.hpp | 4 | ||||
| -rw-r--r-- | Kernel/NewKit/PageAllocator.hpp | 2 | ||||
| -rw-r--r-- | Kernel/NewKit/PageManager.hpp | 4 | ||||
| -rw-r--r-- | Kernel/NewKit/Pair.hpp | 2 | ||||
| -rw-r--r-- | Kernel/NewKit/Pmm.hpp | 4 | ||||
| -rw-r--r-- | Kernel/NewKit/Ref.hxx (renamed from Kernel/NewKit/Ref.hpp) | 41 | ||||
| -rw-r--r-- | Kernel/NewKit/Stream.hpp | 4 | ||||
| -rw-r--r-- | Kernel/NewKit/String.hpp | 15 | ||||
| -rw-r--r-- | Kernel/NewKit/Utils.hpp | 2 | ||||
| -rw-r--r-- | Kernel/NewKit/Variant.hpp | 22 |
25 files changed, 257 insertions, 220 deletions
diff --git a/Kernel/NewKit/ApplicationInterface.hxx b/Kernel/NewKit/ApplicationInterface.hxx deleted file mode 100644 index 66737db7..00000000 --- a/Kernel/NewKit/ApplicationInterface.hxx +++ /dev/null @@ -1,31 +0,0 @@ -/* ------------------------------------------- - - Copyright Zeta Electronics Corporation - -------------------------------------------- */ - -#pragma once - -/// -/// @brief Application object, given by the OS to the process. interact with the OS. -/// @file ApplicationInterface.hxx -/// @author Amlal EL Mahrouss -/// - -#include <NewKit/Defines.hpp> -#include <CFKit/GUIDWrapper.hpp> - -/// \brief Application Interface. -/// \author Amlal El Mahrouss -typedef struct _ApplicationInterface final -{ - /// @brief Releases the object exit the process on main object. - Kernel::Void (*Release)(struct _Application* Self, Kernel::Int32 ExitCode); - /// @brief Invoke a function from the application object. - Kernel::IntPtr (*Invoke)(struct _Application* Self, Kernel::Int32 Sel, ...); - /// @brief Query a new application object from a GUID. - /// @note this doesn't query a process, it query a registered object withtin that app. - Kernel::Void (*Query)(struct _Application* Self, Kernel::VoidPtr* Dst, Kernel::SizeT SzDst, Kernel::XRN::GUIDSequence GuidOf); -} ApplicationInterface, *ApplicationInterfaceRef; - -#define app_cast reinterpret_cast<ApplicationInterfaceRef> diff --git a/Kernel/NewKit/Array.hpp b/Kernel/NewKit/Array.hpp index 447d2616..bf630563 100644 --- a/Kernel/NewKit/Array.hpp +++ b/Kernel/NewKit/Array.hpp @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ #pragma once diff --git a/Kernel/NewKit/ArrayList.hpp b/Kernel/NewKit/ArrayList.hpp index e701f10b..38889a67 100644 --- a/Kernel/NewKit/ArrayList.hpp +++ b/Kernel/NewKit/ArrayList.hpp @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ diff --git a/Kernel/NewKit/Atom.hpp b/Kernel/NewKit/Atom.hpp index 69d485fb..a3e98a4b 100644 --- a/Kernel/NewKit/Atom.hpp +++ b/Kernel/NewKit/Atom.hpp @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ #pragma once diff --git a/Kernel/NewKit/Crc32.hpp b/Kernel/NewKit/Crc32.hpp index c7d42710..c9c8d311 100644 --- a/Kernel/NewKit/Crc32.hpp +++ b/Kernel/NewKit/Crc32.hpp @@ -2,7 +2,7 @@ * ======================================================== * * Kernel Date Added: 13/02/2023 - * Copyright Zeta Electronics Corporation, all rights reserved. + * Copyright ZKA Technologies, all rights reserved. * * ======================================================== */ diff --git a/Kernel/NewKit/CxxAbi.hpp b/Kernel/NewKit/CxxAbi.hpp index 3f858e21..00d136ec 100644 --- a/Kernel/NewKit/CxxAbi.hpp +++ b/Kernel/NewKit/CxxAbi.hpp @@ -1,13 +1,13 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ #pragma once #include <NewKit/Defines.hpp> -#ifdef __GNUC__ +#ifndef __NDK__ #define kDSOMaxObjects (128) @@ -25,4 +25,4 @@ namespace cxxabiv1 typedef void* __guard; } -#endif // __GNUC__
\ No newline at end of file +#endif // __GNUC__ diff --git a/Kernel/NewKit/Defines.hpp b/Kernel/NewKit/Defines.hpp index af8978da..606449ec 100644 --- a/Kernel/NewKit/Defines.hpp +++ b/Kernel/NewKit/Defines.hpp @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ @@ -133,18 +133,18 @@ namespace Kernel }; } // namespace Kernel -#define DEDUCE_ENDIAN(address, value) \ +#define DEDUCE_ENDIAN(address, value) \ (((reinterpret_cast<Kernel::Char*>(address)[0]) == (value)) \ ? (Kernel::Endian::kEndianBig) \ : (Kernel::Endian::kEndianLittle)) -#define Yes (true) -#define No (false) +#define Yes true +#define No false -#define VoidStar Kernel::voidPtr +#define VoidStar Kernel::VoidPtr -#ifdef INIT -#undef INIT -#endif // ifdef INIT +#ifdef cInitObject +#undef cInitObject +#endif // ifdef cInitObject -#define INIT(OBJ, TYPE, ...) TYPE OBJ = TYPE(__VA_ARGS__) +#define cInitObject(OBJ, TYPE, ...) TYPE OBJ = TYPE(__VA_ARGS__) diff --git a/Kernel/NewKit/ErrorOr.hpp b/Kernel/NewKit/ErrorOr.hpp index 34697d8a..7e261abf 100644 --- a/Kernel/NewKit/ErrorOr.hpp +++ b/Kernel/NewKit/ErrorOr.hpp @@ -2,7 +2,7 @@ * ======================================================== * * Kernel - * Copyright Zeta Electronics Corporation, all rights reserved. + * Copyright ZKA Technologies, all rights reserved. * * ======================================================== */ @@ -10,7 +10,7 @@ #pragma once #include <NewKit/Defines.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> namespace Kernel { @@ -34,7 +34,7 @@ namespace Kernel } explicit ErrorOr(T Class) - : mRef(Class) + : mRef(Class, true) { } diff --git a/Kernel/NewKit/Json.hpp b/Kernel/NewKit/Json.hpp deleted file mode 100644 index b2a0d872..00000000 --- a/Kernel/NewKit/Json.hpp +++ /dev/null @@ -1,118 +0,0 @@ - -/* ------------------------------------------- - - Copyright Zeta Electronics Corporation - -------------------------------------------- */ - -#pragma once - -// last-rev: 30/01/24 - -#include <CompilerKit/CompilerKit.hxx> -#include <NewKit/Defines.hpp> -#include <NewKit/Stream.hpp> -#include <NewKit/String.hpp> -#include <NewKit/Utils.hpp> - -namespace Kernel -{ - /// @brief Json value class - class JsonType final - { - public: - explicit JsonType() - : Kernel::JsonType(1, 1) - { - } - - explicit JsonType(SizeT lhsLen, SizeT rhsLen) - : fKey(lhsLen), fValue(rhsLen) - { - } - - ~JsonType() = default; - - NEWOS_COPY_DEFAULT(JsonType); - - private: - StringView fKey; - StringView fValue; - - public: - /// @brief returns the key of the json - /// @return the key as string view. - StringView& AsKey() - { - return fKey; - } - - /// @brief returns the value of the json. - /// @return the key as string view. - StringView& AsValue() - { - return fValue; - } - - static JsonType kUndefined; - }; - - /// @brief Json stream helper class. - struct JsonStreamTrait final - { - JsonType In(const char* full_array) - { - SizeT len = rt_string_len(full_array); - - if (full_array[0] == '\"' && full_array[len - 1] == ',' || - full_array[len - 1] == '\"') - { - Boolean probe_key = true; - - SizeT key_len = 0; - SizeT value_len = 0; - - for (SizeT i = 1; i < len; i++) - { - if (full_array[i] == ' ') - continue; - - JsonType type(kPathLen, kPathLen); - - if (probe_key) - { - type.AsKey().Data()[key_len] = full_array[i]; - ++key_len; - - if (full_array[i] == '\"') - { - probe_key = false; - type.AsKey().Data()[key_len] = 0; - - ++i; - } - } - else - { - type.AsValue().Data()[value_len] = full_array[i]; - ++value_len; - - if (full_array[i] == '\"') - { - type.AsValue().Data()[value_len] = 0; - } - } - } - } - - return JsonType::kUndefined; - } - - JsonType Out(JsonType& out) - { - return out; - } - }; - - using JsonStream = Stream<JsonStreamTrait, JsonType>; -} // namespace Kernel diff --git a/Kernel/NewKit/Json.hxx b/Kernel/NewKit/Json.hxx new file mode 100644 index 00000000..9371bf15 --- /dev/null +++ b/Kernel/NewKit/Json.hxx @@ -0,0 +1,134 @@ + +/* ------------------------------------------- + + Copyright ZKA Technologies + +------------------------------------------- */ + +#pragma once + +// last-rev: 30/01/24 + +#include <CompilerKit/CompilerKit.hxx> +#include <NewKit/Defines.hpp> +#include <NewKit/Stream.hpp> +#include <NewKit/String.hpp> +#include <NewKit/Utils.hpp> + +#define cMaxJsonPath 4096 +#define cJSONLen 32 +#define cJSONNull "null" + +namespace Kernel +{ + /// @brief Json value class + class JsonType final + { + public: + explicit JsonType() + { + auto len = cJSONLen; + StringView key = StringView(len); + key += cJSONNull; + + this->AsKey() = key; + this->AsValue() = key; + } + + explicit JsonType(SizeT lhsLen, SizeT rhsLen) + : fKey(lhsLen), fValue(rhsLen) + { + } + + ~JsonType() = default; + + NEWOS_COPY_DEFAULT(JsonType); + + const Bool& IsUndefined() { return fUndefined; } + + private: + Bool fUndefined; // is this instance undefined? + StringView fKey; + StringView fValue; + + public: + /// @brief returns the key of the json + /// @return the key as string view. + StringView& AsKey() + { + return fKey; + } + + /// @brief returns the value of the json. + /// @return the key as string view. + StringView& AsValue() + { + return fValue; + } + + static JsonType kNull; + }; + + /// @brief Json stream reader helper. + struct JsonStreamReader final + { + STATIC JsonType In(const Char* full_array) + { + if (full_array[0] != '{') + return JsonType::kNull; + + SizeT len = rt_string_len(full_array); + Boolean probe_value = false; + + SizeT key_len = 0; + SizeT value_len = 0; + + JsonType type(cMaxJsonPath, cMaxJsonPath); + + for (SizeT i = 1; i < len; ++i) + { + if (full_array[i] == '\r' || + full_array[i] == '\n') + continue; + + if (probe_value) + { + if (full_array[i] == '}' || + full_array[i] == ',') + { + probe_value = false; + + ++value_len; + } + else + { + type.AsValue().Data()[value_len] = full_array[i]; + + ++value_len; + } + } + else + { + if (full_array[i] == ':') + { + probe_value = true; + type.AsKey().Data()[key_len] = 0; + ++key_len; + } + else + { + type.AsKey().Data()[key_len] = full_array[i]; + + ++key_len; + } + } + } + + type.AsValue().Data()[value_len] = 0; + + return type; + } + }; + + using JsonStream = Stream<JsonStreamReader, JsonType>; +} // namespace Kernel diff --git a/Kernel/NewKit/KernelCheck.hpp b/Kernel/NewKit/KernelCheck.hpp index ae1eec51..ed74e38f 100644 --- a/Kernel/NewKit/KernelCheck.hpp +++ b/Kernel/NewKit/KernelCheck.hpp @@ -1,7 +1,7 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ @@ -40,13 +40,11 @@ enum RUNTIME_CHECK namespace Kernel { - class DumpManager final + /// @brief Dumping factory class. + class RecoveryFactory final { public: - static void Dump(void) - { - // TODO: - } + STATIC Void Recover() noexcept; }; void ke_stop(const Int& id); diff --git a/Kernel/NewKit/Macros.hpp b/Kernel/NewKit/Macros.hpp index 1f121a37..ba636874 100644 --- a/Kernel/NewKit/Macros.hpp +++ b/Kernel/NewKit/Macros.hpp @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ @@ -10,18 +10,34 @@ #define KIB(X) ((X) / 1024) #endif +#ifndef kib_cast +#define kib_cast(X) ((X) * 1024) +#endif + #ifndef MIB #define MIB(X) ((UInt64)KIB(X) / 1024) #endif +#ifndef mib_cast +#define mib_cast(X) ((UInt64)kib_cast(X) * 1024) +#endif + #ifndef GIB #define GIB(X) ((UInt64)MIB(X) / 1024) #endif +#ifndef gib_cast +#define gib_cast(X) ((UInt64)mib_cast(X) * 1024) +#endif + #ifndef TIB #define TIB(X) ((UInt64)GIB(X) / 1024) #endif +#ifndef tib_cast +#define tib_cast(X) ((UInt64)gib_cast(X) * 1024) +#endif + #ifndef ARRAY_SIZE #define ARRAY_SIZE(a) \ (((sizeof(a) / sizeof(*(a))) / \ @@ -37,7 +53,7 @@ #endif // #ifndef ATTRIBUTE #ifndef __MAHROUSS__ -#define __MAHROUSS__ (202401) +#define __MAHROUSS__ (202404) #endif // !__MAHROUSS__ #ifndef EXTERN_C @@ -63,16 +79,16 @@ #endif #ifndef ENUM_STRING -#define ENUM_STRING(NAME, VAL) inline constexpr const char* NAME = VAL +#define ENUM_STRING(NAME, VAL) inline constexpr const char* e##NAME = VAL #endif #ifndef END_STRING_ENUM #define END_STRING_ENUM() } #endif -#ifndef Alloca -#define Alloca(Sz) __builtin_alloca(Sz) -#endif // #ifndef Alloca +#ifndef ALLOCA +#define ALLOCA(Sz) __builtin_alloca(Sz) +#endif // #ifndef ALLOCA #ifndef CANT_REACH #define CANT_REACH() __builtin_unreachable() @@ -91,8 +107,8 @@ #define CONST const #define STRINGIFY(X) #X -#define NEWOS_UNUSED(X) ((void)X) +#define NEWOS_UNUSED(X) ((Kernel::Void)X) #ifndef RGB -#define RGB(R, G, B) (UInt32)(0x##R##G##B) +#define RGB(R, G, B) (Kernel::UInt32)(R | G << 0x8 | B << 0x10) #endif // !RGB diff --git a/Kernel/NewKit/MutableArray.hpp b/Kernel/NewKit/MutableArray.hpp index 6f30b0f9..58038e8f 100644 --- a/Kernel/NewKit/MutableArray.hpp +++ b/Kernel/NewKit/MutableArray.hpp @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ #pragma once diff --git a/Kernel/NewKit/New.hpp b/Kernel/NewKit/New.hpp index 33e5c163..eade355d 100644 --- a/Kernel/NewKit/New.hpp +++ b/Kernel/NewKit/New.hpp @@ -1,12 +1,12 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ #pragma once -#include <KernelKit/KernelHeap.hpp> +#include <KernelKit/Heap.hxx> typedef __SIZE_TYPE__ size_t; // gcc will complain about that diff --git a/Kernel/NewKit/NewKit.hpp b/Kernel/NewKit/NewKit.hpp index bf04eb0b..144a0ea9 100644 --- a/Kernel/NewKit/NewKit.hpp +++ b/Kernel/NewKit/NewKit.hpp @@ -1,7 +1,7 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ @@ -10,13 +10,13 @@ #include <NewKit/Array.hpp> #include <NewKit/ArrayList.hpp> #include <NewKit/ErrorOr.hpp> -#include <NewKit/Json.hpp> +#include <NewKit/Json.hxx> #include <NewKit/KernelCheck.hpp> #include <KernelKit/LockDelegate.hpp> #include <NewKit/MutableArray.hpp> #include <NewKit/New.hpp> #include <NewKit/OwnPtr.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> #include <NewKit/Stream.hpp> -#include <KernelKit/UserHeap.hpp> +#include <KernelKit/ProcessHeap.hxx> #include <NewKit/Utils.hpp> diff --git a/Kernel/NewKit/OwnPtr.hpp b/Kernel/NewKit/OwnPtr.hpp index 2d7cf65b..6157a1b6 100644 --- a/Kernel/NewKit/OwnPtr.hpp +++ b/Kernel/NewKit/OwnPtr.hpp @@ -1,7 +1,7 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ @@ -9,7 +9,7 @@ #include <NewKit/Defines.hpp> #include <NewKit/KernelCheck.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> namespace Kernel { diff --git a/Kernel/NewKit/PageAllocator.hpp b/Kernel/NewKit/PageAllocator.hpp index 40da5129..f7697488 100644 --- a/Kernel/NewKit/PageAllocator.hpp +++ b/Kernel/NewKit/PageAllocator.hpp @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ diff --git a/Kernel/NewKit/PageManager.hpp b/Kernel/NewKit/PageManager.hpp index 233ced0a..57b842ba 100644 --- a/Kernel/NewKit/PageManager.hpp +++ b/Kernel/NewKit/PageManager.hpp @@ -3,7 +3,7 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ @@ -11,7 +11,7 @@ #include <NewKit/Defines.hpp> #include <NewKit/PageAllocator.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> #ifndef kBadAddress #define kBadAddress (0) diff --git a/Kernel/NewKit/Pair.hpp b/Kernel/NewKit/Pair.hpp index 7a7df020..2cf89f59 100644 --- a/Kernel/NewKit/Pair.hpp +++ b/Kernel/NewKit/Pair.hpp @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ diff --git a/Kernel/NewKit/Pmm.hpp b/Kernel/NewKit/Pmm.hpp index fc020fea..46db1879 100644 --- a/Kernel/NewKit/Pmm.hpp +++ b/Kernel/NewKit/Pmm.hpp @@ -1,14 +1,14 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ #pragma once #include <NewKit/PageManager.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> namespace Kernel { diff --git a/Kernel/NewKit/Ref.hpp b/Kernel/NewKit/Ref.hxx index 0d5550fa..69150054 100644 --- a/Kernel/NewKit/Ref.hpp +++ b/Kernel/NewKit/Ref.hxx @@ -1,11 +1,12 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ -#pragma once +#ifndef _NEWKIT_REF_HPP_ +#define _NEWKIT_REF_HPP_ #include <NewKit/Defines.hpp> #include <NewKit/KernelCheck.hpp> @@ -17,34 +18,47 @@ namespace Kernel { public: Ref() = default; - ~Ref() = default; + + ~Ref() + { + if (fStrong) + { + fClass = nullptr; + } + } public: Ref(T cls, const bool& strong = false) - : fClass(cls), fStrong(strong) + : fClass(&cls), fStrong(strong) { } Ref& operator=(T ref) { - fClass = ref; + *fClass = ref; return *this; } public: T operator->() const { - return fClass; + return *fClass; } - T& Leak() + T& Leak() noexcept { - return fClass; + return *fClass; + } + + T& TryLeak() const noexcept + { + MUST_PASS(*fClass); + return *fClass; } T operator*() { - return fClass; + return *fClass; } bool IsStrong() const @@ -52,14 +66,14 @@ namespace Kernel return fStrong; } - operator bool() + operator bool() noexcept { return fStrong; } private: - T fClass; - bool fStrong{false}; + T* fClass; + Bool fStrong{false}; }; template <typename T> @@ -72,6 +86,7 @@ namespace Kernel NonNullRef(T* ref) : fRef(ref, true) { + MUST_PASS(ref != nullptr); } Ref<T>& operator->() @@ -87,3 +102,5 @@ namespace Kernel Ref<T> fRef{nullptr}; }; } // namespace Kernel + +#endif // ifndef _NEWKIT_REF_HPP_ diff --git a/Kernel/NewKit/Stream.hpp b/Kernel/NewKit/Stream.hpp index bd64910e..eefb0a1c 100644 --- a/Kernel/NewKit/Stream.hpp +++ b/Kernel/NewKit/Stream.hpp @@ -1,14 +1,14 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ #pragma once #include <NewKit/Defines.hpp> -#include <NewKit/Ref.hpp> +#include <NewKit/Ref.hxx> namespace Kernel { diff --git a/Kernel/NewKit/String.hpp b/Kernel/NewKit/String.hpp index f9ab9aa4..7440900c 100644 --- a/Kernel/NewKit/String.hpp +++ b/Kernel/NewKit/String.hpp @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ @@ -8,6 +8,7 @@ #include <NewKit/Defines.hpp> #include <NewKit/ErrorOr.hpp> +#include <NewKit/Utils.hpp> #include <NewKit/KernelCheck.hpp> namespace Kernel @@ -15,7 +16,15 @@ namespace Kernel class StringView final { public: - explicit StringView() = default; + explicit StringView() + { + fSz = 4096; + + fData = new Char[fSz]; + MUST_PASS(fData); + + rt_set_memory(fData, 0, fSz); + } explicit StringView(Size Sz) : fSz(Sz) @@ -23,6 +32,8 @@ namespace Kernel MUST_PASS(Sz > 1); fData = new Char[Sz]; MUST_PASS(fData); + + rt_set_memory(fData, 0, Sz); } ~StringView() diff --git a/Kernel/NewKit/Utils.hpp b/Kernel/NewKit/Utils.hpp index 22192135..32749560 100644 --- a/Kernel/NewKit/Utils.hpp +++ b/Kernel/NewKit/Utils.hpp @@ -1,7 +1,7 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ diff --git a/Kernel/NewKit/Variant.hpp b/Kernel/NewKit/Variant.hpp index ee14216a..c118eda1 100644 --- a/Kernel/NewKit/Variant.hpp +++ b/Kernel/NewKit/Variant.hpp @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright Zeta Electronics Corporation + Copyright ZKA Technologies ------------------------------------------- */ @@ -8,6 +8,7 @@ #include <NewKit/Defines.hpp> #include <NewKit/String.hpp> +#include <NewKit/Json.hxx> namespace Kernel { @@ -17,8 +18,9 @@ namespace Kernel enum class VariantKind { kString, - kPointer, - kUndefined + kBlob, + kNull, + kJson, }; public: @@ -35,20 +37,28 @@ namespace Kernel : fPtr((voidPtr)stringView), fKind(VariantKind::kString) { } + + explicit Variant(JsonType* json) + : fPtr((voidPtr)json), fKind(VariantKind::kJson) + { + } + explicit Variant(nullPtr) - : fPtr(nullptr), fKind(VariantKind::kUndefined) + : fPtr(nullptr), fKind(VariantKind::kNull) { } + explicit Variant(voidPtr ptr) - : fPtr(ptr), fKind(VariantKind::kPointer) + : fPtr(ptr), fKind(VariantKind::kBlob) { } public: const Char* ToString(); + VoidPtr Leak(); private: voidPtr fPtr{nullptr}; - VariantKind fKind{VariantKind::kUndefined}; + VariantKind fKind{VariantKind::kNull}; }; } // namespace Kernel |
