From fb790b07aeba8e22e4190cf3e1834d11ecde6c96 Mon Sep 17 00:00:00 2001 From: Amlal Date: Fri, 25 Apr 2025 13:08:33 +0200 Subject: dev: better .clang-format, ran format command. Signed-off-by: Amlal --- .../frameworks/CoreFoundation.fwrk/headers/Array.h | 105 ++++++------- .../frameworks/CoreFoundation.fwrk/headers/Atom.h | 64 +++----- .../CoreFoundation.fwrk/headers/Foundation.h | 100 ++++++------ .../CoreFoundation.fwrk/headers/Object.h | 22 ++- .../CoreFoundation.fwrk/headers/Property.h | 80 +++++----- .../frameworks/CoreFoundation.fwrk/headers/Ref.h | 169 +++++++++------------ .../CoreFoundation.fwrk/headers/String.h | 16 +- 7 files changed, 242 insertions(+), 314 deletions(-) (limited to 'public/frameworks/CoreFoundation.fwrk/headers') diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Array.h b/public/frameworks/CoreFoundation.fwrk/headers/Array.h index e9a36ac4..0b4a8dbf 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Array.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Array.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ @@ -8,64 +8,45 @@ #include -namespace CF -{ - template - class CFArray final - { - public: - explicit CFArray() = default; - ~CFArray() = default; - - CFArray& operator=(const CFArray&) = default; - CFArray(const CFArray&) = default; - - T& operator[](SizeT at) - { - MUST_PASS(at < this->Count()); - return fArray[at]; - } - - Bool Empty() - { - return this->Count() > 0; - } - - SizeT Capacity() - { - return N; - } - - SizeT Count() - { - auto cnt = 0UL; - - for (auto i = 0UL; i < N; ++i) - { - if (fArray[i]) - ++cnt; - } - - return cnt; - } - - const T* CData() - { - return fArray; - } - - operator bool() - { - return !Empty(); - } - - private: - T fArray[N] = {nullptr}; - }; - - template - auto make_array(ValueType val) - { - return CFArray{val}; - } -} // namespace CF +namespace CF { +template +class CFArray final { + public: + explicit CFArray() = default; + ~CFArray() = default; + + CFArray& operator=(const CFArray&) = default; + CFArray(const CFArray&) = default; + + T& operator[](SizeT at) { + MUST_PASS(at < this->Count()); + return fArray[at]; + } + + Bool Empty() { return this->Count() > 0; } + + SizeT Capacity() { return N; } + + SizeT Count() { + auto cnt = 0UL; + + for (auto i = 0UL; i < N; ++i) { + if (fArray[i]) ++cnt; + } + + return cnt; + } + + const T* CData() { return fArray; } + + operator bool() { return !Empty(); } + + private: + T fArray[N] = {nullptr}; +}; + +template +auto make_array(ValueType val) { + return CFArray{val}; +} +} // namespace CF diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Atom.h b/public/frameworks/CoreFoundation.fwrk/headers/Atom.h index 923d6bce..f279f0b1 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Atom.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Atom.h @@ -1,47 +1,33 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ #pragma once #include -namespace CF -{ - template - class CFAtom final - { - public: - explicit CFAtom() = default; - ~CFAtom() = default; - - public: - CFAtom& operator=(const CFAtom&) = delete; - CFAtom(const CFAtom&) = delete; - - public: - T operator[](SizeT bit) - { - return (fArrayOfAtoms & (1 << bit)); - } - - void operator|(SizeT bit) - { - fArrayOfAtoms |= (1 << bit); - } - - friend Boolean operator==(CFAtom& atomic, const T& idx) - { - return atomic[idx] == idx; - } - - friend Boolean operator!=(CFAtom& atomic, const T& idx) - { - return atomic[idx] == idx; - } - - private: - T fArrayOfAtoms; - }; -} // namespace CF +namespace CF { +template +class CFAtom final { + public: + explicit CFAtom() = default; + ~CFAtom() = default; + + public: + CFAtom& operator=(const CFAtom&) = delete; + CFAtom(const CFAtom&) = delete; + + public: + T operator[](SizeT bit) { return (fArrayOfAtoms & (1 << bit)); } + + void operator|(SizeT bit) { fArrayOfAtoms |= (1 << bit); } + + friend Boolean operator==(CFAtom& atomic, const T& idx) { return atomic[idx] == idx; } + + friend Boolean operator!=(CFAtom& atomic, const T& idx) { return atomic[idx] == idx; } + + private: + T fArrayOfAtoms; +}; +} // namespace CF diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h index b1c37635..194b7bb7 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h @@ -1,10 +1,10 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. - FILE: Foundation.h - PURPOSE: Foundation header of the CF framework. + FILE: Foundation.h + PURPOSE: Foundation header of the CF framework. ------------------------------------------- */ @@ -12,68 +12,64 @@ #include -namespace CF -{ - class CFString; - class CFGUID; - class CFProperty; - class CFObject; +namespace CF { +class CFString; +class CFGUID; +class CFProperty; +class CFObject; - template - class CFRef; - class CFFont; - struct CFPoint; - struct CFRect; - struct CFColor; +template +class CFRef; +class CFFont; +struct CFPoint; +struct CFRect; +struct CFColor; #ifndef __LP64__ - typedef SInt32 CFInteger; - typedef float CFReal; +typedef SInt32 CFInteger; +typedef float CFReal; #else - typedef SInt64 CFInteger; - typedef double CFReal; +typedef SInt64 CFInteger; +typedef double CFReal; #endif - typedef SInt32 CFInteger32; - typedef SInt64 CFInteger64; +typedef SInt32 CFInteger32; +typedef SInt64 CFInteger64; - typedef Char CFChar8; - typedef char16_t CFChar16; +typedef Char CFChar8; +typedef char16_t CFChar16; - struct CFPoint - { - CFInteger64 x_1{0UL}; - CFInteger64 y_1{0UL}; +struct CFPoint { + CFInteger64 x_1{0UL}; + CFInteger64 y_1{0UL}; - CFInteger64 x_2{0UL}; - CFInteger64 y_2{0UL}; - CFReal ang{0UL}; + CFInteger64 x_2{0UL}; + CFInteger64 y_2{0UL}; + CFReal ang{0UL}; - operator bool(); + operator bool(); - /// @brief Check if point is within the current CFPoint. - /// @param point the current point to check. - /// @retval true if point is within this point. - /// @retval validations failed. - bool IsWithin(CFPoint& point); - }; + /// @brief Check if point is within the current CFPoint. + /// @param point the current point to check. + /// @retval true if point is within this point. + /// @retval validations failed. + bool IsWithin(CFPoint& point); +}; - struct CFColor final - { - CFInteger64 r, g, b, a{0}; - }; +struct CFColor final { + CFInteger64 r, g, b, a{0}; +}; - struct CFRect final - { - CFInteger64 x{0UL}; - CFInteger64 y{0UL}; +struct CFRect final { + CFInteger64 x{0UL}; + CFInteger64 y{0UL}; - CFInteger64 width{0UL}; - CFInteger64 height{0UL}; + CFInteger64 width{0UL}; + CFInteger64 height{0UL}; - operator bool(); + operator bool(); - BOOL SizeMatches(CFRect& rect) noexcept; - BOOL PositionMatches(CFRect& rect) noexcept; - }; -} // namespace CF \ No newline at end of file + BOOL SizeMatches(CFRect& rect) noexcept; + BOOL PositionMatches(CFRect& rect) noexcept; +}; +} // namespace CF \ No newline at end of file diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Object.h b/public/frameworks/CoreFoundation.fwrk/headers/Object.h index 733512b1..1692f20e 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Object.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Object.h @@ -1,7 +1,7 @@ /* ------------------------------------------- - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ @@ -11,16 +11,14 @@ #define CF_OBJECT : public CF::CFObject -namespace CF -{ - class CFObject; +namespace CF { +class CFObject; - class CFObject - { - public: - explicit CFObject() = default; - virtual ~CFObject() = default; +class CFObject { + public: + explicit CFObject() = default; + virtual ~CFObject() = default; - SCI_COPY_DEFAULT(CFObject); - }; -} // namespace CF \ No newline at end of file + SCI_COPY_DEFAULT(CFObject); +}; +} // 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 b999c54e..58e881e5 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Property.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Property.h @@ -1,53 +1,51 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ #ifndef _PROPS_H #define _PROPS_H -#include #include +#include #define kMaxPropLen (256U) -namespace CF -{ - class CFString; - class CFProperty; - class CFGUID; - - template - 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(); - - 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 fGUID{}; - }; - - template - using CFPropertyArray = CFArray; -} // namespace CF - -#endif // !CFKIT_PROPS_H +namespace CF { +class CFString; +class CFProperty; +class CFGUID; + +template +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(); + + 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 fGUID{}; +}; + +template +using CFPropertyArray = CFArray; +} // 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 2a4ec452..c18c6161 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Ref.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Ref.h @@ -1,110 +1,81 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ #ifndef _REF_H_ #define _REF_H_ -#include #include +#include + +namespace CF { +template +class CFRef; + +template +class CFRef final CF_OBJECT { + public: + CFRef() = default; + + ~CFRef() { + if (MmGetHeapFlags(fClass) != -1) delete fClass; + } + + public: + CFRef(T* cls) : fClass(cls) {} + + CFRef(T cls) : fClass(&cls) {} + + CFRef& 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 +class CFNonNullRef final { + public: + CFNonNullRef() = delete; + CFNonNullRef(nullPtr) = delete; + + CFNonNullRef(T* ref) : fRef(ref) { MUST_PASS(ref); } + + CFRef& operator->() { + MUST_PASS(fRef); + return fRef; + } + + CFNonNullRef& operator=(const CFNonNullRef& ref) = delete; + CFNonNullRef(const CFNonNullRef& ref) = default; + + private: + CFRef fRef{nullptr}; +}; +} // namespace CF -namespace CF -{ - template - class CFRef; - - template - class CFRef final CF_OBJECT - { - public: - CFRef() = default; - - ~CFRef() - { - if (MmGetHeapFlags(fClass) != -1) - delete fClass; - } - - public: - CFRef(T* cls) - : fClass(cls) - { - } - - CFRef(T cls) - : fClass(&cls) - { - } - - CFRef& 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 - class CFNonNullRef final - { - public: - CFNonNullRef() = delete; - CFNonNullRef(nullPtr) = delete; - - CFNonNullRef(T* ref) - : fRef(ref) - { - MUST_PASS(ref); - } - - CFRef& operator->() - { - MUST_PASS(fRef); - return fRef; - } - - CFNonNullRef& operator=(const CFNonNullRef& ref) = delete; - CFNonNullRef(const CFNonNullRef& ref) = default; - - private: - CFRef fRef{nullptr}; - }; -} // namespace CF - -#endif // ifndef _NEWKIT_REF_H_ +#endif // ifndef _NEWKIT_REF_H_ diff --git a/public/frameworks/CoreFoundation.fwrk/headers/String.h b/public/frameworks/CoreFoundation.fwrk/headers/String.h index e420ac91..c28c05cd 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/String.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/String.h @@ -1,7 +1,7 @@ /* ------------------------------------------- - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ @@ -9,12 +9,10 @@ #include -namespace CF -{ - class CFString; +namespace CF { +class CFString; - class CFString final CF_OBJECT - { - public: - }; -} // namespace CF \ No newline at end of file +class CFString final CF_OBJECT { + public: +}; +} // namespace CF \ No newline at end of file -- cgit v1.2.3