diff options
Diffstat (limited to 'public/frameworks/CoreFoundation.fwrk')
4 files changed, 65 insertions, 17 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 |
