diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-10-26 16:01:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-26 16:01:12 +0100 |
| commit | 36269e57831e560df6a0da9c9d02c00671b0163d (patch) | |
| tree | 69f6a0c6f08ef5ef2f6fcbb7302537dbce222e6e /dev/kernel/NeKit | |
| parent | 2117a9b0f4b84f5bd6c99566bcf5849a64104467 (diff) | |
| parent | b6ce6640afaf6c1cc6ad274f3053b2e218a49554 (diff) | |
Merge pull request #68 from nekernel-org/dev
NeKernel: v0.0.6e1
Diffstat (limited to 'dev/kernel/NeKit')
| -rw-r--r-- | dev/kernel/NeKit/ArrayList.h | 2 | ||||
| -rw-r--r-- | dev/kernel/NeKit/Crc32.h | 8 | ||||
| -rw-r--r-- | dev/kernel/NeKit/Defines.h | 29 | ||||
| -rw-r--r-- | dev/kernel/NeKit/ErrorOr.h | 4 | ||||
| -rw-r--r-- | dev/kernel/NeKit/Json.h | 46 | ||||
| -rw-r--r-- | dev/kernel/NeKit/KString.h | 61 | ||||
| -rw-r--r-- | dev/kernel/NeKit/KString.inl | 116 | ||||
| -rw-r--r-- | dev/kernel/NeKit/Pair.h | 38 | ||||
| -rw-r--r-- | dev/kernel/NeKit/Ref.h | 9 | ||||
| -rw-r--r-- | dev/kernel/NeKit/Utils.h | 12 | ||||
| -rw-r--r-- | dev/kernel/NeKit/Variant.h | 7 |
11 files changed, 190 insertions, 142 deletions
diff --git a/dev/kernel/NeKit/ArrayList.h b/dev/kernel/NeKit/ArrayList.h index 1f5226f4..ee1a4b40 100644 --- a/dev/kernel/NeKit/ArrayList.h +++ b/dev/kernel/NeKit/ArrayList.h @@ -12,7 +12,7 @@ namespace Kernel { template <typename T> class ArrayList final { public: - explicit ArrayList(T* list, SizeT length) : fList(reinterpret_cast<T>(list)) {} + explicit ArrayList(T* list, SizeT length) : fList(reinterpret_cast<T>(list)), fLen(length) {} ~ArrayList() = default; diff --git a/dev/kernel/NeKit/Crc32.h b/dev/kernel/NeKit/Crc32.h index 0fc35134..f6b04641 100644 --- a/dev/kernel/NeKit/Crc32.h +++ b/dev/kernel/NeKit/Crc32.h @@ -8,15 +8,13 @@ * ======================================================== */ -#ifndef CRC32_H -#define CRC32_H +#ifndef NEKIT_CRC32_H +#define NEKIT_CRC32_H #include <NeKit/Defines.h> -#define kCrcCnt (256) - namespace Kernel { UInt32 ke_calculate_crc32(const VoidPtr crc, Int32 len) noexcept; } // namespace Kernel -#endif // !CRC32_H +#endif // !NEKIT_CRC32_H diff --git a/dev/kernel/NeKit/Defines.h b/dev/kernel/NeKit/Defines.h index 0f9a7c4a..ed979e03 100644 --- a/dev/kernel/NeKit/Defines.h +++ b/dev/kernel/NeKit/Defines.h @@ -8,11 +8,11 @@ #include <NeKit/Macros.h> -#define NEWKIT_VERSION_STR "0.0.1" -#define NEWKIT_VERSION_BCD 0x0001 +#define NEKIT_VERSION_STR "0.0.1" +#define NEKIT_VERSION_BCD 0x0001 #ifndef __cplusplus -#error Kernel compiles with a C++ compiler. +#error !!! Kernel compiles only with a C++ compiler. !!! #endif #if __cplusplus <= 201703L @@ -35,13 +35,13 @@ using nullPtr = decltype(nullptr); using NullPtr = decltype(nullptr); using Int = int; -using Int32 = int; -using UShort = unsigned short; -using UInt16 = unsigned short; +using Int32 = __INT32_TYPE__; +using UShort = __UINT16_TYPE__; +using UInt16 = __UINT16_TYPE__; using Short = short; -using Int16 = short; -using UInt = unsigned int; -using UInt32 = unsigned int; +using Int16 = __INT16_TYPE__; +using UInt = __UINT32_TYPE__; +using UInt32 = __UINT32_TYPE__; using Long = __INT64_TYPE__; using Int64 = __INT64_TYPE__; using ULong = __UINT64_TYPE__; @@ -49,11 +49,13 @@ using UInt64 = __UINT64_TYPE__; using Boolean = bool; using Bool = bool; using Char = char; -using UChar = unsigned char; -using UInt8 = unsigned char; +using Int8 = __INT8_TYPE__; +using Char8 = char8_t; +using UChar = __UINT8_TYPE__; +using UInt8 = __UINT8_TYPE__; -using SSize = Int64; -using SSizeT = Int64; +using SSize = long; +using SSizeT = long; using Size = __SIZE_TYPE__; using SizeT = __SIZE_TYPE__; using IntPtr = __INTPTR_TYPE__; @@ -83,6 +85,7 @@ typedef UInt32 PhysicalAddressKind; typedef UIntPtr VirtualAddressKind; using Void = void; +using Any = void*; using Lba = UInt64; diff --git a/dev/kernel/NeKit/ErrorOr.h b/dev/kernel/NeKit/ErrorOr.h index e8b3b6fc..3351c65d 100644 --- a/dev/kernel/NeKit/ErrorOr.h +++ b/dev/kernel/NeKit/ErrorOr.h @@ -13,7 +13,7 @@ #include <NeKit/Ref.h> namespace Kernel { -using ErrorT = UInt; +using ErrorT = UInt32; template <typename T> class ErrorOr final { @@ -50,7 +50,7 @@ class ErrorOr final { private: Ref<T> mRef; - Int32 mId{0}; + ErrorT mId{0}; }; using ErrorOrAny = ErrorOr<voidPtr>; diff --git a/dev/kernel/NeKit/Json.h b/dev/kernel/NeKit/Json.h index 24357dd7..35f53b57 100644 --- a/dev/kernel/NeKit/Json.h +++ b/dev/kernel/NeKit/Json.h @@ -7,7 +7,7 @@ #pragma once -// last-rev: 02/04/25 +/// @brief Kernel JSON API. #include <CompilerKit/CompilerKit.h> #include <NeKit/Defines.h> @@ -15,58 +15,58 @@ #include <NeKit/Stream.h> #include <NeKit/Utils.h> -#define kJSONMaxLen (8196) -#define kJSONLen (256) -#define kJSONNullArr "[]" -#define kJSONNullObj "{}" +#define kNeJsonMaxLen (8196) +#define kNeJsonLen (256) +#define kNeJsonNullArr "[]" +#define kNeJsonNullObj "{}" namespace Kernel { /// @brief JavaScript object class -class Json final { +class JsonObject final { public: - explicit Json() { - auto len = kJSONMaxLen; - BasicKString<> key = KString(len); - key += kJSONNullObj; + explicit JsonObject() { + auto len = kNeJsonMaxLen; + KBasicString<> key = KString(len); + key += kNeJsonNullObj; this->AsKey() = key; this->AsValue() = key; } - explicit Json(SizeT lhsLen, SizeT rhsLen) : fKey(lhsLen), fValue(rhsLen) {} + explicit JsonObject(SizeT lhsLen, SizeT rhsLen) : fKey(lhsLen), fValue(rhsLen) {} - ~Json() = default; + ~JsonObject() = default; - NE_COPY_DEFAULT(Json) + NE_COPY_DEFAULT(JsonObject) Bool& IsUndefined() { return fUndefined; } private: Bool fUndefined; // is this instance undefined? - BasicKString<> fKey; - BasicKString<> fValue; + KBasicString<> fKey; + KBasicString<> fValue; public: /// @brief returns the key of the json /// @return the key as string view. - BasicKString<>& AsKey() { return fKey; } + KBasicString<>& AsKey() { return fKey; } /// @brief returns the value of the json. /// @return the key as string view. - BasicKString<>& AsValue() { return fValue; } + KBasicString<>& AsValue() { return fValue; } - static Json kNull; + static JsonObject kNull; }; -/// @brief Json stream reader helper. +/// @brief JsonObject stream reader helper. struct JsonStreamReader final { - STATIC Json In(const Char* full_array) { + STATIC JsonObject In(const Char* full_array) { auto start_val = '{'; auto end_val = '}'; Boolean probe_value = false; if (full_array[0] != start_val) { - if (full_array[0] != '[') return Json::kNull; + if (full_array[0] != '[') return JsonObject::kNull; start_val = '['; end_val = ']'; @@ -79,7 +79,7 @@ struct JsonStreamReader final { SizeT key_len = 0; SizeT value_len = 0; - Json type(kJSONMaxLen, kJSONMaxLen); + JsonObject type(kNeJsonMaxLen, kNeJsonMaxLen); for (SizeT i = 1; i < len; ++i) { if (full_array[i] == '\r' || full_array[i] == '\n') continue; @@ -125,5 +125,5 @@ struct JsonStreamReader final { } }; -using JsonStream = Stream<JsonStreamReader, Json>; +using JsonStream = Stream<JsonStreamReader, JsonObject>; } // namespace Kernel diff --git a/dev/kernel/NeKit/KString.h b/dev/kernel/NeKit/KString.h index bbe49f8e..6a1b04d2 100644 --- a/dev/kernel/NeKit/KString.h +++ b/dev/kernel/NeKit/KString.h @@ -12,52 +12,52 @@ #include <NeKit/KernelPanic.h> #include <NeKit/Utils.h> -#define kMinimumStringSize (8196U) - namespace Kernel { +inline auto kMinimumStringSize = 8196; + /// @brief Kernel string class, not dynamic. -template <SizeT MinSz = kMinimumStringSize> -class BasicKString final { +template <typename CharKind = Char> +class KBasicString final { public: - explicit BasicKString() { - fDataSz = MinSz; + explicit KBasicString() { + fDataSz = kMinimumStringSize; - fData = new Char[fDataSz]; + fData = new CharKind[fDataSz]; MUST_PASS(fData); rt_set_memory(fData, 0, fDataSz); } - explicit BasicKString(SizeT Sz) : fDataSz(Sz) { + explicit KBasicString(SizeT Sz) : fDataSz(Sz) { MUST_PASS(Sz > 1); - fData = new Char[Sz]; + fData = new CharKind[Sz]; MUST_PASS(fData); rt_set_memory(fData, 0, Sz); } - ~BasicKString() { + ~KBasicString() { if (fData) { delete[] fData; fData = nullptr; } } - NE_COPY_DEFAULT(BasicKString) + NE_COPY_DEFAULT(KBasicString) - Char* Data(); - const Char* CData() const; - Size Length() const; + CharKind* Data(); + const CharKind* CData() const; + Size Length() const; - bool operator==(const Char* rhs) const; - bool operator!=(const Char* rhs) const; + bool operator==(const CharKind* rhs) const; + bool operator!=(const CharKind* rhs) const; - bool operator==(const BasicKString<>& rhs) const; - bool operator!=(const BasicKString<>& rhs) const; + bool operator==(const KBasicString<CharKind>& rhs) const; + bool operator!=(const KBasicString<CharKind>& rhs) const; - BasicKString<>& operator+=(const Char* rhs); - BasicKString<>& operator+=(const BasicKString<>& rhs); + KBasicString<CharKind>& operator+=(const CharKind* rhs); + KBasicString<CharKind>& operator+=(const KBasicString<CharKind>& rhs); operator const char*() { return fData; } @@ -66,23 +66,26 @@ class BasicKString final { bool operator!() { return fData; } private: - Char* fData{nullptr}; - Size fDataSz{0}; - Size fCur{0}; + CharKind* fData{nullptr}; + Size fDataSz{0}; + Size fCur{0}; friend class KStringBuilder; }; -using KString = BasicKString<>; +using KString = KBasicString<>; using KStringOr = ErrorOr<KString>; class KStringBuilder final { public: - static ErrorOr<KString> Construct(const Char* data); - static const Char* FromBool(const Char* fmt, bool n); - static const Char* Format(const Char* fmt, const Char* from); - static bool Equals(const Char* lhs, const Char* rhs); - static bool Equals(const Utf8Char* lhs, const Utf8Char* rhs); + template <typename CharKind = Char> + static ErrorOr<KBasicString<CharKind>> Construct(const CharKind* data); + template <typename CharKind = Char> + static const CharKind* FromBool(const CharKind* fmt, bool n); + template <typename CharKind = Char> + static const CharKind* Format(const CharKind* fmt, const CharKind* from); + template <typename CharKind = Char> + static bool Equals(const CharKind* lhs, const CharKind* rhs); }; } // namespace Kernel diff --git a/dev/kernel/NeKit/KString.inl b/dev/kernel/NeKit/KString.inl index 1faefb08..d238818c 100644 --- a/dev/kernel/NeKit/KString.inl +++ b/dev/kernel/NeKit/KString.inl @@ -4,14 +4,13 @@ ------------------------------------------- */ -#include <NeKit/Utils.h> - -/// @file BasicKString<>.cc +/// @file KBasicString.inl /// @brief Kernel String manipulation file. namespace Kernel { -inline void rt_string_append(Char* lhs, const Char* rhs, Int32 cur) { - SizeT sz_rhs = rt_string_len(rhs); +template <typename CharKind> +inline void ort_string_append(CharKind* lhs, const CharKind* rhs, Int32 cur) { + SizeT sz_rhs = ort_string_len<CharKind>(rhs); SizeT rhs_i = 0; for (; rhs_i < sz_rhs; ++rhs_i) { @@ -19,23 +18,23 @@ inline void rt_string_append(Char* lhs, const Char* rhs, Int32 cur) { } } -template <> -inline Char* BasicKString<>::Data() { +template <typename CharKind> +inline CharKind* KBasicString<CharKind>::Data() { return this->fData; } -template <> -inline const Char* BasicKString<>::CData() const { - return const_cast<const Char*>(this->fData); +template <typename CharKind> +inline const CharKind* KBasicString<CharKind>::CData() const { + return const_cast<const CharKind*>(this->fData); } -template <> -inline SizeT BasicKString<>::Length() const { +template <typename CharKind> +inline SizeT KBasicString<CharKind>::Length() const { return this->fDataSz; } -template <> -inline bool BasicKString<>::operator==(const BasicKString<>& rhs) const { +template <typename CharKind> +inline bool KBasicString<CharKind>::operator==(const KBasicString<CharKind>& rhs) const { if (rhs.Length() != this->Length()) return false; for (Size index = 0; index < this->Length(); ++index) { @@ -45,19 +44,19 @@ inline bool BasicKString<>::operator==(const BasicKString<>& rhs) const { return true; } -template <> -inline bool BasicKString<>::operator==(const Char* rhs) const { - if (rt_string_len(rhs) != this->Length()) return false; +template <typename CharKind> +inline bool KBasicString<CharKind>::operator==(const CharKind* rhs) const { + if (ort_string_len<CharKind>(rhs) != this->Length()) return false; - for (Size index = 0; index < rt_string_len(rhs); ++index) { + for (Size index = 0; index < ort_string_len<CharKind>(rhs); ++index) { if (rhs[index] != this->fData[index]) return false; } return true; } -template <> -inline bool BasicKString<>::operator!=(const BasicKString<>& rhs) const { +template <typename CharKind> +inline bool KBasicString<CharKind>::operator!=(const KBasicString<CharKind>& rhs) const { if (rhs.Length() != this->Length()) return false; for (Size index = 0; index < rhs.Length(); ++index) { @@ -67,54 +66,55 @@ inline bool BasicKString<>::operator!=(const BasicKString<>& rhs) const { return true; } -template <> -inline bool BasicKString<>::operator!=(const Char* rhs) const { - if (rt_string_len(rhs) != this->Length()) return false; +template <typename CharKind> +inline bool KBasicString<CharKind>::operator!=(const CharKind* rhs) const { + if (ort_string_len<CharKind>(rhs) != this->Length()) return false; - for (Size index = 0; index < rt_string_len(rhs); ++index) { + for (Size index = 0; index < ort_string_len<CharKind>(rhs); ++index) { if (rhs[index] == this->fData[index]) return false; } return true; } -template <> -inline BasicKString<>& BasicKString<>::operator+=(const BasicKString<>& rhs) { - if (rt_string_len(rhs.fData) > this->Length()) return *this; +template <typename CharKind> +inline KBasicString<CharKind>& KBasicString<CharKind>::operator+=(const KBasicString<CharKind>& rhs) { + if (ort_string_len<CharKind>(rhs.fData) > this->Length()) return *this; - rt_string_append(this->fData, const_cast<Char*>(rhs.fData), this->fCur); - this->fCur += rt_string_len(const_cast<Char*>(rhs.fData)); + ort_string_append(this->fData, const_cast<CharKind*>(rhs.fData), this->fCur); + this->fCur += ort_string_len<CharKind>(const_cast<CharKind*>(rhs.fData)); return *this; } -template <> -inline BasicKString<>& BasicKString<>::operator+=(const Char* rhs) { - rt_string_append(this->fData, const_cast<Char*>(rhs), this->fCur); - this->fCur += rt_string_len(const_cast<Char*>(rhs)); +template <typename CharKind> +inline KBasicString<CharKind>& KBasicString<CharKind>::operator+=(const CharKind* rhs) { + ort_string_append(this->fData, const_cast<CharKind*>(rhs), this->fCur); + this->fCur += ort_string_len<CharKind>(const_cast<CharKind*>(rhs)); return *this; } -inline ErrorOr<BasicKString<>> KStringBuilder::Construct(const Char* data) { - if (!data || *data == 0) return ErrorOr<BasicKString<>>(new BasicKString<>(0)); +template <typename CharKind> +inline ErrorOr<KBasicString<CharKind>> KStringBuilder::Construct(const CharKind* data) { + if (!data || *data == 0) return ErrorOr<KBasicString<CharKind>>(nullptr); - BasicKString<>* view = new BasicKString<>(rt_string_len(data)); + KBasicString<CharKind>* view = new KBasicString<CharKind>(ort_string_len<CharKind>(data)); (*view) += data; - return ErrorOr<BasicKString<>>(*view); + return ErrorOr<KBasicString<CharKind>>(*view); } - -inline const Char* KStringBuilder::FromBool(const Char* fmt, bool i) { +template <typename CharKind> +inline const CharKind* KStringBuilder::FromBool(const CharKind* fmt, bool i) { if (!fmt) return ("?"); - const Char* boolean_expr = i ? "YES" : "NO"; - Char* ret = (Char*) RTL_ALLOCA(rt_string_len(boolean_expr) + rt_string_len(fmt)); + const CharKind* boolean_expr = i ? "YES" : "NO"; + CharKind* ret = (CharKind*) RTL_ALLOCA(ort_string_len<CharKind>(boolean_expr) + ort_string_len<CharKind>(fmt)); if (!ret) return ("?"); - const auto fmt_len = rt_string_len(fmt); - const auto res_len = rt_string_len(boolean_expr); + const auto fmt_len = ort_string_len<CharKind>(fmt); + const auto res_len = ort_string_len<CharKind>(boolean_expr); for (Size idx = 0; idx < fmt_len; ++idx) { if (fmt[idx] == '%') { @@ -133,41 +133,31 @@ inline const Char* KStringBuilder::FromBool(const Char* fmt, bool i) { return ret; } +template <typename CharKind> +inline bool KStringBuilder::Equals(const CharKind* lhs, const CharKind* rhs) { + if (ort_string_len<CharKind>(rhs) != ort_string_len<CharKind>(lhs)) return false; -inline bool KStringBuilder::Equals(const Char* lhs, const Char* rhs) { - if (rt_string_len(rhs) != rt_string_len(lhs)) return false; - - for (Size index = 0; index < rt_string_len(rhs); ++index) { + for (Size index = 0; index < ort_string_len<CharKind>(rhs); ++index) { if (rhs[index] != lhs[index]) return false; } return true; } - -inline bool KStringBuilder::Equals(const Utf8Char* lhs, const Utf8Char* rhs) { - if (urt_string_len(rhs) != urt_string_len(lhs)) return false; - - for (Size index = 0; rhs[index] != 0; ++index) { - if (rhs[index] != lhs[index]) return false; - } - - return true; -} - -inline const Char* KStringBuilder::Format(const Char* fmt, const Char* fmt2) { +template <typename CharKind> +inline const CharKind* KStringBuilder::Format(const CharKind* fmt, const CharKind* fmt2) { if (!fmt || !fmt2) return ("?"); - Char* ret = (Char*) RTL_ALLOCA(sizeof(char) * (rt_string_len(fmt2) + rt_string_len(fmt))); + CharKind* ret = (CharKind*) RTL_ALLOCA(sizeof(char) * (ort_string_len<CharKind>(fmt2) + ort_string_len<CharKind>(fmt))); if (!ret) return ("?"); - const auto len = rt_string_len(fmt); + const auto len = ort_string_len<CharKind>(fmt); for (Size idx = 0; idx < len; ++idx) { - if (fmt[idx] == '%' && idx < rt_string_len(fmt) && fmt[idx] == 's') { + if (fmt[idx] == '%' && idx < ort_string_len<CharKind>(fmt) && fmt[idx] == 's') { Size result_cnt = idx; - for (Size y_idx = 0; y_idx < rt_string_len(fmt2); ++y_idx) { + for (Size y_idx = 0; y_idx < ort_string_len<CharKind>(fmt2); ++y_idx) { ret[result_cnt] = fmt2[y_idx]; ++result_cnt; } diff --git a/dev/kernel/NeKit/Pair.h b/dev/kernel/NeKit/Pair.h index aeeeb8a2..61668f5a 100644 --- a/dev/kernel/NeKit/Pair.h +++ b/dev/kernel/NeKit/Pair.h @@ -6,8 +6,46 @@ #pragma once +#include <CompilerKit/CompilerKit.h> #include <NeKit/Defines.h> +#include <NeKit/ErrorOr.h> namespace Kernel { +template <typename T1, typename T2> class Pair; + +class PairBuilder; + +template <typename T1, typename T2> +class Pair final { + T1 fFirst{nullptr}; + T2 fSecond{nullptr}; + + friend PairBuilder; + + public: + explicit Pair() = default; + ~Pair() = default; + + NE_COPY_DEFAULT(Pair) + + T1& First() { return fFirst; } + T2& Second() { return fSecond; } + + const T1& First() const { return *fFirst; } + const T2& Second() const { return *fSecond; } + + private: + Pair(T1 first, T2 second) : fFirst(first), fSecond(second) {} +}; + +class PairBuilder final { + template <typename T1, typename T2> + STATIC Pair<T1, T2> Construct(T1 first, T2 second) { + return Pair(first, second); + } +}; + +template <typename T1, typename T2> +using PairOr = ErrorOr<Pair<T1, T2>>; } // namespace Kernel diff --git a/dev/kernel/NeKit/Ref.h b/dev/kernel/NeKit/Ref.h index a791ee1a..566f7486 100644 --- a/dev/kernel/NeKit/Ref.h +++ b/dev/kernel/NeKit/Ref.h @@ -5,8 +5,8 @@ ------------------------------------------- */ -#ifndef _NEWKIT_REF_H_ -#define _NEWKIT_REF_H_ +#ifndef _NEKIT_REF_H_ +#define _NEKIT_REF_H_ #include <CompilerKit/CompilerKit.h> #include <KernelKit/HeapMgr.h> @@ -65,6 +65,9 @@ class NonNullRef final { private: Ref<T> fRef{}; }; + +using RefAny = Ref<Any>; +using NonNullRefAny = NonNullRef<Any>; } // namespace Kernel -#endif // ifndef _NEWKIT_REF_H_ +#endif // ifndef _NEKIT_REF_H_ diff --git a/dev/kernel/NeKit/Utils.h b/dev/kernel/NeKit/Utils.h index a7576e77..ee18d04c 100644 --- a/dev/kernel/NeKit/Utils.h +++ b/dev/kernel/NeKit/Utils.h @@ -38,4 +38,16 @@ Int urt_string_cmp(const Utf8Char* src, const Utf8Char* cmp, Size len); Void urt_set_memory(const voidPtr src, UInt32 dst, Size len); Int urt_copy_memory(const voidPtr src, voidPtr dst, Size len); Size urt_string_len(const Utf8Char* str); + +/// OpenTemplate UTILS API + +template <typename CharType = Char> +inline SizeT ort_string_len(const CharType* str) { + if (!str) return 0; + + SizeT len{0}; + + while (str[len] != 0) ++len; + return len; +} } // namespace Kernel diff --git a/dev/kernel/NeKit/Variant.h b/dev/kernel/NeKit/Variant.h index 51548272..700c9d9a 100644 --- a/dev/kernel/NeKit/Variant.h +++ b/dev/kernel/NeKit/Variant.h @@ -33,9 +33,10 @@ class Variant final { ~Variant() = default; public: - explicit Variant(KString* stringView) : fPtr((VoidPtr) stringView), fKind(VariantKind::kString) {} + template <typename CharKind> + explicit Variant(KBasicString<CharKind>* stringView) : fPtr((VoidPtr) stringView), fKind(VariantKind::kString) {} - explicit Variant(Json* json) : fPtr((VoidPtr) json), fKind(VariantKind::kJson) {} + explicit Variant(JsonObject* json) : fPtr((VoidPtr) json), fKind(VariantKind::kJson) {} explicit Variant(nullPtr ptr) : fPtr(ptr), fKind(VariantKind::kNull) {} @@ -55,7 +56,7 @@ class Variant final { VariantKind& Kind(); private: - voidPtr fPtr{nullptr}; + VoidPtr fPtr{nullptr}; VariantKind fKind{VariantKind::kNull}; }; } // namespace Kernel |
