summaryrefslogtreecommitdiffhomepage
path: root/public
diff options
context:
space:
mode:
Diffstat (limited to 'public')
-rw-r--r--public/frameworks/CoreFoundation.fwrk/headers/Foundation.h18
-rw-r--r--public/frameworks/CoreFoundation.fwrk/headers/Property.h18
-rw-r--r--public/frameworks/CoreFoundation.fwrk/headers/Ref.h11
-rw-r--r--public/frameworks/CoreFoundation.fwrk/headers/String.h35
-rw-r--r--public/frameworks/KernelTest.fwrk/headers/Foundation.h16
-rw-r--r--public/frameworks/KernelTest.fwrk/headers/KernelTest.h31
-rw-r--r--public/frameworks/KernelTest.fwrk/headers/SourceLocation.h36
-rw-r--r--public/frameworks/KernelTest.fwrk/headers/TestCase.h56
-rw-r--r--public/frameworks/KernelTest.fwrk/src/CSymbols.cc21
-rw-r--r--public/frameworks/KernelTest.fwrk/src/UnitTests.cc17
10 files changed, 194 insertions, 65 deletions
diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h
index e195c572..68b00264 100644
--- a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h
+++ b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h
@@ -14,7 +14,7 @@
namespace CF {
class CFString;
-class CFGUID;
+union CFGUID;
class CFProperty;
class CFObject;
@@ -72,4 +72,20 @@ struct CFRect final {
BOOL SizeMatches(CFRect& rect) noexcept;
BOOL PositionMatches(CFRect& rect) noexcept;
};
+
+union CFGUID final {
+ alignas(8) UInt16 fU8[16];
+ alignas(8) UInt16 fU16[8];
+ alignas(8) UInt32 fU32[4];
+ alignas(8) UInt64 fU64[2];
+
+ struct {
+ alignas(8) UInt32 fMs1;
+ UInt16 fMs2;
+ UInt16 fMs3;
+ UInt8 fMs4[8];
+ } fUuid;
+};
+
+using CF_GUID_TYPE = union CFGUID;
} // namespace CF \ No newline at end of file
diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Property.h b/public/frameworks/CoreFoundation.fwrk/headers/Property.h
index f3c4a937..b8784f68 100644
--- a/public/frameworks/CoreFoundation.fwrk/headers/Property.h
+++ b/public/frameworks/CoreFoundation.fwrk/headers/Property.h
@@ -4,31 +4,34 @@
======================================== */
-#ifndef _PROPS_H
-#define _PROPS_H
+#pragma once
+#include <CoreFoundation.fwrk/headers/Foundation.h>
#include <CoreFoundation.fwrk/headers/Ref.h>
#include <libSystem/SystemKit/System.h>
-#define kMaxPropLen (256U)
+#define kCFMaxPropLen (256U)
namespace CF {
class CFString;
class CFProperty;
-class CFGUID;
template <typename Cls, SizeT N>
class CFArray;
+/// ================================================================================
/// @brief handle to anything (number, ptr, string...)
+/// ================================================================================
using CFPropertyId = UIntPtr;
+/// ================================================================================
/// @brief User property class.
/// @example /prop/foo or /prop/bar
+/// ================================================================================
class CFProperty final CF_OBJECT {
public:
- CFProperty();
- virtual ~CFProperty();
+ CFProperty(CFRef<CFGUID> guid, CFString& name, CFPropertyId value);
+ ~CFProperty() override = default;
public:
CFProperty& operator=(const CFProperty&) = default;
@@ -41,11 +44,10 @@ class CFProperty final CF_OBJECT {
private:
CFString* fName{nullptr};
CFPropertyId fValue{0UL};
- Ref<CFGUID> fGUID{};
+ CFRef<CFGUID> fGUID{};
};
template <SizeT N>
using CFPropertyArray = CFArray<CFProperty, N>;
} // namespace CF
-#endif // !CFKIT_PROPS_H
diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Ref.h b/public/frameworks/CoreFoundation.fwrk/headers/Ref.h
index c1d5aec7..6757daac 100644
--- a/public/frameworks/CoreFoundation.fwrk/headers/Ref.h
+++ b/public/frameworks/CoreFoundation.fwrk/headers/Ref.h
@@ -5,8 +5,7 @@
======================================== */
-#ifndef _REF_H_
-#define _REF_H_
+#pragma once
#include <CoreFoundation.fwrk/headers/Object.h>
#include <libSystem/SystemKit/System.h>
@@ -15,6 +14,9 @@ namespace CF {
template <typename T>
class CFRef;
+/// ================================================================================
+/// @brief CFRef class for reference counting.
+/// ================================================================================
template <typename T>
class CFRef final CF_OBJECT {
public:
@@ -57,6 +59,9 @@ class CFRef final CF_OBJECT {
T* fClass{nullptr};
};
+/// ================================================================================
+/// @brief CFNonNullRef class for non-null reference counting.
+/// ================================================================================
template <typename T>
class CFNonNullRef final {
public:
@@ -64,6 +69,7 @@ class CFNonNullRef final {
CFNonNullRef(nullPtr) = delete;
CFNonNullRef(T* ref) : fRef(ref) { MUST_PASS(ref); }
+ CFNonNullRef(CFRef<T> ref) : fRef(ref) { MUST_PASS(ref); }
CFRef<T>& operator->() {
MUST_PASS(fRef);
@@ -78,4 +84,3 @@ class CFNonNullRef final {
};
} // namespace CF
-#endif // ifndef _NEKIT_REF_H_
diff --git a/public/frameworks/CoreFoundation.fwrk/headers/String.h b/public/frameworks/CoreFoundation.fwrk/headers/String.h
index 6fb2f817..247d3894 100644
--- a/public/frameworks/CoreFoundation.fwrk/headers/String.h
+++ b/public/frameworks/CoreFoundation.fwrk/headers/String.h
@@ -1,4 +1,3 @@
-
/* ========================================
Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
@@ -8,16 +7,42 @@
#pragma once
#include <CoreFoundation.fwrk/headers/Object.h>
+#include <CoreFoundation.fwrk/headers/Ref.h>
namespace CF {
class CFString;
+class CFStringBuilder;
+/// ================================================================================
+/// @brief CFString class for string manipulations.
+/// ================================================================================
class CFString final CF_OBJECT {
public:
- CFString() = default;
- ~CFString() = default;
+ CFString() = delete;
+
+ explicit CFString(const SizeT sz);
+ explicit CFString(const Char* str);
+
+ ~CFString();
+
+ const char* asBytes() const;
+
+ LIBSYS_COPY_DELETE(CFString);
+
+ private:
+ Char* mStr{nullptr};
+};
+
+/// ================================================================================
+/// @brief CFStringBuilder class for string manipulations.
+/// ================================================================================
+class CFStringBuilder final {
+ public:
+ static CFRef<CFString> Construct(const Char*);
+ static const Char* FromBool(const Char*, BOOL);
+ static const Char* Format(const Char*, const Char*);
- CFString(const CFString&) = delete;
- CFString& operator=(const CFString&) = delete;
+ static BOOL Equals(const Char, const Char*);
+ static BOOL Equals(const Char*, const Char*);
};
} // namespace CF \ No newline at end of file
diff --git a/public/frameworks/KernelTest.fwrk/headers/Foundation.h b/public/frameworks/KernelTest.fwrk/headers/Foundation.h
new file mode 100644
index 00000000..4329af6b
--- /dev/null
+++ b/public/frameworks/KernelTest.fwrk/headers/Foundation.h
@@ -0,0 +1,16 @@
+/* ========================================
+
+ Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
+
+======================================== */
+
+#pragma once
+
+#include <KernelKit/DebugOutput.h>
+#include <NeKit/KernelPanic.h>
+
+#define KT_TEST_VERSION_BCD (0x0001)
+#define KT_TEST_VERSION "dev-nekernel-test"
+
+#define KT_TEST_SUCCESS (kErrorSuccess)
+#define KT_TEST_FAILURE (kErrorSuccess + 1)
diff --git a/public/frameworks/KernelTest.fwrk/headers/KernelTest.h b/public/frameworks/KernelTest.fwrk/headers/KernelTest.h
deleted file mode 100644
index 7b25c8a4..00000000
--- a/public/frameworks/KernelTest.fwrk/headers/KernelTest.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ========================================
-
- Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
-
-======================================== */
-
-#pragma once
-
-#include <NeKit/KernelPanic.h>
-
-/// @brief Kernel Test Framework.
-/// @file KernelTest.h
-
-#define KT_TEST_VERSION_BCD (0x0002)
-#define KT_TEST_VERSION "v0.0.2-kerneltest"
-
-#define KT_TEST_FAILURE (1)
-
-#define KT_TEST_SUCCESS (0)
-
-#define KT_DECL_TEST(NAME, FN) \
- class KT_##NAME final { \
- public: \
- Kernel::Void Run(); \
- const Kernel::Char* ToString(); \
- }; \
- inline Kernel::Void KT_##NAME::Run() { MUST_PASS(FN() == true); } \
- inline const Kernel::Char* KT_##NAME::ToString() { return #FN; }
-
-KT_DECL_TEST(ALWAYS_BREAK, []() -> bool { return false; });
-KT_DECL_TEST(ALWAYS_GOOD, []() -> bool { return true; }); \ No newline at end of file
diff --git a/public/frameworks/KernelTest.fwrk/headers/SourceLocation.h b/public/frameworks/KernelTest.fwrk/headers/SourceLocation.h
new file mode 100644
index 00000000..6507864b
--- /dev/null
+++ b/public/frameworks/KernelTest.fwrk/headers/SourceLocation.h
@@ -0,0 +1,36 @@
+/* ========================================
+
+ Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
+
+======================================== */
+
+#pragma once
+
+#include <CoreFoundation.fwrk/headers/Object.h>
+#include <CoreFoundation.fwrk/headers/String.h>
+#include <KernelTest.fwrk/headers/Foundation.h>
+
+class KTSourceLocation;
+
+/// ================================================================================
+/// @brief SourceLocation class for Kernel Test Framework.
+/// ================================================================================
+class KTSourceLocation final CF_OBJECT {
+ public:
+ explicit KTSourceLocation() = delete;
+ ~KTSourceLocation() override = default;
+
+ LIBSYS_COPY_DELETE(KTSourceLocation);
+
+ public:
+ KTSourceLocation(const Char*, const SInt32 = 0UL);
+
+ CF::CFString File();
+ SInt32 Line();
+
+ CF::CFString operator()();
+
+ private:
+ CF::CFString mFile{4096};
+ SInt32 mLine{0U};
+}; \ No newline at end of file
diff --git a/public/frameworks/KernelTest.fwrk/headers/TestCase.h b/public/frameworks/KernelTest.fwrk/headers/TestCase.h
new file mode 100644
index 00000000..c040ca0f
--- /dev/null
+++ b/public/frameworks/KernelTest.fwrk/headers/TestCase.h
@@ -0,0 +1,56 @@
+/* ========================================
+
+ Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
+
+======================================== */
+
+#pragma once
+
+#include <KernelTest.fwrk/headers/SourceLocation.h>
+
+/// ================================================================================
+/// @brief Kernel Test Framework main header.
+/// @file TestCase.h
+/// ================================================================================
+
+#define KT_RUN_TEST(OBJECT) {KTTestCase##OBJECT{}.Run();}
+
+#define KT_MUST_PASS(MSG, LEFT_COND, RIGHT_COND) \
+ if (LEFT_COND != RIGHT_COND) { \
+ (Kernel::Void)(Kernel::kout << "[KERNEL-TEST] BREAK: LEFT_COND: " << #LEFT_COND \
+ << " RIGHT_COND: " << #RIGHT_COND << Kernel::kendl); \
+ (Kernel::Void)(Kernel::kout << "[KERNEL-TEST] BREAK: MSG: " << MSG << Kernel::kendl); \
+ MUST_PASS(NO); \
+ } else { \
+ (Kernel::Void)(Kernel::kout << "[KERNEL-TEST] PASS: MSG: " << MSG << Kernel::kendl); \
+ }
+
+#define KT_DECL_TEST(NAME, FN) \
+ class KTTestCase##NAME final { \
+ public: \
+ explicit KTTestCase##NAME() = default; \
+ ~KTTestCase##NAME() = default; \
+ LIBSYS_COPY_DELETE(KTTestCase##NAME); \
+ Kernel::Void Run(); \
+ const Kernel::Char* ToString(); \
+ }; \
+ inline Kernel::Void KTTestCase##NAME::Run() { \
+ auto ret = FN() == YES; \
+ if (!ret) { \
+ Kernel::kout << "[KERNEL-TEST] TEST FAILED!" << Kernel::kendl; \
+ MUST_PASS(ret); \
+ } \
+ } \
+ inline const Kernel::Char* KTTestCase##NAME::ToString() { \
+ return #FN; \
+ }
+
+KT_DECL_TEST(AlwaysBreak, []() -> bool {
+ KT_MUST_PASS("AlwaysBreak", YES, NO);
+ return NO;
+});
+
+KT_DECL_TEST(AlwaysPass, []() -> bool {
+ KT_MUST_PASS("AlwaysPass", YES, YES);
+ return YES;
+}); \ No newline at end of file
diff --git a/public/frameworks/KernelTest.fwrk/src/CSymbols.cc b/public/frameworks/KernelTest.fwrk/src/CSymbols.cc
new file mode 100644
index 00000000..575525f0
--- /dev/null
+++ b/public/frameworks/KernelTest.fwrk/src/CSymbols.cc
@@ -0,0 +1,21 @@
+/* ========================================
+
+ Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
+
+======================================== */
+
+#include <public/frameworks/KernelTest.fwrk/headers/TestCase.h>
+
+/// ================================================================================
+/// @brief Function to run breaking test.
+/// ================================================================================
+EXTERN_C Kernel::Void KT_TestBreak() {
+ KT_RUN_TEST(AlwaysBreak);
+}
+
+/// ================================================================================
+/// @brief Function to run passing test.
+/// ================================================================================
+EXTERN_C Kernel::Void KT_TestPass() {
+ KT_RUN_TEST(AlwaysPass);
+} \ No newline at end of file
diff --git a/public/frameworks/KernelTest.fwrk/src/UnitTests.cc b/public/frameworks/KernelTest.fwrk/src/UnitTests.cc
deleted file mode 100644
index ab6effa9..00000000
--- a/public/frameworks/KernelTest.fwrk/src/UnitTests.cc
+++ /dev/null
@@ -1,17 +0,0 @@
-/* ========================================
-
- Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
-
-======================================== */
-
-#include <public/frameworks/KernelTest.fwrk/headers/KernelTest.h>
-
-EXTERN_C Kernel::Void KT_TestBreak() {
- KT_ALWAYS_BREAK brk;
- brk.Run();
-}
-
-EXTERN_C Kernel::Void KT_TestGood() {
- KT_ALWAYS_GOOD good;
- good.Run();
-} \ No newline at end of file