summaryrefslogtreecommitdiffhomepage
path: root/dev/Usr
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-02-11 08:51:02 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-02-11 08:51:02 +0100
commitf511ab3c1e840e1568dec67c4988f42e67d527b7 (patch)
tree7ee9decdcc95c43d41d6d6e289e8bc4cc116888f /dev/Usr
parent5a221a0ba51b55e671efac8f8708a4ab28414816 (diff)
ADD: LibCF
Diffstat (limited to 'dev/Usr')
-rw-r--r--dev/Usr/LibCF/Array.h63
-rw-r--r--dev/Usr/LibCF/Property.h53
-rw-r--r--dev/Usr/LibCF/Ref.h106
-rw-r--r--dev/Usr/LibCompress/API.h18
-rw-r--r--dev/Usr/LibCompress/LCCompress.s7
-rw-r--r--dev/Usr/LibCompress/LCDecompress.s7
-rw-r--r--dev/Usr/LibSystem/.keepme0
-rw-r--r--dev/Usr/LibWS/.keepme0
8 files changed, 222 insertions, 32 deletions
diff --git a/dev/Usr/LibCF/Array.h b/dev/Usr/LibCF/Array.h
new file mode 100644
index 00000000..8533b649
--- /dev/null
+++ b/dev/Usr/LibCF/Array.h
@@ -0,0 +1,63 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <LibSCI/SCI.h>
+
+namespace LibCF
+{
+ template <typename T, SizeT N>
+ class CFArray final
+ {
+ public:
+ explicit CFArray() = default;
+ ~CFArray() = default;
+
+ CFArray& operator=(const CFArray&) = default;
+ CFArray(const CFArray&) = default;
+
+ T& operator[](const SizeT& at)
+ {
+ MUST_PASS(at < this->Count());
+ return fArray[at];
+ }
+
+ Bool Empty()
+ {
+ return this->Count() > 0;
+ }
+
+ const SizeT Capacity()
+ {
+ return N;
+ }
+
+ const SizeT Count()
+ {
+ return N;
+ }
+
+ const T* CData()
+ {
+ return fArray;
+ }
+
+ operator bool()
+ {
+ return !Empty();
+ }
+
+ private:
+ T fArray[N];
+ };
+
+ template <typename ValueType>
+ auto make_list(ValueType val)
+ {
+ return CFArray<ValueType, ARRAY_SIZE(val)>{val};
+ }
+} // namespace Kernel
diff --git a/dev/Usr/LibCF/Property.h b/dev/Usr/LibCF/Property.h
new file mode 100644
index 00000000..629dba27
--- /dev/null
+++ b/dev/Usr/LibCF/Property.h
@@ -0,0 +1,53 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#ifndef CFKIT_PROPS_H
+#define CFKIT_PROPS_H
+
+#include <LibSCI/SCI.h>
+#include <LibCF/Ref.h>
+
+#define kMaxPropLen (256U)
+
+namespace LibCF
+{
+ 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
+ {
+ public:
+ CFProperty();
+ virtual ~CFProperty();
+
+ public:
+ CFProperty& operator=(const CFProperty&) = default;
+ CFProperty(const CFProperty&) = default;
+
+ Bool StringEquals(CFString& name);
+ CFPropertyId& GetValue();
+ CFString& GetKey();
+
+ private:
+ CFString* fName{nullptr};
+ CFPropertyId fValue{0UL};
+ Ref<CFGUID> fGUID{};
+ };
+
+ template <SizeT N>
+ using CFPropertyArray = CFArray<CFProperty, N>;
+} // namespace CFKit
+
+#endif // !CFKIT_PROPS_H
diff --git a/dev/Usr/LibCF/Ref.h b/dev/Usr/LibCF/Ref.h
new file mode 100644
index 00000000..faad67c5
--- /dev/null
+++ b/dev/Usr/LibCF/Ref.h
@@ -0,0 +1,106 @@
+
+/* -------------------------------------------
+
+ Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#ifndef _NEWKIT_REF_H_
+#define _NEWKIT_REF_H_
+
+#include <LibSCI/SCI.h>
+
+namespace LibCF
+{
+ template <typename T>
+ class Ref final
+ {
+ public:
+ Ref() = default;
+
+ ~Ref()
+ {
+ if (MmGetHeapFlags(fClass) != -1)
+ delete fClass;
+ }
+
+ public:
+ Ref(T* cls)
+ : fClass(cls)
+ {
+ }
+
+ Ref(T cls)
+ : fClass(&cls)
+ {
+ }
+
+ Ref& operator=(T ref)
+ {
+ if (!fClass)
+ return *this;
+
+ fClass = &ref;
+ return *this;
+ }
+
+ public:
+ T operator->() const
+ {
+ MUST_PASS(*fClass);
+ return *fClass;
+ }
+
+ T& Leak() noexcept
+ {
+ return *fClass;
+ }
+
+ T& TryLeak() const noexcept
+ {
+ MUST_PASS(*fClass);
+ return *fClass;
+ }
+
+ T operator*()
+ {
+ return *fClass;
+ }
+
+ operator bool() noexcept
+ {
+ return fClass;
+ }
+
+ private:
+ T* fClass{nullptr};
+ };
+
+ template <typename T>
+ class NonNullRef final
+ {
+ public:
+ NonNullRef() = delete;
+ NonNullRef(nullPtr) = delete;
+
+ NonNullRef(T* ref)
+ : fRef(ref)
+ {
+ MUST_PASS(ref);
+ }
+
+ Ref<T>& operator->()
+ {
+ MUST_PASS(fRef);
+ return fRef;
+ }
+
+ NonNullRef& operator=(const NonNullRef<T>& ref) = delete;
+ NonNullRef(const NonNullRef<T>& ref) = default;
+
+ private:
+ Ref<T> fRef{nullptr};
+ };
+} // namespace Kernel
+
+#endif // ifndef _NEWKIT_REF_H_
diff --git a/dev/Usr/LibCompress/API.h b/dev/Usr/LibCompress/API.h
deleted file mode 100644
index 9c3e9fde..00000000
--- a/dev/Usr/LibCompress/API.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* -------------------------------------------
-
- Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved.
-
-------------------------------------------- */
-
-#ifndef COMPRESSKIT_RLE_H
-#define COMPRESSKIT_RLE_H
-
-#include <External/Defines.h>
-// #include <LibCompress/Exports.h>
-
-namespace Kernel
-{
- class ICompressProxy;
-} // namespace Kernel
-
-#endif // !ifndef COMPRESSKIT_RLE_H
diff --git a/dev/Usr/LibCompress/LCCompress.s b/dev/Usr/LibCompress/LCCompress.s
deleted file mode 100644
index c490bbba..00000000
--- a/dev/Usr/LibCompress/LCCompress.s
+++ /dev/null
@@ -1,7 +0,0 @@
-/* -------------------------------------------
-
- Copyright (C) 2024 Amlal EL Mahrouss, all rights reserved.
-
-------------------------------------------- */
-
-.text \ No newline at end of file
diff --git a/dev/Usr/LibCompress/LCDecompress.s b/dev/Usr/LibCompress/LCDecompress.s
deleted file mode 100644
index c490bbba..00000000
--- a/dev/Usr/LibCompress/LCDecompress.s
+++ /dev/null
@@ -1,7 +0,0 @@
-/* -------------------------------------------
-
- Copyright (C) 2024 Amlal EL Mahrouss, all rights reserved.
-
-------------------------------------------- */
-
-.text \ No newline at end of file
diff --git a/dev/Usr/LibSystem/.keepme b/dev/Usr/LibSystem/.keepme
deleted file mode 100644
index e69de29b..00000000
--- a/dev/Usr/LibSystem/.keepme
+++ /dev/null
diff --git a/dev/Usr/LibWS/.keepme b/dev/Usr/LibWS/.keepme
deleted file mode 100644
index e69de29b..00000000
--- a/dev/Usr/LibWS/.keepme
+++ /dev/null